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