PMLog(const char *who, unsigned long event,
unsigned long param1, unsigned long param2)
{
- UInt32 debugFlags = gIOKitDebug;
- UInt32 traceFlags = gIOKitTrace;
- uintptr_t name = 0;
- UInt32 i = 0;
-
- if (debugFlags & kIOLogPower) {
-
clock_sec_t nows;
clock_usec_t nowus;
clock_get_system_microtime(&nows, &nowus);
nowus += (nows % 1000) * 1000000;
- kprintf("pm%u %p %.30s %d %lx %lx\n",
+ kprintf("pm%u %p %.30s %d %lx %lx\n",
nowus, current_thread(), who, // Identity
(int) event, (long) param1, (long) param2); // Args
-
- if (traceFlags & kIOTracePowerMgmt) {
- static const UInt32 sStartStopBitField[] =
- { 0x00000000, 0x00000040 }; // Only Program Hardware so far
-
- // Arcane formula from Hacker's Delight by Warren
- // abs(x) = ((int) x >> 31) ^ (x + ((int) x >> 31))
- UInt32 sgnevent = ((long) event >> 31);
- UInt32 absevent = sgnevent ^ (event + sgnevent);
- UInt32 code = IODBG_POWER(absevent);
-
- UInt32 bit = 1 << (absevent & 0x1f);
- if (absevent < sizeof(sStartStopBitField) * 8
- && (sStartStopBitField[absevent >> 5] & bit) ) {
- // Or in the START or END bits, Start = 1 & END = 2
- // If sgnevent == 0 then START - 0 => START
- // else if sgnevent == -1 then START - -1 => END
- code |= DBG_FUNC_START - sgnevent;
- }
-
- // Get first 8 characters of the name
- while ( i < sizeof(uintptr_t) && who[i] != 0)
- { ((char *)&name)[sizeof(uintptr_t)-i-1]=who[i]; i++; }
- // Record the timestamp.
- IOTimeStampConstant(code, name, event, param1, param2);
- }
- }
}