- Add support for the ucontext system calls (getcontext, setcontext,

swapcontext, and makecontext).
- Fix VM to not erroneously think the stack segment and data segment have
  collided when a user-space thread invokes brk().
- Add test51 to test ucontext functionality.
- Add man pages for ucontext system calls.
This commit is contained in:
Thomas Veerman
2010-03-12 15:58:41 +00:00
parent 3efbb8f133
commit bef0e3eb63
33 changed files with 1232 additions and 19 deletions

View File

@@ -42,6 +42,7 @@
#define USE_PHYSCOPY 1 /* copy using physical addressing */
#define USE_MEMSET 1 /* write char to a given memory area */
#define USE_RUNCTL 1 /* control stop flags of a process */
#define USE_MCONTEXT 1 /* enable getting and setting of mach context*/
/* Length of program names stored in the process table. This is only used
* for the debugging dumps that can be generated with the IS server. The PM

View File

@@ -236,6 +236,10 @@ PUBLIC void system_init(void)
map(SYS_READBIOS, do_readbios); /* read from BIOS locations */
map(SYS_IOPENABLE, do_iopenable); /* Enable I/O */
map(SYS_SDEVIO, do_sdevio); /* phys_insb, _insw, _outsb, _outsw */
/* Machine state switching. */
map(SYS_SETMCONTEXT, do_setmcontext); /* set machine context */
map(SYS_GETMCONTEXT, do_getmcontext); /* get machine context */
#endif
}

View File

@@ -192,5 +192,12 @@ _PROTOTYPE( int do_sprofile, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_cprofile, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_profbuf, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_getmcontext, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_setmcontext, (struct proc * caller, message *m_ptr) );
#if ! USE_MCONTEXT
#define do_getmcontext do_unused
#define do_setmcontext do_unused
#endif
#endif /* SYSTEM_H */

View File

@@ -57,7 +57,8 @@ OBJECTS = \
do_sprofile.o \
do_cprofile.o \
do_profbuf.o \
do_vmctl.o
do_vmctl.o \
do_mcontext.o
build $(SYSTEM): $(SYSTEM)($(OBJECTS))
aal cr $@ *.o

View File

@@ -0,0 +1,94 @@
/* The kernel calls that are implemented in this file:
* m_type: SYS_SETMCONTEXT
* m_type: SYS_GETMCONTEXT
*
* The parameters for these kernel calls are:
* m1_i1: PR_ENDPT # proc endpoint doing call
* m1_p1: PR_MEM_PTR # pointer to mcontext structure
*
*/
#include "../system.h"
#include <string.h>
#include <machine/mcontext.h>
#if USE_MCONTEXT
/*===========================================================================*
* do_getmcontext *
*===========================================================================*/
PUBLIC int do_getmcontext(struct proc * caller, message * m_ptr)
{
/* Retrieve machine context of a process */
register struct proc *rp;
int proc_nr, r;
mcontext_t mc;
if (! isokendpt(m_ptr->PR_ENDPT, &proc_nr)) return(EINVAL);
if (iskerneln(proc_nr)) return(EPERM);
rp = proc_addr(proc_nr);
#if (_MINIX_CHIP == _CHIP_INTEL)
if (!(rp->p_misc_flags & MF_FPU_INITIALIZED))
return(OK); /* No state to copy */
#endif
/* Get the mcontext structure into our address space. */
if ((r = data_copy(m_ptr->PR_ENDPT, (vir_bytes) m_ptr->PR_CTX_PTR, KERNEL,
(vir_bytes) &mc, (phys_bytes) sizeof(struct __mcontext))) != OK)
return(r);
#if (_MINIX_CHIP == _CHIP_INTEL)
/* Copy FPU state */
mc.mc_fpu_flags = 0;
if (rp->p_misc_flags & MF_FPU_INITIALIZED) {
mc.mc_fpu_flags = 0 | rp->p_misc_flags & MF_FPU_INITIALIZED;
memcpy(&(mc.mc_fpu_state), rp->p_fpu_state.fpu_save_area_p,
FPU_XFP_SIZE);
}
#endif
/* Copy the mcontext structure to the user's address space. */
if ((r = data_copy(KERNEL, (vir_bytes) &mc, m_ptr->PR_ENDPT,
(vir_bytes) m_ptr->PR_CTX_PTR,
(phys_bytes) sizeof(struct __mcontext))) != OK)
return(r);
return(OK);
}
/*===========================================================================*
* do_setmcontext *
*===========================================================================*/
PUBLIC int do_setmcontext(struct proc * caller, message * m_ptr)
{
/* Set machine context of a process */
register struct proc *rp;
int proc_nr, r;
mcontext_t mc;
if (!isokendpt(m_ptr->PR_ENDPT, &proc_nr)) return(EINVAL);
rp = proc_addr(proc_nr);
/* Get the mcontext structure into our address space. */
if ((r = data_copy(m_ptr->PR_ENDPT, (vir_bytes) m_ptr->PR_CTX_PTR, KERNEL,
(vir_bytes) &mc, (phys_bytes) sizeof(struct __mcontext))) != OK)
return(r);
#if (_MINIX_CHIP == _CHIP_INTEL)
/* Copy FPU state */
if (mc.mc_fpu_flags & MF_FPU_INITIALIZED) {
rp->p_misc_flags |= MF_FPU_INITIALIZED;
memcpy(rp->p_fpu_state.fpu_save_area_p, &(mc.mc_fpu_state),
FPU_XFP_SIZE);
} else
rp->p_misc_flags &= ~MF_FPU_INITIALIZED;
#endif
return(OK);
}
#endif