diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-17 19:31:30 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-17 19:32:07 +0100 |
commit | f2d5548d7a46d054f5015e29e90995a70106dc19 (patch) | |
tree | eb7add14cfdb2e75a8ae88752a648c165911c82a /Kernel | |
parent | c4a78633b09362efcfe11374d5cbf0e543b1cbac (diff) | |
download | serenity-f2d5548d7a46d054f5015e29e90995a70106dc19.zip |
Kernel: Add MemoryManager::copy_physical_page()
This is a handy helper that copies out the full contents of a physical
page into a caller-provided buffer. It uses quickmapping internally
(and takes the MM lock for the duration.)
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Memory/MemoryManager.cpp | 8 | ||||
-rw-r--r-- | Kernel/Memory/MemoryManager.h | 2 |
2 files changed, 10 insertions, 0 deletions
diff --git a/Kernel/Memory/MemoryManager.cpp b/Kernel/Memory/MemoryManager.cpp index 2a5afa3688..c16984e955 100644 --- a/Kernel/Memory/MemoryManager.cpp +++ b/Kernel/Memory/MemoryManager.cpp @@ -1118,4 +1118,12 @@ void CommittedPhysicalPageSet::uncommit_one() MM.uncommit_user_physical_pages({}, 1); } +void MemoryManager::copy_physical_page(PhysicalPage& physical_page, u8 page_buffer[PAGE_SIZE]) +{ + SpinlockLocker locker(s_mm_lock); + auto* quickmapped_page = quickmap_page(physical_page); + memcpy(page_buffer, quickmapped_page, PAGE_SIZE); + unquickmap_page(); +} + } diff --git a/Kernel/Memory/MemoryManager.h b/Kernel/Memory/MemoryManager.h index e1229d1bb5..edd6dd1640 100644 --- a/Kernel/Memory/MemoryManager.h +++ b/Kernel/Memory/MemoryManager.h @@ -240,6 +240,8 @@ public: PhysicalPageEntry& get_physical_page_entry(PhysicalAddress); PhysicalAddress get_physical_address(PhysicalPage const&); + void copy_physical_page(PhysicalPage&, u8 page_buffer[PAGE_SIZE]); + private: MemoryManager(); ~MemoryManager(); |