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