]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
d7e50217 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
d7e50217 A |
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 | |
13 | * file. | |
14 | * | |
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 | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
d7e50217 A |
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. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * Copyright (c) 1998 Apple Computer, Inc. All rights reserved. | |
27 | * | |
28 | * HISTORY | |
29 | */ | |
30 | ||
31 | #include <IOKit/system.h> | |
32 | ||
33 | #include <architecture/i386/kernBootStruct.h> | |
34 | ||
35 | #include <IOKit/IORegistryEntry.h> | |
36 | #include <libkern/c++/OSContainers.h> | |
37 | #include <IOKit/IOLib.h> | |
38 | #include <libkern/c++/OSUnserialize.h> | |
39 | ||
9bccf70c | 40 | #include <IOKit/platform/ApplePlatformExpert.h> |
1c79356b A |
41 | #include "AppleI386PlatformExpert.h" |
42 | ||
43 | #include <IOKit/assert.h> | |
44 | ||
9bccf70c A |
45 | __BEGIN_DECLS |
46 | extern void kdreboot(void); | |
47 | __END_DECLS | |
1c79356b A |
48 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
49 | ||
50 | #define super IOPlatformExpert | |
51 | ||
52 | OSSymbol * gIntelPICName; | |
53 | ||
54 | OSDefineMetaClassAndStructors(AppleI386PlatformExpert, IOPlatformExpert) | |
55 | ||
56 | IOService * AppleI386PlatformExpert::probe(IOService * /* provider */, | |
57 | SInt32 * score ) | |
58 | { | |
59 | *score = 2000; | |
60 | ||
61 | return (this); | |
62 | } | |
63 | ||
64 | bool AppleI386PlatformExpert::start(IOService * provider) | |
65 | { | |
66 | gIntelPICName = (OSSymbol *) OSSymbol::withCStringNoCopy("intel-pic"); | |
67 | ||
9bccf70c A |
68 | setBootROMType(kBootROMTypeNewWorld); /* hammer to new world for i386 */ |
69 | ||
1c79356b A |
70 | // setupPIC(provider); |
71 | ||
72 | if (!super::start(provider)) | |
73 | return false; | |
74 | ||
9bccf70c A |
75 | // Install halt/restart handler. |
76 | ||
77 | PE_halt_restart = handlePEHaltRestart; | |
78 | ||
1c79356b A |
79 | return true; |
80 | } | |
81 | ||
82 | IOService * AppleI386PlatformExpert::createNub(OSDictionary * from) | |
83 | { | |
84 | IOService * nub; | |
85 | OSData * prop; | |
86 | KERNBOOTSTRUCT * bootStruct; | |
87 | ||
88 | nub = super::createNub(from); | |
89 | ||
90 | if (nub) | |
91 | { | |
92 | if (0 == strcmp( "pci", nub->getName())) | |
93 | { | |
94 | bootStruct = (KERNBOOTSTRUCT *) PE_state.bootArgs; | |
95 | prop = OSData::withBytesNoCopy(&bootStruct->pciInfo, | |
96 | sizeof(bootStruct->pciInfo)); | |
97 | assert(prop); | |
98 | if (prop) | |
99 | from->setObject( "pci-bus-info", prop); | |
100 | } | |
101 | else if (0 != strcmp("intel-pic", nub->getName())) | |
102 | { | |
103 | setupPIC(nub); | |
104 | } | |
105 | } | |
106 | ||
107 | return (nub); | |
108 | } | |
109 | ||
110 | #define kNumVectors 16 | |
111 | ||
112 | void | |
113 | AppleI386PlatformExpert::setupPIC(IOService *nub) | |
114 | { | |
115 | int i; | |
116 | OSDictionary * propTable; | |
117 | OSArray * controller; | |
118 | OSArray * specifier; | |
119 | OSData * tmpData; | |
120 | long tmpLong; | |
121 | ||
122 | propTable = nub->getPropertyTable(); | |
123 | ||
124 | // | |
125 | // For the moment.. assume a classic 8259 interrupt controller | |
126 | // with 16 interrupts. | |
127 | // | |
128 | // Later, this will be changed to detect a APIC and/or MP-Table | |
129 | // and then will set the nubs appropriately. | |
130 | ||
131 | // Create the interrupt specifer array. | |
132 | specifier = OSArray::withCapacity(kNumVectors); | |
133 | assert(specifier); | |
134 | for (i = 0; i < kNumVectors; i++) { | |
135 | tmpLong = i; | |
136 | tmpData = OSData::withBytes(&tmpLong, sizeof(tmpLong)); | |
137 | specifier->setObject(tmpData); | |
138 | } | |
139 | ||
140 | // Create the interrupt controller array. | |
141 | controller = OSArray::withCapacity(kNumVectors); | |
142 | assert(controller); | |
143 | for (i = 0; i < kNumVectors; i++) | |
144 | controller->setObject(gIntelPICName); | |
145 | ||
146 | // Put the two arrays into the property table. | |
147 | propTable->setObject(gIOInterruptControllersKey, controller); | |
148 | propTable->setObject(gIOInterruptSpecifiersKey, specifier); | |
149 | ||
150 | // Release the arrays after being added to the property table. | |
151 | specifier->release(); | |
152 | controller->release(); | |
153 | } | |
154 | ||
155 | bool | |
156 | AppleI386PlatformExpert::matchNubWithPropertyTable(IOService * nub, | |
157 | OSDictionary * propTable ) | |
158 | { | |
159 | OSString * nameProp; | |
160 | OSString * match; | |
161 | ||
162 | if (0 == (nameProp = (OSString *) nub->getProperty(gIONameKey))) | |
163 | return (false); | |
164 | ||
165 | if ( 0 == (match = (OSString *) propTable->getObject(gIONameMatchKey))) | |
166 | return (false); | |
167 | ||
168 | return (match->isEqualTo( nameProp )); | |
169 | } | |
170 | ||
171 | bool AppleI386PlatformExpert::getMachineName( char * name, int maxLength ) | |
172 | { | |
173 | strncpy( name, "x86", maxLength ); | |
174 | ||
175 | return (true); | |
176 | } | |
177 | ||
178 | bool AppleI386PlatformExpert::getModelName( char * name, int maxLength ) | |
179 | { | |
180 | strncpy( name, "x86", maxLength ); | |
181 | ||
182 | return (true); | |
183 | } | |
9bccf70c A |
184 | |
185 | int AppleI386PlatformExpert::handlePEHaltRestart( unsigned int type ) | |
186 | { | |
187 | int ret = 1; | |
188 | ||
189 | switch ( type ) | |
190 | { | |
191 | case kPERestartCPU: | |
192 | // Use the pexpert service to reset the system through | |
193 | // the keyboard controller. | |
194 | kdreboot(); | |
195 | break; | |
196 | ||
197 | case kPEHaltCPU: | |
198 | default: | |
199 | ret = -1; | |
200 | break; | |
201 | } | |
202 | ||
203 | return ret; | |
204 | } |