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