]>
Commit | Line | Data |
---|---|---|
4452a7af A |
1 | /* |
2 | * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_OSREFERENCE_LICENSE_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 License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
27 | */ | |
28 | // 45678901234567890123456789012345678901234567890123456789012345678901234567890 | |
29 | ||
30 | #include <libkern/OSAtomic.h> | |
31 | ||
32 | #include <IOKit/IOLocks.h> | |
33 | #include <IOKit/IOPlatformExpert.h> | |
34 | #include <IOKit/IODeviceTreeSupport.h> | |
35 | #include <IOKit/IOMapper.h> | |
36 | ||
37 | // General constants about all VART/DART style Address Re-Mapping Tables | |
38 | #define kMapperPage (4 * 1024) | |
39 | #define kTransPerPage (kMapperPage / sizeof(ppnum_t)) | |
40 | ||
41 | #define kMinZoneSize 4 // Minimum Zone size in pages | |
42 | #define kMaxNumZones (31 - 14) // 31 bit mapped in 16K super pages | |
43 | ||
44 | class IOCopyMapper : public IOMapper | |
45 | { | |
46 | OSDeclareDefaultStructors(IOCopyMapper); | |
47 | ||
48 | // alias the fTable variable into our mappings table | |
49 | #define fMappings ((ActiveDARTEntry *) super::fTable) | |
50 | ||
51 | private: | |
52 | ||
53 | UInt32 fFreeLists[kMaxNumZones]; | |
54 | ||
55 | IOLock *fTableLock; | |
56 | ||
57 | void *fDummyPage; | |
58 | ||
59 | UInt32 fNumZones; | |
60 | UInt32 fMapperRegionSize; | |
61 | UInt32 fMapperRegionUsed; | |
62 | UInt32 fMapperRegionMaxUsed; | |
63 | UInt32 fFreeSleepers; | |
64 | ppnum_t fDummyPageNumber; | |
65 | ppnum_t fBufferPage; | |
66 | ||
67 | // Internal functions | |
68 | ||
69 | void breakUp(unsigned start, unsigned end, unsigned freeInd); | |
70 | void invalidateDART(ppnum_t pnum, IOItemCount size); | |
71 | void tlbInvalidate(ppnum_t pnum, IOItemCount size); | |
72 | ||
73 | virtual void free(); | |
74 | ||
75 | virtual bool initHardware(IOService * provider); | |
76 | public: | |
77 | virtual ppnum_t iovmAlloc(IOItemCount pages); | |
78 | virtual void iovmFree(ppnum_t addr, IOItemCount pages); | |
79 | ||
80 | virtual void iovmInsert(ppnum_t addr, IOItemCount offset, ppnum_t page); | |
81 | virtual void iovmInsert(ppnum_t addr, IOItemCount offset, | |
82 | ppnum_t *pageList, IOItemCount pageCount); | |
83 | virtual void iovmInsert(ppnum_t addr, IOItemCount offset, | |
84 | upl_page_info_t *pageList, IOItemCount pageCount); | |
85 | ||
86 | virtual addr64_t mapAddr(IOPhysicalAddress addr); | |
87 | }; | |
88 | ||
89 | extern IOCopyMapper * gIOCopyMapper; |