diff options
Diffstat (limited to 'arch/um/include/shared')
44 files changed, 2000 insertions, 0 deletions
diff --git a/arch/um/include/shared/aio.h b/arch/um/include/shared/aio.h new file mode 100644 index 000000000000..423bae9153f8 --- /dev/null +++ b/arch/um/include/shared/aio.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef AIO_H__ | ||
7 | #define AIO_H__ | ||
8 | |||
9 | enum aio_type { AIO_READ, AIO_WRITE, AIO_MMAP }; | ||
10 | |||
11 | struct aio_thread_reply { | ||
12 | void *data; | ||
13 | int err; | ||
14 | }; | ||
15 | |||
16 | struct aio_context { | ||
17 | int reply_fd; | ||
18 | struct aio_context *next; | ||
19 | }; | ||
20 | |||
21 | #define INIT_AIO_CONTEXT { .reply_fd = -1, \ | ||
22 | .next = NULL } | ||
23 | |||
24 | extern int submit_aio(enum aio_type type, int fd, char *buf, int len, | ||
25 | unsigned long long offset, int reply_fd, | ||
26 | struct aio_context *aio); | ||
27 | |||
28 | #endif | ||
diff --git a/arch/um/include/shared/arch.h b/arch/um/include/shared/arch.h new file mode 100644 index 000000000000..2de92a08a76b --- /dev/null +++ b/arch/um/include/shared/arch.h | |||
@@ -0,0 +1,15 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __ARCH_H__ | ||
7 | #define __ARCH_H__ | ||
8 | |||
9 | #include "sysdep/ptrace.h" | ||
10 | |||
11 | extern void arch_check_bugs(void); | ||
12 | extern int arch_fixup(unsigned long address, struct uml_pt_regs *regs); | ||
13 | extern void arch_examine_signal(int sig, struct uml_pt_regs *regs); | ||
14 | |||
15 | #endif | ||
diff --git a/arch/um/include/shared/as-layout.h b/arch/um/include/shared/as-layout.h new file mode 100644 index 000000000000..a92b678503cf --- /dev/null +++ b/arch/um/include/shared/as-layout.h | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __START_H__ | ||
7 | #define __START_H__ | ||
8 | |||
9 | #include "kern_constants.h" | ||
10 | |||
11 | /* | ||
12 | * Stolen from linux/const.h, which can't be directly included since | ||
13 | * this is used in userspace code, which has no access to the kernel | ||
14 | * headers. Changed to be suitable for adding casts to the start, | ||
15 | * rather than "UL" to the end. | ||
16 | */ | ||
17 | |||
18 | /* Some constant macros are used in both assembler and | ||
19 | * C code. Therefore we cannot annotate them always with | ||
20 | * 'UL' and other type specifiers unilaterally. We | ||
21 | * use the following macros to deal with this. | ||
22 | */ | ||
23 | |||
24 | #ifdef __ASSEMBLY__ | ||
25 | #define _UML_AC(X, Y) (Y) | ||
26 | #else | ||
27 | #define __UML_AC(X, Y) (X(Y)) | ||
28 | #define _UML_AC(X, Y) __UML_AC(X, Y) | ||
29 | #endif | ||
30 | |||
31 | #define STUB_START _UML_AC(, 0x100000) | ||
32 | #define STUB_CODE _UML_AC((unsigned long), STUB_START) | ||
33 | #define STUB_DATA _UML_AC((unsigned long), STUB_CODE + UM_KERN_PAGE_SIZE) | ||
34 | #define STUB_END _UML_AC((unsigned long), STUB_DATA + UM_KERN_PAGE_SIZE) | ||
35 | |||
36 | #ifndef __ASSEMBLY__ | ||
37 | |||
38 | #include "sysdep/ptrace.h" | ||
39 | |||
40 | struct cpu_task { | ||
41 | int pid; | ||
42 | void *task; | ||
43 | }; | ||
44 | |||
45 | extern struct cpu_task cpu_tasks[]; | ||
46 | |||
47 | extern unsigned long low_physmem; | ||
48 | extern unsigned long high_physmem; | ||
49 | extern unsigned long uml_physmem; | ||
50 | extern unsigned long uml_reserved; | ||
51 | extern unsigned long end_vm; | ||
52 | extern unsigned long start_vm; | ||
53 | extern unsigned long long highmem; | ||
54 | |||
55 | extern unsigned long _stext, _etext, _sdata, _edata, __bss_start, _end; | ||
56 | extern unsigned long _unprotected_end; | ||
57 | extern unsigned long brk_start; | ||
58 | |||
59 | extern unsigned long host_task_size; | ||
60 | |||
61 | extern int linux_main(int argc, char **argv); | ||
62 | |||
63 | extern void (*sig_info[])(int, struct uml_pt_regs *); | ||
64 | |||
65 | #endif | ||
66 | |||
67 | #endif | ||
diff --git a/arch/um/include/shared/chan_kern.h b/arch/um/include/shared/chan_kern.h new file mode 100644 index 000000000000..1e651457e049 --- /dev/null +++ b/arch/um/include/shared/chan_kern.h | |||
@@ -0,0 +1,50 @@ | |||
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 | struct list_head free_list; | ||
18 | struct line *line; | ||
19 | char *dev; | ||
20 | unsigned int primary:1; | ||
21 | unsigned int input:1; | ||
22 | unsigned int output:1; | ||
23 | unsigned int opened:1; | ||
24 | unsigned int enabled:1; | ||
25 | int fd; | ||
26 | const struct chan_ops *ops; | ||
27 | void *data; | ||
28 | }; | ||
29 | |||
30 | extern void chan_interrupt(struct list_head *chans, struct delayed_work *task, | ||
31 | struct tty_struct *tty, int irq); | ||
32 | extern int parse_chan_pair(char *str, struct line *line, int device, | ||
33 | const struct chan_opts *opts, char **error_out); | ||
34 | extern int write_chan(struct list_head *chans, const char *buf, int len, | ||
35 | int write_irq); | ||
36 | extern int console_write_chan(struct list_head *chans, const char *buf, | ||
37 | int len); | ||
38 | extern int console_open_chan(struct line *line, struct console *co); | ||
39 | extern void deactivate_chan(struct list_head *chans, int irq); | ||
40 | extern void reactivate_chan(struct list_head *chans, int irq); | ||
41 | extern void chan_enable_winch(struct list_head *chans, struct tty_struct *tty); | ||
42 | extern int enable_chan(struct line *line); | ||
43 | extern void close_chan(struct list_head *chans, int delay_free_irq); | ||
44 | extern int chan_window_size(struct list_head *chans, | ||
45 | unsigned short *rows_out, | ||
46 | unsigned short *cols_out); | ||
47 | extern int chan_config_string(struct list_head *chans, char *str, int size, | ||
48 | char **error_out); | ||
49 | |||
50 | #endif | ||
diff --git a/arch/um/include/shared/chan_user.h b/arch/um/include/shared/chan_user.h new file mode 100644 index 000000000000..9b9ced85b703 --- /dev/null +++ b/arch/um/include/shared/chan_user.h | |||
@@ -0,0 +1,55 @@ | |||
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 (*const announce)(char *dev_name, int dev); | ||
13 | char *xterm_title; | ||
14 | const int raw; | ||
15 | }; | ||
16 | |||
17 | enum chan_init_pri { INIT_STATIC, INIT_ALL, INIT_ONE }; | ||
18 | |||
19 | struct chan_ops { | ||
20 | char *type; | ||
21 | void *(*init)(char *, int, const struct chan_opts *); | ||
22 | int (*open)(int, int, int, void *, char **); | ||
23 | void (*close)(int, void *); | ||
24 | int (*read)(int, char *, void *); | ||
25 | int (*write)(int, const char *, int, void *); | ||
26 | int (*console_write)(int, const char *, int); | ||
27 | int (*window_size)(int, void *, unsigned short *, unsigned short *); | ||
28 | void (*free)(void *); | ||
29 | int winch; | ||
30 | }; | ||
31 | |||
32 | extern const struct chan_ops fd_ops, null_ops, port_ops, pts_ops, pty_ops, | ||
33 | tty_ops, xterm_ops; | ||
34 | |||
35 | extern void generic_close(int fd, void *unused); | ||
36 | extern int generic_read(int fd, char *c_out, void *unused); | ||
37 | extern int generic_write(int fd, const char *buf, int n, void *unused); | ||
38 | extern int generic_console_write(int fd, const char *buf, int n); | ||
39 | extern int generic_window_size(int fd, void *unused, unsigned short *rows_out, | ||
40 | unsigned short *cols_out); | ||
41 | extern void generic_free(void *data); | ||
42 | |||
43 | struct tty_struct; | ||
44 | extern void register_winch(int fd, struct tty_struct *tty); | ||
45 | extern void register_winch_irq(int fd, int tty_fd, int pid, | ||
46 | struct tty_struct *tty, unsigned long stack); | ||
47 | |||
48 | #define __channel_help(fn, prefix) \ | ||
49 | __uml_help(fn, prefix "[0-9]*=<channel description>\n" \ | ||
50 | " Attach a console or serial line to a host channel. See\n" \ | ||
51 | " http://user-mode-linux.sourceforge.net/old/input.html for a complete\n" \ | ||
52 | " description of this switch.\n\n" \ | ||
53 | ); | ||
54 | |||
55 | #endif | ||
diff --git a/arch/um/include/shared/common-offsets.h b/arch/um/include/shared/common-offsets.h new file mode 100644 index 000000000000..72009c7e3210 --- /dev/null +++ b/arch/um/include/shared/common-offsets.h | |||
@@ -0,0 +1,54 @@ | |||
1 | /* for use by sys-$SUBARCH/kernel-offsets.c */ | ||
2 | |||
3 | DEFINE(KERNEL_MADV_REMOVE, MADV_REMOVE); | ||
4 | |||
5 | OFFSET(HOST_TASK_REGS, task_struct, thread.regs); | ||
6 | OFFSET(HOST_TASK_PID, task_struct, pid); | ||
7 | |||
8 | DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE); | ||
9 | DEFINE(UM_KERN_PAGE_MASK, PAGE_MASK); | ||
10 | DEFINE(UM_KERN_PAGE_SHIFT, PAGE_SHIFT); | ||
11 | DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); | ||
12 | |||
13 | DEFINE_STR(UM_KERN_EMERG, KERN_EMERG); | ||
14 | DEFINE_STR(UM_KERN_ALERT, KERN_ALERT); | ||
15 | DEFINE_STR(UM_KERN_CRIT, KERN_CRIT); | ||
16 | DEFINE_STR(UM_KERN_ERR, KERN_ERR); | ||
17 | DEFINE_STR(UM_KERN_WARNING, KERN_WARNING); | ||
18 | DEFINE_STR(UM_KERN_NOTICE, KERN_NOTICE); | ||
19 | DEFINE_STR(UM_KERN_INFO, KERN_INFO); | ||
20 | DEFINE_STR(UM_KERN_DEBUG, KERN_DEBUG); | ||
21 | DEFINE_STR(UM_KERN_CONT, KERN_CONT); | ||
22 | |||
23 | DEFINE(UM_ELF_CLASS, ELF_CLASS); | ||
24 | DEFINE(UM_ELFCLASS32, ELFCLASS32); | ||
25 | DEFINE(UM_ELFCLASS64, ELFCLASS64); | ||
26 | |||
27 | DEFINE(UM_NR_CPUS, NR_CPUS); | ||
28 | |||
29 | DEFINE(UM_GFP_KERNEL, GFP_KERNEL); | ||
30 | DEFINE(UM_GFP_ATOMIC, GFP_ATOMIC); | ||
31 | |||
32 | /* For crypto assembler code. */ | ||
33 | DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx)); | ||
34 | |||
35 | DEFINE(UM_THREAD_SIZE, THREAD_SIZE); | ||
36 | |||
37 | DEFINE(UM_HZ, HZ); | ||
38 | |||
39 | DEFINE(UM_USEC_PER_SEC, USEC_PER_SEC); | ||
40 | DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); | ||
41 | DEFINE(UM_NSEC_PER_USEC, NSEC_PER_USEC); | ||
42 | |||
43 | #ifdef CONFIG_PRINTK | ||
44 | DEFINE(UML_CONFIG_PRINTK, CONFIG_PRINTK); | ||
45 | #endif | ||
46 | #ifdef CONFIG_NO_HZ | ||
47 | DEFINE(UML_CONFIG_NO_HZ, CONFIG_NO_HZ); | ||
48 | #endif | ||
49 | #ifdef CONFIG_UML_X86 | ||
50 | DEFINE(UML_CONFIG_UML_X86, CONFIG_UML_X86); | ||
51 | #endif | ||
52 | #ifdef CONFIG_64BIT | ||
53 | DEFINE(UML_CONFIG_64BIT, CONFIG_64BIT); | ||
54 | #endif | ||
diff --git a/arch/um/include/shared/elf_user.h b/arch/um/include/shared/elf_user.h new file mode 100644 index 000000000000..53516b637272 --- /dev/null +++ b/arch/um/include/shared/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/shared/frame_kern.h b/arch/um/include/shared/frame_kern.h new file mode 100644 index 000000000000..ce9514f57211 --- /dev/null +++ b/arch/um/include/shared/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/shared/init.h b/arch/um/include/shared/init.h new file mode 100644 index 000000000000..37dd097c16c0 --- /dev/null +++ b/arch/um/include/shared/init.h | |||
@@ -0,0 +1,151 @@ | |||
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 | #ifndef __KERNEL__ | ||
44 | #ifndef __section | ||
45 | # define __section(S) __attribute__ ((__section__(#S))) | ||
46 | #endif | ||
47 | |||
48 | #if __GNUC__ == 3 | ||
49 | |||
50 | #if __GNUC_MINOR__ >= 3 | ||
51 | # define __used __attribute__((__used__)) | ||
52 | #else | ||
53 | # define __used __attribute__((__unused__)) | ||
54 | #endif | ||
55 | |||
56 | #else | ||
57 | #if __GNUC__ == 4 | ||
58 | # define __used __attribute__((__used__)) | ||
59 | #endif | ||
60 | #endif | ||
61 | |||
62 | #else | ||
63 | #include <linux/compiler.h> | ||
64 | #endif | ||
65 | /* These are for everybody (although not all archs will actually | ||
66 | discard it in modules) */ | ||
67 | #define __init __section(.init.text) | ||
68 | #define __initdata __section(.init.data) | ||
69 | #define __exitdata __section(.exit.data) | ||
70 | #define __exit_call __used __section(.exitcall.exit) | ||
71 | |||
72 | #ifdef MODULE | ||
73 | #define __exit __section(.exit.text) | ||
74 | #else | ||
75 | #define __exit __used __section(.exit.text) | ||
76 | #endif | ||
77 | |||
78 | #endif | ||
79 | |||
80 | #ifndef MODULE | ||
81 | struct uml_param { | ||
82 | const char *str; | ||
83 | int (*setup_func)(char *, int *); | ||
84 | }; | ||
85 | |||
86 | extern initcall_t __uml_initcall_start, __uml_initcall_end; | ||
87 | extern initcall_t __uml_postsetup_start, __uml_postsetup_end; | ||
88 | extern const char *__uml_help_start, *__uml_help_end; | ||
89 | #endif | ||
90 | |||
91 | #define __uml_initcall(fn) \ | ||
92 | static initcall_t __uml_initcall_##fn __uml_init_call = fn | ||
93 | |||
94 | #define __uml_exitcall(fn) \ | ||
95 | static exitcall_t __uml_exitcall_##fn __uml_exit_call = fn | ||
96 | |||
97 | extern struct uml_param __uml_setup_start, __uml_setup_end; | ||
98 | |||
99 | #define __uml_postsetup(fn) \ | ||
100 | static initcall_t __uml_postsetup_##fn __uml_postsetup_call = fn | ||
101 | |||
102 | #define __non_empty_string(dummyname,string) \ | ||
103 | struct __uml_non_empty_string_struct_##dummyname \ | ||
104 | { \ | ||
105 | char _string[sizeof(string)-2]; \ | ||
106 | } | ||
107 | |||
108 | #ifndef MODULE | ||
109 | #define __uml_setup(str, fn, help...) \ | ||
110 | __non_empty_string(fn ##_setup, str); \ | ||
111 | __uml_help(fn, help); \ | ||
112 | static char __uml_setup_str_##fn[] __initdata = str; \ | ||
113 | static struct uml_param __uml_setup_##fn __uml_init_setup = { __uml_setup_str_##fn, fn } | ||
114 | #else | ||
115 | #define __uml_setup(str, fn, help...) \ | ||
116 | |||
117 | #endif | ||
118 | |||
119 | #define __uml_help(fn, help...) \ | ||
120 | __non_empty_string(fn ##__help, help); \ | ||
121 | static char __uml_help_str_##fn[] __initdata = help; \ | ||
122 | static const char *__uml_help_##fn __uml_setup_help = __uml_help_str_##fn | ||
123 | |||
124 | /* | ||
125 | * Mark functions and data as being only used at initialization | ||
126 | * or exit time. | ||
127 | */ | ||
128 | #define __uml_init_setup __used __section(.uml.setup.init) | ||
129 | #define __uml_setup_help __used __section(.uml.help.init) | ||
130 | #define __uml_init_call __used __section(.uml.initcall.init) | ||
131 | #define __uml_postsetup_call __used __section(.uml.postsetup.init) | ||
132 | #define __uml_exit_call __used __section(.uml.exitcall.exit) | ||
133 | |||
134 | #ifndef __KERNEL__ | ||
135 | |||
136 | #define __define_initcall(level,fn) \ | ||
137 | static initcall_t __initcall_##fn __used \ | ||
138 | __attribute__((__section__(".initcall" level ".init"))) = fn | ||
139 | |||
140 | /* Userspace initcalls shouldn't depend on anything in the kernel, so we'll | ||
141 | * make them run first. | ||
142 | */ | ||
143 | #define __initcall(fn) __define_initcall("1", fn) | ||
144 | |||
145 | #define __exitcall(fn) static exitcall_t __exitcall_##fn __exit_call = fn | ||
146 | |||
147 | #define __init_call __used __section(.initcall.init) | ||
148 | |||
149 | #endif | ||
150 | |||
151 | #endif /* _LINUX_UML_INIT_H */ | ||
diff --git a/arch/um/include/shared/initrd.h b/arch/um/include/shared/initrd.h new file mode 100644 index 000000000000..439b9a814985 --- /dev/null +++ b/arch/um/include/shared/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/shared/irq_kern.h b/arch/um/include/shared/irq_kern.h new file mode 100644 index 000000000000..fba3895274f9 --- /dev/null +++ b/arch/um/include/shared/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 | #include "asm/ptrace.h" | ||
11 | |||
12 | extern int um_request_irq(unsigned int irq, int fd, int type, | ||
13 | irq_handler_t handler, | ||
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/shared/irq_user.h b/arch/um/include/shared/irq_user.h new file mode 100644 index 000000000000..c6c784df2673 --- /dev/null +++ b/arch/um/include/shared/irq_user.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __IRQ_USER_H__ | ||
7 | #define __IRQ_USER_H__ | ||
8 | |||
9 | #include "sysdep/ptrace.h" | ||
10 | |||
11 | struct irq_fd { | ||
12 | struct irq_fd *next; | ||
13 | void *id; | ||
14 | int fd; | ||
15 | int type; | ||
16 | int irq; | ||
17 | int events; | ||
18 | int current_events; | ||
19 | }; | ||
20 | |||
21 | enum { IRQ_READ, IRQ_WRITE }; | ||
22 | |||
23 | extern void sigio_handler(int sig, struct uml_pt_regs *regs); | ||
24 | extern void free_irq_by_fd(int fd); | ||
25 | extern void reactivate_fd(int fd, int irqnum); | ||
26 | extern void deactivate_fd(int fd, int irqnum); | ||
27 | extern int deactivate_all_fds(void); | ||
28 | extern int activate_ipi(int fd, int pid); | ||
29 | |||
30 | #endif | ||
diff --git a/arch/um/include/shared/kern.h b/arch/um/include/shared/kern.h new file mode 100644 index 000000000000..4ce3fc650e57 --- /dev/null +++ b/arch/um/include/shared/kern.h | |||
@@ -0,0 +1,40 @@ | |||
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(const 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 void 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 | |||
39 | #endif | ||
40 | |||
diff --git a/arch/um/include/shared/kern_util.h b/arch/um/include/shared/kern_util.h new file mode 100644 index 000000000000..3c341222d252 --- /dev/null +++ b/arch/um/include/shared/kern_util.h | |||
@@ -0,0 +1,69 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __KERN_UTIL_H__ | ||
7 | #define __KERN_UTIL_H__ | ||
8 | |||
9 | #include "sysdep/ptrace.h" | ||
10 | #include "sysdep/faultinfo.h" | ||
11 | |||
12 | extern int uml_exitcode; | ||
13 | |||
14 | extern int ncpus; | ||
15 | extern int kmalloc_ok; | ||
16 | |||
17 | #define UML_ROUND_UP(addr) \ | ||
18 | ((((unsigned long) addr) + PAGE_SIZE - 1) & PAGE_MASK) | ||
19 | |||
20 | extern unsigned long alloc_stack(int order, int atomic); | ||
21 | extern void free_stack(unsigned long stack, int order); | ||
22 | |||
23 | extern int do_signal(void); | ||
24 | extern void copy_sc(struct uml_pt_regs *regs, void *from); | ||
25 | extern void interrupt_end(void); | ||
26 | extern void relay_signal(int sig, struct uml_pt_regs *regs); | ||
27 | |||
28 | extern unsigned long segv(struct faultinfo fi, unsigned long ip, | ||
29 | int is_user, struct uml_pt_regs *regs); | ||
30 | extern int handle_page_fault(unsigned long address, unsigned long ip, | ||
31 | int is_write, int is_user, int *code_out); | ||
32 | |||
33 | extern unsigned int do_IRQ(int irq, struct uml_pt_regs *regs); | ||
34 | extern int smp_sigio_handler(void); | ||
35 | extern void initial_thread_cb(void (*proc)(void *), void *arg); | ||
36 | extern int is_syscall(unsigned long addr); | ||
37 | extern void timer_handler(int sig, struct uml_pt_regs *regs); | ||
38 | |||
39 | extern void timer_handler(int sig, struct uml_pt_regs *regs); | ||
40 | |||
41 | extern int start_uml(void); | ||
42 | extern void paging_init(void); | ||
43 | |||
44 | extern void uml_cleanup(void); | ||
45 | extern void do_uml_exitcalls(void); | ||
46 | |||
47 | /* | ||
48 | * Are we disallowed to sleep? Used to choose between GFP_KERNEL and | ||
49 | * GFP_ATOMIC. | ||
50 | */ | ||
51 | extern int __cant_sleep(void); | ||
52 | extern void *get_current(void); | ||
53 | extern int copy_from_user_proc(void *to, void *from, int size); | ||
54 | extern int cpu(void); | ||
55 | extern char *uml_strdup(const char *string); | ||
56 | |||
57 | extern unsigned long to_irq_stack(unsigned long *mask_out); | ||
58 | extern unsigned long from_irq_stack(int nested); | ||
59 | |||
60 | extern void syscall_trace(struct uml_pt_regs *regs, int entryexit); | ||
61 | extern int singlestepping(void *t); | ||
62 | |||
63 | extern void segv_handler(int sig, struct uml_pt_regs *regs); | ||
64 | extern void bus_handler(int sig, struct uml_pt_regs *regs); | ||
65 | extern void winch(int sig, struct uml_pt_regs *regs); | ||
66 | extern void fatal_sigsegv(void) __attribute__ ((noreturn)); | ||
67 | |||
68 | |||
69 | #endif | ||
diff --git a/arch/um/include/shared/ldt.h b/arch/um/include/shared/ldt.h new file mode 100644 index 000000000000..a7f999a58774 --- /dev/null +++ b/arch/um/include/shared/ldt.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 Fujitsu Siemens Computers GmbH | ||
3 | * Licensed under the GPL | ||
4 | * | ||
5 | * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com> | ||
6 | */ | ||
7 | |||
8 | #ifndef __ASM_LDT_H | ||
9 | #define __ASM_LDT_H | ||
10 | |||
11 | #include <linux/mutex.h> | ||
12 | #include <sysdep/host_ldt.h> | ||
13 | |||
14 | extern void ldt_host_info(void); | ||
15 | |||
16 | #define LDT_PAGES_MAX \ | ||
17 | ((LDT_ENTRIES * LDT_ENTRY_SIZE)/PAGE_SIZE) | ||
18 | #define LDT_ENTRIES_PER_PAGE \ | ||
19 | (PAGE_SIZE/LDT_ENTRY_SIZE) | ||
20 | #define LDT_DIRECT_ENTRIES \ | ||
21 | ((LDT_PAGES_MAX*sizeof(void *))/LDT_ENTRY_SIZE) | ||
22 | |||
23 | struct ldt_entry { | ||
24 | __u32 a; | ||
25 | __u32 b; | ||
26 | }; | ||
27 | |||
28 | typedef struct uml_ldt { | ||
29 | int entry_count; | ||
30 | struct mutex lock; | ||
31 | union { | ||
32 | struct ldt_entry * pages[LDT_PAGES_MAX]; | ||
33 | struct ldt_entry entries[LDT_DIRECT_ENTRIES]; | ||
34 | } u; | ||
35 | } uml_ldt_t; | ||
36 | |||
37 | #endif | ||
diff --git a/arch/um/include/shared/line.h b/arch/um/include/shared/line.h new file mode 100644 index 000000000000..311a0d3d93af --- /dev/null +++ b/arch/um/include/shared/line.h | |||
@@ -0,0 +1,105 @@ | |||
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 "linux/spinlock.h" | ||
14 | #include "linux/mutex.h" | ||
15 | #include "chan_user.h" | ||
16 | #include "mconsole_kern.h" | ||
17 | |||
18 | /* There's only one modifiable field in this - .mc.list */ | ||
19 | struct line_driver { | ||
20 | const char *name; | ||
21 | const char *device_name; | ||
22 | const short major; | ||
23 | const short minor_start; | ||
24 | const short type; | ||
25 | const short subtype; | ||
26 | const int read_irq; | ||
27 | const char *read_irq_name; | ||
28 | const int write_irq; | ||
29 | const char *write_irq_name; | ||
30 | struct mc_device mc; | ||
31 | }; | ||
32 | |||
33 | struct line { | ||
34 | struct tty_struct *tty; | ||
35 | spinlock_t count_lock; | ||
36 | int valid; | ||
37 | |||
38 | char *init_str; | ||
39 | int init_pri; | ||
40 | struct list_head chan_list; | ||
41 | |||
42 | /*This lock is actually, mostly, local to*/ | ||
43 | spinlock_t lock; | ||
44 | int throttled; | ||
45 | /* Yes, this is a real circular buffer. | ||
46 | * XXX: And this should become a struct kfifo! | ||
47 | * | ||
48 | * buffer points to a buffer allocated on demand, of length | ||
49 | * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/ | ||
50 | char *buffer; | ||
51 | char *head; | ||
52 | char *tail; | ||
53 | |||
54 | int sigio; | ||
55 | struct delayed_work task; | ||
56 | const struct line_driver *driver; | ||
57 | int have_irq; | ||
58 | }; | ||
59 | |||
60 | #define LINE_INIT(str, d) \ | ||
61 | { .count_lock = __SPIN_LOCK_UNLOCKED((str).count_lock), \ | ||
62 | .init_str = str, \ | ||
63 | .init_pri = INIT_STATIC, \ | ||
64 | .valid = 1, \ | ||
65 | .lock = __SPIN_LOCK_UNLOCKED((str).lock), \ | ||
66 | .driver = d } | ||
67 | |||
68 | extern void line_close(struct tty_struct *tty, struct file * filp); | ||
69 | extern int line_open(struct line *lines, struct tty_struct *tty); | ||
70 | extern int line_setup(struct line *lines, unsigned int sizeof_lines, | ||
71 | char *init, char **error_out); | ||
72 | extern int line_write(struct tty_struct *tty, const unsigned char *buf, | ||
73 | int len); | ||
74 | extern int line_put_char(struct tty_struct *tty, unsigned char ch); | ||
75 | extern void line_set_termios(struct tty_struct *tty, struct ktermios * old); | ||
76 | extern int line_chars_in_buffer(struct tty_struct *tty); | ||
77 | extern void line_flush_buffer(struct tty_struct *tty); | ||
78 | extern void line_flush_chars(struct tty_struct *tty); | ||
79 | extern int line_write_room(struct tty_struct *tty); | ||
80 | extern int line_ioctl(struct tty_struct *tty, struct file * file, | ||
81 | unsigned int cmd, unsigned long arg); | ||
82 | extern void line_throttle(struct tty_struct *tty); | ||
83 | extern void line_unthrottle(struct tty_struct *tty); | ||
84 | |||
85 | extern char *add_xterm_umid(char *base); | ||
86 | extern int line_setup_irq(int fd, int input, int output, struct line *line, | ||
87 | void *data); | ||
88 | extern void line_close_chan(struct line *line); | ||
89 | extern struct tty_driver *register_lines(struct line_driver *line_driver, | ||
90 | const struct tty_operations *driver, | ||
91 | struct line *lines, int nlines); | ||
92 | extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts); | ||
93 | extern void close_lines(struct line *lines, int nlines); | ||
94 | |||
95 | extern int line_config(struct line *lines, unsigned int sizeof_lines, | ||
96 | char *str, const struct chan_opts *opts, | ||
97 | char **error_out); | ||
98 | extern int line_id(char **str, int *start_out, int *end_out); | ||
99 | extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n, | ||
100 | char **error_out); | ||
101 | extern int line_get_config(char *dev, struct line *lines, | ||
102 | unsigned int sizeof_lines, char *str, | ||
103 | int size, char **error_out); | ||
104 | |||
105 | #endif | ||
diff --git a/arch/um/include/shared/longjmp.h b/arch/um/include/shared/longjmp.h new file mode 100644 index 000000000000..e860bc5848e0 --- /dev/null +++ b/arch/um/include/shared/longjmp.h | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef __UML_LONGJMP_H | ||
2 | #define __UML_LONGJMP_H | ||
3 | |||
4 | #include "sysdep/archsetjmp.h" | ||
5 | #include "os.h" | ||
6 | |||
7 | extern int setjmp(jmp_buf); | ||
8 | extern void longjmp(jmp_buf, int); | ||
9 | |||
10 | #define UML_LONGJMP(buf, val) do { \ | ||
11 | longjmp(*buf, val); \ | ||
12 | } while(0) | ||
13 | |||
14 | #define UML_SETJMP(buf) ({ \ | ||
15 | int n; \ | ||
16 | volatile int enable; \ | ||
17 | enable = get_signals(); \ | ||
18 | n = setjmp(*buf); \ | ||
19 | if(n != 0) \ | ||
20 | set_signals(enable); \ | ||
21 | n; }) | ||
22 | |||
23 | #endif | ||
diff --git a/arch/um/include/shared/mconsole.h b/arch/um/include/shared/mconsole.h new file mode 100644 index 000000000000..c139ae1d6826 --- /dev/null +++ b/arch/um/include/shared/mconsole.h | |||
@@ -0,0 +1,98 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) | ||
3 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.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 | #include "sysdep/ptrace.h" | ||
16 | |||
17 | #define MCONSOLE_MAGIC (0xcafebabe) | ||
18 | #define MCONSOLE_MAX_DATA (512) | ||
19 | #define MCONSOLE_VERSION 2 | ||
20 | |||
21 | struct mconsole_request { | ||
22 | u32 magic; | ||
23 | u32 version; | ||
24 | u32 len; | ||
25 | char data[MCONSOLE_MAX_DATA]; | ||
26 | }; | ||
27 | |||
28 | struct mconsole_reply { | ||
29 | u32 err; | ||
30 | u32 more; | ||
31 | u32 len; | ||
32 | char data[MCONSOLE_MAX_DATA]; | ||
33 | }; | ||
34 | |||
35 | struct mconsole_notify { | ||
36 | u32 magic; | ||
37 | u32 version; | ||
38 | enum { MCONSOLE_SOCKET, MCONSOLE_PANIC, MCONSOLE_HANG, | ||
39 | MCONSOLE_USER_NOTIFY } type; | ||
40 | u32 len; | ||
41 | char data[MCONSOLE_MAX_DATA]; | ||
42 | }; | ||
43 | |||
44 | struct mc_request; | ||
45 | |||
46 | enum mc_context { MCONSOLE_INTR, MCONSOLE_PROC }; | ||
47 | |||
48 | struct mconsole_command | ||
49 | { | ||
50 | char *command; | ||
51 | void (*handler)(struct mc_request *req); | ||
52 | enum mc_context context; | ||
53 | }; | ||
54 | |||
55 | struct mc_request | ||
56 | { | ||
57 | int len; | ||
58 | int as_interrupt; | ||
59 | |||
60 | int originating_fd; | ||
61 | unsigned int originlen; | ||
62 | unsigned char origin[128]; /* sockaddr_un */ | ||
63 | |||
64 | struct mconsole_request request; | ||
65 | struct mconsole_command *cmd; | ||
66 | struct uml_pt_regs regs; | ||
67 | }; | ||
68 | |||
69 | extern char mconsole_socket_name[]; | ||
70 | |||
71 | extern int mconsole_unlink_socket(void); | ||
72 | extern int mconsole_reply_len(struct mc_request *req, const char *reply, | ||
73 | int len, int err, int more); | ||
74 | extern int mconsole_reply(struct mc_request *req, const char *str, int err, | ||
75 | int more); | ||
76 | |||
77 | extern void mconsole_version(struct mc_request *req); | ||
78 | extern void mconsole_help(struct mc_request *req); | ||
79 | extern void mconsole_halt(struct mc_request *req); | ||
80 | extern void mconsole_reboot(struct mc_request *req); | ||
81 | extern void mconsole_config(struct mc_request *req); | ||
82 | extern void mconsole_remove(struct mc_request *req); | ||
83 | extern void mconsole_sysrq(struct mc_request *req); | ||
84 | extern void mconsole_cad(struct mc_request *req); | ||
85 | extern void mconsole_stop(struct mc_request *req); | ||
86 | extern void mconsole_go(struct mc_request *req); | ||
87 | extern void mconsole_log(struct mc_request *req); | ||
88 | extern void mconsole_proc(struct mc_request *req); | ||
89 | extern void mconsole_stack(struct mc_request *req); | ||
90 | |||
91 | extern int mconsole_get_request(int fd, struct mc_request *req); | ||
92 | extern int mconsole_notify(char *sock_name, int type, const void *data, | ||
93 | int len); | ||
94 | extern char *mconsole_notify_socket(void); | ||
95 | extern void lock_notify(void); | ||
96 | extern void unlock_notify(void); | ||
97 | |||
98 | #endif | ||
diff --git a/arch/um/include/shared/mconsole_kern.h b/arch/um/include/shared/mconsole_kern.h new file mode 100644 index 000000000000..d2fe07e78958 --- /dev/null +++ b/arch/um/include/shared/mconsole_kern.h | |||
@@ -0,0 +1,52 @@ | |||
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/list.h" | ||
10 | #include "mconsole.h" | ||
11 | |||
12 | struct mconsole_entry { | ||
13 | struct list_head list; | ||
14 | struct mc_request request; | ||
15 | }; | ||
16 | |||
17 | /* All these methods are called in process context. */ | ||
18 | struct mc_device { | ||
19 | struct list_head list; | ||
20 | char *name; | ||
21 | int (*config)(char *, char **); | ||
22 | int (*get_config)(char *, char *, int, char **); | ||
23 | int (*id)(char **, int *, int *); | ||
24 | int (*remove)(int, char **); | ||
25 | }; | ||
26 | |||
27 | #define CONFIG_CHUNK(str, size, current, chunk, end) \ | ||
28 | do { \ | ||
29 | current += strlen(chunk); \ | ||
30 | if(current >= size) \ | ||
31 | str = NULL; \ | ||
32 | if(str != NULL){ \ | ||
33 | strcpy(str, chunk); \ | ||
34 | str += strlen(chunk); \ | ||
35 | } \ | ||
36 | if(end) \ | ||
37 | current++; \ | ||
38 | } while(0) | ||
39 | |||
40 | #ifdef CONFIG_MCONSOLE | ||
41 | |||
42 | extern void mconsole_register_dev(struct mc_device *new); | ||
43 | |||
44 | #else | ||
45 | |||
46 | static inline void mconsole_register_dev(struct mc_device *new) | ||
47 | { | ||
48 | } | ||
49 | |||
50 | #endif | ||
51 | |||
52 | #endif | ||
diff --git a/arch/um/include/shared/mem.h b/arch/um/include/shared/mem.h new file mode 100644 index 000000000000..5cd40e99e8d5 --- /dev/null +++ b/arch/um/include/shared/mem.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __MEM_H__ | ||
7 | #define __MEM_H__ | ||
8 | |||
9 | extern int phys_mapping(unsigned long phys, unsigned long long *offset_out); | ||
10 | |||
11 | extern unsigned long uml_physmem; | ||
12 | static inline unsigned long to_phys(void *virt) | ||
13 | { | ||
14 | return(((unsigned long) virt) - uml_physmem); | ||
15 | } | ||
16 | |||
17 | static inline void *to_virt(unsigned long phys) | ||
18 | { | ||
19 | return((void *) uml_physmem + phys); | ||
20 | } | ||
21 | |||
22 | #endif | ||
diff --git a/arch/um/include/shared/mem_kern.h b/arch/um/include/shared/mem_kern.h new file mode 100644 index 000000000000..cb7e196d366b --- /dev/null +++ b/arch/um/include/shared/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/shared/mem_user.h b/arch/um/include/shared/mem_user.h new file mode 100644 index 000000000000..46384acd547b --- /dev/null +++ b/arch/um/include/shared/mem_user.h | |||
@@ -0,0 +1,62 @@ | |||
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 int init_mem_user(void); | ||
50 | extern void setup_memory(void *entry); | ||
51 | extern unsigned long find_iomem(char *driver, unsigned long *len_out); | ||
52 | extern int init_maps(unsigned long physmem, unsigned long iomem, | ||
53 | unsigned long highmem); | ||
54 | extern unsigned long get_vm(unsigned long len); | ||
55 | extern void setup_physmem(unsigned long start, unsigned long usable, | ||
56 | unsigned long len, unsigned long long highmem); | ||
57 | extern void add_iomem(char *name, int fd, unsigned long size); | ||
58 | extern unsigned long phys_offset(unsigned long phys); | ||
59 | extern void map_memory(unsigned long virt, unsigned long phys, | ||
60 | unsigned long len, int r, int w, int x); | ||
61 | |||
62 | #endif | ||
diff --git a/arch/um/include/shared/net_kern.h b/arch/um/include/shared/net_kern.h new file mode 100644 index 000000000000..d843c7924a7c --- /dev/null +++ b/arch/um/include/shared/net_kern.h | |||
@@ -0,0 +1,70 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 2007 Jeff Dike (jdike@{addtoit,linux.intel}.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/platform_device.h> | ||
11 | #include <linux/skbuff.h> | ||
12 | #include <linux/socket.h> | ||
13 | #include <linux/list.h> | ||
14 | #include <linux/workqueue.h> | ||
15 | |||
16 | struct uml_net { | ||
17 | struct list_head list; | ||
18 | struct net_device *dev; | ||
19 | struct platform_device pdev; | ||
20 | int index; | ||
21 | unsigned char mac[ETH_ALEN]; | ||
22 | }; | ||
23 | |||
24 | struct uml_net_private { | ||
25 | struct list_head list; | ||
26 | spinlock_t lock; | ||
27 | struct net_device *dev; | ||
28 | struct timer_list tl; | ||
29 | struct net_device_stats stats; | ||
30 | struct work_struct work; | ||
31 | int fd; | ||
32 | unsigned char mac[ETH_ALEN]; | ||
33 | int max_packet; | ||
34 | unsigned short (*protocol)(struct sk_buff *); | ||
35 | int (*open)(void *); | ||
36 | void (*close)(int, void *); | ||
37 | void (*remove)(void *); | ||
38 | int (*read)(int, struct sk_buff *skb, struct uml_net_private *); | ||
39 | int (*write)(int, struct sk_buff *skb, struct uml_net_private *); | ||
40 | |||
41 | void (*add_address)(unsigned char *, unsigned char *, void *); | ||
42 | void (*delete_address)(unsigned char *, unsigned char *, void *); | ||
43 | char user[0]; | ||
44 | }; | ||
45 | |||
46 | struct net_kern_info { | ||
47 | void (*init)(struct net_device *, void *); | ||
48 | unsigned short (*protocol)(struct sk_buff *); | ||
49 | int (*read)(int, struct sk_buff *skb, struct uml_net_private *); | ||
50 | int (*write)(int, struct sk_buff *skb, struct uml_net_private *); | ||
51 | }; | ||
52 | |||
53 | struct transport { | ||
54 | struct list_head list; | ||
55 | const char *name; | ||
56 | int (* const setup)(char *, char **, void *); | ||
57 | const struct net_user_info *user; | ||
58 | const struct net_kern_info *kern; | ||
59 | const int private_size; | ||
60 | const int setup_size; | ||
61 | }; | ||
62 | |||
63 | extern struct net_device *ether_init(int); | ||
64 | extern unsigned short ether_protocol(struct sk_buff *); | ||
65 | extern int tap_setup_common(char *str, char *type, char **dev_name, | ||
66 | char **mac_out, char **gate_addr); | ||
67 | extern void register_transport(struct transport *new); | ||
68 | extern unsigned short eth_protocol(struct sk_buff *skb); | ||
69 | |||
70 | #endif | ||
diff --git a/arch/um/include/shared/net_user.h b/arch/um/include/shared/net_user.h new file mode 100644 index 000000000000..63bee158cd8e --- /dev/null +++ b/arch/um/include/shared/net_user.h | |||
@@ -0,0 +1,53 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.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 | int (*init)(void *, void *); | ||
18 | int (*open)(void *); | ||
19 | void (*close)(int, void *); | ||
20 | void (*remove)(void *); | ||
21 | void (*add_address)(unsigned char *, unsigned char *, void *); | ||
22 | void (*delete_address)(unsigned char *, unsigned char *, void *); | ||
23 | int max_packet; | ||
24 | int mtu; | ||
25 | }; | ||
26 | |||
27 | extern void ether_user_init(void *data, void *dev); | ||
28 | extern void iter_addresses(void *d, void (*cb)(unsigned char *, | ||
29 | unsigned char *, void *), | ||
30 | void *arg); | ||
31 | |||
32 | extern void *get_output_buffer(int *len_out); | ||
33 | extern void free_output_buffer(void *buffer); | ||
34 | |||
35 | extern int tap_open_common(void *dev, char *gate_addr); | ||
36 | extern void tap_check_ips(char *gate_addr, unsigned char *eth_addr); | ||
37 | |||
38 | extern void read_output(int fd, char *output_out, int len); | ||
39 | |||
40 | extern int net_read(int fd, void *buf, int len); | ||
41 | extern int net_recvfrom(int fd, void *buf, int len); | ||
42 | extern int net_write(int fd, void *buf, int len); | ||
43 | extern int net_send(int fd, void *buf, int len); | ||
44 | extern int net_sendto(int fd, void *buf, int len, void *to, int sock_len); | ||
45 | |||
46 | extern void open_addr(unsigned char *addr, unsigned char *netmask, void *arg); | ||
47 | extern void close_addr(unsigned char *addr, unsigned char *netmask, void *arg); | ||
48 | |||
49 | extern char *split_if_spec(char *str, ...); | ||
50 | |||
51 | extern int dev_netmask(void *d, void *m); | ||
52 | |||
53 | #endif | ||
diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h new file mode 100644 index 000000000000..cd40fddcf99d --- /dev/null +++ b/arch/um/include/shared/os.h | |||
@@ -0,0 +1,303 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __OS_H__ | ||
7 | #define __OS_H__ | ||
8 | |||
9 | #include <stdarg.h> | ||
10 | #include "irq_user.h" | ||
11 | #include "longjmp.h" | ||
12 | #include "mm_id.h" | ||
13 | #include "sysdep/tls.h" | ||
14 | |||
15 | #define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR)) | ||
16 | |||
17 | #define OS_TYPE_FILE 1 | ||
18 | #define OS_TYPE_DIR 2 | ||
19 | #define OS_TYPE_SYMLINK 3 | ||
20 | #define OS_TYPE_CHARDEV 4 | ||
21 | #define OS_TYPE_BLOCKDEV 5 | ||
22 | #define OS_TYPE_FIFO 6 | ||
23 | #define OS_TYPE_SOCK 7 | ||
24 | |||
25 | /* os_access() flags */ | ||
26 | #define OS_ACC_F_OK 0 /* Test for existence. */ | ||
27 | #define OS_ACC_X_OK 1 /* Test for execute permission. */ | ||
28 | #define OS_ACC_W_OK 2 /* Test for write permission. */ | ||
29 | #define OS_ACC_R_OK 4 /* Test for read permission. */ | ||
30 | #define OS_ACC_RW_OK (OS_ACC_W_OK | OS_ACC_R_OK) /* Test for RW permission */ | ||
31 | |||
32 | /* | ||
33 | * types taken from stat_file() in hostfs_user.c | ||
34 | * (if they are wrong here, they are wrong there...). | ||
35 | */ | ||
36 | struct uml_stat { | ||
37 | int ust_dev; /* device */ | ||
38 | unsigned long long ust_ino; /* inode */ | ||
39 | int ust_mode; /* protection */ | ||
40 | int ust_nlink; /* number of hard links */ | ||
41 | int ust_uid; /* user ID of owner */ | ||
42 | int ust_gid; /* group ID of owner */ | ||
43 | unsigned long long ust_size; /* total size, in bytes */ | ||
44 | int ust_blksize; /* blocksize for filesystem I/O */ | ||
45 | unsigned long long ust_blocks; /* number of blocks allocated */ | ||
46 | unsigned long ust_atime; /* time of last access */ | ||
47 | unsigned long ust_mtime; /* time of last modification */ | ||
48 | unsigned long ust_ctime; /* time of last change */ | ||
49 | }; | ||
50 | |||
51 | struct openflags { | ||
52 | unsigned int r : 1; | ||
53 | unsigned int w : 1; | ||
54 | unsigned int s : 1; /* O_SYNC */ | ||
55 | unsigned int c : 1; /* O_CREAT */ | ||
56 | unsigned int t : 1; /* O_TRUNC */ | ||
57 | unsigned int a : 1; /* O_APPEND */ | ||
58 | unsigned int e : 1; /* O_EXCL */ | ||
59 | unsigned int cl : 1; /* FD_CLOEXEC */ | ||
60 | }; | ||
61 | |||
62 | #define OPENFLAGS() ((struct openflags) { .r = 0, .w = 0, .s = 0, .c = 0, \ | ||
63 | .t = 0, .a = 0, .e = 0, .cl = 0 }) | ||
64 | |||
65 | static inline struct openflags of_read(struct openflags flags) | ||
66 | { | ||
67 | flags.r = 1; | ||
68 | return flags; | ||
69 | } | ||
70 | |||
71 | static inline struct openflags of_write(struct openflags flags) | ||
72 | { | ||
73 | flags.w = 1; | ||
74 | return flags; | ||
75 | } | ||
76 | |||
77 | static inline struct openflags of_rdwr(struct openflags flags) | ||
78 | { | ||
79 | return of_read(of_write(flags)); | ||
80 | } | ||
81 | |||
82 | static inline struct openflags of_set_rw(struct openflags flags, int r, int w) | ||
83 | { | ||
84 | flags.r = r; | ||
85 | flags.w = w; | ||
86 | return flags; | ||
87 | } | ||
88 | |||
89 | static inline struct openflags of_sync(struct openflags flags) | ||
90 | { | ||
91 | flags.s = 1; | ||
92 | return flags; | ||
93 | } | ||
94 | |||
95 | static inline struct openflags of_create(struct openflags flags) | ||
96 | { | ||
97 | flags.c = 1; | ||
98 | return flags; | ||
99 | } | ||
100 | |||
101 | static inline struct openflags of_trunc(struct openflags flags) | ||
102 | { | ||
103 | flags.t = 1; | ||
104 | return flags; | ||
105 | } | ||
106 | |||
107 | static inline struct openflags of_append(struct openflags flags) | ||
108 | { | ||
109 | flags.a = 1; | ||
110 | return flags; | ||
111 | } | ||
112 | |||
113 | static inline struct openflags of_excl(struct openflags flags) | ||
114 | { | ||
115 | flags.e = 1; | ||
116 | return flags; | ||
117 | } | ||
118 | |||
119 | static inline struct openflags of_cloexec(struct openflags flags) | ||
120 | { | ||
121 | flags.cl = 1; | ||
122 | return flags; | ||
123 | } | ||
124 | |||
125 | /* file.c */ | ||
126 | extern int os_stat_file(const char *file_name, struct uml_stat *buf); | ||
127 | extern int os_stat_fd(const int fd, struct uml_stat *buf); | ||
128 | extern int os_access(const char *file, int mode); | ||
129 | extern int os_set_exec_close(int fd); | ||
130 | extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg); | ||
131 | extern int os_get_ifname(int fd, char *namebuf); | ||
132 | extern int os_set_slip(int fd); | ||
133 | extern int os_mode_fd(int fd, int mode); | ||
134 | |||
135 | extern int os_seek_file(int fd, unsigned long long offset); | ||
136 | extern int os_open_file(const 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(const char *file, unsigned long long *size_out); | ||
140 | extern int os_file_modtime(const 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); | ||
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(const 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(const char *name); | ||
152 | extern int os_file_type(char *file); | ||
153 | extern int os_file_mode(const char *file, struct openflags *mode_out); | ||
154 | extern int os_lock_file(int fd, int excl); | ||
155 | extern void os_flush_stdout(void); | ||
156 | extern int os_stat_filesystem(char *path, long *bsize_out, | ||
157 | long long *blocks_out, long long *bfree_out, | ||
158 | long long *bavail_out, long long *files_out, | ||
159 | long long *ffree_out, void *fsid_out, | ||
160 | int fsid_size, long *namelen_out, | ||
161 | long *spare_out); | ||
162 | extern int os_change_dir(char *dir); | ||
163 | extern int os_fchange_dir(int fd); | ||
164 | |||
165 | /* start_up.c */ | ||
166 | extern void os_early_checks(void); | ||
167 | extern void can_do_skas(void); | ||
168 | extern void os_check_bugs(void); | ||
169 | extern void check_host_supports_tls(int *supports_tls, int *tls_min); | ||
170 | |||
171 | /* mem.c */ | ||
172 | extern int create_mem_file(unsigned long long len); | ||
173 | |||
174 | /* process.c */ | ||
175 | extern unsigned long os_process_pc(int pid); | ||
176 | extern int os_process_parent(int pid); | ||
177 | extern void os_stop_process(int pid); | ||
178 | extern void os_kill_process(int pid, int reap_child); | ||
179 | extern void os_kill_ptraced_process(int pid, int reap_child); | ||
180 | extern long os_ptrace_ldt(long pid, long addr, long data); | ||
181 | |||
182 | extern int os_getpid(void); | ||
183 | extern int os_getpgrp(void); | ||
184 | |||
185 | extern void init_new_thread_signals(void); | ||
186 | extern int run_kernel_thread(int (*fn)(void *), void *arg, jmp_buf **jmp_ptr); | ||
187 | |||
188 | extern int os_map_memory(void *virt, int fd, unsigned long long off, | ||
189 | unsigned long len, int r, int w, int x); | ||
190 | extern int os_protect_memory(void *addr, unsigned long len, | ||
191 | int r, int w, int x); | ||
192 | extern int os_unmap_memory(void *addr, int len); | ||
193 | extern int os_drop_memory(void *addr, int length); | ||
194 | extern int can_drop_memory(void); | ||
195 | extern void os_flush_stdout(void); | ||
196 | |||
197 | /* uaccess.c */ | ||
198 | extern unsigned long __do_user_copy(void *to, const void *from, int n, | ||
199 | void **fault_addr, jmp_buf **fault_catcher, | ||
200 | void (*op)(void *to, const void *from, | ||
201 | int n), int *faulted_out); | ||
202 | |||
203 | /* execvp.c */ | ||
204 | extern int execvp_noalloc(char *buf, const char *file, char *const argv[]); | ||
205 | /* helper.c */ | ||
206 | extern int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv); | ||
207 | extern int run_helper_thread(int (*proc)(void *), void *arg, | ||
208 | unsigned int flags, unsigned long *stack_out); | ||
209 | extern int helper_wait(int pid); | ||
210 | |||
211 | |||
212 | /* tls.c */ | ||
213 | extern int os_set_thread_area(user_desc_t *info, int pid); | ||
214 | extern int os_get_thread_area(user_desc_t *info, int pid); | ||
215 | |||
216 | /* umid.c */ | ||
217 | extern int umid_file_name(char *name, char *buf, int len); | ||
218 | extern int set_umid(char *name); | ||
219 | extern char *get_umid(void); | ||
220 | |||
221 | /* signal.c */ | ||
222 | extern void timer_init(void); | ||
223 | extern void set_sigstack(void *sig_stack, int size); | ||
224 | extern void remove_sigstack(void); | ||
225 | extern void set_handler(int sig, void (*handler)(int), int flags, ...); | ||
226 | extern int change_sig(int signal, int on); | ||
227 | extern void block_signals(void); | ||
228 | extern void unblock_signals(void); | ||
229 | extern int get_signals(void); | ||
230 | extern int set_signals(int enable); | ||
231 | |||
232 | /* util.c */ | ||
233 | extern void stack_protections(unsigned long address); | ||
234 | extern int raw(int fd); | ||
235 | extern void setup_machinename(char *machine_out); | ||
236 | extern void setup_hostinfo(char *buf, int len); | ||
237 | extern void os_dump_core(void) __attribute__ ((noreturn)); | ||
238 | |||
239 | /* time.c */ | ||
240 | extern void idle_sleep(unsigned long long nsecs); | ||
241 | extern int set_interval(void); | ||
242 | extern int timer_one_shot(int ticks); | ||
243 | extern long long disable_timer(void); | ||
244 | extern void uml_idle_timer(void); | ||
245 | extern long long os_nsecs(void); | ||
246 | |||
247 | /* skas/mem.c */ | ||
248 | extern long run_syscall_stub(struct mm_id * mm_idp, | ||
249 | int syscall, unsigned long *args, long expected, | ||
250 | void **addr, int done); | ||
251 | extern long syscall_stub_data(struct mm_id * mm_idp, | ||
252 | unsigned long *data, int data_count, | ||
253 | void **addr, void **stub_addr); | ||
254 | extern int map(struct mm_id * mm_idp, unsigned long virt, | ||
255 | unsigned long len, int prot, int phys_fd, | ||
256 | unsigned long long offset, int done, void **data); | ||
257 | extern int unmap(struct mm_id * mm_idp, unsigned long addr, unsigned long len, | ||
258 | int done, void **data); | ||
259 | extern int protect(struct mm_id * mm_idp, unsigned long addr, | ||
260 | unsigned long len, unsigned int prot, int done, void **data); | ||
261 | |||
262 | /* skas/process.c */ | ||
263 | extern int is_skas_winch(int pid, int fd, void *data); | ||
264 | extern int start_userspace(unsigned long stub_stack); | ||
265 | extern int copy_context_skas0(unsigned long stack, int pid); | ||
266 | extern void userspace(struct uml_pt_regs *regs); | ||
267 | extern int map_stub_pages(int fd, unsigned long code, unsigned long data, | ||
268 | unsigned long stack); | ||
269 | extern void new_thread(void *stack, jmp_buf *buf, void (*handler)(void)); | ||
270 | extern void switch_threads(jmp_buf *me, jmp_buf *you); | ||
271 | extern int start_idle_thread(void *stack, jmp_buf *switch_buf); | ||
272 | extern void initial_thread_cb_skas(void (*proc)(void *), | ||
273 | void *arg); | ||
274 | extern void halt_skas(void); | ||
275 | extern void reboot_skas(void); | ||
276 | |||
277 | /* irq.c */ | ||
278 | extern int os_waiting_for_events(struct irq_fd *active_fds); | ||
279 | extern int os_create_pollfd(int fd, int events, void *tmp_pfd, int size_tmpfds); | ||
280 | extern void os_free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg, | ||
281 | struct irq_fd *active_fds, struct irq_fd ***last_irq_ptr2); | ||
282 | extern void os_free_irq_later(struct irq_fd *active_fds, | ||
283 | int irq, void *dev_id); | ||
284 | extern int os_get_pollfd(int i); | ||
285 | extern void os_set_pollfd(int i, int fd); | ||
286 | extern void os_set_ioignore(void); | ||
287 | |||
288 | /* sigio.c */ | ||
289 | extern int add_sigio_fd(int fd); | ||
290 | extern int ignore_sigio_fd(int fd); | ||
291 | extern void maybe_sigio_broken(int fd, int read); | ||
292 | extern void sigio_broken(int fd, int read); | ||
293 | |||
294 | /* sys-x86_64/prctl.c */ | ||
295 | extern int os_arch_prctl(int pid, int code, unsigned long *addr); | ||
296 | |||
297 | /* tty.c */ | ||
298 | extern int get_pty(void); | ||
299 | |||
300 | /* sys-$ARCH/task_size.c */ | ||
301 | extern unsigned long os_get_top_address(void); | ||
302 | |||
303 | #endif | ||
diff --git a/arch/um/include/shared/process.h b/arch/um/include/shared/process.h new file mode 100644 index 000000000000..bb873a51262e --- /dev/null +++ b/arch/um/include/shared/process.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __PROCESS_H__ | ||
7 | #define __PROCESS_H__ | ||
8 | |||
9 | #include <signal.h> | ||
10 | |||
11 | /* Copied from linux/compiler-gcc.h since we can't include it directly */ | ||
12 | #define barrier() __asm__ __volatile__("": : :"memory") | ||
13 | |||
14 | extern void sig_handler(int sig, struct sigcontext *sc); | ||
15 | extern void alarm_handler(int sig, struct sigcontext *sc); | ||
16 | |||
17 | #endif | ||
diff --git a/arch/um/include/shared/ptrace_user.h b/arch/um/include/shared/ptrace_user.h new file mode 100644 index 000000000000..4bce6e012889 --- /dev/null +++ b/arch/um/include/shared/ptrace_user.h | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.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 | |||
14 | /* syscall emulation path in ptrace */ | ||
15 | |||
16 | #ifndef PTRACE_SYSEMU | ||
17 | #define PTRACE_SYSEMU 31 | ||
18 | #endif | ||
19 | #ifndef PTRACE_SYSEMU_SINGLESTEP | ||
20 | #define PTRACE_SYSEMU_SINGLESTEP 32 | ||
21 | #endif | ||
22 | |||
23 | /* On architectures, that started to support PTRACE_O_TRACESYSGOOD | ||
24 | * in linux 2.4, there are two different definitions of | ||
25 | * PTRACE_SETOPTIONS: linux 2.4 uses 21 while linux 2.6 uses 0x4200. | ||
26 | * For binary compatibility, 2.6 also supports the old "21", named | ||
27 | * PTRACE_OLDSETOPTION. On these architectures, UML always must use | ||
28 | * "21", to ensure the kernel runs on 2.4 and 2.6 host without | ||
29 | * recompilation. So, we use PTRACE_OLDSETOPTIONS in UML. | ||
30 | * We also want to be able to build the kernel on 2.4, which doesn't | ||
31 | * have PTRACE_OLDSETOPTIONS. So, if it is missing, we declare | ||
32 | * PTRACE_OLDSETOPTIONS to to be the same as PTRACE_SETOPTIONS. | ||
33 | * | ||
34 | * On architectures, that start to support PTRACE_O_TRACESYSGOOD on | ||
35 | * linux 2.6, PTRACE_OLDSETOPTIONS never is defined, and also isn't | ||
36 | * supported by the host kernel. In that case, our trick lets us use | ||
37 | * the new 0x4200 with the name PTRACE_OLDSETOPTIONS. | ||
38 | */ | ||
39 | #ifndef PTRACE_OLDSETOPTIONS | ||
40 | #define PTRACE_OLDSETOPTIONS PTRACE_SETOPTIONS | ||
41 | #endif | ||
42 | |||
43 | void set_using_sysemu(int value); | ||
44 | int get_using_sysemu(void); | ||
45 | extern int sysemu_supported; | ||
46 | |||
47 | #define SELECT_PTRACE_OPERATION(sysemu_mode, singlestep_mode) \ | ||
48 | (((int[3][3] ) { \ | ||
49 | { PTRACE_SYSCALL, PTRACE_SYSCALL, PTRACE_SINGLESTEP }, \ | ||
50 | { PTRACE_SYSEMU, PTRACE_SYSEMU, PTRACE_SINGLESTEP }, \ | ||
51 | { PTRACE_SYSEMU, PTRACE_SYSEMU_SINGLESTEP, \ | ||
52 | PTRACE_SYSEMU_SINGLESTEP } }) \ | ||
53 | [sysemu_mode][singlestep_mode]) | ||
54 | |||
55 | #endif | ||
diff --git a/arch/um/include/shared/registers.h b/arch/um/include/shared/registers.h new file mode 100644 index 000000000000..b0b4589e0ebc --- /dev/null +++ b/arch/um/include/shared/registers.h | |||
@@ -0,0 +1,24 @@ | |||
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 | #include "sysdep/archsetjmp.h" | ||
11 | |||
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 int save_fpx_registers(int pid, unsigned long *fp_regs); | ||
15 | extern int restore_fpx_registers(int pid, unsigned long *fp_regs); | ||
16 | extern int save_registers(int pid, struct uml_pt_regs *regs); | ||
17 | extern int restore_registers(int pid, struct uml_pt_regs *regs); | ||
18 | extern int init_registers(int pid); | ||
19 | extern void get_safe_registers(unsigned long *regs); | ||
20 | extern unsigned long get_thread_reg(int reg, jmp_buf *buf); | ||
21 | extern int get_fp_registers(int pid, unsigned long *regs); | ||
22 | extern int put_fp_registers(int pid, unsigned long *regs); | ||
23 | |||
24 | #endif | ||
diff --git a/arch/um/include/shared/sigio.h b/arch/um/include/shared/sigio.h new file mode 100644 index 000000000000..434f1a9ae4b3 --- /dev/null +++ b/arch/um/include/shared/sigio.h | |||
@@ -0,0 +1,14 @@ | |||
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 void sigio_lock(void); | ||
12 | extern void sigio_unlock(void); | ||
13 | |||
14 | #endif | ||
diff --git a/arch/um/include/shared/skas/mm_id.h b/arch/um/include/shared/skas/mm_id.h new file mode 100644 index 000000000000..48dd0989ddaa --- /dev/null +++ b/arch/um/include/shared/skas/mm_id.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2005 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __MM_ID_H | ||
7 | #define __MM_ID_H | ||
8 | |||
9 | struct mm_id { | ||
10 | union { | ||
11 | int mm_fd; | ||
12 | int pid; | ||
13 | } u; | ||
14 | unsigned long stack; | ||
15 | }; | ||
16 | |||
17 | #endif | ||
diff --git a/arch/um/include/shared/skas/proc_mm.h b/arch/um/include/shared/skas/proc_mm.h new file mode 100644 index 000000000000..902809209603 --- /dev/null +++ b/arch/um/include/shared/skas/proc_mm.h | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SKAS_PROC_MM_H | ||
7 | #define __SKAS_PROC_MM_H | ||
8 | |||
9 | #define MM_MMAP 54 | ||
10 | #define MM_MUNMAP 55 | ||
11 | #define MM_MPROTECT 56 | ||
12 | #define MM_COPY_SEGMENTS 57 | ||
13 | |||
14 | struct mm_mmap { | ||
15 | unsigned long addr; | ||
16 | unsigned long len; | ||
17 | unsigned long prot; | ||
18 | unsigned long flags; | ||
19 | unsigned long fd; | ||
20 | unsigned long offset; | ||
21 | }; | ||
22 | |||
23 | struct mm_munmap { | ||
24 | unsigned long addr; | ||
25 | unsigned long len; | ||
26 | }; | ||
27 | |||
28 | struct mm_mprotect { | ||
29 | unsigned long addr; | ||
30 | unsigned long len; | ||
31 | unsigned int prot; | ||
32 | }; | ||
33 | |||
34 | struct proc_mm_op { | ||
35 | int op; | ||
36 | union { | ||
37 | struct mm_mmap mmap; | ||
38 | struct mm_munmap munmap; | ||
39 | struct mm_mprotect mprotect; | ||
40 | int copy_segments; | ||
41 | } u; | ||
42 | }; | ||
43 | |||
44 | #endif | ||
diff --git a/arch/um/include/shared/skas/skas.h b/arch/um/include/shared/skas/skas.h new file mode 100644 index 000000000000..64d2c7443306 --- /dev/null +++ b/arch/um/include/shared/skas/skas.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SKAS_H | ||
7 | #define __SKAS_H | ||
8 | |||
9 | #include "sysdep/ptrace.h" | ||
10 | |||
11 | extern int userspace_pid[]; | ||
12 | extern int proc_mm, ptrace_faultinfo, ptrace_ldt; | ||
13 | extern int skas_needs_stub; | ||
14 | |||
15 | extern int user_thread(unsigned long stack, int flags); | ||
16 | extern void new_thread_handler(void); | ||
17 | extern void handle_syscall(struct uml_pt_regs *regs); | ||
18 | extern int new_mm(unsigned long stack); | ||
19 | extern long execute_syscall_skas(void *r); | ||
20 | extern unsigned long current_stub_stack(void); | ||
21 | |||
22 | #endif | ||
diff --git a/arch/um/include/shared/skas/stub-data.h b/arch/um/include/shared/skas/stub-data.h new file mode 100644 index 000000000000..f6ed92c3727d --- /dev/null +++ b/arch/um/include/shared/skas/stub-data.h | |||
@@ -0,0 +1,18 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2005 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __STUB_DATA_H | ||
7 | #define __STUB_DATA_H | ||
8 | |||
9 | #include <sys/time.h> | ||
10 | |||
11 | struct stub_data { | ||
12 | long offset; | ||
13 | int fd; | ||
14 | struct itimerval timer; | ||
15 | long err; | ||
16 | }; | ||
17 | |||
18 | #endif | ||
diff --git a/arch/um/include/shared/skas_ptrace.h b/arch/um/include/shared/skas_ptrace.h new file mode 100644 index 000000000000..3d31bbacd016 --- /dev/null +++ b/arch/um/include/shared/skas_ptrace.h | |||
@@ -0,0 +1,14 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SKAS_PTRACE_H | ||
7 | #define __SKAS_PTRACE_H | ||
8 | |||
9 | #define PTRACE_FAULTINFO 52 | ||
10 | #define PTRACE_SWITCH_MM 55 | ||
11 | |||
12 | #include "sysdep/skas_ptrace.h" | ||
13 | |||
14 | #endif | ||
diff --git a/arch/um/include/shared/skas_ptregs.h b/arch/um/include/shared/skas_ptregs.h new file mode 100644 index 000000000000..73db19e9c077 --- /dev/null +++ b/arch/um/include/shared/skas_ptregs.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __SKAS_PT_REGS_ | ||
2 | #define __SKAS_PT_REGS_ | ||
3 | |||
4 | #include <user_constants.h> | ||
5 | |||
6 | #endif | ||
diff --git a/arch/um/include/shared/syscall.h b/arch/um/include/shared/syscall.h new file mode 100644 index 000000000000..dda1df901a08 --- /dev/null +++ b/arch/um/include/shared/syscall.h | |||
@@ -0,0 +1,12 @@ | |||
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 | ||
diff --git a/arch/um/include/shared/sysrq.h b/arch/um/include/shared/sysrq.h new file mode 100644 index 000000000000..c8d332b56b98 --- /dev/null +++ b/arch/um/include/shared/sysrq.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef __UM_SYSRQ_H | ||
2 | #define __UM_SYSRQ_H | ||
3 | |||
4 | struct task_struct; | ||
5 | extern void show_trace(struct task_struct* task, unsigned long *stack); | ||
6 | |||
7 | #endif | ||
diff --git a/arch/um/include/shared/task.h b/arch/um/include/shared/task.h new file mode 100644 index 000000000000..3fe726b3cf48 --- /dev/null +++ b/arch/um/include/shared/task.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef __TASK_H | ||
2 | #define __TASK_H | ||
3 | |||
4 | #include <kern_constants.h> | ||
5 | |||
6 | #define TASK_REGS(task) ((struct uml_pt_regs *) &(((char *) (task))[HOST_TASK_REGS])) | ||
7 | #define TASK_PID(task) *((int *) &(((char *) (task))[HOST_TASK_PID])) | ||
8 | |||
9 | #endif | ||
diff --git a/arch/um/include/shared/tlb.h b/arch/um/include/shared/tlb.h new file mode 100644 index 000000000000..ecd2265b301b --- /dev/null +++ b/arch/um/include/shared/tlb.h | |||
@@ -0,0 +1,15 @@ | |||
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 | extern void force_flush_all(void); | ||
12 | extern int flush_tlb_kernel_range_common(unsigned long start, | ||
13 | unsigned long end); | ||
14 | |||
15 | #endif | ||
diff --git a/arch/um/include/shared/ubd_user.h b/arch/um/include/shared/ubd_user.h new file mode 100644 index 000000000000..bb66517f0739 --- /dev/null +++ b/arch/um/include/shared/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/shared/um_malloc.h b/arch/um/include/shared/um_malloc.h new file mode 100644 index 000000000000..c554d706d106 --- /dev/null +++ b/arch/um/include/shared/um_malloc.h | |||
@@ -0,0 +1,19 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2005 Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __UM_MALLOC_H__ | ||
7 | #define __UM_MALLOC_H__ | ||
8 | |||
9 | #include "kern_constants.h" | ||
10 | |||
11 | extern void *uml_kmalloc(int size, int flags); | ||
12 | extern void kfree(const void *ptr); | ||
13 | |||
14 | extern void *vmalloc(unsigned long size); | ||
15 | extern void vfree(void *ptr); | ||
16 | |||
17 | #endif /* __UM_MALLOC_H__ */ | ||
18 | |||
19 | |||
diff --git a/arch/um/include/shared/um_mmu.h b/arch/um/include/shared/um_mmu.h new file mode 100644 index 000000000000..b1a7e47d1027 --- /dev/null +++ b/arch/um/include/shared/um_mmu.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __ARCH_UM_MMU_H | ||
7 | #define __ARCH_UM_MMU_H | ||
8 | |||
9 | #include "mm_id.h" | ||
10 | #include "ldt.h" | ||
11 | |||
12 | typedef struct mm_context { | ||
13 | struct mm_id id; | ||
14 | struct uml_ldt ldt; | ||
15 | struct page **stub_pages; | ||
16 | } mm_context_t; | ||
17 | |||
18 | extern void __switch_mm(struct mm_id * mm_idp); | ||
19 | |||
20 | /* Avoid tangled inclusion with asm/ldt.h */ | ||
21 | extern long init_new_ldt(struct mm_context *to_mm, struct mm_context *from_mm); | ||
22 | extern void free_ldt(struct mm_context *mm); | ||
23 | |||
24 | #endif | ||
diff --git a/arch/um/include/shared/um_uaccess.h b/arch/um/include/shared/um_uaccess.h new file mode 100644 index 000000000000..45c04999d670 --- /dev/null +++ b/arch/um/include/shared/um_uaccess.h | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __ARCH_UM_UACCESS_H | ||
7 | #define __ARCH_UM_UACCESS_H | ||
8 | |||
9 | #include <asm/elf.h> | ||
10 | #include <asm/fixmap.h> | ||
11 | #include "sysdep/archsetjmp.h" | ||
12 | |||
13 | #define __under_task_size(addr, size) \ | ||
14 | (((unsigned long) (addr) < TASK_SIZE) && \ | ||
15 | (((unsigned long) (addr) + (size)) < TASK_SIZE)) | ||
16 | |||
17 | #define __access_ok_vsyscall(type, addr, size) \ | ||
18 | ((type == VERIFY_READ) && \ | ||
19 | ((unsigned long) (addr) >= FIXADDR_USER_START) && \ | ||
20 | ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \ | ||
21 | ((unsigned long) (addr) + (size) >= (unsigned long)(addr))) | ||
22 | |||
23 | #define __addr_range_nowrap(addr, size) \ | ||
24 | ((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) | ||
25 | |||
26 | #define access_ok(type, addr, size) \ | ||
27 | (__addr_range_nowrap(addr, size) && \ | ||
28 | (__under_task_size(addr, size) || \ | ||
29 | __access_ok_vsyscall(type, addr, size) || \ | ||
30 | segment_eq(get_fs(), KERNEL_DS))) | ||
31 | |||
32 | extern int copy_from_user(void *to, const void __user *from, int n); | ||
33 | extern int copy_to_user(void __user *to, const void *from, int n); | ||
34 | |||
35 | extern int __do_copy_to_user(void *to, const void *from, int n, | ||
36 | void **fault_addr, jmp_buf **fault_catcher); | ||
37 | |||
38 | /* | ||
39 | * strncpy_from_user: - Copy a NUL terminated string from userspace. | ||
40 | * @dst: Destination address, in kernel space. This buffer must be at | ||
41 | * least @count bytes long. | ||
42 | * @src: Source address, in user space. | ||
43 | * @count: Maximum number of bytes to copy, including the trailing NUL. | ||
44 | * | ||
45 | * Copies a NUL-terminated string from userspace to kernel space. | ||
46 | * | ||
47 | * On success, returns the length of the string (not including the trailing | ||
48 | * NUL). | ||
49 | * | ||
50 | * If access to userspace fails, returns -EFAULT (some data may have been | ||
51 | * copied). | ||
52 | * | ||
53 | * If @count is smaller than the length of the string, copies @count bytes | ||
54 | * and returns @count. | ||
55 | */ | ||
56 | |||
57 | extern int strncpy_from_user(char *dst, const char __user *src, int count); | ||
58 | |||
59 | /* | ||
60 | * __clear_user: - Zero a block of memory in user space, with less checking. | ||
61 | * @to: Destination address, in user space. | ||
62 | * @n: Number of bytes to zero. | ||
63 | * | ||
64 | * Zero a block of memory in user space. Caller must check | ||
65 | * the specified block with access_ok() before calling this function. | ||
66 | * | ||
67 | * Returns number of bytes that could not be cleared. | ||
68 | * On success, this will be zero. | ||
69 | */ | ||
70 | extern int __clear_user(void __user *mem, int len); | ||
71 | |||
72 | /* | ||
73 | * clear_user: - Zero a block of memory in user space. | ||
74 | * @to: Destination address, in user space. | ||
75 | * @n: Number of bytes to zero. | ||
76 | * | ||
77 | * Zero a block of memory in user space. | ||
78 | * | ||
79 | * Returns number of bytes that could not be cleared. | ||
80 | * On success, this will be zero. | ||
81 | */ | ||
82 | extern int clear_user(void __user *mem, int len); | ||
83 | |||
84 | /* | ||
85 | * strlen_user: - Get the size of a string in user space. | ||
86 | * @str: The string to measure. | ||
87 | * @n: The maximum valid length | ||
88 | * | ||
89 | * Get the size of a NUL-terminated string in user space. | ||
90 | * | ||
91 | * Returns the size of the string INCLUDING the terminating NUL. | ||
92 | * On exception, returns 0. | ||
93 | * If the string is too long, returns a value greater than @n. | ||
94 | */ | ||
95 | extern int strnlen_user(const void __user *str, int len); | ||
96 | |||
97 | #endif | ||
diff --git a/arch/um/include/shared/user.h b/arch/um/include/shared/user.h new file mode 100644 index 000000000000..293f7c794faa --- /dev/null +++ b/arch/um/include/shared/user.h | |||
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __USER_H__ | ||
7 | #define __USER_H__ | ||
8 | |||
9 | #include "kern_constants.h" | ||
10 | |||
11 | /* | ||
12 | * The usual definition - copied here because the kernel provides its own, | ||
13 | * fancier, type-safe, definition. Using that one would require | ||
14 | * copying too much infrastructure for my taste, so userspace files | ||
15 | * get less checking than kernel files. | ||
16 | */ | ||
17 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
18 | |||
19 | /* This is to get size_t */ | ||
20 | #ifdef __KERNEL__ | ||
21 | #include <linux/types.h> | ||
22 | #else | ||
23 | #include <stddef.h> | ||
24 | #endif | ||
25 | |||
26 | extern void panic(const char *fmt, ...) | ||
27 | __attribute__ ((format (printf, 1, 2))); | ||
28 | |||
29 | #ifdef UML_CONFIG_PRINTK | ||
30 | extern int printk(const char *fmt, ...) | ||
31 | __attribute__ ((format (printf, 1, 2))); | ||
32 | #else | ||
33 | static inline int printk(const char *fmt, ...) | ||
34 | { | ||
35 | return 0; | ||
36 | } | ||
37 | #endif | ||
38 | |||
39 | extern void schedule(void); | ||
40 | extern int in_aton(char *str); | ||
41 | extern int open_gdb_chan(void); | ||
42 | extern size_t strlcpy(char *, const char *, size_t); | ||
43 | extern size_t strlcat(char *, const char *, size_t); | ||
44 | |||
45 | #endif | ||