1 /* The kernel call implemented in this file: 2 * m_type: SYS_VMCTL 3 * 4 * The parameters for this kernel call are: 5 * SVMCTL_WHO which process 6 * SVMCTL_PARAM set this setting (VMCTL_*) 7 * SVMCTL_VALUE to this value 8 */ 9 10 #include "kernel/system.h" 11 #include <assert.h> 12 #include <minix/type.h> 13 14 #include "arch_proto.h" 15 16 extern phys_bytes video_mem_vaddr; 17 18 extern char *video_mem; 19 20 static void setcr3(struct proc *p, u32_t cr3, u32_t *v) 21 { 22 /* Set process CR3. */ 23 p->p_seg.p_cr3 = cr3; 24 assert(p->p_seg.p_cr3); 25 p->p_seg.p_cr3_v = v; 26 if(p == get_cpulocal_var(ptproc)) { 27 write_cr3(p->p_seg.p_cr3); 28 } 29 if(p->p_nr == VM_PROC_NR) { 30 if (arch_enable_paging(p) != OK) 31 panic("arch_enable_paging failed"); 32 } 33 RTS_UNSET(p, RTS_VMINHIBIT); 34 } 35 36 /*===========================================================================* 37 * arch_do_vmctl * 38 *===========================================================================*/ 39 int arch_do_vmctl( 40 register message *m_ptr, /* pointer to request message */ 41 struct proc *p 42 ) 43 { 44 switch(m_ptr->SVMCTL_PARAM) { 45 case VMCTL_GET_PDBR: 46 /* Get process page directory base reg (CR3). */ 47 m_ptr->SVMCTL_VALUE = p->p_seg.p_cr3; 48 return OK; 49 case VMCTL_SETADDRSPACE: 50 setcr3(p, m_ptr->SVMCTL_PTROOT, (u32_t *) m_ptr->SVMCTL_PTROOT_V); 51 return OK; 52 case VMCTL_FLUSHTLB: 53 { 54 reload_cr3(); 55 return OK; 56 } 57 case VMCTL_I386_INVLPG: 58 { 59 i386_invlpg(m_ptr->SVMCTL_VALUE); 60 return OK; 61 } 62 } 63 64 65 66 printf("arch_do_vmctl: strange param %d\n", m_ptr->SVMCTL_PARAM); 67 return EINVAL; 68 } 69