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