]>
Commit | Line | Data |
---|---|---|
55e303ae A |
1 | /* |
2 | * Copyright (c) 1998-2003 Apple Computer, Inc. All rights reserved. | |
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); | |
41 | ||
42 | ppnum_t IOMapperInsertPage(ppnum_t addr, unsigned offset, ppnum_t page); | |
43 | void IOMapperInsertPPNPages(ppnum_t addr, unsigned offset, | |
44 | ppnum_t *pageList, unsigned pageCount); | |
45 | void IOMapperInsertUPLPages(ppnum_t addr, unsigned offset, | |
46 | upl_page_info_t *pageList, unsigned pageCount); | |
0c530ab8 A |
47 | |
48 | mach_vm_address_t IOMallocPhysical(mach_vm_size_t size, mach_vm_address_t mask); | |
49 | ||
50 | void IOFreePhysical(mach_vm_address_t address, mach_vm_size_t size); | |
51 | ||
55e303ae A |
52 | __END_DECLS |
53 | ||
54 | #if __cplusplus | |
55 | ||
56 | #include <IOKit/IOService.h> | |
57 | #include <IOKit/IOMemoryDescriptor.h> | |
99c3a104 | 58 | #include <IOKit/IODMACommand.h> |
55e303ae A |
59 | |
60 | class OSData; | |
b0d623f7 A |
61 | |
62 | extern const OSSymbol * gIOMapperIDKey; | |
55e303ae A |
63 | |
64 | class IOMapper : public IOService | |
65 | { | |
66 | OSDeclareAbstractStructors(IOMapper); | |
67 | ||
68 | // Give the platform expert access to setMapperRequired(); | |
69 | friend class IOPlatformExpert; | |
70 | ||
71 | private: | |
72 | enum SystemMapperState { | |
73 | kNoMapper = 0, | |
74 | kUnknown = 1, | |
75 | kHasMapper = 2, // Any other value is pointer to a live mapper | |
76 | kWaitMask = 3, | |
77 | }; | |
78 | protected: | |
79 | void *fTable; | |
80 | ppnum_t fTablePhys; | |
81 | IOItemCount fTableSize; | |
82 | OSData *fTableHandle; | |
83 | bool fIsSystem; | |
84 | ||
55e303ae A |
85 | |
86 | static void setMapperRequired(bool hasMapper); | |
87 | static void waitForSystemMapper(); | |
88 | ||
89 | virtual bool initHardware(IOService *provider) = 0; | |
90 | ||
91 | virtual bool allocTable(IOByteCount size); | |
92 | ||
93 | public: | |
0c530ab8 A |
94 | virtual bool start(IOService *provider); |
95 | virtual void free(); | |
0c530ab8 | 96 | |
55e303ae A |
97 | // Static routines capable of allocating tables that are physically |
98 | // contiguous in real memory space. | |
99 | static OSData * NewARTTable(IOByteCount size, | |
100 | void ** virtAddrP, ppnum_t *physAddrP); | |
101 | static void FreeARTTable(OSData *handle, IOByteCount size); | |
102 | ||
103 | ||
104 | // To get access to the system mapper IOMapper::gSystem | |
105 | static IOMapper *gSystem; | |
106 | ||
107 | virtual ppnum_t iovmAlloc(IOItemCount pages) = 0; | |
108 | virtual void iovmFree(ppnum_t addr, IOItemCount pages) = 0; | |
109 | ||
110 | virtual void iovmInsert(ppnum_t addr, IOItemCount offset, ppnum_t page) = 0; | |
111 | virtual void iovmInsert(ppnum_t addr, IOItemCount offset, | |
112 | ppnum_t *pageList, IOItemCount pageCount); | |
113 | virtual void iovmInsert(ppnum_t addr, IOItemCount offset, | |
114 | upl_page_info_t *pageList, IOItemCount pageCount); | |
b0d623f7 | 115 | |
55e303ae | 116 | static void checkForSystemMapper() |
b0d623f7 | 117 | { if ((uintptr_t) gSystem & kWaitMask) waitForSystemMapper(); }; |
55e303ae | 118 | |
b0d623f7 A |
119 | static IOMapper * copyMapperForDevice(IOService * device); |
120 | ||
121 | ||
55e303ae A |
122 | // Function will panic if the given address is not found in a valid |
123 | // iovm mapping. | |
124 | virtual addr64_t mapAddr(IOPhysicalAddress addr) = 0; | |
125 | ||
0c530ab8 | 126 | // Get the address mask to or into an address to bypass this mapper |
b0d623f7 A |
127 | virtual bool getBypassMask(addr64_t *maskP) const; |
128 | ||
129 | virtual ppnum_t iovmAllocDMACommand(IODMACommand * command, IOItemCount pageCount); | |
130 | virtual void iovmFreeDMACommand(IODMACommand * command, ppnum_t addr, IOItemCount pageCount); | |
131 | ||
99c3a104 A |
132 | virtual ppnum_t iovmMapMemory( |
133 | OSObject * memory, // dma command or iomd | |
134 | ppnum_t offsetPage, | |
135 | ppnum_t pageCount, | |
136 | uint32_t options, | |
137 | upl_page_info_t * pageList, | |
138 | const IODMAMapSpecification * mapSpecification); | |
139 | ||
0c530ab8 | 140 | OSMetaClassDeclareReservedUsed(IOMapper, 0); |
b0d623f7 A |
141 | OSMetaClassDeclareReservedUsed(IOMapper, 1); |
142 | OSMetaClassDeclareReservedUsed(IOMapper, 2); | |
99c3a104 | 143 | OSMetaClassDeclareReservedUsed(IOMapper, 3); |
0c530ab8 | 144 | |
55e303ae | 145 | private: |
55e303ae A |
146 | OSMetaClassDeclareReservedUnused(IOMapper, 4); |
147 | OSMetaClassDeclareReservedUnused(IOMapper, 5); | |
148 | OSMetaClassDeclareReservedUnused(IOMapper, 6); | |
149 | OSMetaClassDeclareReservedUnused(IOMapper, 7); | |
150 | OSMetaClassDeclareReservedUnused(IOMapper, 8); | |
151 | OSMetaClassDeclareReservedUnused(IOMapper, 9); | |
152 | OSMetaClassDeclareReservedUnused(IOMapper, 10); | |
153 | OSMetaClassDeclareReservedUnused(IOMapper, 11); | |
154 | OSMetaClassDeclareReservedUnused(IOMapper, 12); | |
155 | OSMetaClassDeclareReservedUnused(IOMapper, 13); | |
156 | OSMetaClassDeclareReservedUnused(IOMapper, 14); | |
157 | OSMetaClassDeclareReservedUnused(IOMapper, 15); | |
158 | }; | |
159 | ||
160 | #endif /* __cplusplus */ | |
161 | ||
162 | #endif /* !__IOKIT_IOMAPPER_H */ |