- 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
+1 -1
View File
@@ -8,7 +8,7 @@ INCS= alloca.h ansi.h a.out.h ar.h assert.h configfile.h ctype.h \
regexp.h setjmp.h sgtty.h signal.h stdarg.h stddef.h \
stdint.h stdio.h stdlib.h string.h strings.h sysexits.h \
syslog.h tar.h termcap.h termios.h time.h timers.h tools.h \
ttyent.h unistd.h utime.h utmp.h
ttyent.h ucontext.h unistd.h utime.h utmp.h
INCS+= arpa/inet.h
INCS+= minix/a.out.h minix/bitmap.h minix/callnr.h minix/cdrom.h \
minix/com.h minix/config.h minix/const.h minix/cpufeature.h \
+2 -2
View File
@@ -1,7 +1,7 @@
INCSDIR= /usr/include/i386
INCS= archtypes.h bios.h cmos.h cpu.h diskparm.h fpu.h int86.h \
interrupt.h memory.h partition.h pci.h ports.h stackframe.h \
vm.h
interrupt.h mcontext.h memory.h partition.h pci.h ports.h \
stackframe.h vm.h
.include <minix.kinc.mk>
+23
View File
@@ -0,0 +1,23 @@
#ifndef _MACHINE_MCONTEXT_H
#define _MACHINE_MCONTEXT_H 1
#include <machine/fpu.h>
#include <machine/stackframe.h>
#define MCF_MAGIC 0xc0ffee
/* Context to describe processor state */
typedef struct __mcontext {
int mc_magic;
struct stackframe_s mc_p_reg;
#if (_MINIX_CHIP == _CHIP_INTEL)
union fpu_state_u mc_fpu_state;
#endif
short mc_fpu_flags;
} mcontext_t;
_PROTOTYPE( int setmcontext, (const mcontext_t *mcp) );
_PROTOTYPE( int getmcontext, (mcontext_t *mcp) );
#endif /* _MACHINE_MCONTEXT_H */
+2
View File
@@ -56,6 +56,8 @@
#define ITIMER 64
#define GETGROUPS 65
#define SETGROUPS 66
#define GETMCONTEXT 67
#define SETMCONTEXT 68
/* Posix signal handling. */
#define SIGACTION 71
+5 -2
View File
@@ -355,8 +355,10 @@
# define SYS_SAFEMAP (KERNEL_CALL + 47) /* sys_safemap() */
# define SYS_SAFEREVMAP (KERNEL_CALL + 48) /* sys_saferevmap() sys_saferevmap2() */
# define SYS_SAFEUNMAP (KERNEL_CALL + 49) /* sys_safeunmap() */
# define SYS_GETMCONTEXT (KERNEL_CALL + 50) /* sys_getmcontext() */
# define SYS_SETMCONTEXT (KERNEL_CALL + 51) /* sys_setmcontext() */
#define NR_SYS_CALLS 50 /* number of system calls */
#define NR_SYS_CALLS 52 /* number of system calls */
#define SYS_CALL_MASK_SIZE BITMAP_CHUNKS(NR_SYS_CALLS)
/* Field names for SYS_MEMSET. */
@@ -510,7 +512,7 @@
#define SIG_MAP m2_l1 /* used by kernel to pass signal bit map */
#define SIG_CTXT_PTR m2_p1 /* pointer to info to restore signal context */
/* Field names for SYS_FORK, _EXEC, _EXIT, _NEWMAP. */
/* Field names for SYS_FORK, _EXEC, _EXIT, _NEWMAP, GETMCONTEXT, SETMCONTEXT.*/
#define PR_ENDPT m1_i1 /* indicates a process */
#define PR_PRIORITY m1_i2 /* process priority */
#define PR_SLOT m1_i2 /* indicates a process slot */
@@ -522,6 +524,7 @@
*/
#define PR_FORK_FLAGS m1_i3 /* optional flags for fork operation */
#define PR_FORK_MSGADDR m1_p1 /* reply message address of forked child */
#define PR_CTX_PTR m1_p1 /* pointer to mcontext_t structure */
/* Flags for PR_FORK_FLAGS. */
#define PFF_VMINHIBIT 0x01 /* Don't schedule until release by VM. */
+5
View File
@@ -19,6 +19,7 @@
#include <minix/safecopies.h>
#include <minix/sef.h>
#include <machine/mcontext.h>
/* Forward declaration */
struct reg86u;
@@ -250,5 +251,9 @@ _PROTOTYPE( int sys_cprof, (int action, int size, endpoint_t endpt,
void *ctl_ptr, void *mem_ptr) );
_PROTOTYPE( int sys_profbuf, (void *ctl_ptr, void *mem_ptr) );
/* machine context */
_PROTOTYPE( int sys_getmcontext, (endpoint_t proc, mcontext_t *mcp) );
_PROTOTYPE( int sys_setmcontext, (endpoint_t proc, mcontext_t *mcp) );
#endif /* _SYSLIB_H */
+13
View File
@@ -113,6 +113,19 @@ struct sigaction {
#define FPE_FLTINV 7 /* floating-point invalid operation */
#define FPE_FLTSUB 8 /* subscript out of range */
typedef struct sigaltstack {
void *ss_sp;
int ss_flags;
size_t ss_size;
} stack_t;
#define MINSIGSTKSZ 2048 /* Minimal stack size is 2k */
/* Fields for ss_flags */
#define SS_ONSTACK 1 /* Process is executing on an alternate stack */
#define SS_DISABLE 2 /* Alternate stack is disabled */
#endif /* _POSIX_SOURCE */
/* POSIX and ANSI function prototypes. */
+1 -1
View File
@@ -8,7 +8,7 @@ INCS= asynchio.h dir.h file.h ioc_cmos.h ioc_disk.h \
mount.h mtio.h param.h ptrace.h queue.h resource.h \
select.h sem.h shm.h sigcontext.h signal.h socket.h \
soundcard.h statfs.h stat.h svrctl.h timeb.h \
time.h times.h types.h uio.h un.h utsname.h video.h vm.h \
time.h times.h types.h ucontext.h uio.h un.h utsname.h video.h vm.h \
wait.h
.include <minix.kinc.mk>
+22
View File
@@ -0,0 +1,22 @@
#ifndef _SYS_UCONTEXT_H
#define _SYS_UCONTEXT_H 1
#include <signal.h>
#include <machine/mcontext.h>
#define NCARGS 6
#define UCF_SWAPPED 001 /* Context has been swapped in by swapcontext(3) */
#define UCF_IGNFPU 002 /* Ignore FPU context by get or setcontext(3) */
#define UCF_IGNSIGM 004 /* Ignore signal mask by get or setcontext(3) */
typedef struct __ucontext ucontext_t;
struct __ucontext {
unsigned int uc_flags; /* Properties of ucontext */
ucontext_t *uc_link; /* Next context to resume when current is finished */
mcontext_t uc_mcontext; /* Machine state */
sigset_t uc_sigmask; /* Signals blocked in this context */
stack_t uc_stack; /* The stack used by this context */
};
#endif /* _SYS_UCONTEXT_H */
+21
View File
@@ -0,0 +1,21 @@
#ifndef _UCONTEXT_H
#define _UCONTEXT_H 1
#include <sys/ucontext.h>
_PROTOTYPE( void makecontext, (ucontext_t *ucp, void (*func)(void),
int argc, ...) );
_PROTOTYPE( int swapcontext, (ucontext_t *oucp,
const ucontext_t *ucp) );
_PROTOTYPE( int getcontext, (ucontext_t *ucp) );
_PROTOTYPE( int setcontext, (const ucontext_t *ucp) );
_PROTOTYPE( void resumecontext, (ucontext_t *ucp) );
/* These functions get and set ucontext structure through PM/kernel. They don't
* manipulate the stack. */
_PROTOTYPE( int getuctx, (ucontext_t *ucp) );
_PROTOTYPE( int setuctx, (const ucontext_t *ucp) );
#endif /* _UCONTEXT_H */