]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOPlatformExpert.h
4ed12a6a8809b87d41cc9718bb3ed5bf600f8969
[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 * 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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /*
24 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
25 *
26 * HISTORY
27 *
28 */
29
30
31 #ifndef _IOKIT_IOPLATFORMEXPERT_H
32 #define _IOKIT_IOPLATFORMEXPERT_H
33
34 #ifdef __cplusplus
35 #include <IOKit/IOLib.h>
36 #include <IOKit/IOService.h>
37 #include <IOKit/IOInterrupts.h>
38 #include <IOKit/IOInterruptController.h>
39
40 extern "C" {
41 #endif
42
43 extern boolean_t PEGetMachineName( char * name, int maxLength );
44 extern boolean_t PEGetModelName( char * name, int maxLength );
45 extern int PEGetPlatformEpoch( void );
46
47 enum {
48 kPEHaltCPU,
49 kPERestartCPU,
50 kPEHangCPU
51 };
52 extern int (*PE_halt_restart)(unsigned int type);
53 extern int PEHaltRestart(unsigned int type);
54
55 // Save the Panic Info. Returns the number of bytes saved.
56 extern unsigned long PESavePanicInfo(unsigned char *buffer, unsigned long length);
57
58 extern long PEGetGMTTimeOfDay( void );
59 extern void PESetGMTTimeOfDay( long secs );
60
61 #ifdef __cplusplus
62 } /* extern "C" */
63
64 #define kIOPlatformMapperPresentKey "IOPlatformMapperPresent"
65
66 extern OSSymbol * gPlatformInterruptControllerName;
67
68 class IORangeAllocator;
69 class IONVRAMController;
70 class IOPMrootDomain;
71
72 class IOPlatformExpert : public IOService
73 {
74 OSDeclareDefaultStructors(IOPlatformExpert);
75
76 private:
77 long _peBootROMType;
78 long _peChipSetType;
79 long _peMachineType;
80
81 protected:
82 IOPMrootDomain * root;
83 int _pePMFeatures;
84 int _pePrivPMFeatures;
85 int _peNumBatteriesSupported;
86 OSArray * thePowerTree;
87
88 bool searchingForAdditionalParents;
89 OSNumber * multipleParentKeyValue;
90 int numInstancesRegistered;
91
92 struct ExpansionData { };
93 ExpansionData *reserved;
94
95 virtual void setBootROMType(long peBootROMType);
96 virtual void setChipSetType(long peChipSetType);
97 virtual void setMachineType(long peMachineType);
98
99 virtual bool CheckSubTree (OSArray * inSubTree, IOService * theNub, IOService * theDevice, OSDictionary * theParent);
100 virtual bool RegisterServiceInTree (IOService * theService, OSDictionary * theTreeNode, OSDictionary * theTreeParentNode, IOService * theProvider);
101
102 virtual void PMInstantiatePowerDomains ( void );
103
104 public:
105 virtual bool attach( IOService * provider );
106 virtual bool start( IOService * provider );
107 virtual bool configure( IOService * provider );
108 virtual IOService * createNub( OSDictionary * from );
109
110 virtual bool compareNubName( const IOService * nub, OSString * name,
111 OSString ** matched = 0 ) const;
112 virtual IOReturn getNubResources( IOService * nub );
113
114 virtual long getBootROMType(void);
115 virtual long getChipSetType(void);
116 virtual long getMachineType(void);
117
118 virtual bool getModelName( char * name, int maxLength );
119 virtual bool getMachineName( char * name, int maxLength );
120
121 virtual int haltRestart(unsigned int type);
122 virtual void sleepKernel(void);
123
124 virtual long getGMTTimeOfDay( void );
125 virtual void setGMTTimeOfDay( long secs );
126
127 virtual IOReturn getConsoleInfo( PE_Video * consoleInfo );
128 virtual IOReturn setConsoleInfo( PE_Video * consoleInfo, unsigned int op );
129
130 virtual void registerNVRAMController( IONVRAMController * nvram );
131
132 virtual IOReturn registerInterruptController(OSSymbol *name, IOInterruptController *interruptController);
133 virtual IOInterruptController *lookUpInterruptController(OSSymbol *name);
134 virtual void setCPUInterruptProperties(IOService *service);
135 virtual bool atInterruptLevel(void);
136
137 virtual IOReturn callPlatformFunction(const OSSymbol *functionName,
138 bool waitForFunction,
139 void *param1, void *param2,
140 void *param3, void *param4);
141
142 virtual IORangeAllocator * getPhysicalRangeAllocator(void);
143
144 virtual bool platformAdjustService(IOService *service);
145
146 virtual void PMRegisterDevice(IOService * theNub, IOService * theDevice);
147 virtual void PMLog ( const char *,unsigned long, unsigned long, unsigned long );
148
149 virtual bool hasPMFeature (unsigned long featureMask);
150 virtual bool hasPrivPMFeature (unsigned long privFeatureMask);
151 virtual int numBatteriesSupported (void);
152
153 virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
154
155 virtual OSString* createSystemSerialNumberString(OSData* myProperty);
156
157 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 0);
158 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 1);
159 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 2);
160 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 3);
161 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 4);
162 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 5);
163 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 6);
164 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 7);
165 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 8);
166 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 9);
167 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 10);
168 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 11);
169 };
170
171 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
172
173 class IODTNVRAM;
174
175 class IODTPlatformExpert : public IOPlatformExpert
176 {
177 OSDeclareAbstractStructors(IODTPlatformExpert);
178
179 private:
180 IODTNVRAM *dtNVRAM;
181
182 struct ExpansionData { };
183 ExpansionData *reserved;
184
185 public:
186 virtual IOService * probe( IOService * provider,
187 SInt32 * score );
188 virtual bool configure( IOService * provider );
189
190 virtual void processTopLevel( IORegistryEntry * root );
191 virtual const char * deleteList( void ) = 0;
192 virtual const char * excludeList( void ) = 0;
193 virtual IOService * createNub( IORegistryEntry * from );
194 virtual bool createNubs( IOService * parent, OSIterator * iter );
195
196 virtual bool compareNubName( const IOService * nub, OSString * name,
197 OSString ** matched = 0 ) const;
198
199 virtual IOReturn getNubResources( IOService * nub );
200
201 virtual bool getModelName( char * name, int maxLength );
202 virtual bool getMachineName( char * name, int maxLength );
203
204 virtual void registerNVRAMController( IONVRAMController * nvram );
205
206 virtual int haltRestart(unsigned int type);
207
208 /* virtual */ IOReturn readXPRAM(IOByteCount offset, UInt8 * buffer,
209 IOByteCount length);
210
211 /* virtual */ IOReturn writeXPRAM(IOByteCount offset, UInt8 * buffer,
212 IOByteCount length);
213
214 virtual IOReturn readNVRAMProperty(
215 IORegistryEntry * entry,
216 const OSSymbol ** name, OSData ** value );
217
218 virtual IOReturn writeNVRAMProperty(
219 IORegistryEntry * entry,
220 const OSSymbol * name, OSData * value );
221
222 // This returns a dictionary describing all the NVRAM partitions.
223 // The keys will be the partitionIDs of the form "0x52,nvram".
224 // The values will be OSNumbers of the partition's byte count.
225 /* virtual */ OSDictionary *getNVRAMPartitions(void);
226
227 /* virtual */ IOReturn readNVRAMPartition(const OSSymbol * partitionID,
228 IOByteCount offset, UInt8 * buffer,
229 IOByteCount length);
230
231 /* virtual */ IOReturn writeNVRAMPartition(const OSSymbol * partitionID,
232 IOByteCount offset, UInt8 * buffer,
233 IOByteCount length);
234
235 virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
236 virtual OSString* createSystemSerialNumberString(OSData* myProperty);
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 */