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