1 /* 2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <vm/VMTranslationMap.h> 8 9 #include <vm/VMArea.h> 10 11 12 // #pragma mark - VMTranslationMap 13 14 15 VMTranslationMap::VMTranslationMap() 16 : 17 fMapCount(0) 18 { 19 recursive_lock_init(&fLock, "translation map"); 20 } 21 22 23 VMTranslationMap::~VMTranslationMap() 24 { 25 recursive_lock_destroy(&fLock); 26 } 27 28 29 /*! Unmaps a range of pages of an area. 30 31 The default implementation just iterates over all virtual pages of the 32 range and calls UnmapPage(). This is obviously not particularly efficient. 33 */ 34 void 35 VMTranslationMap::UnmapPages(VMArea* area, addr_t base, size_t size) 36 { 37 ASSERT(base % B_PAGE_SIZE == 0); 38 ASSERT(size % B_PAGE_SIZE == 0); 39 40 addr_t address = base; 41 addr_t end = address + size; 42 for (; address != end; address += B_PAGE_SIZE) 43 UnmapPage(area, address); 44 } 45 46 47 /*! Unmaps all of an area's pages. 48 If \a deletingAddressSpace is \c true, the address space the area belongs to 49 is in the process of being destroyed and isn't used by anyone anymore. For 50 some architectures this can be used for optimizations (e.g. not unmapping 51 pages or at least not needing to invalidate TLB entries). 52 If \a ignoreTopCachePageFlags is \c true, the area is in the process of 53 being destroyed and its top cache is otherwise unreferenced. I.e. all mapped 54 pages that live in the top cache area going to be freed and the page 55 accessed and modified flags don't need to be propagated. 56 57 The default implementation just iterates over all virtual pages of the 58 area and calls UnmapPage(). This is obviously not particularly efficient. 59 */ 60 void 61 VMTranslationMap::UnmapArea(VMArea* area, bool deletingAddressSpace, 62 bool ignoreTopCachePageFlags) 63 { 64 addr_t address = area->Base(); 65 addr_t end = address + area->Size(); 66 for (; address != end; address += B_PAGE_SIZE) 67 UnmapPage(area, address); 68 } 69 70 71 // #pragma mark - VMPhysicalPageMapper 72 73 74 VMPhysicalPageMapper::VMPhysicalPageMapper() 75 { 76 } 77 78 79 VMPhysicalPageMapper::~VMPhysicalPageMapper() 80 { 81 } 82