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