1*e3723e1fSApple OSS Distributions /* 2*e3723e1fSApple OSS Distributions * Copyright (c) 2012-2014 Apple Computer, Inc. All Rights Reserved. 3*e3723e1fSApple OSS Distributions * 4*e3723e1fSApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5*e3723e1fSApple OSS Distributions * 6*e3723e1fSApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 7*e3723e1fSApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 8*e3723e1fSApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 9*e3723e1fSApple OSS Distributions * compliance with the License. The rights granted to you under the License 10*e3723e1fSApple OSS Distributions * may not be used to create, or enable the creation or redistribution of, 11*e3723e1fSApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to 12*e3723e1fSApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any 13*e3723e1fSApple OSS Distributions * terms of an Apple operating system software license agreement. 14*e3723e1fSApple OSS Distributions * 15*e3723e1fSApple OSS Distributions * Please obtain a copy of the License at 16*e3723e1fSApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file. 17*e3723e1fSApple OSS Distributions * 18*e3723e1fSApple OSS Distributions * The Original Code and all software distributed under the License are 19*e3723e1fSApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20*e3723e1fSApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21*e3723e1fSApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22*e3723e1fSApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23*e3723e1fSApple OSS Distributions * Please see the License for the specific language governing rights and 24*e3723e1fSApple OSS Distributions * limitations under the License. 25*e3723e1fSApple OSS Distributions * 26*e3723e1fSApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27*e3723e1fSApple OSS Distributions */ 28*e3723e1fSApple OSS Distributions 29*e3723e1fSApple OSS Distributions #ifndef _IOREPORT_TYPES_H_ 30*e3723e1fSApple OSS Distributions #define _IOREPORT_TYPES_H_ 31*e3723e1fSApple OSS Distributions 32*e3723e1fSApple OSS Distributions #include <stdint.h> 33*e3723e1fSApple OSS Distributions 34*e3723e1fSApple OSS Distributions #ifdef __cplusplus 35*e3723e1fSApple OSS Distributions extern "C" { 36*e3723e1fSApple OSS Distributions #endif 37*e3723e1fSApple OSS Distributions 38*e3723e1fSApple OSS Distributions #define IOR_VALUES_PER_ELEMENT 4 39*e3723e1fSApple OSS Distributions 40*e3723e1fSApple OSS Distributions /*! @const kIOReportInvalidValue 41*e3723e1fSApple OSS Distributions * @const kIOReportInvalidIntValue 42*e3723e1fSApple OSS Distributions * @abstract cardinal value used to indicate data errors 43*e3723e1fSApple OSS Distributions * 44*e3723e1fSApple OSS Distributions * @discussion 45*e3723e1fSApple OSS Distributions * kIOReportInvalidValue and kIOReportInvalidIntValue have the 46*e3723e1fSApple OSS Distributions * same bit pattern so that clients checking for one or the other 47*e3723e1fSApple OSS Distributions * don't have to worry about getting the signedness right. 48*e3723e1fSApple OSS Distributions */ 49*e3723e1fSApple OSS Distributions #define kIOReportInvalidIntValue INT64_MIN 50*e3723e1fSApple OSS Distributions #define kIOReportInvalidValue (uint64_t)kIOReportInvalidIntValue 51*e3723e1fSApple OSS Distributions 52*e3723e1fSApple OSS Distributions /*! @typedef IOReportCategories 53*e3723e1fSApple OSS Distributions * @abstract encapsulate important, multi-purpose "tags" for channels 54*e3723e1fSApple OSS Distributions * 55*e3723e1fSApple OSS Distributions * @discussion 56*e3723e1fSApple OSS Distributions * IOReportCategories is the type for the .categories field of 57*e3723e1fSApple OSS Distributions * IOReportChanelType. These categories are inteded to empower a 58*e3723e1fSApple OSS Distributions * limited number of clients to retrieve a broad range of channels 59*e3723e1fSApple OSS Distributions * without knowing much about them. They can be OR'd together as 60*e3723e1fSApple OSS Distributions * needed. Groups and subgroups are a more extensible mechanism 61*e3723e1fSApple OSS Distributions * for aggregating channels produced by different drivers. 62*e3723e1fSApple OSS Distributions */ 63*e3723e1fSApple OSS Distributions typedef uint16_t IOReportCategories; 64*e3723e1fSApple OSS Distributions #define kIOReportCategoryPower (1 << 1) // and energy 65*e3723e1fSApple OSS Distributions #define kIOReportCategoryTraffic (1 << 2) // I/O at any level 66*e3723e1fSApple OSS Distributions #define kIOReportCategoryPerformance (1 << 3) // e.g. cycles/byte 67*e3723e1fSApple OSS Distributions #define kIOReportCategoryPeripheral (1 << 4) // not built-in 68*e3723e1fSApple OSS Distributions 69*e3723e1fSApple OSS Distributions #define kIOReportCategoryField (1 << 8) // consider logging 70*e3723e1fSApple OSS Distributions 71*e3723e1fSApple OSS Distributions // future categories TBD 72*e3723e1fSApple OSS Distributions #define kIOReportCategoryDebug (1 << 15) 73*e3723e1fSApple OSS Distributions #define kIOReportInvalidCategory UINT16_MAX 74*e3723e1fSApple OSS Distributions 75*e3723e1fSApple OSS Distributions 76*e3723e1fSApple OSS Distributions // IOReportChannelType.report_format 77*e3723e1fSApple OSS Distributions typedef uint8_t IOReportFormat; 78*e3723e1fSApple OSS Distributions enum { 79*e3723e1fSApple OSS Distributions kIOReportInvalidFormat = 0, 80*e3723e1fSApple OSS Distributions kIOReportFormatSimple = 1, 81*e3723e1fSApple OSS Distributions kIOReportFormatState = 2, 82*e3723e1fSApple OSS Distributions kIOReportFormatHistogram = 3, 83*e3723e1fSApple OSS Distributions kIOReportFormatSimpleArray = 4 84*e3723e1fSApple OSS Distributions }; 85*e3723e1fSApple OSS Distributions 86*e3723e1fSApple OSS Distributions // simple report values 87*e3723e1fSApple OSS Distributions typedef struct { 88*e3723e1fSApple OSS Distributions int64_t simple_value; 89*e3723e1fSApple OSS Distributions uint64_t reserved1; 90*e3723e1fSApple OSS Distributions uint64_t reserved2; 91*e3723e1fSApple OSS Distributions uint64_t reserved3; 92*e3723e1fSApple OSS Distributions } __attribute((packed)) IOSimpleReportValues; 93*e3723e1fSApple OSS Distributions 94*e3723e1fSApple OSS Distributions // simple value array 95*e3723e1fSApple OSS Distributions typedef struct { 96*e3723e1fSApple OSS Distributions int64_t simple_values[IOR_VALUES_PER_ELEMENT]; 97*e3723e1fSApple OSS Distributions } __attribute((packed)) IOSimpleArrayReportValues; 98*e3723e1fSApple OSS Distributions 99*e3723e1fSApple OSS Distributions // state report values 100*e3723e1fSApple OSS Distributions typedef struct { 101*e3723e1fSApple OSS Distributions uint64_t state_id; // 0..N-1 or 8-char code (see MAKEID()) 102*e3723e1fSApple OSS Distributions uint64_t intransitions; // number of transitions into this state 103*e3723e1fSApple OSS Distributions uint64_t upticks; // ticks spent in state (local timebase) 104*e3723e1fSApple OSS Distributions uint64_t last_intransition;// ticks at last in-transition 105*e3723e1fSApple OSS Distributions } __attribute((packed)) IOStateReportValues; 106*e3723e1fSApple OSS Distributions 107*e3723e1fSApple OSS Distributions // histogram report values 108*e3723e1fSApple OSS Distributions typedef struct { 109*e3723e1fSApple OSS Distributions uint64_t bucket_hits; 110*e3723e1fSApple OSS Distributions int64_t bucket_min; 111*e3723e1fSApple OSS Distributions int64_t bucket_max; 112*e3723e1fSApple OSS Distributions int64_t bucket_sum; 113*e3723e1fSApple OSS Distributions } __attribute((packed)) IOHistogramReportValues; 114*e3723e1fSApple OSS Distributions 115*e3723e1fSApple OSS Distributions 116*e3723e1fSApple OSS Distributions 117*e3723e1fSApple OSS Distributions // configuration actions generally change future behavior 118*e3723e1fSApple OSS Distributions typedef uint32_t IOReportConfigureAction; 119*e3723e1fSApple OSS Distributions enum { 120*e3723e1fSApple OSS Distributions // basics (in common operational order) 121*e3723e1fSApple OSS Distributions kIOReportEnable = 0x01, 122*e3723e1fSApple OSS Distributions kIOReportGetDimensions = 0x02, 123*e3723e1fSApple OSS Distributions kIOReportDisable = 0x00, 124*e3723e1fSApple OSS Distributions 125*e3723e1fSApple OSS Distributions // Enable/disable modifiers 126*e3723e1fSApple OSS Distributions kIOReportNotifyHubOnChange = 0x10, // triggered polling 127*e3723e1fSApple OSS Distributions 128*e3723e1fSApple OSS Distributions kIOReportTraceOnChange = 0x20 // kdebug.h tracing 129*e3723e1fSApple OSS Distributions }; 130*e3723e1fSApple OSS Distributions 131*e3723e1fSApple OSS Distributions // update actions should not have observable side effects 132*e3723e1fSApple OSS Distributions typedef uint32_t IOReportUpdateAction; 133*e3723e1fSApple OSS Distributions enum { 134*e3723e1fSApple OSS Distributions kIOReportCopyChannelData = 1, 135*e3723e1fSApple OSS Distributions kIOReportTraceChannelData = 2 136*e3723e1fSApple OSS Distributions }; 137*e3723e1fSApple OSS Distributions 138*e3723e1fSApple OSS Distributions typedef struct { 139*e3723e1fSApple OSS Distributions uint8_t report_format; // Histogram, StateResidency, etc. 140*e3723e1fSApple OSS Distributions uint8_t reserved; // must be zero 141*e3723e1fSApple OSS Distributions uint16_t categories; // power, traffic, etc (omnibus obs.) 142*e3723e1fSApple OSS Distributions uint16_t nelements; // internal size of channel 143*e3723e1fSApple OSS Distributions 144*e3723e1fSApple OSS Distributions // only meaningful in the data pipeline 145*e3723e1fSApple OSS Distributions int16_t element_idx; // 0..nelements-1 146*e3723e1fSApple OSS Distributions // -1..-(nelements) = invalid (13127884) 147*e3723e1fSApple OSS Distributions } __attribute((packed)) IOReportChannelType; 148*e3723e1fSApple OSS Distributions 149*e3723e1fSApple OSS Distributions /*! 150*e3723e1fSApple OSS Distributions * @define IOREPORT_MAKECHID 151*e3723e1fSApple OSS Distributions * @abstract convert up to 8 printable characters into a 64-bit channel ID 152*e3723e1fSApple OSS Distributions * @param <char0..char7> - printable chars to be packed into a channel ID 153*e3723e1fSApple OSS Distributions * @result a 64-bit channel ID with an implicit ASCII name 154*e3723e1fSApple OSS Distributions * @discussion A simple example: 155*e3723e1fSApple OSS Distributions * IOREPORT_MAKECHID('H', 'i', ' ', 'w', 'o', 'r', 'l', 'd'); 156*e3723e1fSApple OSS Distributions * will evaluate to 0x686920776f726c64. Any NUL bytes are 157*e3723e1fSApple OSS Distributions * ignored (by libIOReport) for naming purposes, but will 158*e3723e1fSApple OSS Distributions * appear in the channel ID. Using a non-NUL non-printable 159*e3723e1fSApple OSS Distributions * character will disable the implicit name. Putting NUL 160*e3723e1fSApple OSS Distributions * bytes first eliminates trailing zeros when the channel 161*e3723e1fSApple OSS Distributions * ID is printed as hex. For example: 162*e3723e1fSApple OSS Distributions * IORERPORT_MAKECHID('\0','\0','n','x','f','e','r','s'); 163*e3723e1fSApple OSS Distributions * To see the text, use xxd -r -p # not -rp; see 12976241 164*e3723e1fSApple OSS Distributions */ 165*e3723e1fSApple OSS Distributions #define __IOR_lshiftchr(c, chshift) ((uint64_t)(c) << (8*(chshift))) 166*e3723e1fSApple OSS Distributions #define IOREPORT_MAKEID(A, B, C, D, E, F, G, H) \ 167*e3723e1fSApple OSS Distributions (__IOR_lshiftchr(A, 7) | __IOR_lshiftchr(B, 6) | __IOR_lshiftchr(C, 5) \ 168*e3723e1fSApple OSS Distributions | __IOR_lshiftchr(D, 4) | __IOR_lshiftchr(E, 3) | __IOR_lshiftchr(F, 2) \ 169*e3723e1fSApple OSS Distributions | __IOR_lshiftchr(G, 1) | __IOR_lshiftchr(H, 0)) 170*e3723e1fSApple OSS Distributions 171*e3723e1fSApple OSS Distributions typedef struct { 172*e3723e1fSApple OSS Distributions uint64_t channel_id; 173*e3723e1fSApple OSS Distributions IOReportChannelType channel_type; 174*e3723e1fSApple OSS Distributions } IOReportChannel; 175*e3723e1fSApple OSS Distributions 176*e3723e1fSApple OSS Distributions typedef struct { 177*e3723e1fSApple OSS Distributions uint32_t nchannels; 178*e3723e1fSApple OSS Distributions IOReportChannel channels[]; 179*e3723e1fSApple OSS Distributions } IOReportChannelList; 180*e3723e1fSApple OSS Distributions 181*e3723e1fSApple OSS Distributions typedef struct { 182*e3723e1fSApple OSS Distributions uint64_t provider_id; 183*e3723e1fSApple OSS Distributions IOReportChannel channel; 184*e3723e1fSApple OSS Distributions } IOReportInterest; 185*e3723e1fSApple OSS Distributions 186*e3723e1fSApple OSS Distributions typedef struct { 187*e3723e1fSApple OSS Distributions uint32_t ninterests; 188*e3723e1fSApple OSS Distributions IOReportInterest interests[]; 189*e3723e1fSApple OSS Distributions } IOReportInterestList; 190*e3723e1fSApple OSS Distributions 191*e3723e1fSApple OSS Distributions typedef struct { 192*e3723e1fSApple OSS Distributions uint64_t v[IOR_VALUES_PER_ELEMENT]; 193*e3723e1fSApple OSS Distributions } __attribute((packed)) IOReportElementValues; 194*e3723e1fSApple OSS Distributions 195*e3723e1fSApple OSS Distributions typedef struct { 196*e3723e1fSApple OSS Distributions uint64_t provider_id; 197*e3723e1fSApple OSS Distributions uint64_t channel_id; 198*e3723e1fSApple OSS Distributions IOReportChannelType channel_type; 199*e3723e1fSApple OSS Distributions uint64_t timestamp;// mach_absolute_time() 200*e3723e1fSApple OSS Distributions IOReportElementValues values; 201*e3723e1fSApple OSS Distributions } __attribute((packed)) IOReportElement; 202*e3723e1fSApple OSS Distributions 203*e3723e1fSApple OSS Distributions 204*e3723e1fSApple OSS Distributions 205*e3723e1fSApple OSS Distributions /* 206*e3723e1fSApple OSS Distributions * IOReporting unit type and constants 207*e3723e1fSApple OSS Distributions */ 208*e3723e1fSApple OSS Distributions 209*e3723e1fSApple OSS Distributions // 1. Mechanism 210*e3723e1fSApple OSS Distributions 211*e3723e1fSApple OSS Distributions // Assume encoded units could be stored in binary format: don't 212*e3723e1fSApple OSS Distributions // change existing values. 213*e3723e1fSApple OSS Distributions 214*e3723e1fSApple OSS Distributions typedef uint64_t IOReportUnit; 215*e3723e1fSApple OSS Distributions typedef uint64_t IOReportUnits; // deprecated typo, please switch 216*e3723e1fSApple OSS Distributions #define __IOR_MAKEUNIT(quantity, scale) \ 217*e3723e1fSApple OSS Distributions (((IOReportUnit)quantity << 56) | (uint64_t)scale) 218*e3723e1fSApple OSS Distributions #define IOREPORT_GETUNIT_QUANTITY(unit) \ 219*e3723e1fSApple OSS Distributions ((IOReportQuantity)((uint64_t)unit >> 56) & 0xff) 220*e3723e1fSApple OSS Distributions #define IOREPORT_GETUNIT_SCALE(unit) \ 221*e3723e1fSApple OSS Distributions ((IOReportScaleFactor)unit & 0x00ffffffffffffff) 222*e3723e1fSApple OSS Distributions 223*e3723e1fSApple OSS Distributions // 8b quantity ID | 32b const val + 8b*2^10 + 8b*2^n | 8b cardinal | 8b unused 224*e3723e1fSApple OSS Distributions typedef uint8_t IOReportQuantity; // SI "quantity" is what's measured 225*e3723e1fSApple OSS Distributions typedef uint64_t IOReportScaleFactor; 226*e3723e1fSApple OSS Distributions 227*e3723e1fSApple OSS Distributions // See <http://en.wikipedia.org/wiki/SI_base_unit> for a list 228*e3723e1fSApple OSS Distributions // of quantities and their symbols. 229*e3723e1fSApple OSS Distributions enum { 230*e3723e1fSApple OSS Distributions // used by state reports, etc 231*e3723e1fSApple OSS Distributions kIOReportQuantityUndefined = 0, 232*e3723e1fSApple OSS Distributions 233*e3723e1fSApple OSS Distributions kIOReportQuantityTime = 1,// Seconds 234*e3723e1fSApple OSS Distributions kIOReportQuantityPower = 2,// Watts 235*e3723e1fSApple OSS Distributions kIOReportQuantityEnergy = 3,// Joules 236*e3723e1fSApple OSS Distributions kIOReportQuantityCurrent = 4,// Amperes 237*e3723e1fSApple OSS Distributions kIOReportQuantityVoltage = 5,// Volts 238*e3723e1fSApple OSS Distributions kIOReportQuantityCapacitance = 6,// Farad 239*e3723e1fSApple OSS Distributions kIOReportQuantityInductance = 7,// Henry 240*e3723e1fSApple OSS Distributions kIOReportQuantityFrequency = 8,// Hertz 241*e3723e1fSApple OSS Distributions kIOReportQuantityData = 9,// bits/bytes (see scale) 242*e3723e1fSApple OSS Distributions kIOReportQuantityTemperature = 10,// Celsius (not Kelvin :) 243*e3723e1fSApple OSS Distributions 244*e3723e1fSApple OSS Distributions kIOReportQuantityEventCount = 100, 245*e3723e1fSApple OSS Distributions kIOReportQuantityPacketCount = 101, 246*e3723e1fSApple OSS Distributions kIOReportQuantityCPUInstrs = 102 247*e3723e1fSApple OSS Distributions }; 248*e3723e1fSApple OSS Distributions 249*e3723e1fSApple OSS Distributions 250*e3723e1fSApple OSS Distributions /* A number of units end up with both IEC (2^n) and SI (10^n) scale factors. 251*e3723e1fSApple OSS Distributions * For example, the "MB" of a 1.44 MB floppy or a 1024MHz clock. We 252*e3723e1fSApple OSS Distributions * thus support separate 2^n and 10^n factors. The exponent encoding 253*e3723e1fSApple OSS Distributions * scheme is modeled loosely on single-precision IEEE 754. 254*e3723e1fSApple OSS Distributions */ 255*e3723e1fSApple OSS Distributions #define kIOReportScaleConstMask 0x000000007fffffff // constant ("uint31") 256*e3723e1fSApple OSS Distributions #define kIOReportScaleOneOver (1LL << 31) // 1/constant 257*e3723e1fSApple OSS Distributions #define kIOReportExpBase (-127) // support base^(-n) 258*e3723e1fSApple OSS Distributions #define kIOReportExpZeroOffset -(kIOReportExpBase) // max exponent = 128 259*e3723e1fSApple OSS Distributions #define kIOReportScaleSIShift 32 // * 10^n 260*e3723e1fSApple OSS Distributions #define kIOReportScaleSIMask 0x000000ff00000000 261*e3723e1fSApple OSS Distributions #define kIOReportScaleIECShift 40 // * 2^n 262*e3723e1fSApple OSS Distributions #define kIOReportScaleIECMask 0x0000ff0000000000 263*e3723e1fSApple OSS Distributions #define kIOReportCardinalShift 48 // placeholders 264*e3723e1fSApple OSS Distributions #define kIOReportCardinalMask 0x00ff000000000000 265*e3723e1fSApple OSS Distributions 266*e3723e1fSApple OSS Distributions 267*e3723e1fSApple OSS Distributions /* 268*e3723e1fSApple OSS Distributions * Scales are described as a factor times unity: 269*e3723e1fSApple OSS Distributions * 1ms = kIOReportScaleMilli * s 270*e3723e1fSApple OSS Distributions * 271*e3723e1fSApple OSS Distributions * A value expressed in a scaled unit can be scaled to unity via 272*e3723e1fSApple OSS Distributions * multiplication by the constant: 273*e3723e1fSApple OSS Distributions * 100ms * kIOReportScaleMilli [1e-3] = 0.1s. 274*e3723e1fSApple OSS Distributions */ 275*e3723e1fSApple OSS Distributions 276*e3723e1fSApple OSS Distributions // SI / decimal 277*e3723e1fSApple OSS Distributions #define kIOReportScalePico ((-12LL + kIOReportExpZeroOffset) \ 278*e3723e1fSApple OSS Distributions << kIOReportScaleSIShift) 279*e3723e1fSApple OSS Distributions #define kIOReportScaleNano ((-9LL + kIOReportExpZeroOffset) \ 280*e3723e1fSApple OSS Distributions << kIOReportScaleSIShift) 281*e3723e1fSApple OSS Distributions #define kIOReportScaleMicro ((-6LL + kIOReportExpZeroOffset) \ 282*e3723e1fSApple OSS Distributions << kIOReportScaleSIShift) 283*e3723e1fSApple OSS Distributions #define kIOReportScaleMilli ((-3LL + kIOReportExpZeroOffset) \ 284*e3723e1fSApple OSS Distributions << kIOReportScaleSIShift) 285*e3723e1fSApple OSS Distributions #define kIOReportScaleUnity 0 // 10^0 = 2^0 = 1 286*e3723e1fSApple OSS Distributions // unity = 0 is a special case for which we give up exp = -127 287*e3723e1fSApple OSS Distributions #define kIOReportScaleKilo ((3LL + kIOReportExpZeroOffset) \ 288*e3723e1fSApple OSS Distributions << kIOReportScaleSIShift) 289*e3723e1fSApple OSS Distributions #define kIOReportScaleMega ((6LL + kIOReportExpZeroOffset) \ 290*e3723e1fSApple OSS Distributions << kIOReportScaleSIShift) 291*e3723e1fSApple OSS Distributions #define kIOReportScaleGiga ((9LL + kIOReportExpZeroOffset) \ 292*e3723e1fSApple OSS Distributions << kIOReportScaleSIShift) 293*e3723e1fSApple OSS Distributions #define kIOReportScaleTera ((12LL + kIOReportExpZeroOffset) \ 294*e3723e1fSApple OSS Distributions << kIOReportScaleSIShift) 295*e3723e1fSApple OSS Distributions 296*e3723e1fSApple OSS Distributions // IEC / computer / binary 297*e3723e1fSApple OSS Distributions // It's not clear we'll ever use 2^(-n), but 1..2^~120 should suffice. 298*e3723e1fSApple OSS Distributions #define kIOReportScaleBits kIOReportScaleUnity 299*e3723e1fSApple OSS Distributions #define kIOReportScaleBytes ((3LL + kIOReportExpZeroOffset) \ 300*e3723e1fSApple OSS Distributions << kIOReportScaleIECShift) 301*e3723e1fSApple OSS Distributions // (bytes have to be added to the exponents up front, can't just OR in) 302*e3723e1fSApple OSS Distributions #define kIOReportScaleKibi ((10LL + kIOReportExpZeroOffset) \ 303*e3723e1fSApple OSS Distributions << kIOReportScaleIECShift) 304*e3723e1fSApple OSS Distributions #define kIOReportScaleKiBytes ((13LL + kIOReportExpZeroOffset) \ 305*e3723e1fSApple OSS Distributions << kIOReportScaleIECShift) 306*e3723e1fSApple OSS Distributions #define kIOReportScaleMebi ((20LL + kIOReportExpZeroOffset) \ 307*e3723e1fSApple OSS Distributions << kIOReportScaleIECShift) 308*e3723e1fSApple OSS Distributions #define kIOReportScaleMiBytes ((23LL + kIOReportExpZeroOffset) \ 309*e3723e1fSApple OSS Distributions << kIOReportScaleIECShift) 310*e3723e1fSApple OSS Distributions #define kIOReportScaleGibi ((30LL + kIOReportExpZeroOffset) \ 311*e3723e1fSApple OSS Distributions << kIOReportScaleIECShift) 312*e3723e1fSApple OSS Distributions #define kIOReportScaleGiBytes ((33LL + kIOReportExpZeroOffset) \ 313*e3723e1fSApple OSS Distributions << kIOReportScaleIECShift) 314*e3723e1fSApple OSS Distributions #define kIOReportScaleTebi ((40LL + kIOReportExpZeroOffset) \ 315*e3723e1fSApple OSS Distributions << kIOReportScaleIECShift) 316*e3723e1fSApple OSS Distributions #define kIOReportScaleTiBytes ((43LL + kIOReportExpZeroOffset) \ 317*e3723e1fSApple OSS Distributions << kIOReportScaleIECShift) 318*e3723e1fSApple OSS Distributions // can't encode more than 2^125 (keeping bits & bytes inside -126..128) 319*e3723e1fSApple OSS Distributions // Also, IOReportScaleValue() is currently limited internally by uint64_t. 320*e3723e1fSApple OSS Distributions 321*e3723e1fSApple OSS Distributions 322*e3723e1fSApple OSS Distributions // Cardinal values, to be filled in appropriately. 323*e3723e1fSApple OSS Distributions // Add values in increasing order. 324*e3723e1fSApple OSS Distributions #define kIOReportScaleMachHWTicks (1LL << kIOReportCardinalShift) 325*e3723e1fSApple OSS Distributions #define kIOReportScaleHWPageSize (2LL << kIOReportCardinalShift) 326*e3723e1fSApple OSS Distributions 327*e3723e1fSApple OSS Distributions // page scales: 2 pages * 4ikB/page = 8096 bytes 328*e3723e1fSApple OSS Distributions #define kIOReportScale4KiB (4 | kIOReportScaleKiBytes) 329*e3723e1fSApple OSS Distributions #define kIOReportScale8KiB (8 | kIOReportScaleKiBytes) 330*e3723e1fSApple OSS Distributions #define kIOReportScale16KiB (16 | kIOReportScaleKiBytes) 331*e3723e1fSApple OSS Distributions 332*e3723e1fSApple OSS Distributions // Clock frequency scales (units add seconds). 333*e3723e1fSApple OSS Distributions // 1 GHz ticks are 1 ns: 1000 ticks * 1e-6 = 1e-3s 334*e3723e1fSApple OSS Distributions // This '1' is a no-op for scaling, but allows a custom label. 335*e3723e1fSApple OSS Distributions #define kIOReportScale1GHz (1 | kIOReportScaleNano) 336*e3723e1fSApple OSS Distributions // 24MHz ticks are 1/24 of a microsecond: (1/24 * kIOReportScaleMicro [1e-6])s 337*e3723e1fSApple OSS Distributions // So for example, 240 24Mticks * 1/24 * 1e-6 = .00001s [1e-5]s 338*e3723e1fSApple OSS Distributions #define kIOReportScale24MHz (kIOReportScaleOneOver|24 |kIOReportScaleMicro) 339*e3723e1fSApple OSS Distributions 340*e3723e1fSApple OSS Distributions // --- END: units mechanism 341*e3723e1fSApple OSS Distributions 342*e3723e1fSApple OSS Distributions 343*e3723e1fSApple OSS Distributions // 2. Unit constants 344*e3723e1fSApple OSS Distributions #define kIOReportUnitNone __IOR_MAKEUNIT(kIOReportQuantityUndefined, \ 345*e3723e1fSApple OSS Distributions kIOReportScaleUnity) 346*e3723e1fSApple OSS Distributions 347*e3723e1fSApple OSS Distributions #define kIOReportUnit_s __IOR_MAKEUNIT(kIOReportQuantityTime, \ 348*e3723e1fSApple OSS Distributions kIOReportScaleUnity) 349*e3723e1fSApple OSS Distributions #define kIOReportUnit_ms __IOR_MAKEUNIT(kIOReportQuantityTime, \ 350*e3723e1fSApple OSS Distributions kIOReportScaleMilli) 351*e3723e1fSApple OSS Distributions #define kIOReportUnit_us __IOR_MAKEUNIT(kIOReportQuantityTime, \ 352*e3723e1fSApple OSS Distributions kIOReportScaleMicro) 353*e3723e1fSApple OSS Distributions #define kIOReportUnit_ns __IOR_MAKEUNIT(kIOReportQuantityTime, \ 354*e3723e1fSApple OSS Distributions kIOReportScaleNano) 355*e3723e1fSApple OSS Distributions 356*e3723e1fSApple OSS Distributions #define kIOReportUnit_J __IOR_MAKEUNIT(kIOReportQuantityEnergy, \ 357*e3723e1fSApple OSS Distributions kIOReportScaleUnity) 358*e3723e1fSApple OSS Distributions #define kIOReportUnit_mJ __IOR_MAKEUNIT(kIOReportQuantityEnergy, \ 359*e3723e1fSApple OSS Distributions kIOReportScaleMilli) 360*e3723e1fSApple OSS Distributions #define kIOReportUnit_uJ __IOR_MAKEUNIT(kIOReportQuantityEnergy, \ 361*e3723e1fSApple OSS Distributions kIOReportScaleMicro) 362*e3723e1fSApple OSS Distributions #define kIOReportUnit_nJ __IOR_MAKEUNIT(kIOReportQuantityEnergy, \ 363*e3723e1fSApple OSS Distributions kIOReportScaleNano) 364*e3723e1fSApple OSS Distributions #define kIOReportUnit_pJ __IOR_MAKEUNIT(kIOReportQuantityEnergy, \ 365*e3723e1fSApple OSS Distributions kIOReportScalePico) 366*e3723e1fSApple OSS Distributions 367*e3723e1fSApple OSS Distributions #define kIOReportUnitHWTicks __IOR_MAKEUNIT(kIOReportQuantityTime, \ 368*e3723e1fSApple OSS Distributions kIOReportScaleMachHWTicks) 369*e3723e1fSApple OSS Distributions #define kIOReportUnit24MHzTicks __IOR_MAKEUNIT(kIOReportQuantityTime, \ 370*e3723e1fSApple OSS Distributions kIOReportScale24MHz) 371*e3723e1fSApple OSS Distributions #define kIOReportUnit1GHzTicks __IOR_MAKEUNIT(kIOReportQuantityTime, \ 372*e3723e1fSApple OSS Distributions kIOReportScale1GHz) 373*e3723e1fSApple OSS Distributions 374*e3723e1fSApple OSS Distributions #define kIOReportUnitBits __IOR_MAKEUNIT(kIOReportQuantityData, \ 375*e3723e1fSApple OSS Distributions kIOReportScaleBits) 376*e3723e1fSApple OSS Distributions #define kIOReportUnitBytes __IOR_MAKEUNIT(kIOReportQuantityData, \ 377*e3723e1fSApple OSS Distributions kIOReportScaleBytes) 378*e3723e1fSApple OSS Distributions #define kIOReportUnit_KiB __IOR_MAKEUNIT(kIOReportQuantityData, \ 379*e3723e1fSApple OSS Distributions kIOReportScaleKiBytes) 380*e3723e1fSApple OSS Distributions #define kIOReportUnit_MiB __IOR_MAKEUNIT(kIOReportQuantityData, \ 381*e3723e1fSApple OSS Distributions kIOReportScaleMiBytes) 382*e3723e1fSApple OSS Distributions #define kIOReportUnit_GiB __IOR_MAKEUNIT(kIOReportQuantityData, \ 383*e3723e1fSApple OSS Distributions kIOReportScaleGiBytes) 384*e3723e1fSApple OSS Distributions #define kIOReportUnit_TiB __IOR_MAKEUNIT(kIOReportQuantityData, \ 385*e3723e1fSApple OSS Distributions kIOReportScaleTiBytes) 386*e3723e1fSApple OSS Distributions 387*e3723e1fSApple OSS Distributions #define kIOReportUnitEvents __IOR_MAKEUNIT(kIOReportQuantityEventCount, \ 388*e3723e1fSApple OSS Distributions kIOReportScaleUnity) 389*e3723e1fSApple OSS Distributions 390*e3723e1fSApple OSS Distributions #define kIOReportUnitPackets __IOR_MAKEUNIT(kIOReportQuantityPacketCount, \ 391*e3723e1fSApple OSS Distributions kIOReportScaleUnity) 392*e3723e1fSApple OSS Distributions 393*e3723e1fSApple OSS Distributions #define kIOReportUnitInstrs __IOR_MAKEUNIT(kIOReportQuantityCPUInstrs, \ 394*e3723e1fSApple OSS Distributions kIOReportScaleUnity) 395*e3723e1fSApple OSS Distributions #define kIOReportUnit_KI __IOR_MAKEUNIT(kIOReportQuantityCPUInstrs, \ 396*e3723e1fSApple OSS Distributions kIOReportScaleKilo) 397*e3723e1fSApple OSS Distributions #define kIOReportUnit_MI __IOR_MAKEUNIT(kIOReportQuantityCPUInstrs, \ 398*e3723e1fSApple OSS Distributions kIOReportScaleMega) 399*e3723e1fSApple OSS Distributions #define kIOReportUnit_GI __IOR_MAKEUNIT(kIOReportQuantityCPUInstrs, \ 400*e3723e1fSApple OSS Distributions kIOReportScaleGiga) 401*e3723e1fSApple OSS Distributions 402*e3723e1fSApple OSS Distributions // Please file bugs (xnu | IOReporting) for additional units. 403*e3723e1fSApple OSS Distributions 404*e3723e1fSApple OSS Distributions // --- END: unit constants 405*e3723e1fSApple OSS Distributions 406*e3723e1fSApple OSS Distributions 407*e3723e1fSApple OSS Distributions #ifdef __cplusplus 408*e3723e1fSApple OSS Distributions } 409*e3723e1fSApple OSS Distributions #endif 410*e3723e1fSApple OSS Distributions 411*e3723e1fSApple OSS Distributions #endif // _IOREPORT_TYPES_H_ 412