AppleI386PlatformExpert.cpp [plain text]
#include <IOKit/system.h>
#include <architecture/i386/kernBootStruct.h>
#include <IOKit/IORegistryEntry.h>
#include <libkern/c++/OSContainers.h>
#include <IOKit/IOLib.h>
#include <libkern/c++/OSUnserialize.h>
#include "AppleI386PlatformExpert.h"
#include <IOKit/assert.h>
#define super IOPlatformExpert
OSSymbol * gIntelPICName;
OSDefineMetaClassAndStructors(AppleI386PlatformExpert, IOPlatformExpert)
IOService * AppleI386PlatformExpert::probe(IOService * ,
SInt32 * score )
{
*score = 2000;
return (this);
}
bool AppleI386PlatformExpert::start(IOService * provider)
{
gIntelPICName = (OSSymbol *) OSSymbol::withCStringNoCopy("intel-pic");
if (!super::start(provider))
return false;
return true;
}
IOService * AppleI386PlatformExpert::createNub(OSDictionary * from)
{
IOService * nub;
OSData * prop;
KERNBOOTSTRUCT * bootStruct;
nub = super::createNub(from);
if (nub)
{
if (0 == strcmp( "pci", nub->getName()))
{
bootStruct = (KERNBOOTSTRUCT *) PE_state.bootArgs;
prop = OSData::withBytesNoCopy(&bootStruct->pciInfo,
sizeof(bootStruct->pciInfo));
assert(prop);
if (prop)
from->setObject( "pci-bus-info", prop);
}
else if (0 != strcmp("intel-pic", nub->getName()))
{
setupPIC(nub);
}
}
return (nub);
}
#define kNumVectors 16
void
AppleI386PlatformExpert::setupPIC(IOService *nub)
{
int i;
OSDictionary * propTable;
OSArray * controller;
OSArray * specifier;
OSData * tmpData;
long tmpLong;
propTable = nub->getPropertyTable();
specifier = OSArray::withCapacity(kNumVectors);
assert(specifier);
for (i = 0; i < kNumVectors; i++) {
tmpLong = i;
tmpData = OSData::withBytes(&tmpLong, sizeof(tmpLong));
specifier->setObject(tmpData);
}
controller = OSArray::withCapacity(kNumVectors);
assert(controller);
for (i = 0; i < kNumVectors; i++)
controller->setObject(gIntelPICName);
propTable->setObject(gIOInterruptControllersKey, controller);
propTable->setObject(gIOInterruptSpecifiersKey, specifier);
specifier->release();
controller->release();
}
bool
AppleI386PlatformExpert::matchNubWithPropertyTable(IOService * nub,
OSDictionary * propTable )
{
OSString * nameProp;
OSString * match;
if (0 == (nameProp = (OSString *) nub->getProperty(gIONameKey)))
return (false);
if ( 0 == (match = (OSString *) propTable->getObject(gIONameMatchKey)))
return (false);
return (match->isEqualTo( nameProp ));
}
bool AppleI386PlatformExpert::getMachineName( char * name, int maxLength )
{
strncpy( name, "x86", maxLength );
return (true);
}
bool AppleI386PlatformExpert::getModelName( char * name, int maxLength )
{
strncpy( name, "x86", maxLength );
return (true);
}