From 60d339f6fe0831060600c62418b71a62ad26c281 Mon Sep 17 00:00:00 2001 From: Gennady Sharapov Date: Sat, 3 Sep 2005 15:57:47 -0700 Subject: [PATCH] uml: move libc-dependent startup and signal code The serial UML OS-abstraction layer patch (um/kernel dir). This moves all systemcalls from process.c file under os-Linux dir and join process.c and process_kern.c files. Signed-off-by: Gennady Sharapov Signed-off-by: Jeff Dike Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/os-Linux/process.c | 58 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 3 deletions(-) (limited to 'arch/um/os-Linux/process.c') diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index 1e126bfd31a7..d32413e4b4ce 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c @@ -3,10 +3,10 @@ * Licensed under the GPL */ -#include #include #include #include +#include #include #include #include @@ -14,6 +14,10 @@ #include "os.h" #include "user.h" #include "user_util.h" +#include "signal_user.h" +#include "process.h" +#include "irq_user.h" +#include "kern_util.h" #define ARBITRARY_ADDR -1 #define FAILURE_PID -1 @@ -114,8 +118,10 @@ void os_usr1_process(int pid) kill(pid, SIGUSR1); } -/*Don't use the glibc version, which caches the result in TLS. It misses some - * syscalls, and also breaks with clone(), which does not unshare the TLS.*/ +/* Don't use the glibc version, which caches the result in TLS. It misses some + * syscalls, and also breaks with clone(), which does not unshare the TLS. + */ + inline _syscall0(pid_t, getpid) int os_getpid(void) @@ -164,6 +170,52 @@ int os_unmap_memory(void *addr, int len) return(0); } +void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)) +{ + int flags = 0, pages; + + if(sig_stack != NULL){ + pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER); + set_sigstack(sig_stack, pages * page_size()); + flags = SA_ONSTACK; + } + if(usr1_handler) set_handler(SIGUSR1, usr1_handler, flags, -1); +} + +void init_new_thread_signals(int altstack) +{ + int flags = altstack ? SA_ONSTACK : 0; + + set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags, + SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); + set_handler(SIGTRAP, (__sighandler_t) sig_handler, flags, + SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); + set_handler(SIGFPE, (__sighandler_t) sig_handler, flags, + SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); + set_handler(SIGILL, (__sighandler_t) sig_handler, flags, + SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); + set_handler(SIGBUS, (__sighandler_t) sig_handler, flags, + SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); + set_handler(SIGUSR2, (__sighandler_t) sig_handler, + flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); + signal(SIGHUP, SIG_IGN); + + init_irq_signals(altstack); +} + +int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr) +{ + sigjmp_buf buf; + int n; + + *jmp_ptr = &buf; + n = sigsetjmp(buf, 1); + if(n != 0) + return(n); + (*fn)(arg); + return(0); +} + /* * Overrides for Emacs so that we follow Linus's tabbing style. * Emacs will notice this stuff at the end of the file and automatically -- cgit v1.2.3