#include <IOKit/IODeviceTreeSupport.h>
#include "PowerExpress.h"
#define super ApplePlatformExpert
OSDefineMetaClassAndStructors(PowerExpressPE, ApplePlatformExpert);
bool PowerExpressPE::start(IOService *provider)
{
OSData *tmpData;
setChipSetType(kChipSetTypePowerExpress);
tmpData = OSDynamicCast(OSData, getProperty("senses"));
if (tmpData) senseArray = (long *)tmpData->getBytesNoCopy();
return super::start(provider);
}
bool PowerExpressPE::platformAdjustService(IOService *service)
{
long cnt, numInterrupts, sourceNumbers[2];
OSData *tmpData;
OSArray *controllers, *specifiers;
OSSymbol *controller;
controllers = OSDynamicCast(OSArray, service->getProperty(gIOInterruptControllersKey));
specifiers = OSDynamicCast(OSArray, service->getProperty(gIOInterruptSpecifiersKey));
if (controllers && specifiers) {
numInterrupts = specifiers->getCount();
for (cnt = 0; cnt < numInterrupts; cnt++) {
controller = OSDynamicCast(OSSymbol, controllers->getObject(cnt));
if (controller == gIODTDefaultInterruptController) {
tmpData = OSDynamicCast(OSData, specifiers->getObject(cnt));
if (tmpData && (tmpData->getLength() == 4)) {
sourceNumbers[0] = *(long *)tmpData->getBytesNoCopy();
sourceNumbers[1] = senseArray[sourceNumbers[0]];
tmpData = OSData::withBytes(sourceNumbers, 2 * sizeof(long));
if (tmpData) {
specifiers->setObject(cnt, tmpData);
tmpData->release();
}
}
}
}
}
if (IODTMatchNubWithKeys(service, "open-pic")) {
service->setProperty("InterruptControllerName",
gIODTDefaultInterruptController);
return true;
}
return true;
}