2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 // 45678901234567890123456789012345678901234567890123456789012345678901234567890
24 #include <libkern/OSAtomic.h>
26 #include <IOKit/IOLocks.h>
27 #include <IOKit/IOPlatformExpert.h>
28 #include <IOKit/IODeviceTreeSupport.h>
29 #include <IOKit/IOMapper.h>
31 // General constants about all VART/DART style Address Re-Mapping Tables
32 #define kMapperPage (4 * 1024)
33 #define kTransPerPage (kMapperPage / sizeof(ppnum_t))
35 #define kMinZoneSize 4 // Minimum Zone size in pages
36 #define kMaxNumZones (31 - 14) // 31 bit mapped in 16K super pages
38 class IOCopyMapper
: public IOMapper
40 OSDeclareDefaultStructors(IOCopyMapper
);
42 // alias the fTable variable into our mappings table
43 #define fMappings ((ActiveDARTEntry *) super::fTable)
47 UInt32 fFreeLists
[kMaxNumZones
];
54 UInt32 fMapperRegionSize
;
55 UInt32 fMapperRegionUsed
;
56 UInt32 fMapperRegionMaxUsed
;
58 ppnum_t fDummyPageNumber
;
63 void breakUp(unsigned start
, unsigned end
, unsigned freeInd
);
64 void invalidateDART(ppnum_t pnum
, IOItemCount size
);
65 void tlbInvalidate(ppnum_t pnum
, IOItemCount size
);
69 virtual bool initHardware(IOService
* provider
);
71 virtual ppnum_t
iovmAlloc(IOItemCount pages
);
72 virtual void iovmFree(ppnum_t addr
, IOItemCount pages
);
74 virtual void iovmInsert(ppnum_t addr
, IOItemCount offset
, ppnum_t page
);
75 virtual void iovmInsert(ppnum_t addr
, IOItemCount offset
,
76 ppnum_t
*pageList
, IOItemCount pageCount
);
77 virtual void iovmInsert(ppnum_t addr
, IOItemCount offset
,
78 upl_page_info_t
*pageList
, IOItemCount pageCount
);
80 virtual addr64_t
mapAddr(IOPhysicalAddress addr
);
83 extern IOCopyMapper
* gIOCopyMapper
;