Gennady Sharapov | ea2ba7d | 2006-01-08 01:01:31 -0800 | [diff] [blame^] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) |
| 3 | * Licensed under the GPL |
| 4 | */ |
| 5 | |
| 6 | #include <stdlib.h> |
| 7 | #include <errno.h> |
| 8 | #include <setjmp.h> |
| 9 | #include <signal.h> |
| 10 | #include <sys/time.h> |
| 11 | #include <sys/wait.h> |
| 12 | #include <asm/page.h> |
| 13 | #include <asm/unistd.h> |
| 14 | #include <asm/ptrace.h> |
| 15 | #include "init.h" |
| 16 | #include "sysdep/ptrace.h" |
| 17 | #include "sigcontext.h" |
| 18 | #include "sysdep/sigcontext.h" |
| 19 | #include "irq_user.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include "time_user.h" |
| 21 | #include "task.h" |
| 22 | #include "mode.h" |
| 23 | #include "choose-mode.h" |
| 24 | #include "kern_util.h" |
| 25 | #include "user_util.h" |
| 26 | #include "os.h" |
| 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | void segv_handler(int sig, union uml_pt_regs *regs) |
| 29 | { |
Bodo Stroesser | c578455 | 2005-05-05 16:15:31 -0700 | [diff] [blame] | 30 | struct faultinfo * fi = UPT_FAULTINFO(regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
Bodo Stroesser | c578455 | 2005-05-05 16:15:31 -0700 | [diff] [blame] | 32 | if(UPT_IS_USER(regs) && !SEGV_IS_FIXABLE(fi)){ |
| 33 | bad_segv(*fi, UPT_IP(regs)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | return; |
| 35 | } |
Bodo Stroesser | c578455 | 2005-05-05 16:15:31 -0700 | [diff] [blame] | 36 | segv(*fi, UPT_IP(regs), UPT_IS_USER(regs), regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | void usr2_handler(int sig, union uml_pt_regs *regs) |
| 40 | { |
| 41 | CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0); |
| 42 | } |
| 43 | |
Gennady Sharapov | ea2ba7d | 2006-01-08 01:01:31 -0800 | [diff] [blame^] | 44 | void (*sig_info[NSIG])(int, union uml_pt_regs *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
Gennady Sharapov | ea2ba7d | 2006-01-08 01:01:31 -0800 | [diff] [blame^] | 46 | void os_fill_handlinfo(struct kern_handlers h) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | { |
Gennady Sharapov | ea2ba7d | 2006-01-08 01:01:31 -0800 | [diff] [blame^] | 48 | sig_info[SIGTRAP] = h.relay_signal; |
| 49 | sig_info[SIGFPE] = h.relay_signal; |
| 50 | sig_info[SIGILL] = h.relay_signal; |
| 51 | sig_info[SIGWINCH] = h.winch; |
| 52 | sig_info[SIGBUS] = h.bus_handler; |
| 53 | sig_info[SIGSEGV] = h.page_fault; |
| 54 | sig_info[SIGIO] = h.sigio_handler; |
| 55 | sig_info[SIGVTALRM] = h.timer_handler; |
| 56 | sig_info[SIGALRM] = h.timer_handler; |
| 57 | sig_info[SIGUSR2] = usr2_handler; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | } |