2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
31 #include <IOKit/system.h>
33 #include <architecture/i386/kernBootStruct.h>
35 #include <IOKit/IORegistryEntry.h>
36 #include <libkern/c++/OSContainers.h>
37 #include <IOKit/IOLib.h>
38 #include <libkern/c++/OSUnserialize.h>
40 #include <IOKit/platform/ApplePlatformExpert.h>
41 #include "AppleI386PlatformExpert.h"
43 #include <IOKit/assert.h>
46 extern void kdreboot(void);
48 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
50 #define super IOPlatformExpert
52 OSSymbol
* gIntelPICName
;
54 OSDefineMetaClassAndStructors(AppleI386PlatformExpert
, IOPlatformExpert
)
56 IOService
* AppleI386PlatformExpert::probe(IOService
* /* provider */,
64 bool AppleI386PlatformExpert::start(IOService
* provider
)
66 gIntelPICName
= (OSSymbol
*) OSSymbol::withCStringNoCopy("intel-pic");
68 setBootROMType(kBootROMTypeNewWorld
); /* hammer to new world for i386 */
70 // setupPIC(provider);
72 if (!super::start(provider
))
75 // Install halt/restart handler.
77 PE_halt_restart
= handlePEHaltRestart
;
82 IOService
* AppleI386PlatformExpert::createNub(OSDictionary
* from
)
86 KERNBOOTSTRUCT
* bootStruct
;
88 nub
= super::createNub(from
);
92 if (0 == strcmp( "pci", nub
->getName()))
94 bootStruct
= (KERNBOOTSTRUCT
*) PE_state
.bootArgs
;
95 prop
= OSData::withBytesNoCopy(&bootStruct
->pciInfo
,
96 sizeof(bootStruct
->pciInfo
));
99 from
->setObject( "pci-bus-info", prop
);
101 else if (0 != strcmp("intel-pic", nub
->getName()))
110 #define kNumVectors 16
113 AppleI386PlatformExpert::setupPIC(IOService
*nub
)
116 OSDictionary
* propTable
;
117 OSArray
* controller
;
122 propTable
= nub
->getPropertyTable();
125 // For the moment.. assume a classic 8259 interrupt controller
126 // with 16 interrupts.
128 // Later, this will be changed to detect a APIC and/or MP-Table
129 // and then will set the nubs appropriately.
131 // Create the interrupt specifer array.
132 specifier
= OSArray::withCapacity(kNumVectors
);
134 for (i
= 0; i
< kNumVectors
; i
++) {
136 tmpData
= OSData::withBytes(&tmpLong
, sizeof(tmpLong
));
137 specifier
->setObject(tmpData
);
140 // Create the interrupt controller array.
141 controller
= OSArray::withCapacity(kNumVectors
);
143 for (i
= 0; i
< kNumVectors
; i
++)
144 controller
->setObject(gIntelPICName
);
146 // Put the two arrays into the property table.
147 propTable
->setObject(gIOInterruptControllersKey
, controller
);
148 propTable
->setObject(gIOInterruptSpecifiersKey
, specifier
);
150 // Release the arrays after being added to the property table.
151 specifier
->release();
152 controller
->release();
156 AppleI386PlatformExpert::matchNubWithPropertyTable(IOService
* nub
,
157 OSDictionary
* propTable
)
162 if (0 == (nameProp
= (OSString
*) nub
->getProperty(gIONameKey
)))
165 if ( 0 == (match
= (OSString
*) propTable
->getObject(gIONameMatchKey
)))
168 return (match
->isEqualTo( nameProp
));
171 bool AppleI386PlatformExpert::getMachineName( char * name
, int maxLength
)
173 strncpy( name
, "x86", maxLength
);
178 bool AppleI386PlatformExpert::getModelName( char * name
, int maxLength
)
180 strncpy( name
, "x86", maxLength
);
185 int AppleI386PlatformExpert::handlePEHaltRestart( unsigned int type
)
192 // Use the pexpert service to reset the system through
193 // the keyboard controller.