]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOPlatformExpert.h
e5ad2a89e2124bdc6d2bad500d783d0cfe0d2e9c
[apple/xnu.git] / iokit / IOKit / IOPlatformExpert.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
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
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.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
27 *
28 * HISTORY
29 *
30 */
31
32
33 #ifndef _IOKIT_IOPLATFORMEXPERT_H
34 #define _IOKIT_IOPLATFORMEXPERT_H
35
36 #ifdef __cplusplus
37 #include <IOKit/IOLib.h>
38 #include <IOKit/IOService.h>
39 #include <IOKit/IOInterrupts.h>
40 #include <IOKit/IOInterruptController.h>
41
42 extern "C" {
43 #endif
44
45 extern boolean_t PEGetMachineName( char * name, int maxLength );
46 extern boolean_t PEGetModelName( char * name, int maxLength );
47 extern int PEGetPlatformEpoch( void );
48
49 enum {
50 kPEHaltCPU,
51 kPERestartCPU,
52 kPEHangCPU
53 };
54 extern int (*PE_halt_restart)(unsigned int type);
55 extern int PEHaltRestart(unsigned int type);
56
57 // Save the Panic Info. Returns the number of bytes saved.
58 extern unsigned long PESavePanicInfo(unsigned char *buffer, unsigned long length);
59
60 extern long PEGetGMTTimeOfDay( void );
61 extern void PESetGMTTimeOfDay( long secs );
62
63 #ifdef __cplusplus
64 } /* extern "C" */
65
66 #define kIOPlatformMapperPresentKey "IOPlatformMapperPresent"
67
68 extern OSSymbol * gPlatformInterruptControllerName;
69
70 class IORangeAllocator;
71 class IONVRAMController;
72 class IOPMrootDomain;
73
74 class IOPlatformExpert : public IOService
75 {
76 OSDeclareDefaultStructors(IOPlatformExpert);
77
78 private:
79 long _peBootROMType;
80 long _peChipSetType;
81 long _peMachineType;
82
83 protected:
84 IOPMrootDomain * root;
85 int _pePMFeatures;
86 int _pePrivPMFeatures;
87 int _peNumBatteriesSupported;
88 OSArray * thePowerTree;
89
90 bool searchingForAdditionalParents;
91 OSNumber * multipleParentKeyValue;
92 int numInstancesRegistered;
93
94 struct ExpansionData { };
95 ExpansionData *reserved;
96
97 virtual void setBootROMType(long peBootROMType);
98 virtual void setChipSetType(long peChipSetType);
99 virtual void setMachineType(long peMachineType);
100
101 virtual bool CheckSubTree (OSArray * inSubTree, IOService * theNub, IOService * theDevice, OSDictionary * theParent);
102 virtual bool RegisterServiceInTree (IOService * theService, OSDictionary * theTreeNode, OSDictionary * theTreeParentNode, IOService * theProvider);
103
104 virtual void PMInstantiatePowerDomains ( void );
105
106 public:
107 virtual bool attach( IOService * provider );
108 virtual bool start( IOService * provider );
109 virtual bool configure( IOService * provider );
110 virtual IOService * createNub( OSDictionary * from );
111
112 virtual bool compareNubName( const IOService * nub, OSString * name,
113 OSString ** matched = 0 ) const;
114 virtual IOReturn getNubResources( IOService * nub );
115
116 virtual long getBootROMType(void);
117 virtual long getChipSetType(void);
118 virtual long getMachineType(void);
119
120 virtual bool getModelName( char * name, int maxLength );
121 virtual bool getMachineName( char * name, int maxLength );
122
123 virtual int haltRestart(unsigned int type);
124 virtual void sleepKernel(void);
125
126 virtual long getGMTTimeOfDay( void );
127 virtual void setGMTTimeOfDay( long secs );
128
129 virtual IOReturn getConsoleInfo( PE_Video * consoleInfo );
130 virtual IOReturn setConsoleInfo( PE_Video * consoleInfo, unsigned int op );
131
132 virtual void registerNVRAMController( IONVRAMController * nvram );
133
134 virtual IOReturn registerInterruptController(OSSymbol *name, IOInterruptController *interruptController);
135 virtual IOInterruptController *lookUpInterruptController(OSSymbol *name);
136 virtual void setCPUInterruptProperties(IOService *service);
137 virtual bool atInterruptLevel(void);
138
139 virtual IOReturn callPlatformFunction(const OSSymbol *functionName,
140 bool waitForFunction,
141 void *param1, void *param2,
142 void *param3, void *param4);
143
144 virtual IORangeAllocator * getPhysicalRangeAllocator(void);
145
146 virtual bool platformAdjustService(IOService *service);
147
148 virtual void PMRegisterDevice(IOService * theNub, IOService * theDevice);
149 virtual void PMLog ( const char *,unsigned long, unsigned long, unsigned long );
150
151 virtual bool hasPMFeature (unsigned long featureMask);
152 virtual bool hasPrivPMFeature (unsigned long privFeatureMask);
153 virtual int numBatteriesSupported (void);
154
155 virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
156
157 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 0);
158
159 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 1);
160 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 2);
161 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 3);
162 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 4);
163 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 5);
164 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 6);
165 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 7);
166 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 8);
167 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 9);
168 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 10);
169 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 11);
170 };
171
172 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
173
174 class IODTNVRAM;
175
176 class IODTPlatformExpert : public IOPlatformExpert
177 {
178 OSDeclareAbstractStructors(IODTPlatformExpert);
179
180 private:
181 IODTNVRAM *dtNVRAM;
182
183 struct ExpansionData { };
184 ExpansionData *reserved;
185
186 public:
187 virtual IOService * probe( IOService * provider,
188 SInt32 * score );
189 virtual bool configure( IOService * provider );
190
191 virtual void processTopLevel( IORegistryEntry * root );
192 virtual const char * deleteList( void ) = 0;
193 virtual const char * excludeList( void ) = 0;
194 virtual IOService * createNub( IORegistryEntry * from );
195 virtual bool createNubs( IOService * parent, OSIterator * iter );
196
197 virtual bool compareNubName( const IOService * nub, OSString * name,
198 OSString ** matched = 0 ) const;
199
200 virtual IOReturn getNubResources( IOService * nub );
201
202 virtual bool getModelName( char * name, int maxLength );
203 virtual bool getMachineName( char * name, int maxLength );
204
205 virtual void registerNVRAMController( IONVRAMController * nvram );
206
207 virtual int haltRestart(unsigned int type);
208
209 /* virtual */ IOReturn readXPRAM(IOByteCount offset, UInt8 * buffer,
210 IOByteCount length);
211
212 /* virtual */ IOReturn writeXPRAM(IOByteCount offset, UInt8 * buffer,
213 IOByteCount length);
214
215 virtual IOReturn readNVRAMProperty(
216 IORegistryEntry * entry,
217 const OSSymbol ** name, OSData ** value );
218
219 virtual IOReturn writeNVRAMProperty(
220 IORegistryEntry * entry,
221 const OSSymbol * name, OSData * value );
222
223 // This returns a dictionary describing all the NVRAM partitions.
224 // The keys will be the partitionIDs of the form "0x52,nvram".
225 // The values will be OSNumbers of the partition's byte count.
226 /* virtual */ OSDictionary *getNVRAMPartitions(void);
227
228 /* virtual */ IOReturn readNVRAMPartition(const OSSymbol * partitionID,
229 IOByteCount offset, UInt8 * buffer,
230 IOByteCount length);
231
232 /* virtual */ IOReturn writeNVRAMPartition(const OSSymbol * partitionID,
233 IOByteCount offset, UInt8 * buffer,
234 IOByteCount length);
235
236 virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
237
238 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 0);
239 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 1);
240 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 2);
241 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 3);
242 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 4);
243 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 5);
244 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 6);
245 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 7);
246 };
247
248 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
249
250 /* generic root nub of service tree */
251
252 class IOPlatformExpertDevice : public IOService
253 {
254 OSDeclareDefaultStructors(IOPlatformExpertDevice)
255
256 private:
257 IOWorkLoop *workLoop;
258
259 struct ExpansionData { };
260 ExpansionData *reserved;
261
262 public:
263 virtual bool initWithArgs( void * p1, void * p2,
264 void * p3, void *p4 );
265 virtual bool compareName( OSString * name, OSString ** matched = 0 ) const;
266
267 virtual IOWorkLoop *getWorkLoop() const;
268
269 virtual void free();
270
271 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 0);
272 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 1);
273 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 2);
274 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 3);
275 };
276
277 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
278
279 /* generic nub for motherboard devices */
280
281 class IOPlatformDevice : public IOService
282 {
283 OSDeclareDefaultStructors(IOPlatformDevice)
284
285 struct ExpansionData { };
286 ExpansionData *reserved;
287
288 public:
289 virtual bool compareName( OSString * name, OSString ** matched = 0 ) const;
290 virtual IOService * matchLocation( IOService * client );
291 virtual IOReturn getResources( void );
292
293 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 0);
294 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 1);
295 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 2);
296 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 3);
297 };
298
299 #endif /* __cplusplus */
300
301 #endif /* ! _IOKIT_IOPLATFORMEXPERT_H */