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