]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOMapper.h
xnu-792.12.6.tar.gz
[apple/xnu.git] / iokit / IOKit / IOMapper.h
1 /*
2 * Copyright (c) 1998-2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30
31 #ifndef __IOKIT_IOMAPPER_H
32 #define __IOKIT_IOMAPPER_H
33
34 #include <sys/cdefs.h>
35
36 __BEGIN_DECLS
37 #include <IOKit/IOTypes.h>
38 #include <mach/vm_types.h>
39
40 // These are C accessors to the system mapper for non-IOKit clients
41 ppnum_t IOMapperIOVMAlloc(unsigned pages);
42 void IOMapperIOVMFree(ppnum_t addr, unsigned pages);
43
44 ppnum_t IOMapperInsertPage(ppnum_t addr, unsigned offset, ppnum_t page);
45 void IOMapperInsertPPNPages(ppnum_t addr, unsigned offset,
46 ppnum_t *pageList, unsigned pageCount);
47 void IOMapperInsertUPLPages(ppnum_t addr, unsigned offset,
48 upl_page_info_t *pageList, unsigned pageCount);
49 __END_DECLS
50
51 #if __cplusplus
52
53 #include <IOKit/IOService.h>
54 #include <IOKit/IOMemoryDescriptor.h>
55
56 class OSData;
57
58 class IOMapper : public IOService
59 {
60 OSDeclareAbstractStructors(IOMapper);
61
62 // Give the platform expert access to setMapperRequired();
63 friend class IOPlatformExpert;
64
65 private:
66 enum SystemMapperState {
67 kNoMapper = 0,
68 kUnknown = 1,
69 kHasMapper = 2, // Any other value is pointer to a live mapper
70 kWaitMask = 3,
71 };
72 protected:
73 void *fTable;
74 ppnum_t fTablePhys;
75 IOItemCount fTableSize;
76 OSData *fTableHandle;
77 bool fIsSystem;
78
79 virtual bool start(IOService *provider);
80 virtual void free();
81
82 static void setMapperRequired(bool hasMapper);
83 static void waitForSystemMapper();
84
85 virtual bool initHardware(IOService *provider) = 0;
86
87 virtual bool allocTable(IOByteCount size);
88
89 public:
90 // Static routines capable of allocating tables that are physically
91 // contiguous in real memory space.
92 static OSData * NewARTTable(IOByteCount size,
93 void ** virtAddrP, ppnum_t *physAddrP);
94 static void FreeARTTable(OSData *handle, IOByteCount size);
95
96
97 // To get access to the system mapper IOMapper::gSystem
98 static IOMapper *gSystem;
99
100 virtual ppnum_t iovmAlloc(IOItemCount pages) = 0;
101 virtual void iovmFree(ppnum_t addr, IOItemCount pages) = 0;
102
103 virtual void iovmInsert(ppnum_t addr, IOItemCount offset, ppnum_t page) = 0;
104 virtual void iovmInsert(ppnum_t addr, IOItemCount offset,
105 ppnum_t *pageList, IOItemCount pageCount);
106 virtual void iovmInsert(ppnum_t addr, IOItemCount offset,
107 upl_page_info_t *pageList, IOItemCount pageCount);
108 static void checkForSystemMapper()
109 { if ((vm_address_t) gSystem & kWaitMask) waitForSystemMapper(); };
110
111 // Function will panic if the given address is not found in a valid
112 // iovm mapping.
113 virtual addr64_t mapAddr(IOPhysicalAddress addr) = 0;
114
115 private:
116 OSMetaClassDeclareReservedUnused(IOMapper, 0);
117 OSMetaClassDeclareReservedUnused(IOMapper, 1);
118 OSMetaClassDeclareReservedUnused(IOMapper, 2);
119 OSMetaClassDeclareReservedUnused(IOMapper, 3);
120 OSMetaClassDeclareReservedUnused(IOMapper, 4);
121 OSMetaClassDeclareReservedUnused(IOMapper, 5);
122 OSMetaClassDeclareReservedUnused(IOMapper, 6);
123 OSMetaClassDeclareReservedUnused(IOMapper, 7);
124 OSMetaClassDeclareReservedUnused(IOMapper, 8);
125 OSMetaClassDeclareReservedUnused(IOMapper, 9);
126 OSMetaClassDeclareReservedUnused(IOMapper, 10);
127 OSMetaClassDeclareReservedUnused(IOMapper, 11);
128 OSMetaClassDeclareReservedUnused(IOMapper, 12);
129 OSMetaClassDeclareReservedUnused(IOMapper, 13);
130 OSMetaClassDeclareReservedUnused(IOMapper, 14);
131 OSMetaClassDeclareReservedUnused(IOMapper, 15);
132 };
133
134 #endif /* __cplusplus */
135
136 #endif /* !__IOKIT_IOMAPPER_H */