1/* 2 * Copyright 2022 Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5#include "PMAPPhysicalPageMapper.h" 6 7 8status_t 9PMAPPhysicalPageMapper::GetPage( 10 phys_addr_t physicalAddress, addr_t* _virtualAddress, void** _handle) 11{ 12 ASSERT(physicalAddress < KERNEL_PMAP_SIZE); 13 14 *_virtualAddress = KERNEL_PMAP_BASE + physicalAddress; 15 *_handle = NULL; 16 17 return B_OK; 18} 19 20 21status_t 22PMAPPhysicalPageMapper::PutPage(addr_t virtualAddress, void* handle) 23{ 24 return B_OK; 25} 26 27 28status_t 29PMAPPhysicalPageMapper::MemsetPhysical(phys_addr_t address, int value, phys_size_t length) 30{ 31 ASSERT(address < KERNEL_PMAP_SIZE); 32 memset(reinterpret_cast<void*>(KERNEL_PMAP_BASE + address), value, length); 33 34 return B_OK; 35} 36 37 38status_t 39PMAPPhysicalPageMapper::MemcpyFromPhysical(void* to, phys_addr_t from, size_t length, bool user) 40{ 41 if (user) 42 panic("MemcpyFromPhysical user not impl"); 43 44 ASSERT(from < KERNEL_PMAP_SIZE); 45 memcpy(to, reinterpret_cast<void*>(KERNEL_PMAP_BASE + from), length); 46 47 return B_OK; 48} 49 50 51status_t 52PMAPPhysicalPageMapper::MemcpyToPhysical(phys_addr_t to, const void* from, size_t length, bool user) 53{ 54 if (user) 55 panic("MemcpyToPhysical user not impl"); 56 57 ASSERT(to < KERNEL_PMAP_SIZE); 58 memcpy(reinterpret_cast<void*>(KERNEL_PMAP_BASE + to), from, length); 59 60 return B_OK; 61} 62 63 64void 65PMAPPhysicalPageMapper::MemcpyPhysicalPage(phys_addr_t to, phys_addr_t from) 66{ 67 ASSERT(to < KERNEL_PMAP_SIZE); 68 ASSERT(from < KERNEL_PMAP_SIZE); 69 memcpy(reinterpret_cast<void*>(KERNEL_PMAP_BASE + to), 70 reinterpret_cast<void*>(KERNEL_PMAP_BASE + from), B_PAGE_SIZE); 71} 72