]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOPlatformExpert.h
64a66a8e97b94087585ccffc8c558b42dbfcc1d9
[apple/xnu.git] / iokit / IOKit / IOPlatformExpert.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
32 *
33 * HISTORY
34 *
35 */
36
37
38 #ifndef _IOKIT_IOPLATFORMEXPERT_H
39 #define _IOKIT_IOPLATFORMEXPERT_H
40
41 #ifdef __cplusplus
42 #include <IOKit/IOLib.h>
43 #include <IOKit/IOService.h>
44 #include <IOKit/IOInterrupts.h>
45 #include <IOKit/IOInterruptController.h>
46
47 extern "C" {
48 #endif
49
50 extern boolean_t PEGetMachineName( char * name, int maxLength );
51 extern boolean_t PEGetModelName( char * name, int maxLength );
52 extern int PEGetPlatformEpoch( void );
53
54 enum {
55 kPEHaltCPU,
56 kPERestartCPU,
57 kPEHangCPU,
58 kPEUPSDelayHaltCPU
59 };
60 extern int (*PE_halt_restart)(unsigned int type);
61 extern int PEHaltRestart(unsigned int type);
62
63 // Save the Panic Info. Returns the number of bytes saved.
64 extern unsigned long PESavePanicInfo(unsigned char *buffer, unsigned long length);
65
66 extern long PEGetGMTTimeOfDay( void );
67 extern void PESetGMTTimeOfDay( long secs );
68
69 #ifdef __cplusplus
70 } /* extern "C" */
71
72 #define kIOPlatformMapperPresentKey "IOPlatformMapperPresent"
73
74 extern OSSymbol * gPlatformInterruptControllerName;
75
76 class IORangeAllocator;
77 class IONVRAMController;
78 class IOPMrootDomain;
79
80 class IOPlatformExpert : public IOService
81 {
82 OSDeclareDefaultStructors(IOPlatformExpert);
83
84 private:
85 long _peBootROMType;
86 long _peChipSetType;
87 long _peMachineType;
88
89 protected:
90 IOPMrootDomain * root;
91 int _pePMFeatures;
92 int _pePrivPMFeatures;
93 int _peNumBatteriesSupported;
94 OSArray * thePowerTree;
95
96 bool searchingForAdditionalParents;
97 OSNumber * multipleParentKeyValue;
98 int numInstancesRegistered;
99
100 struct ExpansionData { };
101 ExpansionData *reserved;
102
103 virtual void setBootROMType(long peBootROMType);
104 virtual void setChipSetType(long peChipSetType);
105 virtual void setMachineType(long peMachineType);
106
107 virtual bool CheckSubTree (OSArray * inSubTree, IOService * theNub, IOService * theDevice, OSDictionary * theParent);
108 virtual bool RegisterServiceInTree (IOService * theService, OSDictionary * theTreeNode, OSDictionary * theTreeParentNode, IOService * theProvider);
109
110 virtual void PMInstantiatePowerDomains ( void );
111
112 public:
113 virtual bool attach( IOService * provider );
114 virtual bool start( IOService * provider );
115 virtual bool configure( IOService * provider );
116 virtual IOService * createNub( OSDictionary * from );
117
118 virtual bool compareNubName( const IOService * nub, OSString * name,
119 OSString ** matched = 0 ) const;
120 virtual IOReturn getNubResources( IOService * nub );
121
122 virtual long getBootROMType(void);
123 virtual long getChipSetType(void);
124 virtual long getMachineType(void);
125
126 virtual bool getModelName( char * name, int maxLength );
127 virtual bool getMachineName( char * name, int maxLength );
128
129 virtual int haltRestart(unsigned int type);
130 virtual void sleepKernel(void);
131
132 virtual long getGMTTimeOfDay( void );
133 virtual void setGMTTimeOfDay( long secs );
134
135 virtual IOReturn getConsoleInfo( PE_Video * consoleInfo );
136 virtual IOReturn setConsoleInfo( PE_Video * consoleInfo, unsigned int op );
137
138 virtual void registerNVRAMController( IONVRAMController * nvram );
139
140 virtual IOReturn registerInterruptController(OSSymbol *name, IOInterruptController *interruptController);
141 virtual IOInterruptController *lookUpInterruptController(OSSymbol *name);
142 virtual void setCPUInterruptProperties(IOService *service);
143 virtual bool atInterruptLevel(void);
144
145 virtual IOReturn callPlatformFunction(const OSSymbol *functionName,
146 bool waitForFunction,
147 void *param1, void *param2,
148 void *param3, void *param4);
149
150 virtual IORangeAllocator * getPhysicalRangeAllocator(void);
151
152 virtual bool platformAdjustService(IOService *service);
153
154 virtual void PMRegisterDevice(IOService * theNub, IOService * theDevice);
155 virtual void PMLog ( const char *,unsigned long, unsigned long, unsigned long );
156
157 virtual bool hasPMFeature (unsigned long featureMask);
158 virtual bool hasPrivPMFeature (unsigned long privFeatureMask);
159 virtual int numBatteriesSupported (void);
160
161 virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
162
163 virtual OSString* createSystemSerialNumberString(OSData* myProperty);
164
165 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 0);
166 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 1);
167 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 2);
168 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 3);
169 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 4);
170 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 5);
171 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 6);
172 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 7);
173 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 8);
174 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 9);
175 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 10);
176 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 11);
177 };
178
179 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
180
181 class IODTNVRAM;
182
183 class IODTPlatformExpert : public IOPlatformExpert
184 {
185 OSDeclareAbstractStructors(IODTPlatformExpert);
186
187 private:
188 IODTNVRAM *dtNVRAM;
189
190 struct ExpansionData { };
191 ExpansionData *reserved;
192
193 public:
194 virtual IOService * probe( IOService * provider,
195 SInt32 * score );
196 virtual bool configure( IOService * provider );
197
198 virtual void processTopLevel( IORegistryEntry * root );
199 virtual const char * deleteList( void ) = 0;
200 virtual const char * excludeList( void ) = 0;
201 virtual IOService * createNub( IORegistryEntry * from );
202 virtual bool createNubs( IOService * parent, OSIterator * iter );
203
204 virtual bool compareNubName( const IOService * nub, OSString * name,
205 OSString ** matched = 0 ) const;
206
207 virtual IOReturn getNubResources( IOService * nub );
208
209 virtual bool getModelName( char * name, int maxLength );
210 virtual bool getMachineName( char * name, int maxLength );
211
212 virtual void registerNVRAMController( IONVRAMController * nvram );
213
214 virtual int haltRestart(unsigned int type);
215
216 /* virtual */ IOReturn readXPRAM(IOByteCount offset, UInt8 * buffer,
217 IOByteCount length);
218
219 /* virtual */ IOReturn writeXPRAM(IOByteCount offset, UInt8 * buffer,
220 IOByteCount length);
221
222 virtual IOReturn readNVRAMProperty(
223 IORegistryEntry * entry,
224 const OSSymbol ** name, OSData ** value );
225
226 virtual IOReturn writeNVRAMProperty(
227 IORegistryEntry * entry,
228 const OSSymbol * name, OSData * value );
229
230 // This returns a dictionary describing all the NVRAM partitions.
231 // The keys will be the partitionIDs of the form "0x52,nvram".
232 // The values will be OSNumbers of the partition's byte count.
233 /* virtual */ OSDictionary *getNVRAMPartitions(void);
234
235 /* virtual */ IOReturn readNVRAMPartition(const OSSymbol * partitionID,
236 IOByteCount offset, UInt8 * buffer,
237 IOByteCount length);
238
239 /* virtual */ IOReturn writeNVRAMPartition(const OSSymbol * partitionID,
240 IOByteCount offset, UInt8 * buffer,
241 IOByteCount length);
242
243 virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
244 virtual OSString* createSystemSerialNumberString(OSData* myProperty);
245
246 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 0);
247 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 1);
248 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 2);
249 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 3);
250 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 4);
251 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 5);
252 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 6);
253 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 7);
254 };
255
256 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
257
258 /* generic root nub of service tree */
259
260 class IOPlatformExpertDevice : public IOService
261 {
262 OSDeclareDefaultStructors(IOPlatformExpertDevice)
263
264 private:
265 IOWorkLoop *workLoop;
266
267 struct ExpansionData { };
268 ExpansionData *reserved;
269
270 public:
271 virtual bool initWithArgs( void * p1, void * p2,
272 void * p3, void *p4 );
273 virtual bool compareName( OSString * name, OSString ** matched = 0 ) const;
274
275 virtual IOWorkLoop *getWorkLoop() const;
276
277 virtual void free();
278
279 virtual bool attachToChild( IORegistryEntry * child,
280 const IORegistryPlane * plane );
281
282 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 0);
283 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 1);
284 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 2);
285 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 3);
286 };
287
288 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
289
290 /* generic nub for motherboard devices */
291
292 class IOPlatformDevice : public IOService
293 {
294 OSDeclareDefaultStructors(IOPlatformDevice)
295
296 struct ExpansionData { };
297 ExpansionData *reserved;
298
299 public:
300 virtual bool compareName( OSString * name, OSString ** matched = 0 ) const;
301 virtual IOService * matchLocation( IOService * client );
302 virtual IOReturn getResources( void );
303
304 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 0);
305 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 1);
306 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 2);
307 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 3);
308 };
309
310 #endif /* __cplusplus */
311
312 #endif /* ! _IOKIT_IOPLATFORMEXPERT_H */