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