1*fdd8201dSApple OSS Distributions /* 2*fdd8201dSApple OSS Distributions * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. 3*fdd8201dSApple OSS Distributions * 4*fdd8201dSApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5*fdd8201dSApple OSS Distributions * 6*fdd8201dSApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 7*fdd8201dSApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 8*fdd8201dSApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 9*fdd8201dSApple OSS Distributions * compliance with the License. The rights granted to you under the License 10*fdd8201dSApple OSS Distributions * may not be used to create, or enable the creation or redistribution of, 11*fdd8201dSApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to 12*fdd8201dSApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any 13*fdd8201dSApple OSS Distributions * terms of an Apple operating system software license agreement. 14*fdd8201dSApple OSS Distributions * 15*fdd8201dSApple OSS Distributions * Please obtain a copy of the License at 16*fdd8201dSApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file. 17*fdd8201dSApple OSS Distributions * 18*fdd8201dSApple OSS Distributions * The Original Code and all software distributed under the License are 19*fdd8201dSApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20*fdd8201dSApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21*fdd8201dSApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22*fdd8201dSApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23*fdd8201dSApple OSS Distributions * Please see the License for the specific language governing rights and 24*fdd8201dSApple OSS Distributions * limitations under the License. 25*fdd8201dSApple OSS Distributions * 26*fdd8201dSApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27*fdd8201dSApple OSS Distributions */ 28*fdd8201dSApple OSS Distributions /* 29*fdd8201dSApple OSS Distributions * Copyright (c) 1998 Apple Computer, Inc. All rights reserved. 30*fdd8201dSApple OSS Distributions * 31*fdd8201dSApple OSS Distributions * HISTORY 32*fdd8201dSApple OSS Distributions * 33*fdd8201dSApple OSS Distributions */ 34*fdd8201dSApple OSS Distributions 35*fdd8201dSApple OSS Distributions #ifndef _IOKIT_IODEVICETREE_H 36*fdd8201dSApple OSS Distributions #define _IOKIT_IODEVICETREE_H 37*fdd8201dSApple OSS Distributions 38*fdd8201dSApple OSS Distributions #include <IOKit/IORegistryEntry.h> 39*fdd8201dSApple OSS Distributions #include <libkern/c++/OSData.h> 40*fdd8201dSApple OSS Distributions #include <libkern/c++/OSPtr.h> 41*fdd8201dSApple OSS Distributions 42*fdd8201dSApple OSS Distributions class IODeviceMemory; 43*fdd8201dSApple OSS Distributions class IOService; 44*fdd8201dSApple OSS Distributions 45*fdd8201dSApple OSS Distributions extern const IORegistryPlane * gIODTPlane; 46*fdd8201dSApple OSS Distributions 47*fdd8201dSApple OSS Distributions extern const OSSymbol * gIODTPHandleKey; 48*fdd8201dSApple OSS Distributions 49*fdd8201dSApple OSS Distributions extern const OSSymbol * gIODTCompatibleKey; 50*fdd8201dSApple OSS Distributions extern const OSSymbol * gIODTTypeKey; 51*fdd8201dSApple OSS Distributions extern const OSSymbol * gIODTModelKey; 52*fdd8201dSApple OSS Distributions extern const OSSymbol * gIODTBridgeModelKey; 53*fdd8201dSApple OSS Distributions extern const OSSymbol * gIODTTargetTypeKey; 54*fdd8201dSApple OSS Distributions 55*fdd8201dSApple OSS Distributions extern const OSSymbol * gIODTAAPLInterruptsKey; 56*fdd8201dSApple OSS Distributions extern const OSSymbol * gIODTDefaultInterruptController; 57*fdd8201dSApple OSS Distributions extern const OSSymbol * gIODTNWInterruptMappingKey; 58*fdd8201dSApple OSS Distributions 59*fdd8201dSApple OSS Distributions LIBKERN_RETURNS_NOT_RETAINED IORegistryEntry * IODeviceTreeAlloc( void * dtTop ); 60*fdd8201dSApple OSS Distributions 61*fdd8201dSApple OSS Distributions 62*fdd8201dSApple OSS Distributions bool IODTMatchNubWithKeys( IORegistryEntry * nub, 63*fdd8201dSApple OSS Distributions const char * keys ); 64*fdd8201dSApple OSS Distributions 65*fdd8201dSApple OSS Distributions bool IODTCompareNubName( const IORegistryEntry * regEntry, 66*fdd8201dSApple OSS Distributions OSString * name, 67*fdd8201dSApple OSS Distributions LIBKERN_RETURNS_RETAINED_ON_NONZERO OSString ** matchingName ); 68*fdd8201dSApple OSS Distributions bool IODTCompareNubName( const IORegistryEntry * regEntry, 69*fdd8201dSApple OSS Distributions OSString * name, 70*fdd8201dSApple OSS Distributions OSSharedPtr<OSString>& matchingName ); 71*fdd8201dSApple OSS Distributions 72*fdd8201dSApple OSS Distributions enum { 73*fdd8201dSApple OSS Distributions kIODTRecursive = 0x00000001, 74*fdd8201dSApple OSS Distributions kIODTExclusive = 0x00000002 75*fdd8201dSApple OSS Distributions }; 76*fdd8201dSApple OSS Distributions 77*fdd8201dSApple OSS Distributions OSCollectionIterator * IODTFindMatchingEntries( IORegistryEntry * from, 78*fdd8201dSApple OSS Distributions IOOptionBits options, const char * keys ); 79*fdd8201dSApple OSS Distributions 80*fdd8201dSApple OSS Distributions #if !defined(__arm64__) 81*fdd8201dSApple OSS Distributions typedef SInt32 (*IODTCompareAddressCellFunc) 82*fdd8201dSApple OSS Distributions (UInt32 cellCount, UInt32 left[], UInt32 right[]); 83*fdd8201dSApple OSS Distributions #else 84*fdd8201dSApple OSS Distributions typedef SInt64 (*IODTCompareAddressCellFunc) 85*fdd8201dSApple OSS Distributions (UInt32 cellCount, UInt32 left[], UInt32 right[]); 86*fdd8201dSApple OSS Distributions #endif 87*fdd8201dSApple OSS Distributions 88*fdd8201dSApple OSS Distributions typedef void (*IODTNVLocationFunc) 89*fdd8201dSApple OSS Distributions (IORegistryEntry * entry, 90*fdd8201dSApple OSS Distributions UInt8 * busNum, UInt8 * deviceNum, UInt8 * functionNum ); 91*fdd8201dSApple OSS Distributions 92*fdd8201dSApple OSS Distributions void IODTSetResolving( IORegistryEntry * regEntry, 93*fdd8201dSApple OSS Distributions IODTCompareAddressCellFunc compareFunc, 94*fdd8201dSApple OSS Distributions IODTNVLocationFunc locationFunc ); 95*fdd8201dSApple OSS Distributions 96*fdd8201dSApple OSS Distributions void IODTGetCellCounts( IORegistryEntry * regEntry, 97*fdd8201dSApple OSS Distributions UInt32 * sizeCount, UInt32 * addressCount); 98*fdd8201dSApple OSS Distributions 99*fdd8201dSApple OSS Distributions bool IODTResolveAddressCell( IORegistryEntry * regEntry, 100*fdd8201dSApple OSS Distributions UInt32 cellsIn[], 101*fdd8201dSApple OSS Distributions IOPhysicalAddress * phys, IOPhysicalLength * len ); 102*fdd8201dSApple OSS Distributions 103*fdd8201dSApple OSS Distributions LIBKERN_RETURNS_NOT_RETAINED OSArray * 104*fdd8201dSApple OSS Distributions IODTResolveAddressing( IORegistryEntry * regEntry, 105*fdd8201dSApple OSS Distributions const char * addressPropertyName, 106*fdd8201dSApple OSS Distributions IODeviceMemory * parent ); 107*fdd8201dSApple OSS Distributions 108*fdd8201dSApple OSS Distributions struct IONVRAMDescriptor { 109*fdd8201dSApple OSS Distributions unsigned int format:4; 110*fdd8201dSApple OSS Distributions unsigned int marker:1; 111*fdd8201dSApple OSS Distributions unsigned int bridgeCount:3; 112*fdd8201dSApple OSS Distributions unsigned int busNum:2; 113*fdd8201dSApple OSS Distributions unsigned int bridgeDevices:6 * 5; 114*fdd8201dSApple OSS Distributions unsigned int functionNum:3; 115*fdd8201dSApple OSS Distributions unsigned int deviceNum:5; 116*fdd8201dSApple OSS Distributions } __attribute__((aligned(2), packed)); 117*fdd8201dSApple OSS Distributions 118*fdd8201dSApple OSS Distributions IOReturn IODTMakeNVDescriptor( IORegistryEntry * regEntry, 119*fdd8201dSApple OSS Distributions IONVRAMDescriptor * hdr ); 120*fdd8201dSApple OSS Distributions 121*fdd8201dSApple OSS Distributions LIBKERN_RETURNS_NOT_RETAINED OSData * 122*fdd8201dSApple OSS Distributions IODTFindSlotName( IORegistryEntry * regEntry, UInt32 deviceNumber ); 123*fdd8201dSApple OSS Distributions 124*fdd8201dSApple OSS Distributions const OSSymbol * IODTInterruptControllerName( 125*fdd8201dSApple OSS Distributions IORegistryEntry * regEntry ); 126*fdd8201dSApple OSS Distributions 127*fdd8201dSApple OSS Distributions bool IODTMapInterrupts( IORegistryEntry * regEntry ); 128*fdd8201dSApple OSS Distributions 129*fdd8201dSApple OSS Distributions enum { 130*fdd8201dSApple OSS Distributions kIODTInterruptShared = 0x00000001 131*fdd8201dSApple OSS Distributions }; 132*fdd8201dSApple OSS Distributions IOReturn IODTGetInterruptOptions( IORegistryEntry * regEntry, int source, IOOptionBits * options ); 133*fdd8201dSApple OSS Distributions 134*fdd8201dSApple OSS Distributions #ifdef __cplusplus 135*fdd8201dSApple OSS Distributions extern "C" { 136*fdd8201dSApple OSS Distributions #endif 137*fdd8201dSApple OSS Distributions 138*fdd8201dSApple OSS Distributions IOReturn IONDRVLibrariesInitialize( IOService * provider ); 139*fdd8201dSApple OSS Distributions 140*fdd8201dSApple OSS Distributions #ifdef __cplusplus 141*fdd8201dSApple OSS Distributions } 142*fdd8201dSApple OSS Distributions #endif 143*fdd8201dSApple OSS Distributions 144*fdd8201dSApple OSS Distributions #endif /* _IOKIT_IODEVICETREE_H */ 145