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