/ duct-tape / xnu / iokit / IOKit / IODeviceTreeSupport.h
IODeviceTreeSupport.h
  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  #ifndef _IOKIT_IODEVICETREE_H
 36  #define _IOKIT_IODEVICETREE_H
 37  
 38  #include <IOKit/IORegistryEntry.h>
 39  #include <libkern/c++/OSData.h>
 40  #include <libkern/c++/OSPtr.h>
 41  
 42  class IODeviceMemory;
 43  class IOService;
 44  
 45  extern const IORegistryPlane *  gIODTPlane;
 46  
 47  extern const OSSymbol *         gIODTPHandleKey;
 48  
 49  extern const OSSymbol *         gIODTCompatibleKey;
 50  extern const OSSymbol *         gIODTTypeKey;
 51  extern const OSSymbol *         gIODTModelKey;
 52  extern const OSSymbol *         gIODTBridgeModelKey;
 53  extern const OSSymbol *         gIODTTargetTypeKey;
 54  
 55  extern const OSSymbol *         gIODTAAPLInterruptsKey;
 56  extern const OSSymbol *         gIODTDefaultInterruptController;
 57  extern const OSSymbol *         gIODTNWInterruptMappingKey;
 58  
 59  LIBKERN_RETURNS_NOT_RETAINED IORegistryEntry * IODeviceTreeAlloc( void * dtTop );
 60  
 61  
 62  bool IODTMatchNubWithKeys( IORegistryEntry * nub,
 63      const char * keys );
 64  
 65  bool IODTCompareNubName( const IORegistryEntry * regEntry,
 66      OSString * name,
 67      LIBKERN_RETURNS_RETAINED_ON_NONZERO OSString ** matchingName );
 68  bool IODTCompareNubName( const IORegistryEntry * regEntry,
 69      OSString * name,
 70      OSSharedPtr<OSString>& matchingName );
 71  
 72  enum {
 73  	kIODTRecursive      = 0x00000001,
 74  	kIODTExclusive      = 0x00000002
 75  };
 76  
 77  OSCollectionIterator * IODTFindMatchingEntries( IORegistryEntry * from,
 78      IOOptionBits options, const char * keys );
 79  
 80  #if !defined(__arm64__)
 81  typedef SInt32 (*IODTCompareAddressCellFunc)
 82  (UInt32 cellCount, UInt32 left[], UInt32 right[]);
 83  #else
 84  typedef SInt64 (*IODTCompareAddressCellFunc)
 85  (UInt32 cellCount, UInt32 left[], UInt32 right[]);
 86  #endif
 87  
 88  typedef void (*IODTNVLocationFunc)
 89  (IORegistryEntry * entry,
 90      UInt8 * busNum, UInt8 * deviceNum, UInt8 * functionNum );
 91  
 92  void IODTSetResolving( IORegistryEntry *        regEntry,
 93      IODTCompareAddressCellFunc      compareFunc,
 94      IODTNVLocationFunc              locationFunc );
 95  
 96  void IODTGetCellCounts( IORegistryEntry * regEntry,
 97      UInt32 * sizeCount, UInt32 * addressCount);
 98  
 99  bool IODTResolveAddressCell( IORegistryEntry * regEntry,
100      UInt32 cellsIn[],
101      IOPhysicalAddress * phys, IOPhysicalLength * len );
102  
103  LIBKERN_RETURNS_NOT_RETAINED OSArray *
104  IODTResolveAddressing( IORegistryEntry * regEntry,
105      const char * addressPropertyName,
106      IODeviceMemory * parent );
107  
108  struct IONVRAMDescriptor {
109  	unsigned int format:4;
110  	unsigned int marker:1;
111  	unsigned int bridgeCount:3;
112  	unsigned int busNum:2;
113  	unsigned int bridgeDevices:6 * 5;
114  	unsigned int functionNum:3;
115  	unsigned int deviceNum:5;
116  } __attribute__((aligned(2), packed));
117  
118  IOReturn IODTMakeNVDescriptor( IORegistryEntry * regEntry,
119      IONVRAMDescriptor * hdr );
120  
121  LIBKERN_RETURNS_NOT_RETAINED OSData *
122  IODTFindSlotName( IORegistryEntry * regEntry, UInt32 deviceNumber );
123  
124  const OSSymbol * IODTInterruptControllerName(
125  	IORegistryEntry * regEntry );
126  
127  bool IODTMapInterrupts( IORegistryEntry * regEntry );
128  
129  enum {
130  	kIODTInterruptShared = 0x00000001
131  };
132  IOReturn IODTGetInterruptOptions( IORegistryEntry * regEntry, int source, IOOptionBits * options );
133  
134  #ifdef __cplusplus
135  extern "C" {
136  #endif
137  
138  IOReturn IONDRVLibrariesInitialize( IOService * provider );
139  
140  #ifdef __cplusplus
141  }
142  #endif
143  
144  #endif /* _IOKIT_IODEVICETREE_H */