]> git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOCopyMapper.h
xnu-792.13.8.tar.gz
[apple/xnu.git] / iokit / Kernel / IOCopyMapper.h
1 /*
2 * Copyright (c) 2006 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 // 45678901234567890123456789012345678901234567890123456789012345678901234567890
31
32 #include <libkern/OSAtomic.h>
33
34 #include <IOKit/IOLocks.h>
35 #include <IOKit/IOPlatformExpert.h>
36 #include <IOKit/IODeviceTreeSupport.h>
37 #include <IOKit/IOMapper.h>
38
39 // General constants about all VART/DART style Address Re-Mapping Tables
40 #define kMapperPage (4 * 1024)
41 #define kTransPerPage (kMapperPage / sizeof(ppnum_t))
42
43 #define kMinZoneSize 4 // Minimum Zone size in pages
44 #define kMaxNumZones (31 - 14) // 31 bit mapped in 16K super pages
45
46 class IOCopyMapper : public IOMapper
47 {
48 OSDeclareDefaultStructors(IOCopyMapper);
49
50 // alias the fTable variable into our mappings table
51 #define fMappings ((ActiveDARTEntry *) super::fTable)
52
53 private:
54
55 UInt32 fFreeLists[kMaxNumZones];
56
57 IOLock *fTableLock;
58
59 void *fDummyPage;
60
61 UInt32 fNumZones;
62 UInt32 fMapperRegionSize;
63 UInt32 fMapperRegionUsed;
64 UInt32 fMapperRegionMaxUsed;
65 UInt32 fFreeSleepers;
66 ppnum_t fDummyPageNumber;
67 ppnum_t fBufferPage;
68
69 // Internal functions
70
71 void breakUp(unsigned start, unsigned end, unsigned freeInd);
72 void invalidateDART(ppnum_t pnum, IOItemCount size);
73 void tlbInvalidate(ppnum_t pnum, IOItemCount size);
74
75 virtual void free();
76
77 virtual bool initHardware(IOService * provider);
78 public:
79 virtual ppnum_t iovmAlloc(IOItemCount pages);
80 virtual void iovmFree(ppnum_t addr, IOItemCount pages);
81
82 virtual void iovmInsert(ppnum_t addr, IOItemCount offset, ppnum_t page);
83 virtual void iovmInsert(ppnum_t addr, IOItemCount offset,
84 ppnum_t *pageList, IOItemCount pageCount);
85 virtual void iovmInsert(ppnum_t addr, IOItemCount offset,
86 upl_page_info_t *pageList, IOItemCount pageCount);
87
88 virtual addr64_t mapAddr(IOPhysicalAddress addr);
89 };
90
91 extern IOCopyMapper * gIOCopyMapper;