1 /* 2 * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef KERNEL_ARCH_X86_PAGING_X86_PHYSICAL_PAGE_MAPPER_H 6 #define KERNEL_ARCH_X86_PAGING_X86_PHYSICAL_PAGE_MAPPER_H 7 8 9 #include <vm/VMTranslationMap.h> 10 11 12 struct kernel_args; 13 14 15 #ifndef __x86_64__ 16 17 18 class TranslationMapPhysicalPageMapper { 19 public: 20 virtual ~TranslationMapPhysicalPageMapper() { } 21 22 virtual void Delete() = 0; 23 24 virtual void* GetPageTableAt(phys_addr_t physicalAddress) = 0; 25 // Must be invoked with thread pinned to current CPU. 26 }; 27 28 29 class X86PhysicalPageMapper : public VMPhysicalPageMapper { 30 public: 31 virtual status_t CreateTranslationMapPhysicalPageMapper( 32 TranslationMapPhysicalPageMapper** _mapper) 33 = 0; 34 35 virtual void* InterruptGetPageTableAt( 36 phys_addr_t physicalAddress) = 0; 37 }; 38 39 40 #else 41 42 43 class TranslationMapPhysicalPageMapper { 44 public: 45 void Delete(); 46 47 void* GetPageTableAt(phys_addr_t physicalAddress); 48 // Must be invoked with thread pinned to current CPU. 49 }; 50 51 52 class X86PhysicalPageMapper final : public VMPhysicalPageMapper { 53 public: 54 status_t CreateTranslationMapPhysicalPageMapper( 55 TranslationMapPhysicalPageMapper** _mapper); 56 57 void* InterruptGetPageTableAt(phys_addr_t physicalAddress); 58 59 status_t GetPage(phys_addr_t physicalAddress, addr_t* virtualAddress, 60 void** handle) override; 61 status_t PutPage(addr_t virtualAddress, void* handle) override; 62 63 status_t GetPageCurrentCPU(phys_addr_t physicalAddress, 64 addr_t* virtualAddress, void** handle) override; 65 status_t PutPageCurrentCPU(addr_t virtualAddress, void* handle) override; 66 67 status_t GetPageDebug(phys_addr_t physicalAddress, 68 addr_t* virtualAddress, void** handle) override; 69 status_t PutPageDebug(addr_t virtualAddress, void* handle) override; 70 71 status_t MemsetPhysical(phys_addr_t address, int value, 72 phys_size_t length) override; 73 status_t MemcpyFromPhysical(void* to, phys_addr_t from, size_t length, 74 bool user) override; 75 status_t MemcpyToPhysical(phys_addr_t to, const void* from, 76 size_t length, bool user) override; 77 void MemcpyPhysicalPage(phys_addr_t to, phys_addr_t from) override; 78 }; 79 80 81 #include "paging/x86_physical_page_mapper_mapped.h" 82 83 84 #endif // __x86_64__ 85 86 87 #endif // KERNEL_ARCH_X86_PAGING_X86_PHYSICAL_PAGE_MAPPER_H 88