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