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