2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
28 #include <IOKit/system.h>
30 #include <architecture/i386/kernBootStruct.h>
32 #include <IOKit/IORegistryEntry.h>
33 #include <libkern/c++/OSContainers.h>
34 #include <IOKit/IOLib.h>
35 #include <libkern/c++/OSUnserialize.h>
37 #include <IOKit/platform/ApplePlatformExpert.h>
38 #include "AppleI386PlatformExpert.h"
40 #include <IOKit/assert.h>
43 extern void kdreboot(void);
45 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
47 #define super IOPlatformExpert
49 OSSymbol
* gIntelPICName
;
51 OSDefineMetaClassAndStructors(AppleI386PlatformExpert
, IOPlatformExpert
)
53 IOService
* AppleI386PlatformExpert::probe(IOService
* /* provider */,
61 bool AppleI386PlatformExpert::start(IOService
* provider
)
63 gIntelPICName
= (OSSymbol
*) OSSymbol::withCStringNoCopy("intel-pic");
65 setBootROMType(kBootROMTypeNewWorld
); /* hammer to new world for i386 */
67 // setupPIC(provider);
69 if (!super::start(provider
))
72 // Install halt/restart handler.
74 PE_halt_restart
= handlePEHaltRestart
;
79 IOService
* AppleI386PlatformExpert::createNub(OSDictionary
* from
)
83 KERNBOOTSTRUCT
* bootStruct
;
85 nub
= super::createNub(from
);
89 if (0 == strcmp( "pci", nub
->getName()))
91 bootStruct
= (KERNBOOTSTRUCT
*) PE_state
.bootArgs
;
92 prop
= OSData::withBytesNoCopy(&bootStruct
->pciInfo
,
93 sizeof(bootStruct
->pciInfo
));
96 from
->setObject( "pci-bus-info", prop
);
98 else if (0 != strcmp("intel-pic", nub
->getName()))
107 #define kNumVectors 16
110 AppleI386PlatformExpert::setupPIC(IOService
*nub
)
113 OSDictionary
* propTable
;
114 OSArray
* controller
;
119 propTable
= nub
->getPropertyTable();
122 // For the moment.. assume a classic 8259 interrupt controller
123 // with 16 interrupts.
125 // Later, this will be changed to detect a APIC and/or MP-Table
126 // and then will set the nubs appropriately.
128 // Create the interrupt specifer array.
129 specifier
= OSArray::withCapacity(kNumVectors
);
131 for (i
= 0; i
< kNumVectors
; i
++) {
133 tmpData
= OSData::withBytes(&tmpLong
, sizeof(tmpLong
));
134 specifier
->setObject(tmpData
);
137 // Create the interrupt controller array.
138 controller
= OSArray::withCapacity(kNumVectors
);
140 for (i
= 0; i
< kNumVectors
; i
++)
141 controller
->setObject(gIntelPICName
);
143 // Put the two arrays into the property table.
144 propTable
->setObject(gIOInterruptControllersKey
, controller
);
145 propTable
->setObject(gIOInterruptSpecifiersKey
, specifier
);
147 // Release the arrays after being added to the property table.
148 specifier
->release();
149 controller
->release();
153 AppleI386PlatformExpert::matchNubWithPropertyTable(IOService
* nub
,
154 OSDictionary
* propTable
)
159 if (0 == (nameProp
= (OSString
*) nub
->getProperty(gIONameKey
)))
162 if ( 0 == (match
= (OSString
*) propTable
->getObject(gIONameMatchKey
)))
165 return (match
->isEqualTo( nameProp
));
168 bool AppleI386PlatformExpert::getMachineName( char * name
, int maxLength
)
170 strncpy( name
, "x86", maxLength
);
175 bool AppleI386PlatformExpert::getModelName( char * name
, int maxLength
)
177 strncpy( name
, "x86", maxLength
);
182 int AppleI386PlatformExpert::handlePEHaltRestart( unsigned int type
)
189 // Use the pexpert service to reset the system through
190 // the keyboard controller.