|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * The contents of this file constitute Original Code as defined in and ! 7: * are subject to the Apple Public Source License Version 1.1 (the ! 8: * "License"). You may not use this file except in compliance with the ! 9: * License. Please obtain a copy of the License at ! 10: * http://www.apple.com/publicsource and read it before using this file. ! 11: * ! 12: * This Original Code and all software distributed under the License are ! 13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 17: * License for the specific language governing rights and limitations ! 18: * under the License. ! 19: * ! 20: * @APPLE_LICENSE_HEADER_END@ ! 21: */ ! 22: /* ! 23: * Copyright (c) 1998 Apple Computer, Inc. All rights reserved. ! 24: * ! 25: * HISTORY ! 26: */ ! 27: ! 28: #include <IOKit/system.h> ! 29: ! 30: #include <architecture/i386/kernBootStruct.h> ! 31: ! 32: #include <IOKit/IORegistryEntry.h> ! 33: #include <libkern/c++/OSContainers.h> ! 34: #include <IOKit/IOLib.h> ! 35: #include <libkern/c++/OSUnserialize.h> ! 36: ! 37: #include "AppleI386PlatformExpert.h" ! 38: ! 39: #include <assert.h> ! 40: ! 41: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ ! 42: ! 43: #define super IOPlatformExpert ! 44: ! 45: OSSymbol * gIntelPICName; ! 46: ! 47: OSDefineMetaClassAndStructors(AppleI386PlatformExpert, IOPlatformExpert) ! 48: ! 49: IOService * AppleI386PlatformExpert::probe(IOService * /* provider */, ! 50: SInt32 * score ) ! 51: { ! 52: *score = 2000; ! 53: ! 54: return (this); ! 55: } ! 56: ! 57: bool AppleI386PlatformExpert::start(IOService * provider) ! 58: { ! 59: gIntelPICName = (OSSymbol *) OSSymbol::withCStringNoCopy("intel-pic"); ! 60: ! 61: // setupPIC(provider); ! 62: ! 63: if (!super::start(provider)) ! 64: return false; ! 65: ! 66: return true; ! 67: } ! 68: ! 69: IOService * AppleI386PlatformExpert::createNub(OSDictionary * from) ! 70: { ! 71: IOService * nub; ! 72: OSData * prop; ! 73: KERNBOOTSTRUCT * bootStruct; ! 74: ! 75: nub = super::createNub(from); ! 76: ! 77: if (nub) ! 78: { ! 79: if (0 == strcmp( "pci", nub->getName())) ! 80: { ! 81: bootStruct = (KERNBOOTSTRUCT *) PE_state.bootArgs; ! 82: prop = OSData::withBytesNoCopy(&bootStruct->pciInfo, ! 83: sizeof(bootStruct->pciInfo)); ! 84: assert(prop); ! 85: if (prop) ! 86: from->setObject( "pci-bus-info", prop); ! 87: } ! 88: else if (0 != strcmp("intel-pic", nub->getName())) ! 89: { ! 90: setupPIC(nub); ! 91: } ! 92: } ! 93: ! 94: return (nub); ! 95: } ! 96: ! 97: #define kNumVectors 16 ! 98: ! 99: void ! 100: AppleI386PlatformExpert::setupPIC(IOService *nub) ! 101: { ! 102: int i; ! 103: OSDictionary * propTable; ! 104: OSArray * controller; ! 105: OSArray * specifier; ! 106: OSData * tmpData; ! 107: long tmpLong; ! 108: ! 109: propTable = nub->getPropertyTable(); ! 110: ! 111: // ! 112: // For the moment.. assume a classic 8259 interrupt controller ! 113: // with 16 interrupts. ! 114: // ! 115: // Later, this will be changed to detect a APIC and/or MP-Table ! 116: // and then will set the nubs appropriately. ! 117: ! 118: // Create the interrupt specifer array. ! 119: specifier = OSArray::withCapacity(kNumVectors); ! 120: assert(specifier); ! 121: for (i = 0; i < kNumVectors; i++) { ! 122: tmpLong = i; ! 123: tmpData = OSData::withBytes(&tmpLong, sizeof(tmpLong)); ! 124: specifier->setObject(tmpData); ! 125: } ! 126: ! 127: // Create the interrupt controller array. ! 128: controller = OSArray::withCapacity(kNumVectors); ! 129: assert(controller); ! 130: for (i = 0; i < kNumVectors; i++) ! 131: controller->setObject(gIntelPICName); ! 132: ! 133: // Put the two arrays into the property table. ! 134: propTable->setObject(gIOInterruptControllersKey, controller); ! 135: propTable->setObject(gIOInterruptSpecifiersKey, specifier); ! 136: ! 137: // Release the arrays after being added to the property table. ! 138: specifier->release(); ! 139: controller->release(); ! 140: } ! 141: ! 142: bool ! 143: AppleI386PlatformExpert::matchNubWithPropertyTable(IOService * nub, ! 144: OSDictionary * propTable ) ! 145: { ! 146: OSString * nameProp; ! 147: OSString * match; ! 148: ! 149: if (0 == (nameProp = (OSString *) nub->getProperty(gIONameKey))) ! 150: return (false); ! 151: ! 152: if ( 0 == (match = (OSString *) propTable->getObject(gIONameMatchKey))) ! 153: return (false); ! 154: ! 155: return (match->isEqualTo( nameProp )); ! 156: } ! 157: ! 158: bool AppleI386PlatformExpert::getMachineName( char * name, int maxLength ) ! 159: { ! 160: strncpy( name, "x86", maxLength ); ! 161: ! 162: return (true); ! 163: } ! 164: ! 165: bool AppleI386PlatformExpert::getModelName( char * name, int maxLength ) ! 166: { ! 167: strncpy( name, "x86", maxLength ); ! 168: ! 169: return (true); ! 170: } ! 171: ! 172: ! 173: /* ! 174: * Backdoor routines for drivers which are not yet IOKit drivers. ! 175: * (aka if_fxp.c ) ! 176: * FIXME/REMOVEME when if_fxp.c becomes part of IOKit. ! 177: */ ! 178: ! 179: extern "C" { ! 180: void IOKitRegisterInterruptHookStub(void * /*unused */, int vector, int isclock); ! 181: ! 182: void IOKitRegisterInterruptHookStub(void * /*unused */, int /* vector */, int isclock) ! 183: { ! 184: panic("RegisterInterruptHook routine called without being setup!\n"); ! 185: } ! 186: ! 187: void (*IOKitRegisterInterruptHook)(void *, int pic, int isclock) = ! 188: IOKitRegisterInterruptHookStub; ! 189: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.