]> Zhao Yanbai Git Server - minix.git/commitdiff
Enable paging - some more code reshuffling
authorTomas Hruby <tom@minix3.org>
Wed, 15 Sep 2010 14:09:41 +0000 (14:09 +0000)
committerTomas Hruby <tom@minix3.org>
Wed, 15 Sep 2010 14:09:41 +0000 (14:09 +0000)
kernel/arch/i386/memory.c
kernel/proto.h
kernel/system/do_vmctl.c

index 6d1394cae9de96fe0a51f2697793150f7029cbff..9875e9c05a8888f3988a3f91b7ed094c2e4457c4 100644 (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
         */
index 4f71d7c94c8a1d4188b342d078ed4141c4f6a429..fb84aa51c7fc50c0472e22c3a7cc0c1c8f86278d 100644 (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));
index c5fdbd865f8810eaa091be2673ba3d623b871c55..82673deaca01c48b6fc28f9d8861c2a58318d1d1 100644 (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;