diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/um/include |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/um/include')
62 files changed, 3890 insertions, 0 deletions
diff --git a/arch/um/include/2_5compat.h b/arch/um/include/2_5compat.h new file mode 100644 index 000000000000..abdb015a4d71 --- /dev/null +++ b/arch/um/include/2_5compat.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __2_5_COMPAT_H__ | ||
7 | #define __2_5_COMPAT_H__ | ||
8 | |||
9 | #define INIT_HARDSECT(arr, maj, sizes) | ||
10 | |||
11 | #define SET_PRI(task) do ; while(0) | ||
12 | |||
13 | #endif | ||
14 | |||
15 | /* | ||
16 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
17 | * Emacs will notice this stuff at the end of the file and automatically | ||
18 | * adjust the settings for this buffer only. This must remain at the end | ||
19 | * of the file. | ||
20 | * --------------------------------------------------------------------------- | ||
21 | * Local variables: | ||
22 | * c-file-style: "linux" | ||
23 | * End: | ||
24 | */ | ||
diff --git a/arch/um/include/chan_kern.h b/arch/um/include/chan_kern.h new file mode 100644 index 000000000000..da9a6717e7a4 --- /dev/null +++ b/arch/um/include/chan_kern.h | |||
@@ -0,0 +1,60 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __CHAN_KERN_H__ | ||
7 | #define __CHAN_KERN_H__ | ||
8 | |||
9 | #include "linux/tty.h" | ||
10 | #include "linux/list.h" | ||
11 | #include "linux/console.h" | ||
12 | #include "chan_user.h" | ||
13 | #include "line.h" | ||
14 | |||
15 | struct chan { | ||
16 | struct list_head list; | ||
17 | char *dev; | ||
18 | unsigned int primary:1; | ||
19 | unsigned int input:1; | ||
20 | unsigned int output:1; | ||
21 | unsigned int opened:1; | ||
22 | int fd; | ||
23 | enum chan_init_pri pri; | ||
24 | struct chan_ops *ops; | ||
25 | void *data; | ||
26 | }; | ||
27 | |||
28 | extern void chan_interrupt(struct list_head *chans, struct work_struct *task, | ||
29 | struct tty_struct *tty, int irq); | ||
30 | extern int parse_chan_pair(char *str, struct list_head *chans, int pri, | ||
31 | int device, struct chan_opts *opts); | ||
32 | extern int open_chan(struct list_head *chans); | ||
33 | extern int write_chan(struct list_head *chans, const char *buf, int len, | ||
34 | int write_irq); | ||
35 | extern int console_write_chan(struct list_head *chans, const char *buf, | ||
36 | int len); | ||
37 | extern int console_open_chan(struct line *line, struct console *co, | ||
38 | struct chan_opts *opts); | ||
39 | extern void close_chan(struct list_head *chans); | ||
40 | extern void chan_enable_winch(struct list_head *chans, struct tty_struct *tty); | ||
41 | extern void enable_chan(struct list_head *chans, struct tty_struct *tty); | ||
42 | extern int chan_window_size(struct list_head *chans, | ||
43 | unsigned short *rows_out, | ||
44 | unsigned short *cols_out); | ||
45 | extern int chan_out_fd(struct list_head *chans); | ||
46 | extern int chan_config_string(struct list_head *chans, char *str, int size, | ||
47 | char **error_out); | ||
48 | |||
49 | #endif | ||
50 | |||
51 | /* | ||
52 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
53 | * Emacs will notice this stuff at the end of the file and automatically | ||
54 | * adjust the settings for this buffer only. This must remain at the end | ||
55 | * of the file. | ||
56 | * --------------------------------------------------------------------------- | ||
57 | * Local variables: | ||
58 | * c-file-style: "linux" | ||
59 | * End: | ||
60 | */ | ||
diff --git a/arch/um/include/chan_user.h b/arch/um/include/chan_user.h new file mode 100644 index 000000000000..f77d9aa4c164 --- /dev/null +++ b/arch/um/include/chan_user.h | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __CHAN_USER_H__ | ||
7 | #define __CHAN_USER_H__ | ||
8 | |||
9 | #include "init.h" | ||
10 | |||
11 | struct chan_opts { | ||
12 | void (*announce)(char *dev_name, int dev); | ||
13 | char *xterm_title; | ||
14 | int raw; | ||
15 | unsigned long tramp_stack; | ||
16 | int in_kernel; | ||
17 | }; | ||
18 | |||
19 | enum chan_init_pri { INIT_STATIC, INIT_ALL, INIT_ONE }; | ||
20 | |||
21 | struct chan_ops { | ||
22 | char *type; | ||
23 | void *(*init)(char *, int, struct chan_opts *); | ||
24 | int (*open)(int, int, int, void *, char **); | ||
25 | void (*close)(int, void *); | ||
26 | int (*read)(int, char *, void *); | ||
27 | int (*write)(int, const char *, int, void *); | ||
28 | int (*console_write)(int, const char *, int, void *); | ||
29 | int (*window_size)(int, void *, unsigned short *, unsigned short *); | ||
30 | void (*free)(void *); | ||
31 | int winch; | ||
32 | }; | ||
33 | |||
34 | extern struct chan_ops fd_ops, null_ops, port_ops, pts_ops, pty_ops, tty_ops, | ||
35 | xterm_ops; | ||
36 | |||
37 | extern void generic_close(int fd, void *unused); | ||
38 | extern int generic_read(int fd, char *c_out, void *unused); | ||
39 | extern int generic_write(int fd, const char *buf, int n, void *unused); | ||
40 | extern int generic_console_write(int fd, const char *buf, int n, void *state); | ||
41 | extern int generic_window_size(int fd, void *unused, unsigned short *rows_out, | ||
42 | unsigned short *cols_out); | ||
43 | extern void generic_free(void *data); | ||
44 | |||
45 | struct tty_struct; | ||
46 | extern void register_winch(int fd, struct tty_struct *tty); | ||
47 | extern void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty); | ||
48 | |||
49 | #define __channel_help(fn, prefix) \ | ||
50 | __uml_help(fn, prefix "[0-9]*=<channel description>\n" \ | ||
51 | " Attach a console or serial line to a host channel. See\n" \ | ||
52 | " http://user-mode-linux.sourceforge.net/input.html for a complete\n" \ | ||
53 | " description of this switch.\n\n" \ | ||
54 | ); | ||
55 | |||
56 | #endif | ||
57 | |||
58 | /* | ||
59 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
60 | * Emacs will notice this stuff at the end of the file and automatically | ||
61 | * adjust the settings for this buffer only. This must remain at the end | ||
62 | * of the file. | ||
63 | * --------------------------------------------------------------------------- | ||
64 | * Local variables: | ||
65 | * c-file-style: "linux" | ||
66 | * End: | ||
67 | */ | ||
diff --git a/arch/um/include/choose-mode.h b/arch/um/include/choose-mode.h new file mode 100644 index 000000000000..8e6b62f5e9ac --- /dev/null +++ b/arch/um/include/choose-mode.h | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __CHOOSE_MODE_H__ | ||
7 | #define __CHOOSE_MODE_H__ | ||
8 | |||
9 | #include "uml-config.h" | ||
10 | |||
11 | #if defined(UML_CONFIG_MODE_TT) && defined(UML_CONFIG_MODE_SKAS) | ||
12 | #define CHOOSE_MODE(tt, skas) (mode_tt ? (tt) : (skas)) | ||
13 | |||
14 | #elif defined(UML_CONFIG_MODE_SKAS) | ||
15 | #define CHOOSE_MODE(tt, skas) (skas) | ||
16 | |||
17 | #elif defined(UML_CONFIG_MODE_TT) | ||
18 | #define CHOOSE_MODE(tt, skas) (tt) | ||
19 | #endif | ||
20 | |||
21 | #define CHOOSE_MODE_PROC(tt, skas, args...) \ | ||
22 | CHOOSE_MODE(tt(args), skas(args)) | ||
23 | |||
24 | extern int mode_tt; | ||
25 | static inline void *__choose_mode(void *tt, void *skas) { | ||
26 | return mode_tt ? tt : skas; | ||
27 | } | ||
28 | |||
29 | #define __CHOOSE_MODE(tt, skas) (*( (typeof(tt) *) __choose_mode(&(tt), &(skas)))) | ||
30 | |||
31 | #endif | ||
32 | |||
33 | /* | ||
34 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
35 | * Emacs will notice this stuff at the end of the file and automatically | ||
36 | * adjust the settings for this buffer only. This must remain at the end | ||
37 | * of the file. | ||
38 | * --------------------------------------------------------------------------- | ||
39 | * Local variables: | ||
40 | * c-file-style: "linux" | ||
41 | * End: | ||
42 | */ | ||
diff --git a/arch/um/include/elf_user.h b/arch/um/include/elf_user.h new file mode 100644 index 000000000000..53516b637272 --- /dev/null +++ b/arch/um/include/elf_user.h | |||
@@ -0,0 +1,19 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 Fujitsu Siemens Computers GmbH | ||
3 | * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com> | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #ifndef __ELF_USER_H__ | ||
8 | #define __ELF_USER_H__ | ||
9 | |||
10 | /* For compilation on a host that doesn't support AT_SYSINFO (Linux 2.4) */ | ||
11 | |||
12 | #ifndef AT_SYSINFO | ||
13 | #define AT_SYSINFO 32 | ||
14 | #endif | ||
15 | #ifndef AT_SYSINFO_EHDR | ||
16 | #define AT_SYSINFO_EHDR 33 | ||
17 | #endif | ||
18 | |||
19 | #endif | ||
diff --git a/arch/um/include/frame_kern.h b/arch/um/include/frame_kern.h new file mode 100644 index 000000000000..ce9514f57211 --- /dev/null +++ b/arch/um/include/frame_kern.h | |||
@@ -0,0 +1,32 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __FRAME_KERN_H_ | ||
7 | #define __FRAME_KERN_H_ | ||
8 | |||
9 | #define _S(nr) (1<<((nr)-1)) | ||
10 | #define _BLOCKABLE (~(_S(SIGKILL) | _S(SIGSTOP))) | ||
11 | |||
12 | extern int setup_signal_stack_sc(unsigned long stack_top, int sig, | ||
13 | struct k_sigaction *ka, | ||
14 | struct pt_regs *regs, | ||
15 | sigset_t *mask); | ||
16 | extern int setup_signal_stack_si(unsigned long stack_top, int sig, | ||
17 | struct k_sigaction *ka, | ||
18 | struct pt_regs *regs, siginfo_t *info, | ||
19 | sigset_t *mask); | ||
20 | |||
21 | #endif | ||
22 | |||
23 | /* | ||
24 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
25 | * Emacs will notice this stuff at the end of the file and automatically | ||
26 | * adjust the settings for this buffer only. This must remain at the end | ||
27 | * of the file. | ||
28 | * --------------------------------------------------------------------------- | ||
29 | * Local variables: | ||
30 | * c-file-style: "linux" | ||
31 | * End: | ||
32 | */ | ||
diff --git a/arch/um/include/helper.h b/arch/um/include/helper.h new file mode 100644 index 000000000000..162ac31192fd --- /dev/null +++ b/arch/um/include/helper.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __HELPER_H__ | ||
7 | #define __HELPER_H__ | ||
8 | |||
9 | extern int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | ||
10 | unsigned long *stack_out); | ||
11 | extern int run_helper_thread(int (*proc)(void *), void *arg, | ||
12 | unsigned int flags, unsigned long *stack_out, | ||
13 | int stack_order); | ||
14 | extern int helper_wait(int pid); | ||
15 | |||
16 | #endif | ||
17 | |||
18 | /* | ||
19 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
20 | * Emacs will notice this stuff at the end of the file and automatically | ||
21 | * adjust the settings for this buffer only. This must remain at the end | ||
22 | * of the file. | ||
23 | * --------------------------------------------------------------------------- | ||
24 | * Local variables: | ||
25 | * c-file-style: "linux" | ||
26 | * End: | ||
27 | */ | ||
diff --git a/arch/um/include/init.h b/arch/um/include/init.h new file mode 100644 index 000000000000..55c2693f8778 --- /dev/null +++ b/arch/um/include/init.h | |||
@@ -0,0 +1,132 @@ | |||
1 | #ifndef _LINUX_UML_INIT_H | ||
2 | #define _LINUX_UML_INIT_H | ||
3 | |||
4 | /* These macros are used to mark some functions or | ||
5 | * initialized data (doesn't apply to uninitialized data) | ||
6 | * as `initialization' functions. The kernel can take this | ||
7 | * as hint that the function is used only during the initialization | ||
8 | * phase and free up used memory resources after | ||
9 | * | ||
10 | * Usage: | ||
11 | * For functions: | ||
12 | * | ||
13 | * You should add __init immediately before the function name, like: | ||
14 | * | ||
15 | * static void __init initme(int x, int y) | ||
16 | * { | ||
17 | * extern int z; z = x * y; | ||
18 | * } | ||
19 | * | ||
20 | * If the function has a prototype somewhere, you can also add | ||
21 | * __init between closing brace of the prototype and semicolon: | ||
22 | * | ||
23 | * extern int initialize_foobar_device(int, int, int) __init; | ||
24 | * | ||
25 | * For initialized data: | ||
26 | * You should insert __initdata between the variable name and equal | ||
27 | * sign followed by value, e.g.: | ||
28 | * | ||
29 | * static int init_variable __initdata = 0; | ||
30 | * static char linux_logo[] __initdata = { 0x32, 0x36, ... }; | ||
31 | * | ||
32 | * Don't forget to initialize data not at file scope, i.e. within a function, | ||
33 | * as gcc otherwise puts the data into the bss section and not into the init | ||
34 | * section. | ||
35 | * | ||
36 | * Also note, that this data cannot be "const". | ||
37 | */ | ||
38 | |||
39 | #ifndef _LINUX_INIT_H | ||
40 | typedef int (*initcall_t)(void); | ||
41 | typedef void (*exitcall_t)(void); | ||
42 | |||
43 | /* These are for everybody (although not all archs will actually | ||
44 | discard it in modules) */ | ||
45 | #define __init __attribute__ ((__section__ (".init.text"))) | ||
46 | #define __initdata __attribute__ ((__section__ (".init.data"))) | ||
47 | #define __exitdata __attribute__ ((__section__(".exit.data"))) | ||
48 | #define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit"))) | ||
49 | |||
50 | #ifdef MODULE | ||
51 | #define __exit __attribute__ ((__section__(".exit.text"))) | ||
52 | #else | ||
53 | #define __exit __attribute_used__ __attribute__ ((__section__(".exit.text"))) | ||
54 | #endif | ||
55 | |||
56 | #endif | ||
57 | |||
58 | #ifndef MODULE | ||
59 | struct uml_param { | ||
60 | const char *str; | ||
61 | int (*setup_func)(char *, int *); | ||
62 | }; | ||
63 | |||
64 | extern initcall_t __uml_initcall_start, __uml_initcall_end; | ||
65 | extern initcall_t __uml_postsetup_start, __uml_postsetup_end; | ||
66 | extern const char *__uml_help_start, *__uml_help_end; | ||
67 | #endif | ||
68 | |||
69 | #define __uml_initcall(fn) \ | ||
70 | static initcall_t __uml_initcall_##fn __uml_init_call = fn | ||
71 | |||
72 | #define __uml_exitcall(fn) \ | ||
73 | static exitcall_t __uml_exitcall_##fn __uml_exit_call = fn | ||
74 | |||
75 | extern struct uml_param __uml_setup_start, __uml_setup_end; | ||
76 | |||
77 | #define __uml_postsetup(fn) \ | ||
78 | static initcall_t __uml_postsetup_##fn __uml_postsetup_call = fn | ||
79 | |||
80 | #define __non_empty_string(dummyname,string) \ | ||
81 | struct __uml_non_empty_string_struct_##dummyname \ | ||
82 | { \ | ||
83 | char _string[sizeof(string)-2]; \ | ||
84 | } | ||
85 | |||
86 | #ifndef MODULE | ||
87 | #define __uml_setup(str, fn, help...) \ | ||
88 | __non_empty_string(fn ##_setup, str); \ | ||
89 | __uml_help(fn, help); \ | ||
90 | static char __uml_setup_str_##fn[] __initdata = str; \ | ||
91 | static struct uml_param __uml_setup_##fn __uml_init_setup = { __uml_setup_str_##fn, fn } | ||
92 | #else | ||
93 | #define __uml_setup(str, fn, help...) \ | ||
94 | |||
95 | #endif | ||
96 | |||
97 | #define __uml_help(fn, help...) \ | ||
98 | __non_empty_string(fn ##__help, help); \ | ||
99 | static char __uml_help_str_##fn[] __initdata = help; \ | ||
100 | static const char *__uml_help_##fn __uml_setup_help = __uml_help_str_##fn | ||
101 | |||
102 | /* | ||
103 | * Mark functions and data as being only used at initialization | ||
104 | * or exit time. | ||
105 | */ | ||
106 | #define __uml_init_setup __attribute_used__ __attribute__ ((__section__ (".uml.setup.init"))) | ||
107 | #define __uml_setup_help __attribute_used__ __attribute__ ((__section__ (".uml.help.init"))) | ||
108 | #define __uml_init_call __attribute_used__ __attribute__ ((__section__ (".uml.initcall.init"))) | ||
109 | #define __uml_postsetup_call __attribute_used__ __attribute__ ((__section__ (".uml.postsetup.init"))) | ||
110 | #define __uml_exit_call __attribute_used__ __attribute__ ((__section__ (".uml.exitcall.exit"))) | ||
111 | |||
112 | #ifndef __KERNEL__ | ||
113 | |||
114 | #define __initcall(fn) static initcall_t __initcall_##fn __init_call = fn | ||
115 | #define __exitcall(fn) static exitcall_t __exitcall_##fn __exit_call = fn | ||
116 | |||
117 | #define __init_call __attribute__ ((unused,__section__ (".initcall.init"))) | ||
118 | |||
119 | #endif | ||
120 | |||
121 | #endif /* _LINUX_UML_INIT_H */ | ||
122 | |||
123 | /* | ||
124 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
125 | * Emacs will notice this stuff at the end of the file and automatically | ||
126 | * adjust the settings for this buffer only. This must remain at the end | ||
127 | * of the file. | ||
128 | * --------------------------------------------------------------------------- | ||
129 | * Local variables: | ||
130 | * c-file-style: "linux" | ||
131 | * End: | ||
132 | */ | ||
diff --git a/arch/um/include/initrd.h b/arch/um/include/initrd.h new file mode 100644 index 000000000000..439b9a814985 --- /dev/null +++ b/arch/um/include/initrd.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __INITRD_USER_H__ | ||
7 | #define __INITRD_USER_H__ | ||
8 | |||
9 | extern int load_initrd(char *filename, void *buf, int size); | ||
10 | |||
11 | #endif | ||
12 | |||
13 | /* | ||
14 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
15 | * Emacs will notice this stuff at the end of the file and automatically | ||
16 | * adjust the settings for this buffer only. This must remain at the end | ||
17 | * of the file. | ||
18 | * --------------------------------------------------------------------------- | ||
19 | * Local variables: | ||
20 | * c-file-style: "linux" | ||
21 | * End: | ||
22 | */ | ||
diff --git a/arch/um/include/irq_kern.h b/arch/um/include/irq_kern.h new file mode 100644 index 000000000000..3af52a634c4c --- /dev/null +++ b/arch/um/include/irq_kern.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __IRQ_KERN_H__ | ||
7 | #define __IRQ_KERN_H__ | ||
8 | |||
9 | #include "linux/interrupt.h" | ||
10 | |||
11 | extern int um_request_irq(unsigned int irq, int fd, int type, | ||
12 | irqreturn_t (*handler)(int, void *, | ||
13 | struct pt_regs *), | ||
14 | unsigned long irqflags, const char * devname, | ||
15 | void *dev_id); | ||
16 | |||
17 | #endif | ||
18 | |||
19 | /* | ||
20 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
21 | * Emacs will notice this stuff at the end of the file and automatically | ||
22 | * adjust the settings for this buffer only. This must remain at the end | ||
23 | * of the file. | ||
24 | * --------------------------------------------------------------------------- | ||
25 | * Local variables: | ||
26 | * c-file-style: "linux" | ||
27 | * End: | ||
28 | */ | ||
diff --git a/arch/um/include/irq_user.h b/arch/um/include/irq_user.h new file mode 100644 index 000000000000..f724b717213f --- /dev/null +++ b/arch/um/include/irq_user.h | |||
@@ -0,0 +1,36 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __IRQ_USER_H__ | ||
7 | #define __IRQ_USER_H__ | ||
8 | |||
9 | enum { IRQ_READ, IRQ_WRITE }; | ||
10 | |||
11 | extern void sigio_handler(int sig, union uml_pt_regs *regs); | ||
12 | extern int activate_fd(int irq, int fd, int type, void *dev_id); | ||
13 | extern void free_irq_by_irq_and_dev(unsigned int irq, void *dev_id); | ||
14 | extern void free_irq_by_fd(int fd); | ||
15 | extern void reactivate_fd(int fd, int irqnum); | ||
16 | extern void deactivate_fd(int fd, int irqnum); | ||
17 | extern int deactivate_all_fds(void); | ||
18 | extern void forward_interrupts(int pid); | ||
19 | extern void init_irq_signals(int on_sigstack); | ||
20 | extern void forward_ipi(int fd, int pid); | ||
21 | extern void free_irq_later(int irq, void *dev_id); | ||
22 | extern int activate_ipi(int fd, int pid); | ||
23 | extern unsigned long irq_lock(void); | ||
24 | extern void irq_unlock(unsigned long flags); | ||
25 | #endif | ||
26 | |||
27 | /* | ||
28 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
29 | * Emacs will notice this stuff at the end of the file and automatically | ||
30 | * adjust the settings for this buffer only. This must remain at the end | ||
31 | * of the file. | ||
32 | * --------------------------------------------------------------------------- | ||
33 | * Local variables: | ||
34 | * c-file-style: "linux" | ||
35 | * End: | ||
36 | */ | ||
diff --git a/arch/um/include/kern.h b/arch/um/include/kern.h new file mode 100644 index 000000000000..1e3170768b5c --- /dev/null +++ b/arch/um/include/kern.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __KERN_H__ | ||
7 | #define __KERN_H__ | ||
8 | |||
9 | /* These are all user-mode things which are convenient to call directly | ||
10 | * from kernel code and for which writing a wrapper is too much of a pain. | ||
11 | * The regular include files can't be included because this file is included | ||
12 | * only into kernel code, and user-space includes conflict with kernel | ||
13 | * includes. | ||
14 | */ | ||
15 | |||
16 | extern int errno; | ||
17 | |||
18 | extern int clone(int (*proc)(void *), void *sp, int flags, void *data); | ||
19 | extern int sleep(int); | ||
20 | extern int printf(char *fmt, ...); | ||
21 | extern char *strerror(int errnum); | ||
22 | extern char *ptsname(int __fd); | ||
23 | extern int munmap(void *, int); | ||
24 | extern void *sbrk(int increment); | ||
25 | extern void *malloc(int size); | ||
26 | extern void perror(char *err); | ||
27 | extern int kill(int pid, int sig); | ||
28 | extern int getuid(void); | ||
29 | extern int getgid(void); | ||
30 | extern int pause(void); | ||
31 | extern int write(int, const void *, int); | ||
32 | extern int exit(int); | ||
33 | extern int close(int); | ||
34 | extern int read(unsigned int, char *, int); | ||
35 | extern int pipe(int *); | ||
36 | extern int sched_yield(void); | ||
37 | extern int ptrace(int op, int pid, long addr, long data); | ||
38 | #endif | ||
39 | |||
40 | /* | ||
41 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
42 | * Emacs will notice this stuff at the end of the file and automatically | ||
43 | * adjust the settings for this buffer only. This must remain at the end | ||
44 | * of the file. | ||
45 | * --------------------------------------------------------------------------- | ||
46 | * Local variables: | ||
47 | * c-file-style: "linux" | ||
48 | * End: | ||
49 | */ | ||
diff --git a/arch/um/include/kern_util.h b/arch/um/include/kern_util.h new file mode 100644 index 000000000000..15389c886b41 --- /dev/null +++ b/arch/um/include/kern_util.h | |||
@@ -0,0 +1,125 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __KERN_UTIL_H__ | ||
7 | #define __KERN_UTIL_H__ | ||
8 | |||
9 | #include "linux/threads.h" | ||
10 | #include "sysdep/ptrace.h" | ||
11 | |||
12 | extern int ncpus; | ||
13 | extern char *linux_prog; | ||
14 | extern char *gdb_init; | ||
15 | extern int kmalloc_ok; | ||
16 | extern int timer_irq_inited; | ||
17 | extern int jail; | ||
18 | extern int nsyscalls; | ||
19 | |||
20 | extern struct task_struct *idle_threads[NR_CPUS]; | ||
21 | |||
22 | #define UML_ROUND_DOWN(addr) ((void *)(((unsigned long) addr) & PAGE_MASK)) | ||
23 | #define UML_ROUND_UP(addr) \ | ||
24 | UML_ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1) | ||
25 | |||
26 | extern int kernel_fork(unsigned long flags, int (*fn)(void *), void * arg); | ||
27 | extern unsigned long stack_sp(unsigned long page); | ||
28 | extern int kernel_thread_proc(void *data); | ||
29 | extern void syscall_segv(int sig); | ||
30 | extern int current_pid(void); | ||
31 | extern unsigned long alloc_stack(int order, int atomic); | ||
32 | extern int do_signal(void); | ||
33 | extern int is_stack_fault(unsigned long sp); | ||
34 | extern unsigned long segv(unsigned long address, unsigned long ip, | ||
35 | int is_write, int is_user, void *sc); | ||
36 | extern int handle_page_fault(unsigned long address, unsigned long ip, | ||
37 | int is_write, int is_user, int *code_out); | ||
38 | extern void syscall_ready(void); | ||
39 | extern void set_tracing(void *t, int tracing); | ||
40 | extern int is_tracing(void *task); | ||
41 | extern int segv_syscall(void); | ||
42 | extern void kern_finish_exec(void *task, int new_pid, unsigned long stack); | ||
43 | extern int page_size(void); | ||
44 | extern unsigned long page_mask(void); | ||
45 | extern int need_finish_fork(void); | ||
46 | extern void free_stack(unsigned long stack, int order); | ||
47 | extern void add_input_request(int op, void (*proc)(int), void *arg); | ||
48 | extern char *current_cmd(void); | ||
49 | extern void timer_handler(int sig, union uml_pt_regs *regs); | ||
50 | extern int set_signals(int enable); | ||
51 | extern void force_sigbus(void); | ||
52 | extern int pid_to_processor_id(int pid); | ||
53 | extern void block_signals(void); | ||
54 | extern void unblock_signals(void); | ||
55 | extern void deliver_signals(void *t); | ||
56 | extern int next_syscall_index(int max); | ||
57 | extern int next_trap_index(int max); | ||
58 | extern void default_idle(void); | ||
59 | extern void finish_fork(void); | ||
60 | extern void paging_init(void); | ||
61 | extern void init_flush_vm(void); | ||
62 | extern void *syscall_sp(void *t); | ||
63 | extern void syscall_trace(union uml_pt_regs *regs, int entryexit); | ||
64 | extern int hz(void); | ||
65 | extern void uml_idle_timer(void); | ||
66 | extern unsigned int do_IRQ(int irq, union uml_pt_regs *regs); | ||
67 | extern int external_pid(void *t); | ||
68 | extern void boot_timer_handler(int sig); | ||
69 | extern void interrupt_end(void); | ||
70 | extern void initial_thread_cb(void (*proc)(void *), void *arg); | ||
71 | extern int debugger_signal(int status, int pid); | ||
72 | extern void debugger_parent_signal(int status, int pid); | ||
73 | extern void child_signal(int pid, int status); | ||
74 | extern int init_ptrace_proxy(int idle_pid, int startup, int stop); | ||
75 | extern int init_parent_proxy(int pid); | ||
76 | extern int singlestepping(void *t); | ||
77 | extern void check_stack_overflow(void *ptr); | ||
78 | extern void relay_signal(int sig, union uml_pt_regs *regs); | ||
79 | extern void not_implemented(void); | ||
80 | extern int user_context(unsigned long sp); | ||
81 | extern void timer_irq(union uml_pt_regs *regs); | ||
82 | extern void unprotect_stack(unsigned long stack); | ||
83 | extern void do_uml_exitcalls(void); | ||
84 | extern int attach_debugger(int idle_pid, int pid, int stop); | ||
85 | extern void bad_segv(unsigned long address, unsigned long ip, int is_write); | ||
86 | extern int config_gdb(char *str); | ||
87 | extern int remove_gdb(void); | ||
88 | extern char *uml_strdup(char *string); | ||
89 | extern void unprotect_kernel_mem(void); | ||
90 | extern void protect_kernel_mem(void); | ||
91 | extern void uml_cleanup(void); | ||
92 | extern void set_current(void *t); | ||
93 | extern void lock_signalled_task(void *t); | ||
94 | extern void IPI_handler(int cpu); | ||
95 | extern int jail_setup(char *line, int *add); | ||
96 | extern void *get_init_task(void); | ||
97 | extern int clear_user_proc(void *buf, int size); | ||
98 | extern int copy_to_user_proc(void *to, void *from, int size); | ||
99 | extern int copy_from_user_proc(void *to, void *from, int size); | ||
100 | extern int strlen_user_proc(char *str); | ||
101 | extern void bus_handler(int sig, union uml_pt_regs *regs); | ||
102 | extern void winch(int sig, union uml_pt_regs *regs); | ||
103 | extern long execute_syscall(void *r); | ||
104 | extern int smp_sigio_handler(void); | ||
105 | extern void *get_current(void); | ||
106 | extern struct task_struct *get_task(int pid, int require); | ||
107 | extern void machine_halt(void); | ||
108 | extern int is_syscall(unsigned long addr); | ||
109 | extern void arch_switch(void); | ||
110 | extern void free_irq(unsigned int, void *); | ||
111 | extern int um_in_interrupt(void); | ||
112 | extern int cpu(void); | ||
113 | |||
114 | #endif | ||
115 | |||
116 | /* | ||
117 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
118 | * Emacs will notice this stuff at the end of the file and automatically | ||
119 | * adjust the settings for this buffer only. This must remain at the end | ||
120 | * of the file. | ||
121 | * --------------------------------------------------------------------------- | ||
122 | * Local variables: | ||
123 | * c-file-style: "linux" | ||
124 | * End: | ||
125 | */ | ||
diff --git a/arch/um/include/line.h b/arch/um/include/line.h new file mode 100644 index 000000000000..6d81ecc17be5 --- /dev/null +++ b/arch/um/include/line.h | |||
@@ -0,0 +1,108 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __LINE_H__ | ||
7 | #define __LINE_H__ | ||
8 | |||
9 | #include "linux/list.h" | ||
10 | #include "linux/workqueue.h" | ||
11 | #include "linux/tty.h" | ||
12 | #include "linux/interrupt.h" | ||
13 | #include "asm/semaphore.h" | ||
14 | #include "chan_user.h" | ||
15 | #include "mconsole_kern.h" | ||
16 | |||
17 | struct line_driver { | ||
18 | char *name; | ||
19 | char *device_name; | ||
20 | char *devfs_name; | ||
21 | short major; | ||
22 | short minor_start; | ||
23 | short type; | ||
24 | short subtype; | ||
25 | int read_irq; | ||
26 | char *read_irq_name; | ||
27 | int write_irq; | ||
28 | char *write_irq_name; | ||
29 | char *symlink_from; | ||
30 | char *symlink_to; | ||
31 | struct mc_device mc; | ||
32 | }; | ||
33 | |||
34 | struct line { | ||
35 | char *init_str; | ||
36 | int init_pri; | ||
37 | struct list_head chan_list; | ||
38 | int valid; | ||
39 | int count; | ||
40 | struct semaphore sem; | ||
41 | char *buffer; | ||
42 | char *head; | ||
43 | char *tail; | ||
44 | int sigio; | ||
45 | struct work_struct task; | ||
46 | struct line_driver *driver; | ||
47 | int have_irq; | ||
48 | }; | ||
49 | |||
50 | #define LINE_INIT(str, d) \ | ||
51 | { init_str : str, \ | ||
52 | init_pri : INIT_STATIC, \ | ||
53 | chan_list : { }, \ | ||
54 | valid : 1, \ | ||
55 | sem : { }, \ | ||
56 | buffer : NULL, \ | ||
57 | head : NULL, \ | ||
58 | tail : NULL, \ | ||
59 | sigio : 0, \ | ||
60 | driver : d, \ | ||
61 | have_irq : 0 } | ||
62 | |||
63 | struct lines { | ||
64 | int num; | ||
65 | }; | ||
66 | |||
67 | #define LINES_INIT(n) { num : n } | ||
68 | |||
69 | extern void line_close(struct tty_struct *tty, struct file * filp); | ||
70 | extern int line_open(struct line *lines, struct tty_struct *tty, | ||
71 | struct chan_opts *opts); | ||
72 | extern int line_setup(struct line *lines, int num, char *init, | ||
73 | int all_allowed); | ||
74 | extern int line_write(struct tty_struct *tty, const unsigned char *buf, int len); | ||
75 | extern void line_put_char(struct tty_struct *tty, unsigned char ch); | ||
76 | extern void line_set_termios(struct tty_struct *tty, struct termios * old); | ||
77 | extern int line_chars_in_buffer(struct tty_struct *tty); | ||
78 | extern int line_write_room(struct tty_struct *tty); | ||
79 | extern int line_ioctl(struct tty_struct *tty, struct file * file, | ||
80 | unsigned int cmd, unsigned long arg); | ||
81 | extern char *add_xterm_umid(char *base); | ||
82 | extern int line_setup_irq(int fd, int input, int output, struct tty_struct *tty); | ||
83 | extern void line_close_chan(struct line *line); | ||
84 | extern void line_disable(struct tty_struct *tty, int current_irq); | ||
85 | extern struct tty_driver * line_register_devfs(struct lines *set, | ||
86 | struct line_driver *line_driver, | ||
87 | struct tty_operations *driver, | ||
88 | struct line *lines, | ||
89 | int nlines); | ||
90 | extern void lines_init(struct line *lines, int nlines); | ||
91 | extern void close_lines(struct line *lines, int nlines); | ||
92 | extern int line_config(struct line *lines, int num, char *str); | ||
93 | extern int line_remove(struct line *lines, int num, char *str); | ||
94 | extern int line_get_config(char *dev, struct line *lines, int num, char *str, | ||
95 | int size, char **error_out); | ||
96 | |||
97 | #endif | ||
98 | |||
99 | /* | ||
100 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
101 | * Emacs will notice this stuff at the end of the file and automatically | ||
102 | * adjust the settings for this buffer only. This must remain at the end | ||
103 | * of the file. | ||
104 | * --------------------------------------------------------------------------- | ||
105 | * Local variables: | ||
106 | * c-file-style: "linux" | ||
107 | * End: | ||
108 | */ | ||
diff --git a/arch/um/include/mconsole.h b/arch/um/include/mconsole.h new file mode 100644 index 000000000000..9fbe3083fdd8 --- /dev/null +++ b/arch/um/include/mconsole.h | |||
@@ -0,0 +1,103 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) | ||
3 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #ifndef __MCONSOLE_H__ | ||
8 | #define __MCONSOLE_H__ | ||
9 | |||
10 | #ifndef __KERNEL__ | ||
11 | #include <stdint.h> | ||
12 | #define u32 uint32_t | ||
13 | #endif | ||
14 | |||
15 | #define MCONSOLE_MAGIC (0xcafebabe) | ||
16 | #define MCONSOLE_MAX_DATA (512) | ||
17 | #define MCONSOLE_VERSION 2 | ||
18 | |||
19 | struct mconsole_request { | ||
20 | u32 magic; | ||
21 | u32 version; | ||
22 | u32 len; | ||
23 | char data[MCONSOLE_MAX_DATA]; | ||
24 | }; | ||
25 | |||
26 | struct mconsole_reply { | ||
27 | u32 err; | ||
28 | u32 more; | ||
29 | u32 len; | ||
30 | char data[MCONSOLE_MAX_DATA]; | ||
31 | }; | ||
32 | |||
33 | struct mconsole_notify { | ||
34 | u32 magic; | ||
35 | u32 version; | ||
36 | enum { MCONSOLE_SOCKET, MCONSOLE_PANIC, MCONSOLE_HANG, | ||
37 | MCONSOLE_USER_NOTIFY } type; | ||
38 | u32 len; | ||
39 | char data[MCONSOLE_MAX_DATA]; | ||
40 | }; | ||
41 | |||
42 | struct mc_request; | ||
43 | |||
44 | enum mc_context { MCONSOLE_INTR, MCONSOLE_PROC }; | ||
45 | |||
46 | struct mconsole_command | ||
47 | { | ||
48 | char *command; | ||
49 | void (*handler)(struct mc_request *req); | ||
50 | enum mc_context context; | ||
51 | }; | ||
52 | |||
53 | struct mc_request | ||
54 | { | ||
55 | int len; | ||
56 | int as_interrupt; | ||
57 | |||
58 | int originating_fd; | ||
59 | int originlen; | ||
60 | unsigned char origin[128]; /* sockaddr_un */ | ||
61 | |||
62 | struct mconsole_request request; | ||
63 | struct mconsole_command *cmd; | ||
64 | }; | ||
65 | |||
66 | extern char mconsole_socket_name[]; | ||
67 | |||
68 | extern int mconsole_unlink_socket(void); | ||
69 | extern int mconsole_reply(struct mc_request *req, char *reply, int err, | ||
70 | int more); | ||
71 | |||
72 | extern void mconsole_version(struct mc_request *req); | ||
73 | extern void mconsole_help(struct mc_request *req); | ||
74 | extern void mconsole_halt(struct mc_request *req); | ||
75 | extern void mconsole_reboot(struct mc_request *req); | ||
76 | extern void mconsole_config(struct mc_request *req); | ||
77 | extern void mconsole_remove(struct mc_request *req); | ||
78 | extern void mconsole_sysrq(struct mc_request *req); | ||
79 | extern void mconsole_cad(struct mc_request *req); | ||
80 | extern void mconsole_stop(struct mc_request *req); | ||
81 | extern void mconsole_go(struct mc_request *req); | ||
82 | extern void mconsole_log(struct mc_request *req); | ||
83 | extern void mconsole_proc(struct mc_request *req); | ||
84 | |||
85 | extern int mconsole_get_request(int fd, struct mc_request *req); | ||
86 | extern int mconsole_notify(char *sock_name, int type, const void *data, | ||
87 | int len); | ||
88 | extern char *mconsole_notify_socket(void); | ||
89 | extern void lock_notify(void); | ||
90 | extern void unlock_notify(void); | ||
91 | |||
92 | #endif | ||
93 | |||
94 | /* | ||
95 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
96 | * Emacs will notice this stuff at the end of the file and automatically | ||
97 | * adjust the settings for this buffer only. This must remain at the end | ||
98 | * of the file. | ||
99 | * --------------------------------------------------------------------------- | ||
100 | * Local variables: | ||
101 | * c-file-style: "linux" | ||
102 | * End: | ||
103 | */ | ||
diff --git a/arch/um/include/mconsole_kern.h b/arch/um/include/mconsole_kern.h new file mode 100644 index 000000000000..61c274fcee5d --- /dev/null +++ b/arch/um/include/mconsole_kern.h | |||
@@ -0,0 +1,62 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __MCONSOLE_KERN_H__ | ||
7 | #define __MCONSOLE_KERN_H__ | ||
8 | |||
9 | #include "linux/config.h" | ||
10 | #include "linux/list.h" | ||
11 | #include "mconsole.h" | ||
12 | |||
13 | struct mconsole_entry { | ||
14 | struct list_head list; | ||
15 | struct mc_request request; | ||
16 | }; | ||
17 | |||
18 | struct mc_device { | ||
19 | struct list_head list; | ||
20 | char *name; | ||
21 | int (*config)(char *); | ||
22 | int (*get_config)(char *, char *, int, char **); | ||
23 | int (*remove)(char *); | ||
24 | }; | ||
25 | |||
26 | #define CONFIG_CHUNK(str, size, current, chunk, end) \ | ||
27 | do { \ | ||
28 | current += strlen(chunk); \ | ||
29 | if(current >= size) \ | ||
30 | str = NULL; \ | ||
31 | if(str != NULL){ \ | ||
32 | strcpy(str, chunk); \ | ||
33 | str += strlen(chunk); \ | ||
34 | } \ | ||
35 | if(end) \ | ||
36 | current++; \ | ||
37 | } while(0) | ||
38 | |||
39 | #ifdef CONFIG_MCONSOLE | ||
40 | |||
41 | extern void mconsole_register_dev(struct mc_device *new); | ||
42 | |||
43 | #else | ||
44 | |||
45 | static inline void mconsole_register_dev(struct mc_device *new) | ||
46 | { | ||
47 | } | ||
48 | |||
49 | #endif | ||
50 | |||
51 | #endif | ||
52 | |||
53 | /* | ||
54 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
55 | * Emacs will notice this stuff at the end of the file and automatically | ||
56 | * adjust the settings for this buffer only. This must remain at the end | ||
57 | * of the file. | ||
58 | * --------------------------------------------------------------------------- | ||
59 | * Local variables: | ||
60 | * c-file-style: "linux" | ||
61 | * End: | ||
62 | */ | ||
diff --git a/arch/um/include/mem.h b/arch/um/include/mem.h new file mode 100644 index 000000000000..10c46c38949a --- /dev/null +++ b/arch/um/include/mem.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002, 2003 Jeff Dike (jdike@addtoit.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __MEM_H__ | ||
7 | #define __MEM_H__ | ||
8 | |||
9 | #include "linux/types.h" | ||
10 | |||
11 | extern int phys_mapping(unsigned long phys, __u64 *offset_out); | ||
12 | extern int physmem_subst_mapping(void *virt, int fd, __u64 offset, int w); | ||
13 | extern int is_remapped(void *virt); | ||
14 | extern int physmem_remove_mapping(void *virt); | ||
15 | extern void physmem_forget_descriptor(int fd); | ||
16 | |||
17 | #endif | ||
18 | |||
19 | /* | ||
20 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
21 | * Emacs will notice this stuff at the end of the file and automatically | ||
22 | * adjust the settings for this buffer only. This must remain at the end | ||
23 | * of the file. | ||
24 | * --------------------------------------------------------------------------- | ||
25 | * Local variables: | ||
26 | * c-file-style: "linux" | ||
27 | * End: | ||
28 | */ | ||
diff --git a/arch/um/include/mem_kern.h b/arch/um/include/mem_kern.h new file mode 100644 index 000000000000..cb7e196d366b --- /dev/null +++ b/arch/um/include/mem_kern.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2003 Jeff Dike (jdike@addtoit.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __MEM_KERN_H__ | ||
7 | #define __MEM_KERN_H__ | ||
8 | |||
9 | #include "linux/list.h" | ||
10 | #include "linux/types.h" | ||
11 | |||
12 | struct remapper { | ||
13 | struct list_head list; | ||
14 | int (*proc)(int, unsigned long, int, __u64); | ||
15 | }; | ||
16 | |||
17 | extern void register_remapper(struct remapper *info); | ||
18 | |||
19 | #endif | ||
20 | |||
21 | /* | ||
22 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
23 | * Emacs will notice this stuff at the end of the file and automatically | ||
24 | * adjust the settings for this buffer only. This must remain at the end | ||
25 | * of the file. | ||
26 | * --------------------------------------------------------------------------- | ||
27 | * Local variables: | ||
28 | * c-file-style: "linux" | ||
29 | * End: | ||
30 | */ | ||
diff --git a/arch/um/include/mem_user.h b/arch/um/include/mem_user.h new file mode 100644 index 000000000000..d6404bb64662 --- /dev/null +++ b/arch/um/include/mem_user.h | |||
@@ -0,0 +1,83 @@ | |||
1 | /* | ||
2 | * arch/um/include/mem_user.h | ||
3 | * | ||
4 | * BRIEF MODULE DESCRIPTION | ||
5 | * user side memory interface for support IO memory inside user mode linux | ||
6 | * | ||
7 | * Copyright (C) 2001 RidgeRun, Inc. | ||
8 | * Author: RidgeRun, Inc. | ||
9 | * Greg Lonnon glonnon@ridgerun.com or info@ridgerun.com | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify it | ||
12 | * under the terms of the GNU General Public License as published by the | ||
13 | * Free Software Foundation; either version 2 of the License, or (at your | ||
14 | * option) any later version. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
19 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
22 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
23 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | * You should have received a copy of the GNU General Public License along | ||
28 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
29 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
30 | */ | ||
31 | |||
32 | #ifndef _MEM_USER_H | ||
33 | #define _MEM_USER_H | ||
34 | |||
35 | struct iomem_region { | ||
36 | struct iomem_region *next; | ||
37 | char *driver; | ||
38 | int fd; | ||
39 | int size; | ||
40 | unsigned long phys; | ||
41 | unsigned long virt; | ||
42 | }; | ||
43 | |||
44 | extern struct iomem_region *iomem_regions; | ||
45 | extern int iomem_size; | ||
46 | |||
47 | #define ROUND_4M(n) ((((unsigned long) (n)) + (1 << 22)) & ~((1 << 22) - 1)) | ||
48 | |||
49 | extern unsigned long host_task_size; | ||
50 | extern unsigned long task_size; | ||
51 | |||
52 | extern void check_devanon(void); | ||
53 | extern int init_mem_user(void); | ||
54 | extern int create_mem_file(unsigned long len); | ||
55 | extern void setup_memory(void *entry); | ||
56 | extern unsigned long find_iomem(char *driver, unsigned long *len_out); | ||
57 | extern int init_maps(unsigned long physmem, unsigned long iomem, | ||
58 | unsigned long highmem); | ||
59 | extern unsigned long get_vm(unsigned long len); | ||
60 | extern void setup_physmem(unsigned long start, unsigned long usable, | ||
61 | unsigned long len, unsigned long highmem); | ||
62 | extern void add_iomem(char *name, int fd, unsigned long size); | ||
63 | extern unsigned long phys_offset(unsigned long phys); | ||
64 | extern void unmap_physmem(void); | ||
65 | extern void map_memory(unsigned long virt, unsigned long phys, | ||
66 | unsigned long len, int r, int w, int x); | ||
67 | extern int protect_memory(unsigned long addr, unsigned long len, | ||
68 | int r, int w, int x, int must_succeed); | ||
69 | extern unsigned long get_kmem_end(void); | ||
70 | extern void check_tmpexec(void); | ||
71 | |||
72 | #endif | ||
73 | |||
74 | /* | ||
75 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
76 | * Emacs will notice this stuff at the end of the file and automatically | ||
77 | * adjust the settings for this buffer only. This must remain at the end | ||
78 | * of the file. | ||
79 | * --------------------------------------------------------------------------- | ||
80 | * Local variables: | ||
81 | * c-file-style: "linux" | ||
82 | * End: | ||
83 | */ | ||
diff --git a/arch/um/include/mode.h b/arch/um/include/mode.h new file mode 100644 index 000000000000..786cf563eb05 --- /dev/null +++ b/arch/um/include/mode.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __MODE_H__ | ||
7 | #define __MODE_H__ | ||
8 | |||
9 | #include "uml-config.h" | ||
10 | |||
11 | #ifdef UML_CONFIG_MODE_TT | ||
12 | #include "mode-tt.h" | ||
13 | #endif | ||
14 | |||
15 | #ifdef UML_CONFIG_MODE_SKAS | ||
16 | #include "mode-skas.h" | ||
17 | #endif | ||
18 | |||
19 | #endif | ||
20 | |||
21 | /* | ||
22 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
23 | * Emacs will notice this stuff at the end of the file and automatically | ||
24 | * adjust the settings for this buffer only. This must remain at the end | ||
25 | * of the file. | ||
26 | * --------------------------------------------------------------------------- | ||
27 | * Local variables: | ||
28 | * c-file-style: "linux" | ||
29 | * End: | ||
30 | */ | ||
diff --git a/arch/um/include/mode_kern.h b/arch/um/include/mode_kern.h new file mode 100644 index 000000000000..2d88afd0cf16 --- /dev/null +++ b/arch/um/include/mode_kern.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __MODE_KERN_H__ | ||
7 | #define __MODE_KERN_H__ | ||
8 | |||
9 | #include "linux/config.h" | ||
10 | |||
11 | #ifdef CONFIG_MODE_TT | ||
12 | #include "mode_kern-tt.h" | ||
13 | #endif | ||
14 | |||
15 | #ifdef CONFIG_MODE_SKAS | ||
16 | #include "mode_kern-skas.h" | ||
17 | #endif | ||
18 | |||
19 | #endif | ||
20 | |||
21 | /* | ||
22 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
23 | * Emacs will notice this stuff at the end of the file and automatically | ||
24 | * adjust the settings for this buffer only. This must remain at the end | ||
25 | * of the file. | ||
26 | * --------------------------------------------------------------------------- | ||
27 | * Local variables: | ||
28 | * c-file-style: "linux" | ||
29 | * End: | ||
30 | */ | ||
diff --git a/arch/um/include/net_kern.h b/arch/um/include/net_kern.h new file mode 100644 index 000000000000..1c07949a13d6 --- /dev/null +++ b/arch/um/include/net_kern.h | |||
@@ -0,0 +1,82 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __UM_NET_KERN_H | ||
7 | #define __UM_NET_KERN_H | ||
8 | |||
9 | #include "linux/netdevice.h" | ||
10 | #include "linux/skbuff.h" | ||
11 | #include "linux/socket.h" | ||
12 | #include "linux/list.h" | ||
13 | |||
14 | struct uml_net { | ||
15 | struct list_head list; | ||
16 | struct net_device *dev; | ||
17 | struct platform_device pdev; | ||
18 | int index; | ||
19 | unsigned char mac[ETH_ALEN]; | ||
20 | int have_mac; | ||
21 | }; | ||
22 | |||
23 | struct uml_net_private { | ||
24 | struct list_head list; | ||
25 | spinlock_t lock; | ||
26 | struct net_device *dev; | ||
27 | struct timer_list tl; | ||
28 | struct net_device_stats stats; | ||
29 | int fd; | ||
30 | unsigned char mac[ETH_ALEN]; | ||
31 | int have_mac; | ||
32 | unsigned short (*protocol)(struct sk_buff *); | ||
33 | int (*open)(void *); | ||
34 | void (*close)(int, void *); | ||
35 | void (*remove)(void *); | ||
36 | int (*read)(int, struct sk_buff **skb, struct uml_net_private *); | ||
37 | int (*write)(int, struct sk_buff **skb, struct uml_net_private *); | ||
38 | |||
39 | void (*add_address)(unsigned char *, unsigned char *, void *); | ||
40 | void (*delete_address)(unsigned char *, unsigned char *, void *); | ||
41 | int (*set_mtu)(int mtu, void *); | ||
42 | int user[1]; | ||
43 | }; | ||
44 | |||
45 | struct net_kern_info { | ||
46 | void (*init)(struct net_device *, void *); | ||
47 | unsigned short (*protocol)(struct sk_buff *); | ||
48 | int (*read)(int, struct sk_buff **skb, struct uml_net_private *); | ||
49 | int (*write)(int, struct sk_buff **skb, struct uml_net_private *); | ||
50 | }; | ||
51 | |||
52 | struct transport { | ||
53 | struct list_head list; | ||
54 | char *name; | ||
55 | int (*setup)(char *, char **, void *); | ||
56 | struct net_user_info *user; | ||
57 | struct net_kern_info *kern; | ||
58 | int private_size; | ||
59 | int setup_size; | ||
60 | }; | ||
61 | |||
62 | extern struct net_device *ether_init(int); | ||
63 | extern unsigned short ether_protocol(struct sk_buff *); | ||
64 | extern int setup_etheraddr(char *str, unsigned char *addr); | ||
65 | extern struct sk_buff *ether_adjust_skb(struct sk_buff *skb, int extra); | ||
66 | extern int tap_setup_common(char *str, char *type, char **dev_name, | ||
67 | char **mac_out, char **gate_addr); | ||
68 | extern void register_transport(struct transport *new); | ||
69 | extern unsigned short eth_protocol(struct sk_buff *skb); | ||
70 | |||
71 | #endif | ||
72 | |||
73 | /* | ||
74 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
75 | * Emacs will notice this stuff at the end of the file and automatically | ||
76 | * adjust the settings for this buffer only. This must remain at the end | ||
77 | * of the file. | ||
78 | * --------------------------------------------------------------------------- | ||
79 | * Local variables: | ||
80 | * c-file-style: "linux" | ||
81 | * End: | ||
82 | */ | ||
diff --git a/arch/um/include/net_user.h b/arch/um/include/net_user.h new file mode 100644 index 000000000000..36807b796e9f --- /dev/null +++ b/arch/um/include/net_user.h | |||
@@ -0,0 +1,66 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __UM_NET_USER_H__ | ||
7 | #define __UM_NET_USER_H__ | ||
8 | |||
9 | #define ETH_ADDR_LEN (6) | ||
10 | #define ETH_HEADER_ETHERTAP (16) | ||
11 | #define ETH_HEADER_OTHER (14) | ||
12 | #define ETH_MAX_PACKET (1500) | ||
13 | |||
14 | #define UML_NET_VERSION (4) | ||
15 | |||
16 | struct net_user_info { | ||
17 | void (*init)(void *, void *); | ||
18 | int (*open)(void *); | ||
19 | void (*close)(int, void *); | ||
20 | void (*remove)(void *); | ||
21 | int (*set_mtu)(int mtu, void *); | ||
22 | void (*add_address)(unsigned char *, unsigned char *, void *); | ||
23 | void (*delete_address)(unsigned char *, unsigned char *, void *); | ||
24 | int max_packet; | ||
25 | }; | ||
26 | |||
27 | extern void ether_user_init(void *data, void *dev); | ||
28 | extern void dev_ip_addr(void *d, char *buf, char *bin_buf); | ||
29 | extern void set_ether_mac(void *d, unsigned char *addr); | ||
30 | extern void iter_addresses(void *d, void (*cb)(unsigned char *, | ||
31 | unsigned char *, void *), | ||
32 | void *arg); | ||
33 | |||
34 | extern void *get_output_buffer(int *len_out); | ||
35 | extern void free_output_buffer(void *buffer); | ||
36 | |||
37 | extern int tap_open_common(void *dev, char *gate_addr); | ||
38 | extern void tap_check_ips(char *gate_addr, char *eth_addr); | ||
39 | |||
40 | extern void read_output(int fd, char *output_out, int len); | ||
41 | |||
42 | extern int net_read(int fd, void *buf, int len); | ||
43 | extern int net_recvfrom(int fd, void *buf, int len); | ||
44 | extern int net_write(int fd, void *buf, int len); | ||
45 | extern int net_send(int fd, void *buf, int len); | ||
46 | extern int net_sendto(int fd, void *buf, int len, void *to, int sock_len); | ||
47 | |||
48 | extern void open_addr(unsigned char *addr, unsigned char *netmask, void *arg); | ||
49 | extern void close_addr(unsigned char *addr, unsigned char *netmask, void *arg); | ||
50 | |||
51 | extern char *split_if_spec(char *str, ...); | ||
52 | |||
53 | extern int dev_netmask(void *d, void *m); | ||
54 | |||
55 | #endif | ||
56 | |||
57 | /* | ||
58 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
59 | * Emacs will notice this stuff at the end of the file and automatically | ||
60 | * adjust the settings for this buffer only. This must remain at the end | ||
61 | * of the file. | ||
62 | * --------------------------------------------------------------------------- | ||
63 | * Local variables: | ||
64 | * c-file-style: "linux" | ||
65 | * End: | ||
66 | */ | ||
diff --git a/arch/um/include/os.h b/arch/um/include/os.h new file mode 100644 index 000000000000..07340c8cf203 --- /dev/null +++ b/arch/um/include/os.h | |||
@@ -0,0 +1,183 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __OS_H__ | ||
7 | #define __OS_H__ | ||
8 | |||
9 | #include "asm/types.h" | ||
10 | #include "../os/include/file.h" | ||
11 | |||
12 | #define OS_TYPE_FILE 1 | ||
13 | #define OS_TYPE_DIR 2 | ||
14 | #define OS_TYPE_SYMLINK 3 | ||
15 | #define OS_TYPE_CHARDEV 4 | ||
16 | #define OS_TYPE_BLOCKDEV 5 | ||
17 | #define OS_TYPE_FIFO 6 | ||
18 | #define OS_TYPE_SOCK 7 | ||
19 | |||
20 | /* os_access() flags */ | ||
21 | #define OS_ACC_F_OK 0 /* Test for existence. */ | ||
22 | #define OS_ACC_X_OK 1 /* Test for execute permission. */ | ||
23 | #define OS_ACC_W_OK 2 /* Test for write permission. */ | ||
24 | #define OS_ACC_R_OK 4 /* Test for read permission. */ | ||
25 | #define OS_ACC_RW_OK (OS_ACC_W_OK | OS_ACC_R_OK) /* Test for RW permission */ | ||
26 | |||
27 | /* | ||
28 | * types taken from stat_file() in hostfs_user.c | ||
29 | * (if they are wrong here, they are wrong there...). | ||
30 | */ | ||
31 | struct uml_stat { | ||
32 | int ust_dev; /* device */ | ||
33 | unsigned long long ust_ino; /* inode */ | ||
34 | int ust_mode; /* protection */ | ||
35 | int ust_nlink; /* number of hard links */ | ||
36 | int ust_uid; /* user ID of owner */ | ||
37 | int ust_gid; /* group ID of owner */ | ||
38 | unsigned long long ust_size; /* total size, in bytes */ | ||
39 | int ust_blksize; /* blocksize for filesystem I/O */ | ||
40 | unsigned long long ust_blocks; /* number of blocks allocated */ | ||
41 | unsigned long ust_atime; /* time of last access */ | ||
42 | unsigned long ust_mtime; /* time of last modification */ | ||
43 | unsigned long ust_ctime; /* time of last change */ | ||
44 | }; | ||
45 | |||
46 | struct openflags { | ||
47 | unsigned int r : 1; | ||
48 | unsigned int w : 1; | ||
49 | unsigned int s : 1; /* O_SYNC */ | ||
50 | unsigned int c : 1; /* O_CREAT */ | ||
51 | unsigned int t : 1; /* O_TRUNC */ | ||
52 | unsigned int a : 1; /* O_APPEND */ | ||
53 | unsigned int e : 1; /* O_EXCL */ | ||
54 | unsigned int cl : 1; /* FD_CLOEXEC */ | ||
55 | }; | ||
56 | |||
57 | #define OPENFLAGS() ((struct openflags) { .r = 0, .w = 0, .s = 0, .c = 0, \ | ||
58 | .t = 0, .a = 0, .e = 0, .cl = 0 }) | ||
59 | |||
60 | static inline struct openflags of_read(struct openflags flags) | ||
61 | { | ||
62 | flags.r = 1; | ||
63 | return(flags); | ||
64 | } | ||
65 | |||
66 | static inline struct openflags of_write(struct openflags flags) | ||
67 | { | ||
68 | flags.w = 1; | ||
69 | return(flags); | ||
70 | } | ||
71 | |||
72 | static inline struct openflags of_rdwr(struct openflags flags) | ||
73 | { | ||
74 | return(of_read(of_write(flags))); | ||
75 | } | ||
76 | |||
77 | static inline struct openflags of_set_rw(struct openflags flags, int r, int w) | ||
78 | { | ||
79 | flags.r = r; | ||
80 | flags.w = w; | ||
81 | return(flags); | ||
82 | } | ||
83 | |||
84 | static inline struct openflags of_sync(struct openflags flags) | ||
85 | { | ||
86 | flags.s = 1; | ||
87 | return(flags); | ||
88 | } | ||
89 | |||
90 | static inline struct openflags of_create(struct openflags flags) | ||
91 | { | ||
92 | flags.c = 1; | ||
93 | return(flags); | ||
94 | } | ||
95 | |||
96 | static inline struct openflags of_trunc(struct openflags flags) | ||
97 | { | ||
98 | flags.t = 1; | ||
99 | return(flags); | ||
100 | } | ||
101 | |||
102 | static inline struct openflags of_append(struct openflags flags) | ||
103 | { | ||
104 | flags.a = 1; | ||
105 | return(flags); | ||
106 | } | ||
107 | |||
108 | static inline struct openflags of_excl(struct openflags flags) | ||
109 | { | ||
110 | flags.e = 1; | ||
111 | return(flags); | ||
112 | } | ||
113 | |||
114 | static inline struct openflags of_cloexec(struct openflags flags) | ||
115 | { | ||
116 | flags.cl = 1; | ||
117 | return(flags); | ||
118 | } | ||
119 | |||
120 | extern int os_stat_file(const char *file_name, struct uml_stat *buf); | ||
121 | extern int os_stat_fd(const int fd, struct uml_stat *buf); | ||
122 | extern int os_access(const char *file, int mode); | ||
123 | extern void os_print_error(int error, const char* str); | ||
124 | extern int os_get_exec_close(int fd, int *close_on_exec); | ||
125 | extern int os_set_exec_close(int fd, int close_on_exec); | ||
126 | extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg); | ||
127 | extern int os_window_size(int fd, int *rows, int *cols); | ||
128 | extern int os_new_tty_pgrp(int fd, int pid); | ||
129 | extern int os_get_ifname(int fd, char *namebuf); | ||
130 | extern int os_set_slip(int fd); | ||
131 | extern int os_set_owner(int fd, int pid); | ||
132 | extern int os_sigio_async(int master, int slave); | ||
133 | extern int os_mode_fd(int fd, int mode); | ||
134 | |||
135 | extern int os_seek_file(int fd, __u64 offset); | ||
136 | extern int os_open_file(char *file, struct openflags flags, int mode); | ||
137 | extern int os_read_file(int fd, void *buf, int len); | ||
138 | extern int os_write_file(int fd, const void *buf, int count); | ||
139 | extern int os_file_size(char *file, long long *size_out); | ||
140 | extern int os_file_modtime(char *file, unsigned long *modtime); | ||
141 | extern int os_pipe(int *fd, int stream, int close_on_exec); | ||
142 | extern int os_set_fd_async(int fd, int owner); | ||
143 | extern int os_clear_fd_async(int fd); | ||
144 | extern int os_set_fd_block(int fd, int blocking); | ||
145 | extern int os_accept_connection(int fd); | ||
146 | extern int os_create_unix_socket(char *file, int len, int close_on_exec); | ||
147 | extern int os_shutdown_socket(int fd, int r, int w); | ||
148 | extern void os_close_file(int fd); | ||
149 | extern int os_rcv_fd(int fd, int *helper_pid_out); | ||
150 | extern int create_unix_socket(char *file, int len, int close_on_exec); | ||
151 | extern int os_connect_socket(char *name); | ||
152 | extern int os_file_type(char *file); | ||
153 | extern int os_file_mode(char *file, struct openflags *mode_out); | ||
154 | extern int os_lock_file(int fd, int excl); | ||
155 | |||
156 | extern unsigned long os_process_pc(int pid); | ||
157 | extern int os_process_parent(int pid); | ||
158 | extern void os_stop_process(int pid); | ||
159 | extern void os_kill_process(int pid, int reap_child); | ||
160 | extern void os_kill_ptraced_process(int pid, int reap_child); | ||
161 | extern void os_usr1_process(int pid); | ||
162 | extern int os_getpid(void); | ||
163 | |||
164 | extern int os_map_memory(void *virt, int fd, unsigned long long off, | ||
165 | unsigned long len, int r, int w, int x); | ||
166 | extern int os_protect_memory(void *addr, unsigned long len, | ||
167 | int r, int w, int x); | ||
168 | extern int os_unmap_memory(void *addr, int len); | ||
169 | extern void os_flush_stdout(void); | ||
170 | extern unsigned long long os_usecs(void); | ||
171 | |||
172 | #endif | ||
173 | |||
174 | /* | ||
175 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
176 | * Emacs will notice this stuff at the end of the file and automatically | ||
177 | * adjust the settings for this buffer only. This must remain at the end | ||
178 | * of the file. | ||
179 | * --------------------------------------------------------------------------- | ||
180 | * Local variables: | ||
181 | * c-file-style: "linux" | ||
182 | * End: | ||
183 | */ | ||
diff --git a/arch/um/include/process.h b/arch/um/include/process.h new file mode 100644 index 000000000000..5af9157ff54f --- /dev/null +++ b/arch/um/include/process.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __PROCESS_H__ | ||
7 | #define __PROCESS_H__ | ||
8 | |||
9 | #include <signal.h> | ||
10 | |||
11 | extern void sig_handler(int sig, struct sigcontext sc); | ||
12 | extern void alarm_handler(int sig, struct sigcontext sc); | ||
13 | |||
14 | #endif | ||
15 | |||
16 | /* | ||
17 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
18 | * Emacs will notice this stuff at the end of the file and automatically | ||
19 | * adjust the settings for this buffer only. This must remain at the end | ||
20 | * of the file. | ||
21 | * --------------------------------------------------------------------------- | ||
22 | * Local variables: | ||
23 | * c-file-style: "linux" | ||
24 | * End: | ||
25 | */ | ||
diff --git a/arch/um/include/ptrace_user.h b/arch/um/include/ptrace_user.h new file mode 100644 index 000000000000..f3450e6bc18d --- /dev/null +++ b/arch/um/include/ptrace_user.h | |||
@@ -0,0 +1,60 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __PTRACE_USER_H__ | ||
7 | #define __PTRACE_USER_H__ | ||
8 | |||
9 | #include "sysdep/ptrace_user.h" | ||
10 | |||
11 | extern int ptrace_getregs(long pid, unsigned long *regs_out); | ||
12 | extern int ptrace_setregs(long pid, unsigned long *regs_in); | ||
13 | extern int ptrace_getfpregs(long pid, unsigned long *regs_out); | ||
14 | extern int ptrace_setfpregs(long pid, unsigned long *regs); | ||
15 | extern void arch_enter_kernel(void *task, int pid); | ||
16 | extern void arch_leave_kernel(void *task, int pid); | ||
17 | extern void ptrace_pokeuser(unsigned long addr, unsigned long data); | ||
18 | |||
19 | |||
20 | /* syscall emulation path in ptrace */ | ||
21 | |||
22 | #ifndef PTRACE_SYSEMU | ||
23 | #define PTRACE_SYSEMU 31 | ||
24 | #endif | ||
25 | #ifndef PTRACE_SYSEMU_SINGLESTEP | ||
26 | #define PTRACE_SYSEMU_SINGLESTEP 32 | ||
27 | #endif | ||
28 | |||
29 | /* On architectures, that started to support PTRACE_O_TRACESYSGOOD | ||
30 | * in linux 2.4, there are two different definitions of | ||
31 | * PTRACE_SETOPTIONS: linux 2.4 uses 21 while linux 2.6 uses 0x4200. | ||
32 | * For binary compatibility, 2.6 also supports the old "21", named | ||
33 | * PTRACE_OLDSETOPTION. On these architectures, UML always must use | ||
34 | * "21", to ensure the kernel runs on 2.4 and 2.6 host without | ||
35 | * recompilation. So, we use PTRACE_OLDSETOPTIONS in UML. | ||
36 | * We also want to be able to build the kernel on 2.4, which doesn't | ||
37 | * have PTRACE_OLDSETOPTIONS. So, if it is missing, we declare | ||
38 | * PTRACE_OLDSETOPTIONS to to be the same as PTRACE_SETOPTIONS. | ||
39 | * | ||
40 | * On architectures, that start to support PTRACE_O_TRACESYSGOOD on | ||
41 | * linux 2.6, PTRACE_OLDSETOPTIONS never is defined, and also isn't | ||
42 | * supported by the host kernel. In that case, our trick lets us use | ||
43 | * the new 0x4200 with the name PTRACE_OLDSETOPTIONS. | ||
44 | */ | ||
45 | #ifndef PTRACE_OLDSETOPTIONS | ||
46 | #define PTRACE_OLDSETOPTIONS PTRACE_SETOPTIONS | ||
47 | #endif | ||
48 | |||
49 | void set_using_sysemu(int value); | ||
50 | int get_using_sysemu(void); | ||
51 | extern int sysemu_supported; | ||
52 | |||
53 | #define SELECT_PTRACE_OPERATION(sysemu_mode, singlestep_mode) \ | ||
54 | (((int[3][3] ) { \ | ||
55 | { PTRACE_SYSCALL, PTRACE_SYSCALL, PTRACE_SINGLESTEP }, \ | ||
56 | { PTRACE_SYSEMU, PTRACE_SYSEMU, PTRACE_SINGLESTEP }, \ | ||
57 | { PTRACE_SYSEMU, PTRACE_SYSEMU_SINGLESTEP, PTRACE_SYSEMU_SINGLESTEP }}) \ | ||
58 | [sysemu_mode][singlestep_mode]) | ||
59 | |||
60 | #endif | ||
diff --git a/arch/um/include/registers.h b/arch/um/include/registers.h new file mode 100644 index 000000000000..8744abb5224f --- /dev/null +++ b/arch/um/include/registers.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 PathScale, Inc | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __REGISTERS_H | ||
7 | #define __REGISTERS_H | ||
8 | |||
9 | #include "sysdep/ptrace.h" | ||
10 | |||
11 | extern void init_thread_registers(union uml_pt_regs *to); | ||
12 | extern int save_fp_registers(int pid, unsigned long *fp_regs); | ||
13 | extern int restore_fp_registers(int pid, unsigned long *fp_regs); | ||
14 | extern void save_registers(int pid, union uml_pt_regs *regs); | ||
15 | extern void restore_registers(int pid, union uml_pt_regs *regs); | ||
16 | extern void init_registers(int pid); | ||
17 | |||
18 | #endif | ||
19 | |||
20 | /* | ||
21 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
22 | * Emacs will notice this stuff at the end of the file and automatically | ||
23 | * adjust the settings for this buffer only. This must remain at the end | ||
24 | * of the file. | ||
25 | * --------------------------------------------------------------------------- | ||
26 | * Local variables: | ||
27 | * c-file-style: "linux" | ||
28 | * End: | ||
29 | */ | ||
diff --git a/arch/um/include/sigcontext.h b/arch/um/include/sigcontext.h new file mode 100644 index 000000000000..59816ca7a8df --- /dev/null +++ b/arch/um/include/sigcontext.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __UML_SIGCONTEXT_H__ | ||
7 | #define __UML_SIGCONTEXT_H__ | ||
8 | |||
9 | #include "sysdep/sigcontext.h" | ||
10 | |||
11 | extern int sc_size(void *data); | ||
12 | extern void sc_to_sc(void *to_ptr, void *from_ptr); | ||
13 | |||
14 | #endif | ||
15 | |||
16 | /* | ||
17 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
18 | * Emacs will notice this stuff at the end of the file and automatically | ||
19 | * adjust the settings for this buffer only. This must remain at the end | ||
20 | * of the file. | ||
21 | * --------------------------------------------------------------------------- | ||
22 | * Local variables: | ||
23 | * c-file-style: "linux" | ||
24 | * End: | ||
25 | */ | ||
diff --git a/arch/um/include/sigio.h b/arch/um/include/sigio.h new file mode 100644 index 000000000000..37d76e29a147 --- /dev/null +++ b/arch/um/include/sigio.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SIGIO_H__ | ||
7 | #define __SIGIO_H__ | ||
8 | |||
9 | extern int write_sigio_irq(int fd); | ||
10 | extern int register_sigio_fd(int fd); | ||
11 | extern int read_sigio_fd(int fd); | ||
12 | extern int add_sigio_fd(int fd, int read); | ||
13 | extern int ignore_sigio_fd(int fd); | ||
14 | extern void sigio_lock(void); | ||
15 | extern void sigio_unlock(void); | ||
16 | |||
17 | #endif | ||
18 | |||
19 | /* | ||
20 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
21 | * Emacs will notice this stuff at the end of the file and automatically | ||
22 | * adjust the settings for this buffer only. This must remain at the end | ||
23 | * of the file. | ||
24 | * --------------------------------------------------------------------------- | ||
25 | * Local variables: | ||
26 | * c-file-style: "linux" | ||
27 | * End: | ||
28 | */ | ||
diff --git a/arch/um/include/signal_kern.h b/arch/um/include/signal_kern.h new file mode 100644 index 000000000000..aeb5d5ab1dfd --- /dev/null +++ b/arch/um/include/signal_kern.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SIGNAL_KERN_H__ | ||
7 | #define __SIGNAL_KERN_H__ | ||
8 | |||
9 | extern int have_signals(void *t); | ||
10 | |||
11 | #endif | ||
12 | |||
13 | /* | ||
14 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
15 | * Emacs will notice this stuff at the end of the file and automatically | ||
16 | * adjust the settings for this buffer only. This must remain at the end | ||
17 | * of the file. | ||
18 | * --------------------------------------------------------------------------- | ||
19 | * Local variables: | ||
20 | * c-file-style: "linux" | ||
21 | * End: | ||
22 | */ | ||
diff --git a/arch/um/include/signal_user.h b/arch/um/include/signal_user.h new file mode 100644 index 000000000000..b075e543d864 --- /dev/null +++ b/arch/um/include/signal_user.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SIGNAL_USER_H__ | ||
7 | #define __SIGNAL_USER_H__ | ||
8 | |||
9 | extern int signal_stack_size; | ||
10 | |||
11 | extern int change_sig(int signal, int on); | ||
12 | extern void set_sigstack(void *stack, int size); | ||
13 | extern void set_handler(int sig, void (*handler)(int), int flags, ...); | ||
14 | extern int set_signals(int enable); | ||
15 | extern int get_signals(void); | ||
16 | |||
17 | #endif | ||
18 | |||
19 | /* | ||
20 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
21 | * Emacs will notice this stuff at the end of the file and automatically | ||
22 | * adjust the settings for this buffer only. This must remain at the end | ||
23 | * of the file. | ||
24 | * --------------------------------------------------------------------------- | ||
25 | * Local variables: | ||
26 | * c-file-style: "linux" | ||
27 | * End: | ||
28 | */ | ||
diff --git a/arch/um/include/skas_ptrace.h b/arch/um/include/skas_ptrace.h new file mode 100644 index 000000000000..cfb5fb4f5b91 --- /dev/null +++ b/arch/um/include/skas_ptrace.h | |||
@@ -0,0 +1,36 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SKAS_PTRACE_H | ||
7 | #define __SKAS_PTRACE_H | ||
8 | |||
9 | struct ptrace_faultinfo { | ||
10 | int is_write; | ||
11 | unsigned long addr; | ||
12 | }; | ||
13 | |||
14 | struct ptrace_ldt { | ||
15 | int func; | ||
16 | void *ptr; | ||
17 | unsigned long bytecount; | ||
18 | }; | ||
19 | |||
20 | #define PTRACE_FAULTINFO 52 | ||
21 | #define PTRACE_SIGPENDING 53 | ||
22 | #define PTRACE_LDT 54 | ||
23 | #define PTRACE_SWITCH_MM 55 | ||
24 | |||
25 | #endif | ||
26 | |||
27 | /* | ||
28 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
29 | * Emacs will notice this stuff at the end of the file and automatically | ||
30 | * adjust the settings for this buffer only. This must remain at the end | ||
31 | * of the file. | ||
32 | * --------------------------------------------------------------------------- | ||
33 | * Local variables: | ||
34 | * c-file-style: "linux" | ||
35 | * End: | ||
36 | */ | ||
diff --git a/arch/um/include/syscall_user.h b/arch/um/include/syscall_user.h new file mode 100644 index 000000000000..811d0ec2445e --- /dev/null +++ b/arch/um/include/syscall_user.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYSCALL_USER_H | ||
7 | #define __SYSCALL_USER_H | ||
8 | |||
9 | extern int record_syscall_start(int syscall); | ||
10 | extern void record_syscall_end(int index, long result); | ||
11 | |||
12 | #endif | ||
13 | |||
14 | /* | ||
15 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
16 | * Emacs will notice this stuff at the end of the file and automatically | ||
17 | * adjust the settings for this buffer only. This must remain at the end | ||
18 | * of the file. | ||
19 | * --------------------------------------------------------------------------- | ||
20 | * Local variables: | ||
21 | * c-file-style: "linux" | ||
22 | * End: | ||
23 | */ | ||
diff --git a/arch/um/include/sysdep-i386/checksum.h b/arch/um/include/sysdep-i386/checksum.h new file mode 100644 index 000000000000..3a2a45811aa3 --- /dev/null +++ b/arch/um/include/sysdep-i386/checksum.h | |||
@@ -0,0 +1,219 @@ | |||
1 | /* | ||
2 | * Licensed under the GPL | ||
3 | */ | ||
4 | |||
5 | #ifndef __UM_SYSDEP_CHECKSUM_H | ||
6 | #define __UM_SYSDEP_CHECKSUM_H | ||
7 | |||
8 | #include "linux/in6.h" | ||
9 | #include "linux/string.h" | ||
10 | |||
11 | /* | ||
12 | * computes the checksum of a memory block at buff, length len, | ||
13 | * and adds in "sum" (32-bit) | ||
14 | * | ||
15 | * returns a 32-bit number suitable for feeding into itself | ||
16 | * or csum_tcpudp_magic | ||
17 | * | ||
18 | * this function must be called with even lengths, except | ||
19 | * for the last fragment, which may be odd | ||
20 | * | ||
21 | * it's best to have buff aligned on a 32-bit boundary | ||
22 | */ | ||
23 | unsigned int csum_partial(const unsigned char * buff, int len, | ||
24 | unsigned int sum); | ||
25 | |||
26 | /* | ||
27 | * the same as csum_partial, but copies from src while it | ||
28 | * checksums, and handles user-space pointer exceptions correctly, when needed. | ||
29 | * | ||
30 | * here even more important to align src and dst on a 32-bit (or even | ||
31 | * better 64-bit) boundary | ||
32 | */ | ||
33 | |||
34 | unsigned int csum_partial_copy_to(const unsigned char *src, unsigned char *dst, | ||
35 | int len, int sum, int *err_ptr); | ||
36 | unsigned int csum_partial_copy_from(const unsigned char *src, unsigned char *dst, | ||
37 | int len, int sum, int *err_ptr); | ||
38 | |||
39 | /* | ||
40 | * Note: when you get a NULL pointer exception here this means someone | ||
41 | * passed in an incorrect kernel address to one of these functions. | ||
42 | * | ||
43 | * If you use these functions directly please don't forget the | ||
44 | * access_ok(). | ||
45 | */ | ||
46 | |||
47 | static __inline__ | ||
48 | unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *dst, | ||
49 | int len, int sum) | ||
50 | { | ||
51 | memcpy(dst, src, len); | ||
52 | return(csum_partial(dst, len, sum)); | ||
53 | } | ||
54 | |||
55 | static __inline__ | ||
56 | unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, | ||
57 | int len, int sum, int *err_ptr) | ||
58 | { | ||
59 | return csum_partial_copy_from(src, dst, len, sum, err_ptr); | ||
60 | } | ||
61 | |||
62 | /* | ||
63 | * These are the old (and unsafe) way of doing checksums, a warning message | ||
64 | * will be printed if they are used and an exception occurs. | ||
65 | * | ||
66 | * these functions should go away after some time. | ||
67 | */ | ||
68 | |||
69 | #define csum_partial_copy_fromuser csum_partial_copy_from_user | ||
70 | unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst, int len, int sum); | ||
71 | |||
72 | /* | ||
73 | * This is a version of ip_compute_csum() optimized for IP headers, | ||
74 | * which always checksum on 4 octet boundaries. | ||
75 | * | ||
76 | * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by | ||
77 | * Arnt Gulbrandsen. | ||
78 | */ | ||
79 | static inline unsigned short ip_fast_csum(unsigned char * iph, | ||
80 | unsigned int ihl) | ||
81 | { | ||
82 | unsigned int sum; | ||
83 | |||
84 | __asm__ __volatile__( | ||
85 | "movl (%1), %0 ;\n" | ||
86 | "subl $4, %2 ;\n" | ||
87 | "jbe 2f ;\n" | ||
88 | "addl 4(%1), %0 ;\n" | ||
89 | "adcl 8(%1), %0 ;\n" | ||
90 | "adcl 12(%1), %0 ;\n" | ||
91 | "1: adcl 16(%1), %0 ;\n" | ||
92 | "lea 4(%1), %1 ;\n" | ||
93 | "decl %2 ;\n" | ||
94 | "jne 1b ;\n" | ||
95 | "adcl $0, %0 ;\n" | ||
96 | "movl %0, %2 ;\n" | ||
97 | "shrl $16, %0 ;\n" | ||
98 | "addw %w2, %w0 ;\n" | ||
99 | "adcl $0, %0 ;\n" | ||
100 | "notl %0 ;\n" | ||
101 | "2: ;\n" | ||
102 | /* Since the input registers which are loaded with iph and ipl | ||
103 | are modified, we must also specify them as outputs, or gcc | ||
104 | will assume they contain their original values. */ | ||
105 | : "=r" (sum), "=r" (iph), "=r" (ihl) | ||
106 | : "1" (iph), "2" (ihl) | ||
107 | : "memory"); | ||
108 | return(sum); | ||
109 | } | ||
110 | |||
111 | /* | ||
112 | * Fold a partial checksum | ||
113 | */ | ||
114 | |||
115 | static inline unsigned int csum_fold(unsigned int sum) | ||
116 | { | ||
117 | __asm__( | ||
118 | "addl %1, %0 ;\n" | ||
119 | "adcl $0xffff, %0 ;\n" | ||
120 | : "=r" (sum) | ||
121 | : "r" (sum << 16), "0" (sum & 0xffff0000) | ||
122 | ); | ||
123 | return (~sum) >> 16; | ||
124 | } | ||
125 | |||
126 | static inline unsigned long csum_tcpudp_nofold(unsigned long saddr, | ||
127 | unsigned long daddr, | ||
128 | unsigned short len, | ||
129 | unsigned short proto, | ||
130 | unsigned int sum) | ||
131 | { | ||
132 | __asm__( | ||
133 | "addl %1, %0 ;\n" | ||
134 | "adcl %2, %0 ;\n" | ||
135 | "adcl %3, %0 ;\n" | ||
136 | "adcl $0, %0 ;\n" | ||
137 | : "=r" (sum) | ||
138 | : "g" (daddr), "g"(saddr), "g"((ntohs(len)<<16)+proto*256), "0"(sum)); | ||
139 | return sum; | ||
140 | } | ||
141 | |||
142 | /* | ||
143 | * computes the checksum of the TCP/UDP pseudo-header | ||
144 | * returns a 16-bit checksum, already complemented | ||
145 | */ | ||
146 | static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, | ||
147 | unsigned long daddr, | ||
148 | unsigned short len, | ||
149 | unsigned short proto, | ||
150 | unsigned int sum) | ||
151 | { | ||
152 | return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); | ||
153 | } | ||
154 | |||
155 | /* | ||
156 | * this routine is used for miscellaneous IP-like checksums, mainly | ||
157 | * in icmp.c | ||
158 | */ | ||
159 | |||
160 | static inline unsigned short ip_compute_csum(unsigned char * buff, int len) | ||
161 | { | ||
162 | return csum_fold (csum_partial(buff, len, 0)); | ||
163 | } | ||
164 | |||
165 | #define _HAVE_ARCH_IPV6_CSUM | ||
166 | static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, | ||
167 | struct in6_addr *daddr, | ||
168 | __u32 len, | ||
169 | unsigned short proto, | ||
170 | unsigned int sum) | ||
171 | { | ||
172 | __asm__( | ||
173 | "addl 0(%1), %0 ;\n" | ||
174 | "adcl 4(%1), %0 ;\n" | ||
175 | "adcl 8(%1), %0 ;\n" | ||
176 | "adcl 12(%1), %0 ;\n" | ||
177 | "adcl 0(%2), %0 ;\n" | ||
178 | "adcl 4(%2), %0 ;\n" | ||
179 | "adcl 8(%2), %0 ;\n" | ||
180 | "adcl 12(%2), %0 ;\n" | ||
181 | "adcl %3, %0 ;\n" | ||
182 | "adcl %4, %0 ;\n" | ||
183 | "adcl $0, %0 ;\n" | ||
184 | : "=&r" (sum) | ||
185 | : "r" (saddr), "r" (daddr), | ||
186 | "r"(htonl(len)), "r"(htonl(proto)), "0"(sum)); | ||
187 | |||
188 | return csum_fold(sum); | ||
189 | } | ||
190 | |||
191 | /* | ||
192 | * Copy and checksum to user | ||
193 | */ | ||
194 | #define HAVE_CSUM_COPY_USER | ||
195 | static __inline__ unsigned int csum_and_copy_to_user(const unsigned char *src, | ||
196 | unsigned char *dst, | ||
197 | int len, int sum, int *err_ptr) | ||
198 | { | ||
199 | if (access_ok(VERIFY_WRITE, dst, len)) | ||
200 | return(csum_partial_copy_to(src, dst, len, sum, err_ptr)); | ||
201 | |||
202 | if (len) | ||
203 | *err_ptr = -EFAULT; | ||
204 | |||
205 | return -1; /* invalid checksum */ | ||
206 | } | ||
207 | |||
208 | #endif | ||
209 | |||
210 | /* | ||
211 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
212 | * Emacs will notice this stuff at the end of the file and automatically | ||
213 | * adjust the settings for this buffer only. This must remain at the end | ||
214 | * of the file. | ||
215 | * --------------------------------------------------------------------------- | ||
216 | * Local variables: | ||
217 | * c-file-style: "linux" | ||
218 | * End: | ||
219 | */ | ||
diff --git a/arch/um/include/sysdep-i386/ptrace.h b/arch/um/include/sysdep-i386/ptrace.h new file mode 100644 index 000000000000..661d495e2044 --- /dev/null +++ b/arch/um/include/sysdep-i386/ptrace.h | |||
@@ -0,0 +1,241 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYSDEP_I386_PTRACE_H | ||
7 | #define __SYSDEP_I386_PTRACE_H | ||
8 | |||
9 | #include "uml-config.h" | ||
10 | #include "user_constants.h" | ||
11 | |||
12 | #define MAX_REG_NR (UM_FRAME_SIZE / sizeof(unsigned long)) | ||
13 | #define MAX_REG_OFFSET (UM_FRAME_SIZE) | ||
14 | |||
15 | extern void update_debugregs(int seq); | ||
16 | |||
17 | /* syscall emulation path in ptrace */ | ||
18 | |||
19 | #ifndef PTRACE_SYSEMU | ||
20 | #define PTRACE_SYSEMU 31 | ||
21 | #endif | ||
22 | |||
23 | void set_using_sysemu(int value); | ||
24 | int get_using_sysemu(void); | ||
25 | extern int sysemu_supported; | ||
26 | |||
27 | #ifdef UML_CONFIG_MODE_TT | ||
28 | #include "sysdep/sc.h" | ||
29 | #endif | ||
30 | |||
31 | #ifdef UML_CONFIG_MODE_SKAS | ||
32 | |||
33 | #include "skas_ptregs.h" | ||
34 | |||
35 | #define REGS_IP(r) ((r)[HOST_IP]) | ||
36 | #define REGS_SP(r) ((r)[HOST_SP]) | ||
37 | #define REGS_EFLAGS(r) ((r)[HOST_EFLAGS]) | ||
38 | #define REGS_EAX(r) ((r)[HOST_EAX]) | ||
39 | #define REGS_EBX(r) ((r)[HOST_EBX]) | ||
40 | #define REGS_ECX(r) ((r)[HOST_ECX]) | ||
41 | #define REGS_EDX(r) ((r)[HOST_EDX]) | ||
42 | #define REGS_ESI(r) ((r)[HOST_ESI]) | ||
43 | #define REGS_EDI(r) ((r)[HOST_EDI]) | ||
44 | #define REGS_EBP(r) ((r)[HOST_EBP]) | ||
45 | #define REGS_CS(r) ((r)[HOST_CS]) | ||
46 | #define REGS_SS(r) ((r)[HOST_SS]) | ||
47 | #define REGS_DS(r) ((r)[HOST_DS]) | ||
48 | #define REGS_ES(r) ((r)[HOST_ES]) | ||
49 | #define REGS_FS(r) ((r)[HOST_FS]) | ||
50 | #define REGS_GS(r) ((r)[HOST_GS]) | ||
51 | |||
52 | #define REGS_SET_SYSCALL_RETURN(r, res) REGS_EAX(r) = (res) | ||
53 | |||
54 | #define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r)) | ||
55 | |||
56 | #define REGS_SEGV_IS_FIXABLE(r) SEGV_IS_FIXABLE((r)->trap_type) | ||
57 | |||
58 | #define REGS_FAULT_ADDR(r) ((r)->fault_addr) | ||
59 | |||
60 | #define REGS_FAULT_WRITE(r) FAULT_WRITE((r)->fault_type) | ||
61 | |||
62 | #endif | ||
63 | #ifndef PTRACE_SYSEMU_SINGLESTEP | ||
64 | #define PTRACE_SYSEMU_SINGLESTEP 32 | ||
65 | #endif | ||
66 | |||
67 | #include "choose-mode.h" | ||
68 | |||
69 | union uml_pt_regs { | ||
70 | #ifdef UML_CONFIG_MODE_TT | ||
71 | struct tt_regs { | ||
72 | long syscall; | ||
73 | void *sc; | ||
74 | } tt; | ||
75 | #endif | ||
76 | #ifdef UML_CONFIG_MODE_SKAS | ||
77 | struct skas_regs { | ||
78 | unsigned long regs[HOST_FRAME_SIZE]; | ||
79 | unsigned long fp[HOST_FP_SIZE]; | ||
80 | unsigned long xfp[HOST_XFP_SIZE]; | ||
81 | unsigned long fault_addr; | ||
82 | unsigned long fault_type; | ||
83 | unsigned long trap_type; | ||
84 | long syscall; | ||
85 | int is_user; | ||
86 | } skas; | ||
87 | #endif | ||
88 | }; | ||
89 | |||
90 | #define EMPTY_UML_PT_REGS { } | ||
91 | |||
92 | extern int mode_tt; | ||
93 | |||
94 | #define UPT_SC(r) ((r)->tt.sc) | ||
95 | #define UPT_IP(r) \ | ||
96 | __CHOOSE_MODE(SC_IP(UPT_SC(r)), REGS_IP((r)->skas.regs)) | ||
97 | #define UPT_SP(r) \ | ||
98 | __CHOOSE_MODE(SC_SP(UPT_SC(r)), REGS_SP((r)->skas.regs)) | ||
99 | #define UPT_EFLAGS(r) \ | ||
100 | __CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs)) | ||
101 | #define UPT_EAX(r) \ | ||
102 | __CHOOSE_MODE(SC_EAX(UPT_SC(r)), REGS_EAX((r)->skas.regs)) | ||
103 | #define UPT_EBX(r) \ | ||
104 | __CHOOSE_MODE(SC_EBX(UPT_SC(r)), REGS_EBX((r)->skas.regs)) | ||
105 | #define UPT_ECX(r) \ | ||
106 | __CHOOSE_MODE(SC_ECX(UPT_SC(r)), REGS_ECX((r)->skas.regs)) | ||
107 | #define UPT_EDX(r) \ | ||
108 | __CHOOSE_MODE(SC_EDX(UPT_SC(r)), REGS_EDX((r)->skas.regs)) | ||
109 | #define UPT_ESI(r) \ | ||
110 | __CHOOSE_MODE(SC_ESI(UPT_SC(r)), REGS_ESI((r)->skas.regs)) | ||
111 | #define UPT_EDI(r) \ | ||
112 | __CHOOSE_MODE(SC_EDI(UPT_SC(r)), REGS_EDI((r)->skas.regs)) | ||
113 | #define UPT_EBP(r) \ | ||
114 | __CHOOSE_MODE(SC_EBP(UPT_SC(r)), REGS_EBP((r)->skas.regs)) | ||
115 | #define UPT_ORIG_EAX(r) \ | ||
116 | __CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall) | ||
117 | #define UPT_CS(r) \ | ||
118 | __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs)) | ||
119 | #define UPT_SS(r) \ | ||
120 | __CHOOSE_MODE(SC_SS(UPT_SC(r)), REGS_SS((r)->skas.regs)) | ||
121 | #define UPT_DS(r) \ | ||
122 | __CHOOSE_MODE(SC_DS(UPT_SC(r)), REGS_DS((r)->skas.regs)) | ||
123 | #define UPT_ES(r) \ | ||
124 | __CHOOSE_MODE(SC_ES(UPT_SC(r)), REGS_ES((r)->skas.regs)) | ||
125 | #define UPT_FS(r) \ | ||
126 | __CHOOSE_MODE(SC_FS(UPT_SC(r)), REGS_FS((r)->skas.regs)) | ||
127 | #define UPT_GS(r) \ | ||
128 | __CHOOSE_MODE(SC_GS(UPT_SC(r)), REGS_GS((r)->skas.regs)) | ||
129 | |||
130 | #define UPT_SYSCALL_ARG1(r) UPT_EBX(r) | ||
131 | #define UPT_SYSCALL_ARG2(r) UPT_ECX(r) | ||
132 | #define UPT_SYSCALL_ARG3(r) UPT_EDX(r) | ||
133 | #define UPT_SYSCALL_ARG4(r) UPT_ESI(r) | ||
134 | #define UPT_SYSCALL_ARG5(r) UPT_EDI(r) | ||
135 | #define UPT_SYSCALL_ARG6(r) UPT_EBP(r) | ||
136 | |||
137 | extern int user_context(unsigned long sp); | ||
138 | |||
139 | #define UPT_IS_USER(r) \ | ||
140 | CHOOSE_MODE(user_context(UPT_SP(r)), (r)->skas.is_user) | ||
141 | |||
142 | struct syscall_args { | ||
143 | unsigned long args[6]; | ||
144 | }; | ||
145 | |||
146 | #define SYSCALL_ARGS(r) ((struct syscall_args) \ | ||
147 | { .args = { UPT_SYSCALL_ARG1(r), \ | ||
148 | UPT_SYSCALL_ARG2(r), \ | ||
149 | UPT_SYSCALL_ARG3(r), \ | ||
150 | UPT_SYSCALL_ARG4(r), \ | ||
151 | UPT_SYSCALL_ARG5(r), \ | ||
152 | UPT_SYSCALL_ARG6(r) } } ) | ||
153 | |||
154 | #define UPT_REG(regs, reg) \ | ||
155 | ({ unsigned long val; \ | ||
156 | switch(reg){ \ | ||
157 | case EIP: val = UPT_IP(regs); break; \ | ||
158 | case UESP: val = UPT_SP(regs); break; \ | ||
159 | case EAX: val = UPT_EAX(regs); break; \ | ||
160 | case EBX: val = UPT_EBX(regs); break; \ | ||
161 | case ECX: val = UPT_ECX(regs); break; \ | ||
162 | case EDX: val = UPT_EDX(regs); break; \ | ||
163 | case ESI: val = UPT_ESI(regs); break; \ | ||
164 | case EDI: val = UPT_EDI(regs); break; \ | ||
165 | case EBP: val = UPT_EBP(regs); break; \ | ||
166 | case ORIG_EAX: val = UPT_ORIG_EAX(regs); break; \ | ||
167 | case CS: val = UPT_CS(regs); break; \ | ||
168 | case SS: val = UPT_SS(regs); break; \ | ||
169 | case DS: val = UPT_DS(regs); break; \ | ||
170 | case ES: val = UPT_ES(regs); break; \ | ||
171 | case FS: val = UPT_FS(regs); break; \ | ||
172 | case GS: val = UPT_GS(regs); break; \ | ||
173 | case EFL: val = UPT_EFLAGS(regs); break; \ | ||
174 | default : \ | ||
175 | panic("Bad register in UPT_REG : %d\n", reg); \ | ||
176 | val = -1; \ | ||
177 | } \ | ||
178 | val; \ | ||
179 | }) | ||
180 | |||
181 | |||
182 | #define UPT_SET(regs, reg, val) \ | ||
183 | do { \ | ||
184 | switch(reg){ \ | ||
185 | case EIP: UPT_IP(regs) = val; break; \ | ||
186 | case UESP: UPT_SP(regs) = val; break; \ | ||
187 | case EAX: UPT_EAX(regs) = val; break; \ | ||
188 | case EBX: UPT_EBX(regs) = val; break; \ | ||
189 | case ECX: UPT_ECX(regs) = val; break; \ | ||
190 | case EDX: UPT_EDX(regs) = val; break; \ | ||
191 | case ESI: UPT_ESI(regs) = val; break; \ | ||
192 | case EDI: UPT_EDI(regs) = val; break; \ | ||
193 | case EBP: UPT_EBP(regs) = val; break; \ | ||
194 | case ORIG_EAX: UPT_ORIG_EAX(regs) = val; break; \ | ||
195 | case CS: UPT_CS(regs) = val; break; \ | ||
196 | case SS: UPT_SS(regs) = val; break; \ | ||
197 | case DS: UPT_DS(regs) = val; break; \ | ||
198 | case ES: UPT_ES(regs) = val; break; \ | ||
199 | case FS: UPT_FS(regs) = val; break; \ | ||
200 | case GS: UPT_GS(regs) = val; break; \ | ||
201 | case EFL: UPT_EFLAGS(regs) = val; break; \ | ||
202 | default : \ | ||
203 | panic("Bad register in UPT_SET : %d\n", reg); \ | ||
204 | break; \ | ||
205 | } \ | ||
206 | } while (0) | ||
207 | |||
208 | #define UPT_SET_SYSCALL_RETURN(r, res) \ | ||
209 | CHOOSE_MODE(SC_SET_SYSCALL_RETURN(UPT_SC(r), (res)), \ | ||
210 | REGS_SET_SYSCALL_RETURN((r)->skas.regs, (res))) | ||
211 | |||
212 | #define UPT_RESTART_SYSCALL(r) \ | ||
213 | CHOOSE_MODE(SC_RESTART_SYSCALL(UPT_SC(r)), \ | ||
214 | REGS_RESTART_SYSCALL((r)->skas.regs)) | ||
215 | |||
216 | #define UPT_ORIG_SYSCALL(r) UPT_EAX(r) | ||
217 | #define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r) | ||
218 | #define UPT_SYSCALL_RET(r) UPT_EAX(r) | ||
219 | |||
220 | #define UPT_SEGV_IS_FIXABLE(r) \ | ||
221 | CHOOSE_MODE(SC_SEGV_IS_FIXABLE(UPT_SC(r)), \ | ||
222 | REGS_SEGV_IS_FIXABLE(&r->skas)) | ||
223 | |||
224 | #define UPT_FAULT_ADDR(r) \ | ||
225 | __CHOOSE_MODE(SC_FAULT_ADDR(UPT_SC(r)), REGS_FAULT_ADDR(&r->skas)) | ||
226 | |||
227 | #define UPT_FAULT_WRITE(r) \ | ||
228 | CHOOSE_MODE(SC_FAULT_WRITE(UPT_SC(r)), REGS_FAULT_WRITE(&r->skas)) | ||
229 | |||
230 | #endif | ||
231 | |||
232 | /* | ||
233 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
234 | * Emacs will notice this stuff at the end of the file and automatically | ||
235 | * adjust the settings for this buffer only. This must remain at the end | ||
236 | * of the file. | ||
237 | * --------------------------------------------------------------------------- | ||
238 | * Local variables: | ||
239 | * c-file-style: "linux" | ||
240 | * End: | ||
241 | */ | ||
diff --git a/arch/um/include/sysdep-i386/ptrace_user.h b/arch/um/include/sysdep-i386/ptrace_user.h new file mode 100644 index 000000000000..eca8066e7a43 --- /dev/null +++ b/arch/um/include/sysdep-i386/ptrace_user.h | |||
@@ -0,0 +1,62 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYSDEP_I386_PTRACE_USER_H__ | ||
7 | #define __SYSDEP_I386_PTRACE_USER_H__ | ||
8 | |||
9 | #include <sys/ptrace.h> | ||
10 | #include <linux/ptrace.h> | ||
11 | #include <asm/ptrace.h> | ||
12 | |||
13 | #define PT_OFFSET(r) ((r) * sizeof(long)) | ||
14 | |||
15 | #define PT_SYSCALL_NR(regs) ((regs)[ORIG_EAX]) | ||
16 | #define PT_SYSCALL_NR_OFFSET PT_OFFSET(ORIG_EAX) | ||
17 | |||
18 | #define PT_SYSCALL_ARG1_OFFSET PT_OFFSET(EBX) | ||
19 | #define PT_SYSCALL_ARG2_OFFSET PT_OFFSET(ECX) | ||
20 | #define PT_SYSCALL_ARG3_OFFSET PT_OFFSET(EDX) | ||
21 | #define PT_SYSCALL_ARG4_OFFSET PT_OFFSET(ESI) | ||
22 | #define PT_SYSCALL_ARG5_OFFSET PT_OFFSET(EDI) | ||
23 | |||
24 | #define PT_SYSCALL_RET_OFFSET PT_OFFSET(EAX) | ||
25 | |||
26 | #define PT_IP_OFFSET PT_OFFSET(EIP) | ||
27 | #define PT_IP(regs) ((regs)[EIP]) | ||
28 | #define PT_SP(regs) ((regs)[UESP]) | ||
29 | |||
30 | #ifndef FRAME_SIZE | ||
31 | #define FRAME_SIZE (17) | ||
32 | #endif | ||
33 | #define FRAME_SIZE_OFFSET (FRAME_SIZE * sizeof(unsigned long)) | ||
34 | |||
35 | #define FP_FRAME_SIZE (27) | ||
36 | #define FPX_FRAME_SIZE (128) | ||
37 | |||
38 | #ifdef PTRACE_GETREGS | ||
39 | #define UM_HAVE_GETREGS | ||
40 | #endif | ||
41 | |||
42 | #ifdef PTRACE_SETREGS | ||
43 | #define UM_HAVE_SETREGS | ||
44 | #endif | ||
45 | |||
46 | #ifdef PTRACE_GETFPREGS | ||
47 | #define UM_HAVE_GETFPREGS | ||
48 | #endif | ||
49 | |||
50 | #ifdef PTRACE_SETFPREGS | ||
51 | #define UM_HAVE_SETFPREGS | ||
52 | #endif | ||
53 | |||
54 | #ifdef PTRACE_GETFPXREGS | ||
55 | #define UM_HAVE_GETFPXREGS | ||
56 | #endif | ||
57 | |||
58 | #ifdef PTRACE_SETFPXREGS | ||
59 | #define UM_HAVE_SETFPXREGS | ||
60 | #endif | ||
61 | |||
62 | #endif | ||
diff --git a/arch/um/include/sysdep-i386/sigcontext.h b/arch/um/include/sysdep-i386/sigcontext.h new file mode 100644 index 000000000000..dfee589de360 --- /dev/null +++ b/arch/um/include/sysdep-i386/sigcontext.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYS_SIGCONTEXT_I386_H | ||
7 | #define __SYS_SIGCONTEXT_I386_H | ||
8 | |||
9 | #include <sysdep/sc.h> | ||
10 | |||
11 | #define IP_RESTART_SYSCALL(ip) ((ip) -= 2) | ||
12 | |||
13 | #define SC_RESTART_SYSCALL(sc) IP_RESTART_SYSCALL(SC_IP(sc)) | ||
14 | #define SC_SET_SYSCALL_RETURN(sc, result) SC_EAX(sc) = (result) | ||
15 | |||
16 | #define SC_FAULT_ADDR(sc) SC_CR2(sc) | ||
17 | #define SC_FAULT_TYPE(sc) SC_ERR(sc) | ||
18 | |||
19 | #define FAULT_WRITE(err) (err & 2) | ||
20 | #define TO_SC_ERR(is_write) ((is_write) ? 2 : 0) | ||
21 | |||
22 | #define SC_FAULT_WRITE(sc) (FAULT_WRITE(SC_ERR(sc))) | ||
23 | |||
24 | #define SC_TRAP_TYPE(sc) SC_TRAPNO(sc) | ||
25 | |||
26 | /* ptrace expects that, at the start of a system call, %eax contains | ||
27 | * -ENOSYS, so this makes it so. | ||
28 | */ | ||
29 | #define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0) | ||
30 | |||
31 | /* This is Page Fault */ | ||
32 | #define SEGV_IS_FIXABLE(trap) (trap == 14) | ||
33 | |||
34 | #define SC_SEGV_IS_FIXABLE(sc) (SEGV_IS_FIXABLE(SC_TRAPNO(sc))) | ||
35 | |||
36 | extern unsigned long *sc_sigmask(void *sc_ptr); | ||
37 | extern int sc_get_fpregs(unsigned long buf, void *sc_ptr); | ||
38 | |||
39 | #endif | ||
40 | /* | ||
41 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
42 | * Emacs will notice this stuff at the end of the file and automatically | ||
43 | * adjust the settings for this buffer only. This must remain at the end | ||
44 | * of the file. | ||
45 | * --------------------------------------------------------------------------- | ||
46 | * Local variables: | ||
47 | * c-file-style: "linux" | ||
48 | * End: | ||
49 | */ | ||
diff --git a/arch/um/include/sysdep-i386/signal.h b/arch/um/include/sysdep-i386/signal.h new file mode 100644 index 000000000000..b1e1f7a77499 --- /dev/null +++ b/arch/um/include/sysdep-i386/signal.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 PathScale, Inc | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __I386_SIGNAL_H_ | ||
7 | #define __I386_SIGNAL_H_ | ||
8 | |||
9 | #include <signal.h> | ||
10 | |||
11 | #define ARCH_GET_SIGCONTEXT(sc, sig) \ | ||
12 | do sc = (struct sigcontext *) (&sig + 1); while(0) | ||
13 | |||
14 | #endif | ||
15 | |||
16 | /* | ||
17 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
18 | * Emacs will notice this stuff at the end of the file and automatically | ||
19 | * adjust the settings for this buffer only. This must remain at the end | ||
20 | * of the file. | ||
21 | * --------------------------------------------------------------------------- | ||
22 | * Local variables: | ||
23 | * c-file-style: "linux" | ||
24 | * End: | ||
25 | */ | ||
diff --git a/arch/um/include/sysdep-i386/syscalls.h b/arch/um/include/sysdep-i386/syscalls.h new file mode 100644 index 000000000000..5db81ec9087d --- /dev/null +++ b/arch/um/include/sysdep-i386/syscalls.h | |||
@@ -0,0 +1,123 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #include "asm/unistd.h" | ||
7 | #include "sysdep/ptrace.h" | ||
8 | |||
9 | typedef long syscall_handler_t(struct pt_regs); | ||
10 | |||
11 | /* Not declared on x86, incompatible declarations on x86_64, so these have | ||
12 | * to go here rather than in sys_call_table.c | ||
13 | */ | ||
14 | extern syscall_handler_t sys_ptrace; | ||
15 | extern syscall_handler_t sys_rt_sigaction; | ||
16 | |||
17 | extern syscall_handler_t old_mmap_i386; | ||
18 | |||
19 | #define EXECUTE_SYSCALL(syscall, regs) \ | ||
20 | ((long (*)(struct syscall_args)) (*sys_call_table[syscall]))(SYSCALL_ARGS(®s->regs)) | ||
21 | |||
22 | extern long sys_mmap2(unsigned long addr, unsigned long len, | ||
23 | unsigned long prot, unsigned long flags, | ||
24 | unsigned long fd, unsigned long pgoff); | ||
25 | |||
26 | /* On i386 they choose a meaningless naming.*/ | ||
27 | #define __NR_kexec_load __NR_sys_kexec_load | ||
28 | |||
29 | #define ARCH_SYSCALLS \ | ||
30 | [ __NR_waitpid ] = (syscall_handler_t *) sys_waitpid, \ | ||
31 | [ __NR_break ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
32 | [ __NR_oldstat ] = (syscall_handler_t *) sys_stat, \ | ||
33 | [ __NR_umount ] = (syscall_handler_t *) sys_oldumount, \ | ||
34 | [ __NR_stime ] = um_stime, \ | ||
35 | [ __NR_oldfstat ] = (syscall_handler_t *) sys_fstat, \ | ||
36 | [ __NR_stty ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
37 | [ __NR_gtty ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
38 | [ __NR_nice ] = (syscall_handler_t *) sys_nice, \ | ||
39 | [ __NR_ftime ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
40 | [ __NR_prof ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
41 | [ __NR_signal ] = (syscall_handler_t *) sys_signal, \ | ||
42 | [ __NR_lock ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
43 | [ __NR_mpx ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
44 | [ __NR_ulimit ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
45 | [ __NR_oldolduname ] = (syscall_handler_t *) sys_olduname, \ | ||
46 | [ __NR_sigaction ] = (syscall_handler_t *) sys_sigaction, \ | ||
47 | [ __NR_sgetmask ] = (syscall_handler_t *) sys_sgetmask, \ | ||
48 | [ __NR_ssetmask ] = (syscall_handler_t *) sys_ssetmask, \ | ||
49 | [ __NR_sigsuspend ] = (syscall_handler_t *) sys_sigsuspend, \ | ||
50 | [ __NR_sigpending ] = (syscall_handler_t *) sys_sigpending, \ | ||
51 | [ __NR_oldlstat ] = (syscall_handler_t *) sys_lstat, \ | ||
52 | [ __NR_readdir ] = old_readdir, \ | ||
53 | [ __NR_profil ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
54 | [ __NR_socketcall ] = (syscall_handler_t *) sys_socketcall, \ | ||
55 | [ __NR_olduname ] = (syscall_handler_t *) sys_uname, \ | ||
56 | [ __NR_iopl ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
57 | [ __NR_idle ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
58 | [ __NR_ipc ] = (syscall_handler_t *) sys_ipc, \ | ||
59 | [ __NR_sigreturn ] = (syscall_handler_t *) sys_sigreturn, \ | ||
60 | [ __NR_sigprocmask ] = (syscall_handler_t *) sys_sigprocmask, \ | ||
61 | [ __NR_bdflush ] = (syscall_handler_t *) sys_bdflush, \ | ||
62 | [ __NR__llseek ] = (syscall_handler_t *) sys_llseek, \ | ||
63 | [ __NR__newselect ] = (syscall_handler_t *) sys_select, \ | ||
64 | [ __NR_vm86 ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
65 | [ __NR_mmap ] = (syscall_handler_t *) old_mmap_i386, \ | ||
66 | [ __NR_ugetrlimit ] = (syscall_handler_t *) sys_getrlimit, \ | ||
67 | [ __NR_mmap2 ] = (syscall_handler_t *) sys_mmap2, \ | ||
68 | [ __NR_truncate64 ] = (syscall_handler_t *) sys_truncate64, \ | ||
69 | [ __NR_ftruncate64 ] = (syscall_handler_t *) sys_ftruncate64, \ | ||
70 | [ __NR_stat64 ] = (syscall_handler_t *) sys_stat64, \ | ||
71 | [ __NR_lstat64 ] = (syscall_handler_t *) sys_lstat64, \ | ||
72 | [ __NR_fstat64 ] = (syscall_handler_t *) sys_fstat64, \ | ||
73 | [ __NR_fcntl64 ] = (syscall_handler_t *) sys_fcntl64, \ | ||
74 | [ __NR_sendfile64 ] = (syscall_handler_t *) sys_sendfile64, \ | ||
75 | [ __NR_statfs64 ] = (syscall_handler_t *) sys_statfs64, \ | ||
76 | [ __NR_fstatfs64 ] = (syscall_handler_t *) sys_fstatfs64, \ | ||
77 | [ __NR_fadvise64_64 ] = (syscall_handler_t *) sys_fadvise64_64, \ | ||
78 | [ __NR_select ] = (syscall_handler_t *) old_select, \ | ||
79 | [ __NR_vm86old ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
80 | [ __NR_modify_ldt ] = (syscall_handler_t *) sys_modify_ldt, \ | ||
81 | [ __NR_lchown32 ] = (syscall_handler_t *) sys_lchown, \ | ||
82 | [ __NR_getuid32 ] = (syscall_handler_t *) sys_getuid, \ | ||
83 | [ __NR_getgid32 ] = (syscall_handler_t *) sys_getgid, \ | ||
84 | [ __NR_geteuid32 ] = (syscall_handler_t *) sys_geteuid, \ | ||
85 | [ __NR_getegid32 ] = (syscall_handler_t *) sys_getegid, \ | ||
86 | [ __NR_setreuid32 ] = (syscall_handler_t *) sys_setreuid, \ | ||
87 | [ __NR_setregid32 ] = (syscall_handler_t *) sys_setregid, \ | ||
88 | [ __NR_getgroups32 ] = (syscall_handler_t *) sys_getgroups, \ | ||
89 | [ __NR_setgroups32 ] = (syscall_handler_t *) sys_setgroups, \ | ||
90 | [ __NR_fchown32 ] = (syscall_handler_t *) sys_fchown, \ | ||
91 | [ __NR_setresuid32 ] = (syscall_handler_t *) sys_setresuid, \ | ||
92 | [ __NR_getresuid32 ] = (syscall_handler_t *) sys_getresuid, \ | ||
93 | [ __NR_setresgid32 ] = (syscall_handler_t *) sys_setresgid, \ | ||
94 | [ __NR_getresgid32 ] = (syscall_handler_t *) sys_getresgid, \ | ||
95 | [ __NR_chown32 ] = (syscall_handler_t *) sys_chown, \ | ||
96 | [ __NR_setuid32 ] = (syscall_handler_t *) sys_setuid, \ | ||
97 | [ __NR_setgid32 ] = (syscall_handler_t *) sys_setgid, \ | ||
98 | [ __NR_setfsuid32 ] = (syscall_handler_t *) sys_setfsuid, \ | ||
99 | [ __NR_setfsgid32 ] = (syscall_handler_t *) sys_setfsgid, \ | ||
100 | [ __NR_pivot_root ] = (syscall_handler_t *) sys_pivot_root, \ | ||
101 | [ __NR_mincore ] = (syscall_handler_t *) sys_mincore, \ | ||
102 | [ __NR_madvise ] = (syscall_handler_t *) sys_madvise, \ | ||
103 | [ 222 ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
104 | [ 223 ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
105 | [ __NR_set_thread_area ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
106 | [ __NR_get_thread_area ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
107 | [ 251 ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
108 | [ 285 ] = (syscall_handler_t *) sys_ni_syscall, | ||
109 | |||
110 | /* 222 doesn't yet have a name in include/asm-i386/unistd.h */ | ||
111 | |||
112 | #define LAST_ARCH_SYSCALL 285 | ||
113 | |||
114 | /* | ||
115 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
116 | * Emacs will notice this stuff at the end of the file and automatically | ||
117 | * adjust the settings for this buffer only. This must remain at the end | ||
118 | * of the file. | ||
119 | * --------------------------------------------------------------------------- | ||
120 | * Local variables: | ||
121 | * c-file-style: "linux" | ||
122 | * End: | ||
123 | */ | ||
diff --git a/arch/um/include/sysdep-ia64/ptrace.h b/arch/um/include/sysdep-ia64/ptrace.h new file mode 100644 index 000000000000..42dd8fb6f2f9 --- /dev/null +++ b/arch/um/include/sysdep-ia64/ptrace.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYSDEP_IA64_PTRACE_H | ||
7 | #define __SYSDEP_IA64_PTRACE_H | ||
8 | |||
9 | struct sys_pt_regs { | ||
10 | int foo; | ||
11 | }; | ||
12 | |||
13 | #define EMPTY_REGS { 0 } | ||
14 | |||
15 | #endif | ||
16 | |||
17 | /* | ||
18 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
19 | * Emacs will notice this stuff at the end of the file and automatically | ||
20 | * adjust the settings for this buffer only. This must remain at the end | ||
21 | * of the file. | ||
22 | * --------------------------------------------------------------------------- | ||
23 | * Local variables: | ||
24 | * c-file-style: "linux" | ||
25 | * End: | ||
26 | */ | ||
diff --git a/arch/um/include/sysdep-ia64/sigcontext.h b/arch/um/include/sysdep-ia64/sigcontext.h new file mode 100644 index 000000000000..f15fb25260ba --- /dev/null +++ b/arch/um/include/sysdep-ia64/sigcontext.h | |||
@@ -0,0 +1,20 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYSDEP_IA64_SIGCONTEXT_H | ||
7 | #define __SYSDEP_IA64_SIGCONTEXT_H | ||
8 | |||
9 | #endif | ||
10 | |||
11 | /* | ||
12 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
13 | * Emacs will notice this stuff at the end of the file and automatically | ||
14 | * adjust the settings for this buffer only. This must remain at the end | ||
15 | * of the file. | ||
16 | * --------------------------------------------------------------------------- | ||
17 | * Local variables: | ||
18 | * c-file-style: "linux" | ||
19 | * End: | ||
20 | */ | ||
diff --git a/arch/um/include/sysdep-ia64/syscalls.h b/arch/um/include/sysdep-ia64/syscalls.h new file mode 100644 index 000000000000..4a1f46ef1ebc --- /dev/null +++ b/arch/um/include/sysdep-ia64/syscalls.h | |||
@@ -0,0 +1,20 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYSDEP_IA64_SYSCALLS_H | ||
7 | #define __SYSDEP_IA64_SYSCALLS_H | ||
8 | |||
9 | #endif | ||
10 | |||
11 | /* | ||
12 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
13 | * Emacs will notice this stuff at the end of the file and automatically | ||
14 | * adjust the settings for this buffer only. This must remain at the end | ||
15 | * of the file. | ||
16 | * --------------------------------------------------------------------------- | ||
17 | * Local variables: | ||
18 | * c-file-style: "linux" | ||
19 | * End: | ||
20 | */ | ||
diff --git a/arch/um/include/sysdep-ppc/ptrace.h b/arch/um/include/sysdep-ppc/ptrace.h new file mode 100644 index 000000000000..8a27353733a9 --- /dev/null +++ b/arch/um/include/sysdep-ppc/ptrace.h | |||
@@ -0,0 +1,104 @@ | |||
1 | /* | ||
2 | * Licensed under the GPL | ||
3 | */ | ||
4 | |||
5 | #ifndef __SYS_PTRACE_PPC_H | ||
6 | #define __SYS_PTRACE_PPC_H | ||
7 | |||
8 | #include "linux/config.h" | ||
9 | #include "linux/types.h" | ||
10 | |||
11 | /* the following taken from <asm-ppc/ptrace.h> */ | ||
12 | |||
13 | #ifdef CONFIG_PPC64 | ||
14 | #define PPC_REG unsigned long /*long*/ | ||
15 | #else | ||
16 | #define PPC_REG unsigned long | ||
17 | #endif | ||
18 | struct sys_pt_regs_s { | ||
19 | PPC_REG gpr[32]; | ||
20 | PPC_REG nip; | ||
21 | PPC_REG msr; | ||
22 | PPC_REG orig_gpr3; /* Used for restarting system calls */ | ||
23 | PPC_REG ctr; | ||
24 | PPC_REG link; | ||
25 | PPC_REG xer; | ||
26 | PPC_REG ccr; | ||
27 | PPC_REG mq; /* 601 only (not used at present) */ | ||
28 | /* Used on APUS to hold IPL value. */ | ||
29 | PPC_REG trap; /* Reason for being here */ | ||
30 | PPC_REG dar; /* Fault registers */ | ||
31 | PPC_REG dsisr; | ||
32 | PPC_REG result; /* Result of a system call */ | ||
33 | }; | ||
34 | |||
35 | #define NUM_REGS (sizeof(struct sys_pt_regs_s) / sizeof(PPC_REG)) | ||
36 | |||
37 | struct sys_pt_regs { | ||
38 | PPC_REG regs[sizeof(struct sys_pt_regs_s) / sizeof(PPC_REG)]; | ||
39 | }; | ||
40 | |||
41 | #define UM_MAX_REG (PT_FPR0) | ||
42 | #define UM_MAX_REG_OFFSET (UM_MAX_REG * sizeof(PPC_REG)) | ||
43 | |||
44 | #define EMPTY_REGS { { [ 0 ... NUM_REGS - 1] = 0 } } | ||
45 | |||
46 | #define UM_REG(r, n) ((r)->regs[n]) | ||
47 | |||
48 | #define UM_SYSCALL_RET(r) UM_REG(r, PT_R3) | ||
49 | #define UM_SP(r) UM_REG(r, PT_R1) | ||
50 | #define UM_IP(r) UM_REG(r, PT_NIP) | ||
51 | #define UM_ELF_ZERO(r) UM_REG(r, PT_FPSCR) | ||
52 | #define UM_SYSCALL_NR(r) UM_REG(r, PT_R0) | ||
53 | #define UM_SYSCALL_ARG1(r) UM_REG(r, PT_ORIG_R3) | ||
54 | #define UM_SYSCALL_ARG2(r) UM_REG(r, PT_R4) | ||
55 | #define UM_SYSCALL_ARG3(r) UM_REG(r, PT_R5) | ||
56 | #define UM_SYSCALL_ARG4(r) UM_REG(r, PT_R6) | ||
57 | #define UM_SYSCALL_ARG5(r) UM_REG(r, PT_R7) | ||
58 | #define UM_SYSCALL_ARG6(r) UM_REG(r, PT_R8) | ||
59 | |||
60 | #define UM_SYSCALL_NR_OFFSET (PT_R0 * sizeof(PPC_REG)) | ||
61 | #define UM_SYSCALL_RET_OFFSET (PT_R3 * sizeof(PPC_REG)) | ||
62 | #define UM_SYSCALL_ARG1_OFFSET (PT_R3 * sizeof(PPC_REG)) | ||
63 | #define UM_SYSCALL_ARG2_OFFSET (PT_R4 * sizeof(PPC_REG)) | ||
64 | #define UM_SYSCALL_ARG3_OFFSET (PT_R5 * sizeof(PPC_REG)) | ||
65 | #define UM_SYSCALL_ARG4_OFFSET (PT_R6 * sizeof(PPC_REG)) | ||
66 | #define UM_SYSCALL_ARG5_OFFSET (PT_R7 * sizeof(PPC_REG)) | ||
67 | #define UM_SYSCALL_ARG6_OFFSET (PT_R8 * sizeof(PPC_REG)) | ||
68 | #define UM_SP_OFFSET (PT_R1 * sizeof(PPC_REG)) | ||
69 | #define UM_IP_OFFSET (PT_NIP * sizeof(PPC_REG)) | ||
70 | #define UM_ELF_ZERO_OFFSET (PT_R3 * sizeof(PPC_REG)) | ||
71 | |||
72 | #define UM_SET_SYSCALL_RETURN(_regs, result) \ | ||
73 | do { \ | ||
74 | if (result < 0) { \ | ||
75 | (_regs)->regs[PT_CCR] |= 0x10000000; \ | ||
76 | UM_SYSCALL_RET((_regs)) = -result; \ | ||
77 | } else { \ | ||
78 | UM_SYSCALL_RET((_regs)) = result; \ | ||
79 | } \ | ||
80 | } while(0) | ||
81 | |||
82 | extern void shove_aux_table(unsigned long sp); | ||
83 | #define UM_FIX_EXEC_STACK(sp) shove_aux_table(sp); | ||
84 | |||
85 | /* These aren't actually defined. The undefs are just to make sure | ||
86 | * everyone's clear on the concept. | ||
87 | */ | ||
88 | #undef UML_HAVE_GETREGS | ||
89 | #undef UML_HAVE_GETFPREGS | ||
90 | #undef UML_HAVE_SETREGS | ||
91 | #undef UML_HAVE_SETFPREGS | ||
92 | |||
93 | #endif | ||
94 | |||
95 | /* | ||
96 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
97 | * Emacs will notice this stuff at the end of the file and automatically | ||
98 | * adjust the settings for this buffer only. This must remain at the end | ||
99 | * of the file. | ||
100 | * --------------------------------------------------------------------------- | ||
101 | * Local variables: | ||
102 | * c-file-style: "linux" | ||
103 | * End: | ||
104 | */ | ||
diff --git a/arch/um/include/sysdep-ppc/sigcontext.h b/arch/um/include/sysdep-ppc/sigcontext.h new file mode 100644 index 000000000000..f20d965de9c7 --- /dev/null +++ b/arch/um/include/sysdep-ppc/sigcontext.h | |||
@@ -0,0 +1,62 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYS_SIGCONTEXT_PPC_H | ||
7 | #define __SYS_SIGCONTEXT_PPC_H | ||
8 | |||
9 | #define DSISR_WRITE 0x02000000 | ||
10 | |||
11 | #define SC_FAULT_ADDR(sc) ({ \ | ||
12 | struct sigcontext *_sc = (sc); \ | ||
13 | long retval = -1; \ | ||
14 | switch (_sc->regs->trap) { \ | ||
15 | case 0x300: \ | ||
16 | /* data exception */ \ | ||
17 | retval = _sc->regs->dar; \ | ||
18 | break; \ | ||
19 | case 0x400: \ | ||
20 | /* instruction exception */ \ | ||
21 | retval = _sc->regs->nip; \ | ||
22 | break; \ | ||
23 | default: \ | ||
24 | panic("SC_FAULT_ADDR: unhandled trap type\n"); \ | ||
25 | } \ | ||
26 | retval; \ | ||
27 | }) | ||
28 | |||
29 | #define SC_FAULT_WRITE(sc) ({ \ | ||
30 | struct sigcontext *_sc = (sc); \ | ||
31 | long retval = -1; \ | ||
32 | switch (_sc->regs->trap) { \ | ||
33 | case 0x300: \ | ||
34 | /* data exception */ \ | ||
35 | retval = !!(_sc->regs->dsisr & DSISR_WRITE); \ | ||
36 | break; \ | ||
37 | case 0x400: \ | ||
38 | /* instruction exception: not a write */ \ | ||
39 | retval = 0; \ | ||
40 | break; \ | ||
41 | default: \ | ||
42 | panic("SC_FAULT_ADDR: unhandled trap type\n"); \ | ||
43 | } \ | ||
44 | retval; \ | ||
45 | }) | ||
46 | |||
47 | #define SC_IP(sc) ((sc)->regs->nip) | ||
48 | #define SC_SP(sc) ((sc)->regs->gpr[1]) | ||
49 | #define SEGV_IS_FIXABLE(sc) (1) | ||
50 | |||
51 | #endif | ||
52 | |||
53 | /* | ||
54 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
55 | * Emacs will notice this stuff at the end of the file and automatically | ||
56 | * adjust the settings for this buffer only. This must remain at the end | ||
57 | * of the file. | ||
58 | * --------------------------------------------------------------------------- | ||
59 | * Local variables: | ||
60 | * c-file-style: "linux" | ||
61 | * End: | ||
62 | */ | ||
diff --git a/arch/um/include/sysdep-ppc/syscalls.h b/arch/um/include/sysdep-ppc/syscalls.h new file mode 100644 index 000000000000..679df351e19b --- /dev/null +++ b/arch/um/include/sysdep-ppc/syscalls.h | |||
@@ -0,0 +1,53 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | typedef long syscall_handler_t(unsigned long arg1, unsigned long arg2, | ||
7 | unsigned long arg3, unsigned long arg4, | ||
8 | unsigned long arg5, unsigned long arg6); | ||
9 | |||
10 | #define EXECUTE_SYSCALL(syscall, regs) \ | ||
11 | (*sys_call_table[syscall])(UM_SYSCALL_ARG1(®s), \ | ||
12 | UM_SYSCALL_ARG2(®s), \ | ||
13 | UM_SYSCALL_ARG3(®s), \ | ||
14 | UM_SYSCALL_ARG4(®s), \ | ||
15 | UM_SYSCALL_ARG5(®s), \ | ||
16 | UM_SYSCALL_ARG6(®s)) | ||
17 | |||
18 | extern syscall_handler_t sys_mincore; | ||
19 | extern syscall_handler_t sys_madvise; | ||
20 | |||
21 | /* old_mmap needs the correct prototype since syscall_kern.c includes | ||
22 | * this file. | ||
23 | */ | ||
24 | int old_mmap(unsigned long addr, unsigned long len, | ||
25 | unsigned long prot, unsigned long flags, | ||
26 | unsigned long fd, unsigned long offset); | ||
27 | |||
28 | #define ARCH_SYSCALLS \ | ||
29 | [ __NR_modify_ldt ] = sys_ni_syscall, \ | ||
30 | [ __NR_pciconfig_read ] = sys_ni_syscall, \ | ||
31 | [ __NR_pciconfig_write ] = sys_ni_syscall, \ | ||
32 | [ __NR_pciconfig_iobase ] = sys_ni_syscall, \ | ||
33 | [ __NR_pivot_root ] = sys_ni_syscall, \ | ||
34 | [ __NR_multiplexer ] = sys_ni_syscall, \ | ||
35 | [ __NR_mmap ] = old_mmap, \ | ||
36 | [ __NR_madvise ] = sys_madvise, \ | ||
37 | [ __NR_mincore ] = sys_mincore, \ | ||
38 | [ __NR_iopl ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
39 | [ __NR_utimes ] = (syscall_handler_t *) sys_utimes, \ | ||
40 | [ __NR_fadvise64 ] = (syscall_handler_t *) sys_fadvise64, | ||
41 | |||
42 | #define LAST_ARCH_SYSCALL __NR_fadvise64 | ||
43 | |||
44 | /* | ||
45 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
46 | * Emacs will notice this stuff at the end of the file and automatically | ||
47 | * adjust the settings for this buffer only. This must remain at the end | ||
48 | * of the file. | ||
49 | * --------------------------------------------------------------------------- | ||
50 | * Local variables: | ||
51 | * c-file-style: "linux" | ||
52 | * End: | ||
53 | */ | ||
diff --git a/arch/um/include/sysdep-x86_64/checksum.h b/arch/um/include/sysdep-x86_64/checksum.h new file mode 100644 index 000000000000..572c6c19be33 --- /dev/null +++ b/arch/um/include/sysdep-x86_64/checksum.h | |||
@@ -0,0 +1,151 @@ | |||
1 | /* | ||
2 | * Licensed under the GPL | ||
3 | */ | ||
4 | |||
5 | #ifndef __UM_SYSDEP_CHECKSUM_H | ||
6 | #define __UM_SYSDEP_CHECKSUM_H | ||
7 | |||
8 | #include "linux/string.h" | ||
9 | #include "linux/in6.h" | ||
10 | #include "asm/uaccess.h" | ||
11 | |||
12 | extern unsigned int csum_partial_copy_from(const unsigned char *src, unsigned char *dst, int len, | ||
13 | int sum, int *err_ptr); | ||
14 | extern unsigned csum_partial(const unsigned char *buff, unsigned len, | ||
15 | unsigned sum); | ||
16 | |||
17 | /* | ||
18 | * Note: when you get a NULL pointer exception here this means someone | ||
19 | * passed in an incorrect kernel address to one of these functions. | ||
20 | * | ||
21 | * If you use these functions directly please don't forget the | ||
22 | * access_ok(). | ||
23 | */ | ||
24 | |||
25 | static __inline__ | ||
26 | unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *dst, | ||
27 | int len, int sum) | ||
28 | { | ||
29 | memcpy(dst, src, len); | ||
30 | return(csum_partial(dst, len, sum)); | ||
31 | } | ||
32 | |||
33 | static __inline__ | ||
34 | unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, | ||
35 | int len, int sum, int *err_ptr) | ||
36 | { | ||
37 | return csum_partial_copy_from(src, dst, len, sum, err_ptr); | ||
38 | } | ||
39 | |||
40 | /** | ||
41 | * csum_fold - Fold and invert a 32bit checksum. | ||
42 | * sum: 32bit unfolded sum | ||
43 | * | ||
44 | * Fold a 32bit running checksum to 16bit and invert it. This is usually | ||
45 | * the last step before putting a checksum into a packet. | ||
46 | * Make sure not to mix with 64bit checksums. | ||
47 | */ | ||
48 | static inline unsigned int csum_fold(unsigned int sum) | ||
49 | { | ||
50 | __asm__( | ||
51 | " addl %1,%0\n" | ||
52 | " adcl $0xffff,%0" | ||
53 | : "=r" (sum) | ||
54 | : "r" (sum << 16), "0" (sum & 0xffff0000) | ||
55 | ); | ||
56 | return (~sum) >> 16; | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * csum_tcpup_nofold - Compute an IPv4 pseudo header checksum. | ||
61 | * @saddr: source address | ||
62 | * @daddr: destination address | ||
63 | * @len: length of packet | ||
64 | * @proto: ip protocol of packet | ||
65 | * @sum: initial sum to be added in (32bit unfolded) | ||
66 | * | ||
67 | * Returns the pseudo header checksum the input data. Result is | ||
68 | * 32bit unfolded. | ||
69 | */ | ||
70 | static inline unsigned long | ||
71 | csum_tcpudp_nofold(unsigned saddr, unsigned daddr, unsigned short len, | ||
72 | unsigned short proto, unsigned int sum) | ||
73 | { | ||
74 | asm(" addl %1, %0\n" | ||
75 | " adcl %2, %0\n" | ||
76 | " adcl %3, %0\n" | ||
77 | " adcl $0, %0\n" | ||
78 | : "=r" (sum) | ||
79 | : "g" (daddr), "g" (saddr), "g" ((ntohs(len)<<16)+proto*256), "0" (sum)); | ||
80 | return sum; | ||
81 | } | ||
82 | |||
83 | /* | ||
84 | * computes the checksum of the TCP/UDP pseudo-header | ||
85 | * returns a 16-bit checksum, already complemented | ||
86 | */ | ||
87 | static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, | ||
88 | unsigned long daddr, | ||
89 | unsigned short len, | ||
90 | unsigned short proto, | ||
91 | unsigned int sum) | ||
92 | { | ||
93 | return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * ip_fast_csum - Compute the IPv4 header checksum efficiently. | ||
98 | * iph: ipv4 header | ||
99 | * ihl: length of header / 4 | ||
100 | */ | ||
101 | static inline unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl) | ||
102 | { | ||
103 | unsigned int sum; | ||
104 | |||
105 | asm( " movl (%1), %0\n" | ||
106 | " subl $4, %2\n" | ||
107 | " jbe 2f\n" | ||
108 | " addl 4(%1), %0\n" | ||
109 | " adcl 8(%1), %0\n" | ||
110 | " adcl 12(%1), %0\n" | ||
111 | "1: adcl 16(%1), %0\n" | ||
112 | " lea 4(%1), %1\n" | ||
113 | " decl %2\n" | ||
114 | " jne 1b\n" | ||
115 | " adcl $0, %0\n" | ||
116 | " movl %0, %2\n" | ||
117 | " shrl $16, %0\n" | ||
118 | " addw %w2, %w0\n" | ||
119 | " adcl $0, %0\n" | ||
120 | " notl %0\n" | ||
121 | "2:" | ||
122 | /* Since the input registers which are loaded with iph and ipl | ||
123 | are modified, we must also specify them as outputs, or gcc | ||
124 | will assume they contain their original values. */ | ||
125 | : "=r" (sum), "=r" (iph), "=r" (ihl) | ||
126 | : "1" (iph), "2" (ihl) | ||
127 | : "memory"); | ||
128 | return(sum); | ||
129 | } | ||
130 | |||
131 | static inline unsigned add32_with_carry(unsigned a, unsigned b) | ||
132 | { | ||
133 | asm("addl %2,%0\n\t" | ||
134 | "adcl $0,%0" | ||
135 | : "=r" (a) | ||
136 | : "0" (a), "r" (b)); | ||
137 | return a; | ||
138 | } | ||
139 | |||
140 | #endif | ||
141 | |||
142 | /* | ||
143 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
144 | * Emacs will notice this stuff at the end of the file and automatically | ||
145 | * adjust the settings for this buffer only. This must remain at the end | ||
146 | * of the file. | ||
147 | * --------------------------------------------------------------------------- | ||
148 | * Local variables: | ||
149 | * c-file-style: "linux" | ||
150 | * End: | ||
151 | */ | ||
diff --git a/arch/um/include/sysdep-x86_64/ptrace.h b/arch/um/include/sysdep-x86_64/ptrace.h new file mode 100644 index 000000000000..915c82daffbd --- /dev/null +++ b/arch/um/include/sysdep-x86_64/ptrace.h | |||
@@ -0,0 +1,264 @@ | |||
1 | /* | ||
2 | * Copyright 2003 PathScale, Inc. | ||
3 | * | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #ifndef __SYSDEP_X86_64_PTRACE_H | ||
8 | #define __SYSDEP_X86_64_PTRACE_H | ||
9 | |||
10 | #include "uml-config.h" | ||
11 | #include "user_constants.h" | ||
12 | |||
13 | #define MAX_REG_OFFSET (UM_FRAME_SIZE) | ||
14 | #define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long)) | ||
15 | |||
16 | #ifdef UML_CONFIG_MODE_TT | ||
17 | #include "sysdep/sc.h" | ||
18 | #endif | ||
19 | |||
20 | #ifdef UML_CONFIG_MODE_SKAS | ||
21 | #include "skas_ptregs.h" | ||
22 | |||
23 | #define REGS_IP(r) ((r)[HOST_IP]) | ||
24 | #define REGS_SP(r) ((r)[HOST_SP]) | ||
25 | |||
26 | #define REGS_RBX(r) ((r)[HOST_RBX]) | ||
27 | #define REGS_RCX(r) ((r)[HOST_RCX]) | ||
28 | #define REGS_RDX(r) ((r)[HOST_RDX]) | ||
29 | #define REGS_RSI(r) ((r)[HOST_RSI]) | ||
30 | #define REGS_RDI(r) ((r)[HOST_RDI]) | ||
31 | #define REGS_RBP(r) ((r)[HOST_RBP]) | ||
32 | #define REGS_RAX(r) ((r)[HOST_RAX]) | ||
33 | #define REGS_R8(r) ((r)[HOST_R8]) | ||
34 | #define REGS_R9(r) ((r)[HOST_R9]) | ||
35 | #define REGS_R10(r) ((r)[HOST_R10]) | ||
36 | #define REGS_R11(r) ((r)[HOST_R11]) | ||
37 | #define REGS_R12(r) ((r)[HOST_R12]) | ||
38 | #define REGS_R13(r) ((r)[HOST_R13]) | ||
39 | #define REGS_R14(r) ((r)[HOST_R14]) | ||
40 | #define REGS_R15(r) ((r)[HOST_R15]) | ||
41 | #define REGS_CS(r) ((r)[HOST_CS]) | ||
42 | #define REGS_EFLAGS(r) ((r)[HOST_EFLAGS]) | ||
43 | #define REGS_SS(r) ((r)[HOST_SS]) | ||
44 | |||
45 | #define HOST_FS_BASE 21 | ||
46 | #define HOST_GS_BASE 22 | ||
47 | #define HOST_DS 23 | ||
48 | #define HOST_ES 24 | ||
49 | #define HOST_FS 25 | ||
50 | #define HOST_GS 26 | ||
51 | |||
52 | #define REGS_FS_BASE(r) ((r)[HOST_FS_BASE]) | ||
53 | #define REGS_GS_BASE(r) ((r)[HOST_GS_BASE]) | ||
54 | #define REGS_DS(r) ((r)[HOST_DS]) | ||
55 | #define REGS_ES(r) ((r)[HOST_ES]) | ||
56 | #define REGS_FS(r) ((r)[HOST_FS]) | ||
57 | #define REGS_GS(r) ((r)[HOST_GS]) | ||
58 | |||
59 | #define REGS_ORIG_RAX(r) ((r)[HOST_ORIG_RAX]) | ||
60 | |||
61 | #define REGS_SET_SYSCALL_RETURN(r, res) REGS_RAX(r) = (res) | ||
62 | |||
63 | #define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r)) | ||
64 | |||
65 | #define REGS_SEGV_IS_FIXABLE(r) SEGV_IS_FIXABLE((r)->trap_type) | ||
66 | |||
67 | #define REGS_FAULT_ADDR(r) ((r)->fault_addr) | ||
68 | |||
69 | #define REGS_FAULT_WRITE(r) FAULT_WRITE((r)->fault_type) | ||
70 | |||
71 | #define REGS_TRAP(r) ((r)->trap_type) | ||
72 | |||
73 | #define REGS_ERR(r) ((r)->fault_type) | ||
74 | |||
75 | #endif | ||
76 | |||
77 | #include "choose-mode.h" | ||
78 | |||
79 | /* XXX */ | ||
80 | union uml_pt_regs { | ||
81 | #ifdef UML_CONFIG_MODE_TT | ||
82 | struct tt_regs { | ||
83 | long syscall; | ||
84 | unsigned long orig_rax; | ||
85 | void *sc; | ||
86 | } tt; | ||
87 | #endif | ||
88 | #ifdef UML_CONFIG_MODE_SKAS | ||
89 | struct skas_regs { | ||
90 | /* XXX */ | ||
91 | unsigned long regs[27]; | ||
92 | unsigned long fp[65]; | ||
93 | unsigned long fault_addr; | ||
94 | unsigned long fault_type; | ||
95 | unsigned long trap_type; | ||
96 | long syscall; | ||
97 | int is_user; | ||
98 | } skas; | ||
99 | #endif | ||
100 | }; | ||
101 | |||
102 | #define EMPTY_UML_PT_REGS { } | ||
103 | |||
104 | /* XXX */ | ||
105 | extern int mode_tt; | ||
106 | |||
107 | #define UPT_RBX(r) __CHOOSE_MODE(SC_RBX(UPT_SC(r)), REGS_RBX((r)->skas.regs)) | ||
108 | #define UPT_RCX(r) __CHOOSE_MODE(SC_RCX(UPT_SC(r)), REGS_RCX((r)->skas.regs)) | ||
109 | #define UPT_RDX(r) __CHOOSE_MODE(SC_RDX(UPT_SC(r)), REGS_RDX((r)->skas.regs)) | ||
110 | #define UPT_RSI(r) __CHOOSE_MODE(SC_RSI(UPT_SC(r)), REGS_RSI((r)->skas.regs)) | ||
111 | #define UPT_RDI(r) __CHOOSE_MODE(SC_RDI(UPT_SC(r)), REGS_RDI((r)->skas.regs)) | ||
112 | #define UPT_RBP(r) __CHOOSE_MODE(SC_RBP(UPT_SC(r)), REGS_RBP((r)->skas.regs)) | ||
113 | #define UPT_RAX(r) __CHOOSE_MODE(SC_RAX(UPT_SC(r)), REGS_RAX((r)->skas.regs)) | ||
114 | #define UPT_R8(r) __CHOOSE_MODE(SC_R8(UPT_SC(r)), REGS_R8((r)->skas.regs)) | ||
115 | #define UPT_R9(r) __CHOOSE_MODE(SC_R9(UPT_SC(r)), REGS_R9((r)->skas.regs)) | ||
116 | #define UPT_R10(r) __CHOOSE_MODE(SC_R10(UPT_SC(r)), REGS_R10((r)->skas.regs)) | ||
117 | #define UPT_R11(r) __CHOOSE_MODE(SC_R11(UPT_SC(r)), REGS_R11((r)->skas.regs)) | ||
118 | #define UPT_R12(r) __CHOOSE_MODE(SC_R12(UPT_SC(r)), REGS_R12((r)->skas.regs)) | ||
119 | #define UPT_R13(r) __CHOOSE_MODE(SC_R13(UPT_SC(r)), REGS_R13((r)->skas.regs)) | ||
120 | #define UPT_R14(r) __CHOOSE_MODE(SC_R14(UPT_SC(r)), REGS_R14((r)->skas.regs)) | ||
121 | #define UPT_R15(r) __CHOOSE_MODE(SC_R15(UPT_SC(r)), REGS_R15((r)->skas.regs)) | ||
122 | #define UPT_CS(r) __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs)) | ||
123 | #define UPT_FS(r) __CHOOSE_MODE(SC_FS(UPT_SC(r)), REGS_FS((r)->skas.regs)) | ||
124 | #define UPT_GS(r) __CHOOSE_MODE(SC_GS(UPT_SC(r)), REGS_GS((r)->skas.regs)) | ||
125 | #define UPT_DS(r) __CHOOSE_MODE(SC_DS(UPT_SC(r)), REGS_DS((r)->skas.regs)) | ||
126 | #define UPT_ES(r) __CHOOSE_MODE(SC_ES(UPT_SC(r)), REGS_ES((r)->skas.regs)) | ||
127 | #define UPT_CS(r) __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs)) | ||
128 | #define UPT_ORIG_RAX(r) \ | ||
129 | __CHOOSE_MODE((r)->tt.orig_rax, REGS_ORIG_RAX((r)->skas.regs)) | ||
130 | |||
131 | #define UPT_IP(r) __CHOOSE_MODE(SC_IP(UPT_SC(r)), REGS_IP((r)->skas.regs)) | ||
132 | #define UPT_SP(r) __CHOOSE_MODE(SC_SP(UPT_SC(r)), REGS_SP((r)->skas.regs)) | ||
133 | |||
134 | #define UPT_EFLAGS(r) \ | ||
135 | __CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs)) | ||
136 | #define UPT_SC(r) ((r)->tt.sc) | ||
137 | #define UPT_SYSCALL_NR(r) __CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall) | ||
138 | |||
139 | extern int user_context(unsigned long sp); | ||
140 | |||
141 | #define UPT_IS_USER(r) \ | ||
142 | CHOOSE_MODE(user_context(UPT_SP(r)), (r)->skas.is_user) | ||
143 | |||
144 | #define UPT_SYSCALL_ARG1(r) UPT_RDI(r) | ||
145 | #define UPT_SYSCALL_ARG2(r) UPT_RSI(r) | ||
146 | #define UPT_SYSCALL_ARG3(r) UPT_RDX(r) | ||
147 | #define UPT_SYSCALL_ARG4(r) UPT_R10(r) | ||
148 | #define UPT_SYSCALL_ARG5(r) UPT_R8(r) | ||
149 | #define UPT_SYSCALL_ARG6(r) UPT_R9(r) | ||
150 | |||
151 | struct syscall_args { | ||
152 | unsigned long args[6]; | ||
153 | }; | ||
154 | |||
155 | #define SYSCALL_ARGS(r) ((struct syscall_args) \ | ||
156 | { .args = { UPT_SYSCALL_ARG1(r), \ | ||
157 | UPT_SYSCALL_ARG2(r), \ | ||
158 | UPT_SYSCALL_ARG3(r), \ | ||
159 | UPT_SYSCALL_ARG4(r), \ | ||
160 | UPT_SYSCALL_ARG5(r), \ | ||
161 | UPT_SYSCALL_ARG6(r) } } ) | ||
162 | |||
163 | #define UPT_REG(regs, reg) \ | ||
164 | ({ unsigned long val; \ | ||
165 | switch(reg){ \ | ||
166 | case R8: val = UPT_R8(regs); break; \ | ||
167 | case R9: val = UPT_R9(regs); break; \ | ||
168 | case R10: val = UPT_R10(regs); break; \ | ||
169 | case R11: val = UPT_R11(regs); break; \ | ||
170 | case R12: val = UPT_R12(regs); break; \ | ||
171 | case R13: val = UPT_R13(regs); break; \ | ||
172 | case R14: val = UPT_R14(regs); break; \ | ||
173 | case R15: val = UPT_R15(regs); break; \ | ||
174 | case RIP: val = UPT_IP(regs); break; \ | ||
175 | case RSP: val = UPT_SP(regs); break; \ | ||
176 | case RAX: val = UPT_RAX(regs); break; \ | ||
177 | case RBX: val = UPT_RBX(regs); break; \ | ||
178 | case RCX: val = UPT_RCX(regs); break; \ | ||
179 | case RDX: val = UPT_RDX(regs); break; \ | ||
180 | case RSI: val = UPT_RSI(regs); break; \ | ||
181 | case RDI: val = UPT_RDI(regs); break; \ | ||
182 | case RBP: val = UPT_RBP(regs); break; \ | ||
183 | case ORIG_RAX: val = UPT_ORIG_RAX(regs); break; \ | ||
184 | case CS: val = UPT_CS(regs); break; \ | ||
185 | case DS: val = UPT_DS(regs); break; \ | ||
186 | case ES: val = UPT_ES(regs); break; \ | ||
187 | case FS: val = UPT_FS(regs); break; \ | ||
188 | case GS: val = UPT_GS(regs); break; \ | ||
189 | case EFLAGS: val = UPT_EFLAGS(regs); break; \ | ||
190 | default : \ | ||
191 | panic("Bad register in UPT_REG : %d\n", reg); \ | ||
192 | val = -1; \ | ||
193 | } \ | ||
194 | val; \ | ||
195 | }) | ||
196 | |||
197 | |||
198 | #define UPT_SET(regs, reg, val) \ | ||
199 | ({ unsigned long val; \ | ||
200 | switch(reg){ \ | ||
201 | case R8: UPT_R8(regs) = val; break; \ | ||
202 | case R9: UPT_R9(regs) = val; break; \ | ||
203 | case R10: UPT_R10(regs) = val; break; \ | ||
204 | case R11: UPT_R11(regs) = val; break; \ | ||
205 | case R12: UPT_R12(regs) = val; break; \ | ||
206 | case R13: UPT_R13(regs) = val; break; \ | ||
207 | case R14: UPT_R14(regs) = val; break; \ | ||
208 | case R15: UPT_R15(regs) = val; break; \ | ||
209 | case RIP: UPT_IP(regs) = val; break; \ | ||
210 | case RSP: UPT_SP(regs) = val; break; \ | ||
211 | case RAX: UPT_RAX(regs) = val; break; \ | ||
212 | case RBX: UPT_RBX(regs) = val; break; \ | ||
213 | case RCX: UPT_RCX(regs) = val; break; \ | ||
214 | case RDX: UPT_RDX(regs) = val; break; \ | ||
215 | case RSI: UPT_RSI(regs) = val; break; \ | ||
216 | case RDI: UPT_RDI(regs) = val; break; \ | ||
217 | case RBP: UPT_RBP(regs) = val; break; \ | ||
218 | case ORIG_RAX: UPT_ORIG_RAX(regs) = val; break; \ | ||
219 | case CS: UPT_CS(regs) = val; break; \ | ||
220 | case DS: UPT_DS(regs) = val; break; \ | ||
221 | case ES: UPT_ES(regs) = val; break; \ | ||
222 | case FS: UPT_FS(regs) = val; break; \ | ||
223 | case GS: UPT_GS(regs) = val; break; \ | ||
224 | case EFLAGS: UPT_EFLAGS(regs) = val; break; \ | ||
225 | default : \ | ||
226 | panic("Bad register in UPT_SET : %d\n", reg); \ | ||
227 | break; \ | ||
228 | } \ | ||
229 | val; \ | ||
230 | }) | ||
231 | |||
232 | #define UPT_SET_SYSCALL_RETURN(r, res) \ | ||
233 | CHOOSE_MODE(SC_SET_SYSCALL_RETURN(UPT_SC(r), (res)), \ | ||
234 | REGS_SET_SYSCALL_RETURN((r)->skas.regs, (res))) | ||
235 | |||
236 | #define UPT_RESTART_SYSCALL(r) \ | ||
237 | CHOOSE_MODE(SC_RESTART_SYSCALL(UPT_SC(r)), \ | ||
238 | REGS_RESTART_SYSCALL((r)->skas.regs)) | ||
239 | |||
240 | #define UPT_SEGV_IS_FIXABLE(r) \ | ||
241 | CHOOSE_MODE(SC_SEGV_IS_FIXABLE(UPT_SC(r)), \ | ||
242 | REGS_SEGV_IS_FIXABLE(&r->skas)) | ||
243 | |||
244 | #define UPT_FAULT_ADDR(r) \ | ||
245 | __CHOOSE_MODE(SC_FAULT_ADDR(UPT_SC(r)), REGS_FAULT_ADDR(&r->skas)) | ||
246 | |||
247 | #define UPT_FAULT_WRITE(r) \ | ||
248 | CHOOSE_MODE(SC_FAULT_WRITE(UPT_SC(r)), REGS_FAULT_WRITE(&r->skas)) | ||
249 | |||
250 | #define UPT_TRAP(r) __CHOOSE_MODE(SC_TRAP_TYPE(UPT_SC(r)), REGS_TRAP(&r->skas)) | ||
251 | #define UPT_ERR(r) __CHOOSE_MODE(SC_FAULT_TYPE(UPT_SC(r)), REGS_ERR(&r->skas)) | ||
252 | |||
253 | #endif | ||
254 | |||
255 | /* | ||
256 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
257 | * Emacs will notice this stuff at the end of the file and automatically | ||
258 | * adjust the settings for this buffer only. This must remain at the end | ||
259 | * of the file. | ||
260 | * --------------------------------------------------------------------------- | ||
261 | * Local variables: | ||
262 | * c-file-style: "linux" | ||
263 | * End: | ||
264 | */ | ||
diff --git a/arch/um/include/sysdep-x86_64/ptrace_user.h b/arch/um/include/sysdep-x86_64/ptrace_user.h new file mode 100644 index 000000000000..31729973fb14 --- /dev/null +++ b/arch/um/include/sysdep-x86_64/ptrace_user.h | |||
@@ -0,0 +1,69 @@ | |||
1 | /* | ||
2 | * Copyright 2003 PathScale, Inc. | ||
3 | * | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #ifndef __SYSDEP_X86_64_PTRACE_USER_H__ | ||
8 | #define __SYSDEP_X86_64_PTRACE_USER_H__ | ||
9 | |||
10 | #define __FRAME_OFFSETS | ||
11 | #include <sys/ptrace.h> | ||
12 | #include <linux/ptrace.h> | ||
13 | #include <asm/ptrace.h> | ||
14 | #undef __FRAME_OFFSETS | ||
15 | |||
16 | #define PT_INDEX(off) ((off) / sizeof(unsigned long)) | ||
17 | |||
18 | #define PT_SYSCALL_NR(regs) ((regs)[PT_INDEX(ORIG_RAX)]) | ||
19 | #define PT_SYSCALL_NR_OFFSET (ORIG_RAX) | ||
20 | |||
21 | #define PT_SYSCALL_ARG1(regs) (((unsigned long *) (regs))[PT_INDEX(RDI)]) | ||
22 | #define PT_SYSCALL_ARG1_OFFSET (RDI) | ||
23 | |||
24 | #define PT_SYSCALL_ARG2(regs) (((unsigned long *) (regs))[PT_INDEX(RSI)]) | ||
25 | #define PT_SYSCALL_ARG2_OFFSET (RSI) | ||
26 | |||
27 | #define PT_SYSCALL_ARG3(regs) (((unsigned long *) (regs))[PT_INDEX(RDX)]) | ||
28 | #define PT_SYSCALL_ARG3_OFFSET (RDX) | ||
29 | |||
30 | #define PT_SYSCALL_ARG4(regs) (((unsigned long *) (regs))[PT_INDEX(RCX)]) | ||
31 | #define PT_SYSCALL_ARG4_OFFSET (RCX) | ||
32 | |||
33 | #define PT_SYSCALL_ARG5(regs) (((unsigned long *) (regs))[PT_INDEX(R8)]) | ||
34 | #define PT_SYSCALL_ARG5_OFFSET (R8) | ||
35 | |||
36 | #define PT_SYSCALL_ARG6(regs) (((unsigned long *) (regs))[PT_INDEX(R9)]) | ||
37 | #define PT_SYSCALL_ARG6_OFFSET (R9) | ||
38 | |||
39 | #define PT_SYSCALL_RET_OFFSET (RAX) | ||
40 | |||
41 | #define PT_IP_OFFSET (RIP) | ||
42 | #define PT_IP(regs) ((regs)[PT_INDEX(RIP)]) | ||
43 | |||
44 | #define PT_SP_OFFSET (RSP) | ||
45 | #define PT_SP(regs) ((regs)[PT_INDEX(RSP)]) | ||
46 | |||
47 | #define PT_ORIG_RAX_OFFSET (ORIG_RAX) | ||
48 | #define PT_ORIG_RAX(regs) ((regs)[PT_INDEX(ORIG_RAX)]) | ||
49 | |||
50 | /* x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though | ||
51 | * it's defined in the kernel's include/linux/ptrace.h. Additionally, use the | ||
52 | * 2.4 name and value for 2.4 host compatibility. | ||
53 | */ | ||
54 | #ifndef PTRACE_OLDSETOPTIONS | ||
55 | #define PTRACE_OLDSETOPTIONS 21 | ||
56 | #endif | ||
57 | |||
58 | #endif | ||
59 | |||
60 | /* | ||
61 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
62 | * Emacs will notice this stuff at the end of the file and automatically | ||
63 | * adjust the settings for this buffer only. This must remain at the end | ||
64 | * of the file. | ||
65 | * --------------------------------------------------------------------------- | ||
66 | * Local variables: | ||
67 | * c-file-style: "linux" | ||
68 | * End: | ||
69 | */ | ||
diff --git a/arch/um/include/sysdep-x86_64/sigcontext.h b/arch/um/include/sysdep-x86_64/sigcontext.h new file mode 100644 index 000000000000..1e38a54ff4cf --- /dev/null +++ b/arch/um/include/sysdep-x86_64/sigcontext.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | * Copyright 2003 PathScale, Inc. | ||
3 | * | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #ifndef __SYSDEP_X86_64_SIGCONTEXT_H | ||
8 | #define __SYSDEP_X86_64_SIGCONTEXT_H | ||
9 | |||
10 | #include <sysdep/sc.h> | ||
11 | |||
12 | #define IP_RESTART_SYSCALL(ip) ((ip) -= 2) | ||
13 | |||
14 | #define SC_RESTART_SYSCALL(sc) IP_RESTART_SYSCALL(SC_IP(sc)) | ||
15 | #define SC_SET_SYSCALL_RETURN(sc, result) SC_RAX(sc) = (result) | ||
16 | |||
17 | #define SC_FAULT_ADDR(sc) SC_CR2(sc) | ||
18 | #define SC_FAULT_TYPE(sc) SC_ERR(sc) | ||
19 | |||
20 | #define FAULT_WRITE(err) ((err) & 2) | ||
21 | |||
22 | #define SC_FAULT_WRITE(sc) FAULT_WRITE(SC_FAULT_TYPE(sc)) | ||
23 | |||
24 | #define SC_TRAP_TYPE(sc) SC_TRAPNO(sc) | ||
25 | |||
26 | /* ptrace expects that, at the start of a system call, %eax contains | ||
27 | * -ENOSYS, so this makes it so. | ||
28 | */ | ||
29 | |||
30 | #define SC_START_SYSCALL(sc) do SC_RAX(sc) = -ENOSYS; while(0) | ||
31 | |||
32 | #define SEGV_IS_FIXABLE(trap) ((trap) == 14) | ||
33 | #define SC_SEGV_IS_FIXABLE(sc) SEGV_IS_FIXABLE(SC_TRAP_TYPE(sc)) | ||
34 | |||
35 | extern unsigned long *sc_sigmask(void *sc_ptr); | ||
36 | |||
37 | #endif | ||
38 | |||
39 | /* | ||
40 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
41 | * Emacs will notice this stuff at the end of the file and automatically | ||
42 | * adjust the settings for this buffer only. This must remain at the end | ||
43 | * of the file. | ||
44 | * --------------------------------------------------------------------------- | ||
45 | * Local variables: | ||
46 | * c-file-style: "linux" | ||
47 | * End: | ||
48 | */ | ||
49 | |||
diff --git a/arch/um/include/sysdep-x86_64/signal.h b/arch/um/include/sysdep-x86_64/signal.h new file mode 100644 index 000000000000..e5e52756fab4 --- /dev/null +++ b/arch/um/include/sysdep-x86_64/signal.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 PathScale, Inc | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __X86_64_SIGNAL_H_ | ||
7 | #define __X86_64_SIGNAL_H_ | ||
8 | |||
9 | #define ARCH_GET_SIGCONTEXT(sc, sig_addr) \ | ||
10 | do { \ | ||
11 | struct ucontext *__uc; \ | ||
12 | asm("movq %%rdx, %0" : "=r" (__uc)); \ | ||
13 | sc = (struct sigcontext *) &__uc->uc_mcontext; \ | ||
14 | } while(0) | ||
15 | |||
16 | #endif | ||
17 | |||
18 | /* | ||
19 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
20 | * Emacs will notice this stuff at the end of the file and automatically | ||
21 | * adjust the settings for this buffer only. This must remain at the end | ||
22 | * of the file. | ||
23 | * --------------------------------------------------------------------------- | ||
24 | * Local variables: | ||
25 | * c-file-style: "linux" | ||
26 | * End: | ||
27 | */ | ||
diff --git a/arch/um/include/sysdep-x86_64/syscalls.h b/arch/um/include/sysdep-x86_64/syscalls.h new file mode 100644 index 000000000000..b187a4157ff3 --- /dev/null +++ b/arch/um/include/sysdep-x86_64/syscalls.h | |||
@@ -0,0 +1,91 @@ | |||
1 | /* | ||
2 | * Copyright 2003 PathScale, Inc. | ||
3 | * | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #ifndef __SYSDEP_X86_64_SYSCALLS_H__ | ||
8 | #define __SYSDEP_X86_64_SYSCALLS_H__ | ||
9 | |||
10 | #include <linux/msg.h> | ||
11 | #include <linux/shm.h> | ||
12 | |||
13 | typedef long syscall_handler_t(void); | ||
14 | |||
15 | extern syscall_handler_t *ia32_sys_call_table[]; | ||
16 | |||
17 | #define EXECUTE_SYSCALL(syscall, regs) \ | ||
18 | (((long (*)(long, long, long, long, long, long)) \ | ||
19 | (*sys_call_table[syscall]))(UPT_SYSCALL_ARG1(®s->regs), \ | ||
20 | UPT_SYSCALL_ARG2(®s->regs), \ | ||
21 | UPT_SYSCALL_ARG3(®s->regs), \ | ||
22 | UPT_SYSCALL_ARG4(®s->regs), \ | ||
23 | UPT_SYSCALL_ARG5(®s->regs), \ | ||
24 | UPT_SYSCALL_ARG6(®s->regs))) | ||
25 | |||
26 | extern long old_mmap(unsigned long addr, unsigned long len, | ||
27 | unsigned long prot, unsigned long flags, | ||
28 | unsigned long fd, unsigned long pgoff); | ||
29 | extern syscall_handler_t wrap_sys_shmat; | ||
30 | extern syscall_handler_t sys_modify_ldt; | ||
31 | extern syscall_handler_t sys_arch_prctl; | ||
32 | |||
33 | #define ARCH_SYSCALLS \ | ||
34 | [ __NR_mmap ] = (syscall_handler_t *) old_mmap, \ | ||
35 | [ __NR_select ] = (syscall_handler_t *) sys_select, \ | ||
36 | [ __NR_mincore ] = (syscall_handler_t *) sys_mincore, \ | ||
37 | [ __NR_madvise ] = (syscall_handler_t *) sys_madvise, \ | ||
38 | [ __NR_shmget ] = (syscall_handler_t *) sys_shmget, \ | ||
39 | [ __NR_shmat ] = (syscall_handler_t *) wrap_sys_shmat, \ | ||
40 | [ __NR_shmctl ] = (syscall_handler_t *) sys_shmctl, \ | ||
41 | [ __NR_semop ] = (syscall_handler_t *) sys_semop, \ | ||
42 | [ __NR_semget ] = (syscall_handler_t *) sys_semget, \ | ||
43 | [ __NR_semctl ] = (syscall_handler_t *) sys_semctl, \ | ||
44 | [ __NR_shmdt ] = (syscall_handler_t *) sys_shmdt, \ | ||
45 | [ __NR_msgget ] = (syscall_handler_t *) sys_msgget, \ | ||
46 | [ __NR_msgsnd ] = (syscall_handler_t *) sys_msgsnd, \ | ||
47 | [ __NR_msgrcv ] = (syscall_handler_t *) sys_msgrcv, \ | ||
48 | [ __NR_msgctl ] = (syscall_handler_t *) sys_msgctl, \ | ||
49 | [ __NR_pivot_root ] = (syscall_handler_t *) sys_pivot_root, \ | ||
50 | [ __NR_tuxcall ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
51 | [ __NR_security ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
52 | [ __NR_epoll_ctl_old ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
53 | [ __NR_epoll_wait_old ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
54 | [ __NR_modify_ldt ] = (syscall_handler_t *) sys_modify_ldt, \ | ||
55 | [ __NR_arch_prctl ] = (syscall_handler_t *) sys_arch_prctl, \ | ||
56 | [ __NR_socket ] = (syscall_handler_t *) sys_socket, \ | ||
57 | [ __NR_connect ] = (syscall_handler_t *) sys_connect, \ | ||
58 | [ __NR_accept ] = (syscall_handler_t *) sys_accept, \ | ||
59 | [ __NR_recvfrom ] = (syscall_handler_t *) sys_recvfrom, \ | ||
60 | [ __NR_recvmsg ] = (syscall_handler_t *) sys_recvmsg, \ | ||
61 | [ __NR_sendmsg ] = (syscall_handler_t *) sys_sendmsg, \ | ||
62 | [ __NR_bind ] = (syscall_handler_t *) sys_bind, \ | ||
63 | [ __NR_listen ] = (syscall_handler_t *) sys_listen, \ | ||
64 | [ __NR_getsockname ] = (syscall_handler_t *) sys_getsockname, \ | ||
65 | [ __NR_getpeername ] = (syscall_handler_t *) sys_getpeername, \ | ||
66 | [ __NR_socketpair ] = (syscall_handler_t *) sys_socketpair, \ | ||
67 | [ __NR_sendto ] = (syscall_handler_t *) sys_sendto, \ | ||
68 | [ __NR_shutdown ] = (syscall_handler_t *) sys_shutdown, \ | ||
69 | [ __NR_setsockopt ] = (syscall_handler_t *) sys_setsockopt, \ | ||
70 | [ __NR_getsockopt ] = (syscall_handler_t *) sys_getsockopt, \ | ||
71 | [ __NR_iopl ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
72 | [ __NR_set_thread_area ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
73 | [ __NR_get_thread_area ] = (syscall_handler_t *) sys_ni_syscall, \ | ||
74 | [ __NR_semtimedop ] = (syscall_handler_t *) sys_semtimedop, \ | ||
75 | [ 251 ] = (syscall_handler_t *) sys_ni_syscall, | ||
76 | |||
77 | #define LAST_ARCH_SYSCALL 251 | ||
78 | #define NR_syscalls 1024 | ||
79 | |||
80 | #endif | ||
81 | |||
82 | /* | ||
83 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
84 | * Emacs will notice this stuff at the end of the file and automatically | ||
85 | * adjust the settings for this buffer only. This must remain at the end | ||
86 | * of the file. | ||
87 | * --------------------------------------------------------------------------- | ||
88 | * Local variables: | ||
89 | * c-file-style: "linux" | ||
90 | * End: | ||
91 | */ | ||
diff --git a/arch/um/include/sysrq.h b/arch/um/include/sysrq.h new file mode 100644 index 000000000000..2ce9423460b3 --- /dev/null +++ b/arch/um/include/sysrq.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __UM_SYSRQ_H | ||
2 | #define __UM_SYSRQ_H | ||
3 | |||
4 | extern void show_trace(unsigned long *stack); | ||
5 | |||
6 | #endif | ||
diff --git a/arch/um/include/tempfile.h b/arch/um/include/tempfile.h new file mode 100644 index 000000000000..e36d9e0f5105 --- /dev/null +++ b/arch/um/include/tempfile.h | |||
@@ -0,0 +1,21 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __TEMPFILE_H__ | ||
7 | #define __TEMPFILE_H__ | ||
8 | |||
9 | extern int make_tempfile(const char *template, char **tempname, int do_unlink); | ||
10 | |||
11 | #endif | ||
12 | /* | ||
13 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
14 | * Emacs will notice this stuff at the end of the file and automatically | ||
15 | * adjust the settings for this buffer only. This must remain at the end | ||
16 | * of the file. | ||
17 | * --------------------------------------------------------------------------- | ||
18 | * Local variables: | ||
19 | * c-file-style: "linux" | ||
20 | * End: | ||
21 | */ | ||
diff --git a/arch/um/include/time_user.h b/arch/um/include/time_user.h new file mode 100644 index 000000000000..6793a2fcd0ae --- /dev/null +++ b/arch/um/include/time_user.h | |||
@@ -0,0 +1,18 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __TIME_USER_H__ | ||
7 | #define __TIME_USER_H__ | ||
8 | |||
9 | extern void timer(void); | ||
10 | extern void switch_timers(int to_real); | ||
11 | extern void set_interval(int timer_type); | ||
12 | extern void idle_sleep(int secs); | ||
13 | extern void enable_timer(void); | ||
14 | extern void disable_timer(void); | ||
15 | extern unsigned long time_lock(void); | ||
16 | extern void time_unlock(unsigned long); | ||
17 | |||
18 | #endif | ||
diff --git a/arch/um/include/tlb.h b/arch/um/include/tlb.h new file mode 100644 index 000000000000..da1097285b8c --- /dev/null +++ b/arch/um/include/tlb.h | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __TLB_H__ | ||
7 | #define __TLB_H__ | ||
8 | |||
9 | #include "um_mmu.h" | ||
10 | |||
11 | struct host_vm_op { | ||
12 | enum { MMAP, MUNMAP, MPROTECT } type; | ||
13 | union { | ||
14 | struct { | ||
15 | unsigned long addr; | ||
16 | unsigned long len; | ||
17 | unsigned int r:1; | ||
18 | unsigned int w:1; | ||
19 | unsigned int x:1; | ||
20 | int fd; | ||
21 | __u64 offset; | ||
22 | } mmap; | ||
23 | struct { | ||
24 | unsigned long addr; | ||
25 | unsigned long len; | ||
26 | } munmap; | ||
27 | struct { | ||
28 | unsigned long addr; | ||
29 | unsigned long len; | ||
30 | unsigned int r:1; | ||
31 | unsigned int w:1; | ||
32 | unsigned int x:1; | ||
33 | } mprotect; | ||
34 | } u; | ||
35 | }; | ||
36 | |||
37 | extern void mprotect_kernel_vm(int w); | ||
38 | extern void force_flush_all(void); | ||
39 | extern void fix_range_common(struct mm_struct *mm, unsigned long start_addr, | ||
40 | unsigned long end_addr, int force, int data, | ||
41 | void (*do_ops)(int, struct host_vm_op *, int)); | ||
42 | extern int flush_tlb_kernel_range_common(unsigned long start, | ||
43 | unsigned long end); | ||
44 | |||
45 | extern int add_mmap(unsigned long virt, unsigned long phys, unsigned long len, | ||
46 | int r, int w, int x, struct host_vm_op *ops, int index, | ||
47 | int last_filled, int data, | ||
48 | void (*do_ops)(int, struct host_vm_op *, int)); | ||
49 | extern int add_munmap(unsigned long addr, unsigned long len, | ||
50 | struct host_vm_op *ops, int index, int last_filled, | ||
51 | int data, void (*do_ops)(int, struct host_vm_op *, int)); | ||
52 | extern int add_mprotect(unsigned long addr, unsigned long len, int r, int w, | ||
53 | int x, struct host_vm_op *ops, int index, | ||
54 | int last_filled, int data, | ||
55 | void (*do_ops)(int, struct host_vm_op *, int)); | ||
56 | #endif | ||
57 | |||
58 | /* | ||
59 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
60 | * Emacs will notice this stuff at the end of the file and automatically | ||
61 | * adjust the settings for this buffer only. This must remain at the end | ||
62 | * of the file. | ||
63 | * --------------------------------------------------------------------------- | ||
64 | * Local variables: | ||
65 | * c-file-style: "linux" | ||
66 | * End: | ||
67 | */ | ||
diff --git a/arch/um/include/ubd_user.h b/arch/um/include/ubd_user.h new file mode 100644 index 000000000000..bb66517f0739 --- /dev/null +++ b/arch/um/include/ubd_user.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Copyright (C) 2001 RidgeRun, Inc (glonnon@ridgerun.com) | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #ifndef __UM_UBD_USER_H | ||
8 | #define __UM_UBD_USER_H | ||
9 | |||
10 | extern void ignore_sigwinch_sig(void); | ||
11 | extern int start_io_thread(unsigned long sp, int *fds_out); | ||
12 | extern int io_thread(void *arg); | ||
13 | extern int kernel_fd; | ||
14 | |||
15 | #endif | ||
16 | |||
17 | /* | ||
18 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
19 | * Emacs will notice this stuff at the end of the file and automatically | ||
20 | * adjust the settings for this buffer only. This must remain at the end | ||
21 | * of the file. | ||
22 | * --------------------------------------------------------------------------- | ||
23 | * Local variables: | ||
24 | * c-file-style: "linux" | ||
25 | * End: | ||
26 | */ | ||
diff --git a/arch/um/include/um_mmu.h b/arch/um/include/um_mmu.h new file mode 100644 index 000000000000..0fa643238300 --- /dev/null +++ b/arch/um/include/um_mmu.h | |||
@@ -0,0 +1,40 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __ARCH_UM_MMU_H | ||
7 | #define __ARCH_UM_MMU_H | ||
8 | |||
9 | #include "uml-config.h" | ||
10 | #include "choose-mode.h" | ||
11 | |||
12 | #ifdef UML_CONFIG_MODE_TT | ||
13 | #include "mmu-tt.h" | ||
14 | #endif | ||
15 | |||
16 | #ifdef UML_CONFIG_MODE_SKAS | ||
17 | #include "mmu-skas.h" | ||
18 | #endif | ||
19 | |||
20 | typedef union mm_context { | ||
21 | #ifdef UML_CONFIG_MODE_TT | ||
22 | struct mmu_context_tt tt; | ||
23 | #endif | ||
24 | #ifdef UML_CONFIG_MODE_SKAS | ||
25 | struct mmu_context_skas skas; | ||
26 | #endif | ||
27 | } mm_context_t; | ||
28 | |||
29 | #endif | ||
30 | |||
31 | /* | ||
32 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
33 | * Emacs will notice this stuff at the end of the file and automatically | ||
34 | * adjust the settings for this buffer only. This must remain at the end | ||
35 | * of the file. | ||
36 | * --------------------------------------------------------------------------- | ||
37 | * Local variables: | ||
38 | * c-file-style: "linux" | ||
39 | * End: | ||
40 | */ | ||
diff --git a/arch/um/include/um_uaccess.h b/arch/um/include/um_uaccess.h new file mode 100644 index 000000000000..6e348cb6de24 --- /dev/null +++ b/arch/um/include/um_uaccess.h | |||
@@ -0,0 +1,125 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __ARCH_UM_UACCESS_H | ||
7 | #define __ARCH_UM_UACCESS_H | ||
8 | |||
9 | #include "linux/config.h" | ||
10 | #include "choose-mode.h" | ||
11 | |||
12 | #ifdef CONFIG_MODE_TT | ||
13 | #include "uaccess-tt.h" | ||
14 | #endif | ||
15 | |||
16 | #ifdef CONFIG_MODE_SKAS | ||
17 | #include "uaccess-skas.h" | ||
18 | #endif | ||
19 | |||
20 | #define access_ok(type, addr, size) \ | ||
21 | CHOOSE_MODE_PROC(access_ok_tt, access_ok_skas, type, addr, size) | ||
22 | |||
23 | /* this function will go away soon - use access_ok() instead */ | ||
24 | static inline int __deprecated verify_area(int type, const void __user *addr, unsigned long size) | ||
25 | { | ||
26 | return (CHOOSE_MODE_PROC(verify_area_tt, verify_area_skas, type, addr, | ||
27 | size)); | ||
28 | } | ||
29 | |||
30 | static inline int copy_from_user(void *to, const void __user *from, int n) | ||
31 | { | ||
32 | return(CHOOSE_MODE_PROC(copy_from_user_tt, copy_from_user_skas, to, | ||
33 | from, n)); | ||
34 | } | ||
35 | |||
36 | static inline int copy_to_user(void __user *to, const void *from, int n) | ||
37 | { | ||
38 | return(CHOOSE_MODE_PROC(copy_to_user_tt, copy_to_user_skas, to, | ||
39 | from, n)); | ||
40 | } | ||
41 | |||
42 | /* | ||
43 | * strncpy_from_user: - Copy a NUL terminated string from userspace. | ||
44 | * @dst: Destination address, in kernel space. This buffer must be at | ||
45 | * least @count bytes long. | ||
46 | * @src: Source address, in user space. | ||
47 | * @count: Maximum number of bytes to copy, including the trailing NUL. | ||
48 | * | ||
49 | * Copies a NUL-terminated string from userspace to kernel space. | ||
50 | * | ||
51 | * On success, returns the length of the string (not including the trailing | ||
52 | * NUL). | ||
53 | * | ||
54 | * If access to userspace fails, returns -EFAULT (some data may have been | ||
55 | * copied). | ||
56 | * | ||
57 | * If @count is smaller than the length of the string, copies @count bytes | ||
58 | * and returns @count. | ||
59 | */ | ||
60 | |||
61 | static inline int strncpy_from_user(char *dst, const char __user *src, int count) | ||
62 | { | ||
63 | return(CHOOSE_MODE_PROC(strncpy_from_user_tt, strncpy_from_user_skas, | ||
64 | dst, src, count)); | ||
65 | } | ||
66 | |||
67 | /* | ||
68 | * __clear_user: - Zero a block of memory in user space, with less checking. | ||
69 | * @to: Destination address, in user space. | ||
70 | * @n: Number of bytes to zero. | ||
71 | * | ||
72 | * Zero a block of memory in user space. Caller must check | ||
73 | * the specified block with access_ok() before calling this function. | ||
74 | * | ||
75 | * Returns number of bytes that could not be cleared. | ||
76 | * On success, this will be zero. | ||
77 | */ | ||
78 | static inline int __clear_user(void *mem, int len) | ||
79 | { | ||
80 | return(CHOOSE_MODE_PROC(__clear_user_tt, __clear_user_skas, mem, len)); | ||
81 | } | ||
82 | |||
83 | /* | ||
84 | * clear_user: - Zero a block of memory in user space. | ||
85 | * @to: Destination address, in user space. | ||
86 | * @n: Number of bytes to zero. | ||
87 | * | ||
88 | * Zero a block of memory in user space. | ||
89 | * | ||
90 | * Returns number of bytes that could not be cleared. | ||
91 | * On success, this will be zero. | ||
92 | */ | ||
93 | static inline int clear_user(void __user *mem, int len) | ||
94 | { | ||
95 | return(CHOOSE_MODE_PROC(clear_user_tt, clear_user_skas, mem, len)); | ||
96 | } | ||
97 | |||
98 | /* | ||
99 | * strlen_user: - Get the size of a string in user space. | ||
100 | * @str: The string to measure. | ||
101 | * @n: The maximum valid length | ||
102 | * | ||
103 | * Get the size of a NUL-terminated string in user space. | ||
104 | * | ||
105 | * Returns the size of the string INCLUDING the terminating NUL. | ||
106 | * On exception, returns 0. | ||
107 | * If the string is too long, returns a value greater than @n. | ||
108 | */ | ||
109 | static inline int strnlen_user(const void __user *str, long len) | ||
110 | { | ||
111 | return(CHOOSE_MODE_PROC(strnlen_user_tt, strnlen_user_skas, str, len)); | ||
112 | } | ||
113 | |||
114 | #endif | ||
115 | |||
116 | /* | ||
117 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
118 | * Emacs will notice this stuff at the end of the file and automatically | ||
119 | * adjust the settings for this buffer only. This must remain at the end | ||
120 | * of the file. | ||
121 | * --------------------------------------------------------------------------- | ||
122 | * Local variables: | ||
123 | * c-file-style: "linux" | ||
124 | * End: | ||
125 | */ | ||
diff --git a/arch/um/include/umid.h b/arch/um/include/umid.h new file mode 100644 index 000000000000..11373c851f15 --- /dev/null +++ b/arch/um/include/umid.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __UMID_H__ | ||
7 | #define __UMID_H__ | ||
8 | |||
9 | extern int umid_file_name(char *name, char *buf, int len); | ||
10 | |||
11 | #endif | ||
12 | |||
13 | /* | ||
14 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
15 | * Emacs will notice this stuff at the end of the file and automatically | ||
16 | * adjust the settings for this buffer only. This must remain at the end | ||
17 | * of the file. | ||
18 | * --------------------------------------------------------------------------- | ||
19 | * Local variables: | ||
20 | * c-file-style: "linux" | ||
21 | * End: | ||
22 | */ | ||
diff --git a/arch/um/include/uml_uaccess.h b/arch/um/include/uml_uaccess.h new file mode 100644 index 000000000000..f77eb6428453 --- /dev/null +++ b/arch/um/include/uml_uaccess.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __UML_UACCESS_H__ | ||
7 | #define __UML_UACCESS_H__ | ||
8 | |||
9 | extern int __do_copy_to_user(void *to, const void *from, int n, | ||
10 | void **fault_addr, void **fault_catcher); | ||
11 | extern unsigned long __do_user_copy(void *to, const void *from, int n, | ||
12 | void **fault_addr, void **fault_catcher, | ||
13 | void (*op)(void *to, const void *from, | ||
14 | int n), int *faulted_out); | ||
15 | void __do_copy(void *to, const void *from, int n); | ||
16 | |||
17 | #endif | ||
18 | |||
19 | /* | ||
20 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
21 | * Emacs will notice this stuff at the end of the file and automatically | ||
22 | * adjust the settings for this buffer only. This must remain at the end | ||
23 | * of the file. | ||
24 | * --------------------------------------------------------------------------- | ||
25 | * Local variables: | ||
26 | * c-file-style: "linux" | ||
27 | * End: | ||
28 | */ | ||
diff --git a/arch/um/include/user.h b/arch/um/include/user.h new file mode 100644 index 000000000000..57ee9e261228 --- /dev/null +++ b/arch/um/include/user.h | |||
@@ -0,0 +1,32 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __USER_H__ | ||
7 | #define __USER_H__ | ||
8 | |||
9 | extern void panic(const char *fmt, ...); | ||
10 | extern int printk(const char *fmt, ...); | ||
11 | extern void schedule(void); | ||
12 | extern void *um_kmalloc(int size); | ||
13 | extern void *um_kmalloc_atomic(int size); | ||
14 | extern void kfree(void *ptr); | ||
15 | extern int in_aton(char *str); | ||
16 | extern int open_gdb_chan(void); | ||
17 | extern int strlcpy(char *, const char *, int); | ||
18 | extern void *um_vmalloc(int size); | ||
19 | extern void vfree(void *ptr); | ||
20 | |||
21 | #endif | ||
22 | |||
23 | /* | ||
24 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
25 | * Emacs will notice this stuff at the end of the file and automatically | ||
26 | * adjust the settings for this buffer only. This must remain at the end | ||
27 | * of the file. | ||
28 | * --------------------------------------------------------------------------- | ||
29 | * Local variables: | ||
30 | * c-file-style: "linux" | ||
31 | * End: | ||
32 | */ | ||
diff --git a/arch/um/include/user_util.h b/arch/um/include/user_util.h new file mode 100644 index 000000000000..103cd320386c --- /dev/null +++ b/arch/um/include/user_util.h | |||
@@ -0,0 +1,106 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __USER_UTIL_H__ | ||
7 | #define __USER_UTIL_H__ | ||
8 | |||
9 | #include "sysdep/ptrace.h" | ||
10 | |||
11 | #define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR)) | ||
12 | |||
13 | extern int mode_tt; | ||
14 | |||
15 | extern int grantpt(int __fd); | ||
16 | extern int unlockpt(int __fd); | ||
17 | extern char *ptsname(int __fd); | ||
18 | |||
19 | struct cpu_task { | ||
20 | int pid; | ||
21 | void *task; | ||
22 | }; | ||
23 | |||
24 | extern struct cpu_task cpu_tasks[]; | ||
25 | |||
26 | struct signal_info { | ||
27 | void (*handler)(int, union uml_pt_regs *); | ||
28 | int is_irq; | ||
29 | }; | ||
30 | |||
31 | extern struct signal_info sig_info[]; | ||
32 | |||
33 | extern unsigned long low_physmem; | ||
34 | extern unsigned long high_physmem; | ||
35 | extern unsigned long uml_physmem; | ||
36 | extern unsigned long uml_reserved; | ||
37 | extern unsigned long end_vm; | ||
38 | extern unsigned long start_vm; | ||
39 | extern unsigned long highmem; | ||
40 | |||
41 | extern char host_info[]; | ||
42 | |||
43 | extern char saved_command_line[]; | ||
44 | extern char command_line[]; | ||
45 | |||
46 | extern char *tempdir; | ||
47 | |||
48 | extern unsigned long _stext, _etext, _sdata, _edata, __bss_start, _end; | ||
49 | extern unsigned long _unprotected_end; | ||
50 | extern unsigned long brk_start; | ||
51 | |||
52 | extern int pty_output_sigio; | ||
53 | extern int pty_close_sigio; | ||
54 | |||
55 | extern void stop(void); | ||
56 | extern void stack_protections(unsigned long address); | ||
57 | extern void task_protections(unsigned long address); | ||
58 | extern int wait_for_stop(int pid, int sig, int cont_type, void *relay); | ||
59 | extern void *add_signal_handler(int sig, void (*handler)(int)); | ||
60 | extern int start_fork_tramp(void *arg, unsigned long temp_stack, | ||
61 | int clone_flags, int (*tramp)(void *)); | ||
62 | extern int linux_main(int argc, char **argv); | ||
63 | extern void set_cmdline(char *cmd); | ||
64 | extern void input_cb(void (*proc)(void *), void *arg, int arg_len); | ||
65 | extern int get_pty(void); | ||
66 | extern void *um_kmalloc(int size); | ||
67 | extern int switcheroo(int fd, int prot, void *from, void *to, int size); | ||
68 | extern void setup_machinename(char *machine_out); | ||
69 | extern void setup_hostinfo(void); | ||
70 | extern void add_arg(char *arg); | ||
71 | extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)); | ||
72 | extern void init_new_thread_signals(int altstack); | ||
73 | extern void do_exec(int old_pid, int new_pid); | ||
74 | extern void tracer_panic(char *msg, ...); | ||
75 | extern char *get_umid(int only_if_set); | ||
76 | extern void do_longjmp(void *p, int val); | ||
77 | extern int detach(int pid, int sig); | ||
78 | extern int attach(int pid); | ||
79 | extern void kill_child_dead(int pid); | ||
80 | extern int cont(int pid); | ||
81 | extern void check_ptrace(void); | ||
82 | extern void check_sigio(void); | ||
83 | extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr); | ||
84 | extern void write_sigio_workaround(void); | ||
85 | extern void arch_check_bugs(void); | ||
86 | extern int cpu_feature(char *what, char *buf, int len); | ||
87 | extern int arch_handle_signal(int sig, union uml_pt_regs *regs); | ||
88 | extern int arch_fixup(unsigned long address, void *sc_ptr); | ||
89 | extern void forward_pending_sigio(int target); | ||
90 | extern int can_do_skas(void); | ||
91 | extern void arch_init_thread(void); | ||
92 | extern int setjmp_wrapper(void (*proc)(void *, void *), ...); | ||
93 | extern int raw(int fd); | ||
94 | |||
95 | #endif | ||
96 | |||
97 | /* | ||
98 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
99 | * Emacs will notice this stuff at the end of the file and automatically | ||
100 | * adjust the settings for this buffer only. This must remain at the end | ||
101 | * of the file. | ||
102 | * --------------------------------------------------------------------------- | ||
103 | * Local variables: | ||
104 | * c-file-style: "linux" | ||
105 | * End: | ||
106 | */ | ||