]>
Commit | Line | Data |
---|---|---|
55e303ae | 1 | /* |
39037602 | 2 | * Copyright (c) 1998-2016 Apple Inc. All rights reserved. |
55e303ae | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
55e303ae | 5 | * |
2d21ac55 A |
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. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
55e303ae A |
27 | */ |
28 | ||
29 | #ifndef __IOKIT_IOMAPPER_H | |
30 | #define __IOKIT_IOMAPPER_H | |
31 | ||
32 | #include <sys/cdefs.h> | |
33 | ||
34 | __BEGIN_DECLS | |
35 | #include <IOKit/IOTypes.h> | |
36 | #include <mach/vm_types.h> | |
37 | ||
38 | // These are C accessors to the system mapper for non-IOKit clients | |
39 | ppnum_t IOMapperIOVMAlloc(unsigned pages); | |
40 | void IOMapperIOVMFree(ppnum_t addr, unsigned pages); | |
55e303ae | 41 | ppnum_t IOMapperInsertPage(ppnum_t addr, unsigned offset, ppnum_t page); |
0c530ab8 | 42 | |
55e303ae A |
43 | __END_DECLS |
44 | ||
45 | #if __cplusplus | |
46 | ||
47 | #include <IOKit/IOService.h> | |
48 | #include <IOKit/IOMemoryDescriptor.h> | |
99c3a104 | 49 | #include <IOKit/IODMACommand.h> |
55e303ae A |
50 | |
51 | class OSData; | |
b0d623f7 A |
52 | |
53 | extern const OSSymbol * gIOMapperIDKey; | |
55e303ae A |
54 | |
55 | class IOMapper : public IOService | |
56 | { | |
57 | OSDeclareAbstractStructors(IOMapper); | |
58 | ||
59 | // Give the platform expert access to setMapperRequired(); | |
60 | friend class IOPlatformExpert; | |
3e170ce0 | 61 | friend class IOMemoryDescriptor; |
5ba3f43e | 62 | friend class IOGeneralMemoryDescriptor; |
55e303ae A |
63 | |
64 | private: | |
65 | enum SystemMapperState { | |
66 | kNoMapper = 0, | |
67 | kUnknown = 1, | |
68 | kHasMapper = 2, // Any other value is pointer to a live mapper | |
69 | kWaitMask = 3, | |
70 | }; | |
71 | protected: | |
3e170ce0 | 72 | #ifdef XNU_KERNEL_PRIVATE |
5ba3f43e A |
73 | uint64_t __reservedA[6]; |
74 | kern_allocation_name_t fAllocName; | |
3e170ce0 A |
75 | uint32_t __reservedB; |
76 | uint32_t fPageSize; | |
77 | #else | |
78 | uint64_t __reserved[8]; | |
79 | #endif | |
55e303ae A |
80 | bool fIsSystem; |
81 | ||
55e303ae A |
82 | static void setMapperRequired(bool hasMapper); |
83 | static void waitForSystemMapper(); | |
84 | ||
85 | virtual bool initHardware(IOService *provider) = 0; | |
86 | ||
55e303ae | 87 | public: |
3e170ce0 A |
88 | virtual bool start(IOService *provider) APPLE_KEXT_OVERRIDE; |
89 | virtual void free() APPLE_KEXT_OVERRIDE; | |
55e303ae A |
90 | |
91 | // To get access to the system mapper IOMapper::gSystem | |
92 | static IOMapper *gSystem; | |
93 | ||
55e303ae | 94 | static void checkForSystemMapper() |
39037602 | 95 | { if ((uintptr_t) gSystem & kWaitMask) waitForSystemMapper(); } |
55e303ae | 96 | |
b0d623f7 | 97 | static IOMapper * copyMapperForDevice(IOService * device); |
39236c6e | 98 | static IOMapper * copyMapperForDeviceWithIndex(IOService * device, unsigned int index); |
b0d623f7 | 99 | |
3e170ce0 A |
100 | // { subclasses |
101 | ||
102 | virtual uint64_t getPageSize(void) const = 0; | |
103 | ||
104 | virtual IOReturn iovmMapMemory(IOMemoryDescriptor * memory, | |
105 | uint64_t descriptorOffset, | |
106 | uint64_t length, | |
107 | uint32_t mapOptions, | |
108 | const IODMAMapSpecification * mapSpecification, | |
109 | IODMACommand * dmaCommand, | |
110 | const IODMAMapPageList * pageList, | |
111 | uint64_t * mapAddress, | |
112 | uint64_t * mapLength) = 0; | |
113 | ||
114 | virtual IOReturn iovmUnmapMemory(IOMemoryDescriptor * memory, | |
115 | IODMACommand * dmaCommand, | |
116 | uint64_t mapAddress, | |
117 | uint64_t mapLength) = 0; | |
118 | ||
119 | virtual IOReturn iovmInsert(uint32_t options, | |
120 | uint64_t mapAddress, | |
121 | uint64_t offset, | |
122 | uint64_t physicalAddress, | |
123 | uint64_t length) = 0; | |
124 | ||
125 | virtual uint64_t mapToPhysicalAddress(uint64_t mappedAddress) = 0; | |
126 | ||
127 | // } | |
0c530ab8 | 128 | |
55e303ae | 129 | private: |
3e170ce0 A |
130 | OSMetaClassDeclareReservedUnused(IOMapper, 0); |
131 | OSMetaClassDeclareReservedUnused(IOMapper, 1); | |
132 | OSMetaClassDeclareReservedUnused(IOMapper, 2); | |
133 | OSMetaClassDeclareReservedUnused(IOMapper, 3); | |
55e303ae A |
134 | OSMetaClassDeclareReservedUnused(IOMapper, 4); |
135 | OSMetaClassDeclareReservedUnused(IOMapper, 5); | |
136 | OSMetaClassDeclareReservedUnused(IOMapper, 6); | |
137 | OSMetaClassDeclareReservedUnused(IOMapper, 7); | |
138 | OSMetaClassDeclareReservedUnused(IOMapper, 8); | |
139 | OSMetaClassDeclareReservedUnused(IOMapper, 9); | |
140 | OSMetaClassDeclareReservedUnused(IOMapper, 10); | |
141 | OSMetaClassDeclareReservedUnused(IOMapper, 11); | |
142 | OSMetaClassDeclareReservedUnused(IOMapper, 12); | |
143 | OSMetaClassDeclareReservedUnused(IOMapper, 13); | |
144 | OSMetaClassDeclareReservedUnused(IOMapper, 14); | |
145 | OSMetaClassDeclareReservedUnused(IOMapper, 15); | |
146 | }; | |
147 | ||
148 | #endif /* __cplusplus */ | |
149 | ||
150 | #endif /* !__IOKIT_IOMAPPER_H */ |