minix/lib/libc/sys-minix/init.c
Ben Gras 2d72cbec41 SYSENTER/SYSCALL support
. add cpufeature detection of both
	. use it for both ipc and kernelcall traps, using a register
	  for call number
	. SYSENTER/SYSCALL does not save any context, therefore userland
	  has to save it
	. to accomodate multiple kernel entry/exit types, the entry
	  type is recorded in the process struct. hitherto all types
	  were interrupt (soft int, exception, hard int); now SYSENTER/SYSCALL
	  is new, with the difference that context is not fully restored
	  from proc struct when running the process again. this can't be
	  done as some information is missing.
	. complication: cases in which the kernel has to fully change
	  process context (i.e. sigreturn). in that case the exit type
	  is changed from SYSENTER/SYSEXIT to soft-int (i.e. iret) and
	  context is fully restored from the proc struct. this does mean
	  the PC and SP must change, as the sysenter/sysexit userland code
	  will otherwise try to restore its own context. this is true in the
	  sigreturn case.
	. override all usage by setting libc_ipc=1
2012-09-24 15:53:43 +02:00

30 lines
819 B
C

#include <stdio.h>
#include <minix/ipc.h>
/* Minix kernel info, IPC functions pointers */
struct minix_kerninfo *_minix_kerninfo = NULL;
void __minix_init(void) __attribute__((__constructor__, __used__));
struct minix_ipcvecs _minix_ipcvecs = {
.sendrec_ptr = _sendrec_orig,
.send_ptr = _send_orig,
.notify_ptr = _notify_orig,
.senda_ptr = _senda_orig,
.sendnb_ptr = _sendnb_orig,
.receive_ptr = _receive_orig,
.do_kernel_call_ptr = _do_kernel_call_orig,
};
void __minix_init(void)
{
if((_minix_kernel_info_struct(&_minix_kerninfo)) != 0
|| _minix_kerninfo->kerninfo_magic != KERNINFO_MAGIC) {
_minix_kerninfo = NULL;
} else if((_minix_kerninfo->ki_flags & MINIX_KIF_IPCVECS) &&
_minix_kerninfo->minix_ipcvecs) {
_minix_ipcvecs = *_minix_kerninfo->minix_ipcvecs;
}
}