2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 // 45678901234567890123456789012345678901234567890123456789012345678901234567890
30 #include <libkern/OSAtomic.h>
32 #include <IOKit/IOLocks.h>
33 #include <IOKit/IOPlatformExpert.h>
34 #include <IOKit/IODeviceTreeSupport.h>
35 #include <IOKit/IOMapper.h>
37 // General constants about all VART/DART style Address Re-Mapping Tables
38 #define kMapperPage (4 * 1024)
39 #define kTransPerPage (kMapperPage / sizeof(ppnum_t))
41 #define kMinZoneSize 4 // Minimum Zone size in pages
42 #define kMaxNumZones (31 - 14) // 31 bit mapped in 16K super pages
44 class IOCopyMapper
: public IOMapper
46 OSDeclareDefaultStructors(IOCopyMapper
);
48 // alias the fTable variable into our mappings table
49 #define fMappings ((ActiveDARTEntry *) super::fTable)
53 UInt32 fFreeLists
[kMaxNumZones
];
60 UInt32 fMapperRegionSize
;
61 UInt32 fMapperRegionUsed
;
62 UInt32 fMapperRegionMaxUsed
;
64 ppnum_t fDummyPageNumber
;
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
);
75 virtual bool initHardware(IOService
* provider
);
77 virtual ppnum_t
iovmAlloc(IOItemCount pages
);
78 virtual void iovmFree(ppnum_t addr
, IOItemCount pages
);
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
);
86 virtual addr64_t
mapAddr(IOPhysicalAddress addr
);
89 extern IOCopyMapper
* gIOCopyMapper
;