2005-10-14 10:58:59 +02:00
|
|
|
/* The kernel call that is implemented in this file:
|
2005-07-19 14:21:36 +02:00
|
|
|
* m_type: SYS_SIGRETURN
|
2005-07-14 17:12:12 +02:00
|
|
|
*
|
2005-10-14 10:58:59 +02:00
|
|
|
* The parameters for this kernel call are:
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
* m2_i1: SIG_ENDPT # process returning from handler
|
2005-07-19 14:21:36 +02:00
|
|
|
* m2_p1: SIG_CTXT_PTR # pointer to sigcontext structure
|
2005-07-14 17:12:12 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../system.h"
|
2005-07-19 17:01:47 +02:00
|
|
|
#include <string.h>
|
2005-07-14 17:12:12 +02:00
|
|
|
#include <signal.h>
|
2007-05-08 17:43:00 +02:00
|
|
|
#include <ibm/cpu.h>
|
2005-07-14 17:12:12 +02:00
|
|
|
#include <sys/sigcontext.h>
|
|
|
|
|
|
|
|
#if USE_SIGRETURN
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_sigreturn *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int do_sigreturn(m_ptr)
|
|
|
|
message *m_ptr; /* pointer to request message */
|
|
|
|
{
|
|
|
|
/* POSIX style signals require sys_sigreturn to put things in order before
|
|
|
|
* the signalled process can resume execution
|
|
|
|
*/
|
|
|
|
struct sigcontext sc;
|
|
|
|
register struct proc *rp;
|
2009-09-15 11:57:22 +02:00
|
|
|
int proc_nr, r;
|
2005-07-14 17:12:12 +02:00
|
|
|
|
2009-09-15 11:57:22 +02:00
|
|
|
if (! isokendpt(m_ptr->SIG_ENDPT, &proc_nr)) return(EINVAL);
|
|
|
|
if (iskerneln(proc_nr)) return(EPERM);
|
|
|
|
rp = proc_addr(proc_nr);
|
2005-07-14 17:12:12 +02:00
|
|
|
|
|
|
|
/* Copy in the sigcontext structure. */
|
2008-11-19 13:26:10 +01:00
|
|
|
if((r=data_copy(m_ptr->SIG_ENDPT, (vir_bytes) m_ptr->SIG_CTXT_PTR,
|
|
|
|
SYSTEM, (vir_bytes) &sc, sizeof(struct sigcontext))) != OK)
|
|
|
|
return r;
|
2005-07-14 17:12:12 +02:00
|
|
|
|
2007-05-08 17:43:00 +02:00
|
|
|
/* Restore user bits of psw from sc, maintain system bits from proc. */
|
|
|
|
sc.sc_psw = (sc.sc_psw & X86_FLAGS_USER) |
|
|
|
|
(rp->p_reg.psw & ~X86_FLAGS_USER);
|
2005-07-14 17:12:12 +02:00
|
|
|
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
#if (_MINIX_CHIP == _CHIP_INTEL)
|
2005-07-14 17:12:12 +02:00
|
|
|
/* Don't panic kernel if user gave bad selectors. */
|
|
|
|
sc.sc_cs = rp->p_reg.cs;
|
|
|
|
sc.sc_ds = rp->p_reg.ds;
|
|
|
|
sc.sc_es = rp->p_reg.es;
|
2009-09-25 19:44:26 +02:00
|
|
|
sc.sc_ss = rp->p_reg.ss;
|
2005-07-14 17:12:12 +02:00
|
|
|
#if _WORD_SIZE == 4
|
|
|
|
sc.sc_fs = rp->p_reg.fs;
|
|
|
|
sc.sc_gs = rp->p_reg.gs;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Restore the registers. */
|
2009-12-02 14:01:48 +01:00
|
|
|
memcpy(&rp->p_reg, &sc.sc_regs, sizeof(sigregs));
|
|
|
|
#if (_MINIX_CHIP == _CHIP_INTEL)
|
|
|
|
if(sc.sc_flags & MF_FPU_INITIALIZED)
|
|
|
|
{
|
2009-12-03 00:12:46 +01:00
|
|
|
memcpy(rp->p_fpu_state.fpu_save_area_p, &sc.sc_fpu_state,
|
|
|
|
FPU_XFP_SIZE);
|
2009-12-02 14:01:48 +01:00
|
|
|
rp->p_misc_flags |= MF_FPU_INITIALIZED; /* Restore math usage flag. */
|
|
|
|
}
|
|
|
|
#endif
|
2009-07-07 20:55:11 +02:00
|
|
|
|
2005-07-14 17:12:12 +02:00
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
#endif /* USE_SIGRETURN */
|
|
|
|
|