728f0f0c49
* Userspace change to use the new kernel calls - _taskcall(SYSTASK...) changed to _kernel_call(...) - int 32 reused for the kernel calls - _do_kernel_call() to make the trap to kernel - kernel_call() to make the actuall kernel call from C using _do_kernel_call() - unlike ipc call the kernel call always succeeds as kernel is always available, however, kernel may return an error * Kernel side implementation of kernel calls - the SYSTEm task does not run, only the proc table entry is preserved - every data_copy(SYSTEM is no data_copy(KERNEL - "locking" is an empty operation now as everything runs in kernel - sys_task() is replaced by kernel_call() which copies the message into kernel, dispatches the call to its handler and finishes by either copying the results back to userspace (if need be) or by suspending the process because of VM - suspended processes are later made runnable once the memory issue is resolved, picked up by the scheduler and only at this time the call is resumed (in fact restarted) which does not need to copy the message from userspace as the message is already saved in the process structure. - no ned for the vmrestart queue, the scheduler will restart the system calls - no special case in do_vmctl(), all requests remove the RTS_VMREQUEST flag
50 lines
1.5 KiB
C
50 lines
1.5 KiB
C
/* The kernel call implemented in this file:
|
|
* m_type: SYS_NEWMAP
|
|
*
|
|
* The parameters for this kernel call are:
|
|
* m1_i1: PR_ENDPT (install new map for this process)
|
|
* m1_p1: PR_MEM_PTR (pointer to the new memory map)
|
|
*/
|
|
#include "../system.h"
|
|
#include <minix/endpoint.h>
|
|
|
|
#if USE_NEWMAP
|
|
|
|
/*===========================================================================*
|
|
* do_newmap *
|
|
*===========================================================================*/
|
|
PUBLIC int do_newmap(struct proc * caller, message * m_ptr)
|
|
{
|
|
/* Handle sys_newmap(). Fetch the memory map. */
|
|
struct proc *rp; /* process whose map is to be loaded */
|
|
struct mem_map *map_ptr; /* virtual address of map inside caller */
|
|
int proc_nr;
|
|
|
|
map_ptr = (struct mem_map *) m_ptr->PR_MEM_PTR;
|
|
if (! isokendpt(m_ptr->PR_ENDPT, &proc_nr)) return(EINVAL);
|
|
if (iskerneln(proc_nr)) return(EPERM);
|
|
rp = proc_addr(proc_nr);
|
|
|
|
return newmap(caller, rp, map_ptr);
|
|
}
|
|
|
|
|
|
/*===========================================================================*
|
|
* newmap *
|
|
*===========================================================================*/
|
|
PUBLIC int newmap(struct proc *caller, struct proc *rp, struct mem_map *map_ptr)
|
|
{
|
|
int r;
|
|
/* Fetch the memory map. */
|
|
if((r=data_copy(caller->p_endpoint, (vir_bytes) map_ptr,
|
|
KERNEL, (vir_bytes) rp->p_memmap, sizeof(rp->p_memmap))) != OK) {
|
|
kprintf("newmap: data_copy failed! (%d)\n", r);
|
|
return r;
|
|
}
|
|
|
|
alloc_segments(rp);
|
|
|
|
return(OK);
|
|
}
|
|
#endif /* USE_NEWMAP */
|
|
|