xref: /minix3/minix/kernel/arch/earm/arch_do_vmctl.c (revision 6077d1ad241af1cd2881b708610d6ceb54ed9612)
1433d6423SLionel Sambuc /* The kernel call implemented in this file:
2433d6423SLionel Sambuc  *   m_type:	SYS_VMCTL
3433d6423SLionel Sambuc  *
4433d6423SLionel Sambuc  * The parameters for this kernel call are:
5433d6423SLionel Sambuc  *   	SVMCTL_WHO	which process
6433d6423SLionel Sambuc  *    	SVMCTL_PARAM	set this setting (VMCTL_*)
7433d6423SLionel Sambuc  *    	SVMCTL_VALUE	to this value
8433d6423SLionel Sambuc  */
9433d6423SLionel Sambuc 
10433d6423SLionel Sambuc #include "kernel/system.h"
11433d6423SLionel Sambuc #include <assert.h>
12433d6423SLionel Sambuc #include <minix/type.h>
13433d6423SLionel Sambuc 
14433d6423SLionel Sambuc #include "arch_proto.h"
15433d6423SLionel Sambuc 
set_ttbr(struct proc * p,u32_t ttbr,u32_t * v)16433d6423SLionel Sambuc static void set_ttbr(struct proc *p, u32_t ttbr, u32_t *v)
17433d6423SLionel Sambuc {
18433d6423SLionel Sambuc 	/* Set process TTBR. */
19433d6423SLionel Sambuc 	p->p_seg.p_ttbr = ttbr;
20433d6423SLionel Sambuc 	assert(p->p_seg.p_ttbr);
21433d6423SLionel Sambuc 	p->p_seg.p_ttbr_v = v;
22433d6423SLionel Sambuc 	if(p == get_cpulocal_var(ptproc)) {
23433d6423SLionel Sambuc 		write_ttbr0(p->p_seg.p_ttbr);
24433d6423SLionel Sambuc 	}
25433d6423SLionel Sambuc 	if(p->p_nr == VM_PROC_NR) {
26433d6423SLionel Sambuc 		if (arch_enable_paging(p) != OK)
27433d6423SLionel Sambuc 			panic("arch_enable_paging failed");
28433d6423SLionel Sambuc 	}
29433d6423SLionel Sambuc 	RTS_UNSET(p, RTS_VMINHIBIT);
30433d6423SLionel Sambuc }
31433d6423SLionel Sambuc 
32433d6423SLionel Sambuc /*===========================================================================*
33433d6423SLionel Sambuc  *				arch_do_vmctl				     *
34433d6423SLionel Sambuc  *===========================================================================*/
arch_do_vmctl(register message * m_ptr,struct proc * p)35*6077d1adSDr. Florian Grätz int arch_do_vmctl(
36*6077d1adSDr. Florian Grätz   register message *m_ptr,	/* pointer to request message */
37*6077d1adSDr. Florian Grätz   struct proc *p
38*6077d1adSDr. Florian Grätz )
39433d6423SLionel Sambuc {
40433d6423SLionel Sambuc   switch(m_ptr->SVMCTL_PARAM) {
41433d6423SLionel Sambuc 	case VMCTL_GET_PDBR:
42433d6423SLionel Sambuc 		/* Get process page directory base reg (TTBR). */
43433d6423SLionel Sambuc 		m_ptr->SVMCTL_VALUE = p->p_seg.p_ttbr;
44433d6423SLionel Sambuc 		return OK;
45433d6423SLionel Sambuc 	case VMCTL_SETADDRSPACE:
46433d6423SLionel Sambuc 		set_ttbr(p, m_ptr->SVMCTL_PTROOT, (u32_t *) m_ptr->SVMCTL_PTROOT_V);
47433d6423SLionel Sambuc 		return OK;
48433d6423SLionel Sambuc 	case VMCTL_FLUSHTLB:
49433d6423SLionel Sambuc 	{
50433d6423SLionel Sambuc 		reload_ttbr0();
51433d6423SLionel Sambuc 		return OK;
52433d6423SLionel Sambuc 	}
53433d6423SLionel Sambuc   }
54433d6423SLionel Sambuc 
55433d6423SLionel Sambuc   printf("arch_do_vmctl: strange param %d\n", m_ptr->SVMCTL_PARAM);
56433d6423SLionel Sambuc   return EINVAL;
57433d6423SLionel Sambuc }
58