+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+void
+IOCPUInitialize(void)
+{
+ gIOCPUsLock = IOLockAlloc();
+ gIOCPUs = OSArray::withCapacity(1);
+
+ for (uint32_t qidx = kQueueSleep; qidx < kQueueCount; qidx++)
+ {
+ queue_init(&gActionQueues[qidx]);
+ }
+
+ gIOCPUStateKey = OSSymbol::withCStringNoCopy("IOCPUState");
+
+ gIOCPUStateNames[kIOCPUStateUnregistered] =
+ OSString::withCStringNoCopy("Unregistered");
+ gIOCPUStateNames[kIOCPUStateUninitalized] =
+ OSString::withCStringNoCopy("Uninitalized");
+ gIOCPUStateNames[kIOCPUStateStopped] =
+ OSString::withCStringNoCopy("Stopped");
+ gIOCPUStateNames[kIOCPUStateRunning] =
+ OSString::withCStringNoCopy("Running");
+
+ gIOPlatformSleepActionKey = gActionSymbols[kQueueSleep]
+ = OSSymbol::withCStringNoCopy(kIOPlatformSleepActionKey);
+ gIOPlatformWakeActionKey = gActionSymbols[kQueueWake]
+ = OSSymbol::withCStringNoCopy(kIOPlatformWakeActionKey);
+ gIOPlatformQuiesceActionKey = gActionSymbols[kQueueQuiesce]
+ = OSSymbol::withCStringNoCopy(kIOPlatformQuiesceActionKey);
+ gIOPlatformActiveActionKey = gActionSymbols[kQueueActive]
+ = OSSymbol::withCStringNoCopy(kIOPlatformActiveActionKey);
+ gIOPlatformHaltRestartActionKey = gActionSymbols[kQueueHaltRestart]
+ = OSSymbol::withCStringNoCopy(kIOPlatformHaltRestartActionKey);
+ gIOPlatformPanicActionKey = gActionSymbols[kQueuePanic]
+ = OSSymbol::withCStringNoCopy(kIOPlatformPanicActionKey);
+}
+
+IOReturn
+IOInstallServicePlatformActions(IOService * service)
+{
+ IOLockLock(gIOCPUsLock);
+
+ IOInstallServicePlatformAction(service, kQueueHaltRestart);
+ IOInstallServicePlatformAction(service, kQueuePanic);
+
+ IOLockUnlock(gIOCPUsLock);
+
+ return (kIOReturnSuccess);
+}
+
+IOReturn
+IORemoveServicePlatformActions(IOService * service)
+{
+ iocpu_platform_action_entry_t * entry;
+ iocpu_platform_action_entry_t * next;
+
+ IOLockLock(gIOCPUsLock);
+
+ for (uint32_t qidx = kQueueSleep; qidx < kQueueCount; qidx++)
+ {
+ next = (typeof(entry)) queue_first(&gActionQueues[qidx]);
+ while (!queue_end(&gActionQueues[qidx], &next->link))
+ {
+ entry = next;
+ next = (typeof(entry)) queue_next(&entry->link);
+ if (service == entry->refcon0)
+ {
+ iocpu_remove_platform_action(entry);
+ IODelete(entry, iocpu_platform_action_entry_t, 1);
+ }
+ }
+ }
+
+ IOLockUnlock(gIOCPUsLock);
+
+ return (kIOReturnSuccess);
+}
+
+