mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[kernel] Remove page_manager::map_pages
The last use of page_manager::map_pages was during loading of ELF binaries. Switched to vm_space::allow instead.
This commit is contained in:
@@ -52,30 +52,6 @@ page_manager::dump_pml4(page_table *pml4, bool recurse)
|
||||
pml4->dump(page_table::level::pml4, recurse);
|
||||
}
|
||||
|
||||
void *
|
||||
page_manager::map_pages(uintptr_t address, size_t count, bool user, page_table *pml4)
|
||||
{
|
||||
kassert(address, "Cannot call map_pages with 0 address");
|
||||
|
||||
void *ret = reinterpret_cast<void *>(address);
|
||||
if (!pml4) pml4 = get_pml4();
|
||||
|
||||
while (count) {
|
||||
uintptr_t phys = 0;
|
||||
size_t n = m_frames.allocate(count, &phys);
|
||||
|
||||
log::info(logs::paging, "Paging in %d pages at p:%016lx to v:%016lx into %016lx table",
|
||||
n, phys, address, pml4);
|
||||
|
||||
page_in(pml4, phys, address, n, user);
|
||||
|
||||
address += n * frame_size;
|
||||
count -= n;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
page_manager::check_needs_page(page_table *table, unsigned index, bool user)
|
||||
{
|
||||
|
||||
@@ -49,14 +49,6 @@ public:
|
||||
__asm__ __volatile__ ( "mov %0, %%cr3" :: "r" (p) );
|
||||
}
|
||||
|
||||
/// Allocate and map pages into virtual memory.
|
||||
/// \arg address The virtual address at which to map the pages
|
||||
/// \arg count The number of pages to map
|
||||
/// \arg user True is this memory is user-accessible
|
||||
/// \arg pml4 The pml4 to map into - null for the current one
|
||||
/// \returns A pointer to the start of the mapped region
|
||||
void * map_pages(uintptr_t address, size_t count, bool user = false, page_table *pml4 = nullptr);
|
||||
|
||||
/// Dump the given or current PML4 to the console
|
||||
/// \arg pml4 The page table to use, null for the current one
|
||||
/// \arg recurse Whether to print sub-tables
|
||||
|
||||
@@ -67,10 +67,8 @@ load_process_image(const void *image_start, size_t bytes, TCB *tcb)
|
||||
{
|
||||
// We're now in the process space for this process, allocate memory for the
|
||||
// process code and load it
|
||||
page_manager *pager = page_manager::get();
|
||||
|
||||
thread *th = thread::from_tcb(tcb);
|
||||
process &proc = th->parent();
|
||||
process &proc = process::current();
|
||||
vm_space &space = proc.space();
|
||||
|
||||
log::debug(logs::loader, "Loading task! ELF: %016lx [%d]", image_start, bytes);
|
||||
|
||||
@@ -87,18 +85,16 @@ load_process_image(const void *image_start, size_t bytes, TCB *tcb)
|
||||
|
||||
uintptr_t aligned = header->vaddr & ~(memory::frame_size - 1);
|
||||
size_t size = (header->vaddr + header->mem_size) - aligned;
|
||||
size_t pages = page_manager::page_count(size);
|
||||
size_t pagesize = page_manager::page_count(size) * memory::frame_size;
|
||||
|
||||
log::debug(logs::loader, " Loadable segment %02u: vaddr %016lx size %016lx",
|
||||
i, header->vaddr, header->mem_size);
|
||||
|
||||
log::debug(logs::loader, " - aligned to: vaddr %016lx pages %d",
|
||||
aligned, pages);
|
||||
aligned, pagesize >> 12);
|
||||
|
||||
void *mapped = pager->map_pages(aligned, pages, true);
|
||||
kassert(mapped, "Tried to map userspace pages and failed!");
|
||||
|
||||
kutil::memset(mapped, 0, pages * memory::frame_size);
|
||||
space.allow(aligned, pagesize, true);
|
||||
kutil::memset(reinterpret_cast<void*>(aligned), 0, pagesize);
|
||||
}
|
||||
|
||||
const unsigned section_count = image.section_count();
|
||||
@@ -127,7 +123,7 @@ load_process_image(const void *image_start, size_t bytes, TCB *tcb)
|
||||
extern channel *std_out;
|
||||
init->output = proc.add_handle(std_out);
|
||||
|
||||
th->clear_state(thread::state::loading);
|
||||
thread::current().clear_state(thread::state::loading);
|
||||
|
||||
uintptr_t entrypoint = image.entrypoint();
|
||||
log::debug(logs::loader, " Loaded! New thread rip: %016lx", entrypoint);
|
||||
|
||||
Reference in New Issue
Block a user