mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 06:45:07 +00:00
Remove MM::allocate_physical_pages() since it wasn't used.
Everyone was allocating one page at a time with allocate_physical_page().
This commit is contained in:
parent
36b3dc6c32
commit
c97a5862ce
2 changed files with 9 additions and 27 deletions
|
@ -94,12 +94,13 @@ RetainPtr<PhysicalPage> MemoryManager::allocate_page_table(PageDirectory& page_d
|
||||||
{
|
{
|
||||||
auto& page_directory_physical_ptr = page_directory.physical_pages[index];
|
auto& page_directory_physical_ptr = page_directory.physical_pages[index];
|
||||||
ASSERT(!page_directory_physical_ptr);
|
ASSERT(!page_directory_physical_ptr);
|
||||||
auto ppages = allocate_physical_pages(1);
|
auto physical_page = allocate_physical_page();
|
||||||
ASSERT(ppages.size() == 1);
|
if (!physical_page)
|
||||||
dword address = ppages[0]->paddr().get();
|
return nullptr;
|
||||||
|
dword address = physical_page->paddr().get();
|
||||||
create_identity_mapping(LinearAddress(address), PAGE_SIZE);
|
create_identity_mapping(LinearAddress(address), PAGE_SIZE);
|
||||||
memset((void*)address, 0, PAGE_SIZE);
|
memset((void*)address, 0, PAGE_SIZE);
|
||||||
page_directory.physical_pages[index] = move(ppages[0]);
|
page_directory.physical_pages[index] = move(physical_page);
|
||||||
return page_directory.physical_pages[index];
|
return page_directory.physical_pages[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,15 +241,14 @@ bool MemoryManager::copy_on_write(Process& process, Region& region, unsigned pag
|
||||||
dbgprintf(" >> It's a COW page and it's time to COW!\n");
|
dbgprintf(" >> It's a COW page and it's time to COW!\n");
|
||||||
#endif
|
#endif
|
||||||
auto physical_page_to_copy = move(vmo.physical_pages()[page_index_in_region]);
|
auto physical_page_to_copy = move(vmo.physical_pages()[page_index_in_region]);
|
||||||
auto ppages = allocate_physical_pages(1);
|
auto physical_page = allocate_physical_page();
|
||||||
ASSERT(ppages.size() == 1);
|
byte* dest_ptr = quickmap_page(*physical_page);
|
||||||
byte* dest_ptr = quickmap_page(*ppages[0]);
|
|
||||||
const byte* src_ptr = region.linearAddress.offset(page_index_in_region * PAGE_SIZE).asPtr();
|
const byte* src_ptr = region.linearAddress.offset(page_index_in_region * PAGE_SIZE).asPtr();
|
||||||
#ifdef PAGE_FAULT_DEBUG
|
#ifdef PAGE_FAULT_DEBUG
|
||||||
dbgprintf(" >> COW P%x <- P%x\n", ppages[0]->paddr().get(), physical_page_to_copy->paddr().get());
|
dbgprintf(" >> COW P%x <- P%x\n", physical_page->paddr().get(), physical_page_to_copy->paddr().get());
|
||||||
#endif
|
#endif
|
||||||
memcpy(dest_ptr, src_ptr, PAGE_SIZE);
|
memcpy(dest_ptr, src_ptr, PAGE_SIZE);
|
||||||
vmo.physical_pages()[page_index_in_region] = move(ppages[0]);
|
vmo.physical_pages()[page_index_in_region] = move(physical_page);
|
||||||
unquickmap_page();
|
unquickmap_page();
|
||||||
region.cow_map.set(page_index_in_region, false);
|
region.cow_map.set(page_index_in_region, false);
|
||||||
remap_region_page(process.m_page_directory, region, page_index_in_region, true);
|
remap_region_page(process.m_page_directory, region, page_index_in_region, true);
|
||||||
|
@ -352,23 +352,6 @@ RetainPtr<PhysicalPage> MemoryManager::allocate_physical_page()
|
||||||
return m_free_physical_pages.takeLast();
|
return m_free_physical_pages.takeLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<RetainPtr<PhysicalPage>> MemoryManager::allocate_physical_pages(size_t count)
|
|
||||||
{
|
|
||||||
InterruptDisabler disabler;
|
|
||||||
if (count > m_free_physical_pages.size())
|
|
||||||
return { };
|
|
||||||
|
|
||||||
Vector<RetainPtr<PhysicalPage>> pages;
|
|
||||||
pages.ensureCapacity(count);
|
|
||||||
for (size_t i = 0; i < count; ++i) {
|
|
||||||
pages.append(m_free_physical_pages.takeLast());
|
|
||||||
#ifdef MM_DEBUG
|
|
||||||
dbgprintf("MM: allocate_physical_pages vending P%x\n", pages.last()->paddr().get());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return pages;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MemoryManager::enter_kernel_paging_scope()
|
void MemoryManager::enter_kernel_paging_scope()
|
||||||
{
|
{
|
||||||
InterruptDisabler disabler;
|
InterruptDisabler disabler;
|
||||||
|
|
|
@ -175,7 +175,6 @@ public:
|
||||||
bool validate_user_read(const Process&, LinearAddress) const;
|
bool validate_user_read(const Process&, LinearAddress) const;
|
||||||
bool validate_user_write(const Process&, LinearAddress) const;
|
bool validate_user_write(const Process&, LinearAddress) const;
|
||||||
|
|
||||||
Vector<RetainPtr<PhysicalPage>> allocate_physical_pages(size_t count);
|
|
||||||
RetainPtr<PhysicalPage> allocate_physical_page();
|
RetainPtr<PhysicalPage> allocate_physical_page();
|
||||||
|
|
||||||
void remap_region(Process&, Region&);
|
void remap_region(Process&, Region&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue