more changes on original files
[linux-2.4.git] / arch / arm / kernel / arthur.c
1 /*
2  *  linux/arch/arm/kernel/arthur.c
3  *
4  *  Copyright (C) 1998, 1999, 2000, 2001 Philip Blundell
5  *
6  * Arthur personality
7  */
8
9 /*
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version
13  * 2 of the License, or (at your option) any later version.
14  */
15
16 #include <linux/module.h>
17 #include <linux/personality.h>
18 #include <linux/stddef.h>
19 #include <linux/signal.h>
20 #include <linux/sched.h>
21 #include <linux/init.h>
22
23 #include <asm/ptrace.h>
24
25 /* Arthur doesn't have many signals, and a lot of those that it does
26    have don't map easily to any Linux equivalent.  Never mind.  */
27
28 #define ARTHUR_SIGABRT          1
29 #define ARTHUR_SIGFPE           2
30 #define ARTHUR_SIGILL           3
31 #define ARTHUR_SIGINT           4
32 #define ARTHUR_SIGSEGV          5
33 #define ARTHUR_SIGTERM          6
34 #define ARTHUR_SIGSTAK          7
35 #define ARTHUR_SIGUSR1          8
36 #define ARTHUR_SIGUSR2          9
37 #define ARTHUR_SIGOSERROR       10
38
39 static unsigned long arthur_to_linux_signals[32] = {
40         0,      1,      2,      3,      4,      5,      6,      7,
41         8,      9,      10,     11,     12,     13,     14,     15,
42         16,     17,     18,     19,     20,     21,     22,     23,
43         24,     25,     26,     27,     28,     29,     30,     31
44 };
45
46 /*
47  * Linux to Arthur signal map.
48  */
49 static unsigned long arthur_invmap[32] = {
50         [0]             = 0,
51         [SIGHUP]        = -1,
52         [SIGINT]        = ARTHUR_SIGINT,
53         [SIGQUIT]       = -1,
54         [SIGILL]        = ARTHUR_SIGILL,
55         [SIGTRAP]       = 5,
56         [SIGABRT]       = ARTHUR_SIGABRT,
57         [SIGBUS]        = 7,
58         [SIGFPE]        = ARTHUR_SIGFPE,
59         [SIGKILL]       = 9,
60         [SIGUSR1]       = ARTHUR_SIGUSR1,
61         [SIGSEGV]       = ARTHUR_SIGSEGV,       
62         [SIGUSR2]       = ARTHUR_SIGUSR2,
63         [SIGPIPE]       = 13,
64         [SIGALRM]       = 14,
65         [SIGTERM]       = ARTHUR_SIGTERM,
66         [SIGSTKFLT]     = 16,
67         [SIGCHLD]       = 17,
68         [SIGCONT]       = 18,
69         [SIGSTOP]       = 19,
70         [SIGTSTP]       = 20,
71         [SIGTTIN]       = 21,
72         [SIGTTOU]       = 22,
73         [SIGURG]        = 23,
74         [SIGXCPU]       = 24,
75         [SIGXFSZ]       = 25,
76         [SIGVTALRM]     = 26,
77         [SIGPROF]       = 27,
78         [SIGWINCH]      = 28,
79         [SIGIO]         = 29,
80         [SIGPWR]        = 30,
81         [SIGSYS]        = 31
82 };
83
84 static void arthur_lcall7(int nr, struct pt_regs *regs)
85 {
86         struct siginfo info;
87
88         info.si_signo = SIGSWI;
89         info.si_errno = nr;
90         /* Bounce it to the emulator */
91         send_sig_info(SIGSWI, &info, current);
92 }
93
94 static struct exec_domain arthur_exec_domain = {
95         .name           = "Arthur",     /* name */
96         .handler        = arthur_lcall7,
97         .pers_low       = PER_RISCOS,
98         .pers_high      = PER_RISCOS,
99         .signal_map     = arthur_to_linux_signals,
100         .signal_invmap  = arthur_invmap,
101         .module         = THIS_MODULE,
102 };
103
104 /*
105  * We could do with some locking to stop Arthur being removed while
106  * processes are using it.
107  */
108
109 static int __init arthur_init(void)
110 {
111         return register_exec_domain(&arthur_exec_domain);
112 }
113
114 static void __exit arthur_exit(void)
115 {
116         unregister_exec_domain(&arthur_exec_domain);
117 }
118
119 module_init(arthur_init);
120 module_exit(arthur_exit);
121
122 MODULE_AUTHOR("Philip Blundell");
123 MODULE_LICENSE("GPL");