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