Enable paging - some more code reshuffling

This commit is contained in:
Tomas Hruby 2010-09-15 14:09:41 +00:00
parent 6c3b981cd6
commit ce4fd0c0fb
3 changed files with 26 additions and 28 deletions

View File

@ -38,32 +38,11 @@ FORWARD _PROTOTYPE( u32_t phys_get32, (phys_bytes v) );
FORWARD _PROTOTYPE( void vm_enable_paging, (void) );
/* *** Internal VM Functions *** */
PUBLIC void vm_init(struct proc *newptproc)
PUBLIC void segmentation2paging(struct proc * current)
{
if(vm_running)
panic("vm_init: vm_running");
/* switch_address_space() checks what is in cr3, and doesn't do
* anything if it's the same as the cr3 of its argument, newptproc.
* If MINIX was previously booted, this could very well be the case.
*
* The first time switch_address_space() is called, we want to
* force it to do something (load cr3 and set newptproc), so we
* zero cr3, and force paging off to make that a safe thing to do.
*
* After that, vm_enable_paging() enables paging with the page table
* of newptproc loaded.
*/
vm_stop();
write_cr3(0);
switch_address_space(newptproc);
assert(ptproc == newptproc);
catch_pagefaults = 0;
/* switch to the current process page tables before turning paging on */
switch_address_space(current);
vm_enable_paging();
vm_running = 1;
}
/* This function sets up a mapping from within the kernel's address
@ -1042,6 +1021,26 @@ PUBLIC int arch_enable_paging(struct proc * caller, const message * m_ptr)
struct vm_ep_data ep_data;
int r;
/* switch_address_space() checks what is in cr3, and do nothing if it's
* the same as the cr3 of its argument, newptproc. If MINIX was
* previously booted, this could very well be the case.
*
* The first time switch_address_space() is called, we want to
* force it to do something (load cr3 and set newptproc), so we
* zero cr3, and force paging off to make that a safe thing to do.
*
* After that, segmentation2paging() enables paging with the page table
* of caller loaded.
*/
vm_stop();
write_cr3(0);
/* switch from segmentation only to paging */
segmentation2paging(caller);
vm_running = 1;
/*
* copy the extra data associated with the call from userspace
*/

View File

@ -152,7 +152,6 @@ _PROTOTYPE( int data_copy_vmcheck, (struct proc *,
endpoint_t from, vir_bytes from_addr,
endpoint_t to, vir_bytes to_addr, size_t bytes));
_PROTOTYPE( void alloc_segments, (struct proc *rp) );
_PROTOTYPE( void vm_init, (struct proc *first) );
_PROTOTYPE( void vm_stop, (void) );
_PROTOTYPE( phys_bytes umap_local, (register struct proc *rp, int seg,
vir_bytes vir_addr, vir_bytes bytes));

View File

@ -123,10 +123,10 @@ PUBLIC int do_vmctl(struct proc * caller, message * m_ptr)
case VMCTL_ENABLE_PAGING:
if(vm_running)
panic("do_vmctl: paging already enabled");
vm_init(p);
if(!vm_running)
if (arch_enable_paging(caller, m_ptr) != OK)
panic("do_vmctl: paging enabling failed");
return arch_enable_paging(caller, m_ptr);
return OK;
case VMCTL_KERN_PHYSMAP:
{
int i = m_ptr->SVMCTL_VALUE;