diff options
author | Gennady Sharapov <Gennady.V.Sharapov@intel.com> | 2006-01-18 20:42:41 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-18 22:20:19 -0500 |
commit | 4fef0c10fa174b57a10854b8b4b2b90d155706e0 (patch) | |
tree | 02cfcc989114da9a6d46484753937cc0e3a60b52 /arch/um | |
parent | 12919aa6e015dd85170fc3b1a3e10a5dfd116c72 (diff) |
[PATCH] uml: move libc-dependent utility procedures
The serial UML OS-abstraction layer patch (um/kernel dir).
This moves all systemcalls from user_util.c file under os-Linux dir
Signed-off-by: Gennady Sharapov <Gennady.V.Sharapov@intel.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/drivers/fd.c | 1 | ||||
-rw-r--r-- | arch/um/include/os.h | 10 | ||||
-rw-r--r-- | arch/um/include/user_util.h | 18 | ||||
-rw-r--r-- | arch/um/kernel/Makefile | 5 | ||||
-rw-r--r-- | arch/um/kernel/skas/uaccess.c | 2 | ||||
-rw-r--r-- | arch/um/kernel/tt/gdb.c | 1 | ||||
-rw-r--r-- | arch/um/kernel/tt/ptproxy/ptrace.c | 1 | ||||
-rw-r--r-- | arch/um/kernel/tt/ptproxy/sysdep.c | 1 | ||||
-rw-r--r-- | arch/um/os-Linux/Makefile | 4 | ||||
-rw-r--r-- | arch/um/os-Linux/tt.c | 48 | ||||
-rw-r--r-- | arch/um/os-Linux/util.c (renamed from arch/um/kernel/user_util.c) | 68 |
11 files changed, 72 insertions, 87 deletions
diff --git a/arch/um/drivers/fd.c b/arch/um/drivers/fd.c index 3296e86a03a5..c41f75e4acb5 100644 --- a/arch/um/drivers/fd.c +++ b/arch/um/drivers/fd.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include "user.h" | 11 | #include "user.h" |
12 | #include "user_util.h" | 12 | #include "user_util.h" |
13 | #include "chan_user.h" | 13 | #include "chan_user.h" |
14 | #include "os.h" | ||
14 | 15 | ||
15 | struct fd_chan { | 16 | struct fd_chan { |
16 | int fd; | 17 | int fd; |
diff --git a/arch/um/include/os.h b/arch/um/include/os.h index dd72d66cf0ed..7f27dfe0ecac 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h | |||
@@ -195,6 +195,8 @@ extern unsigned long long os_usecs(void); | |||
195 | /* tt.c | 195 | /* tt.c |
196 | * for tt mode only (will be deleted in future...) | 196 | * for tt mode only (will be deleted in future...) |
197 | */ | 197 | */ |
198 | extern void stop(void); | ||
199 | extern int wait_for_stop(int pid, int sig, int cont_type, void *relay); | ||
198 | extern int protect_memory(unsigned long addr, unsigned long len, | 200 | extern int protect_memory(unsigned long addr, unsigned long len, |
199 | int r, int w, int x, int must_succeed); | 201 | int r, int w, int x, int must_succeed); |
200 | extern void forward_pending_sigio(int target); | 202 | extern void forward_pending_sigio(int target); |
@@ -235,4 +237,12 @@ extern int set_signals(int enable); | |||
235 | extern void os_fill_handlinfo(struct kern_handlers h); | 237 | extern void os_fill_handlinfo(struct kern_handlers h); |
236 | extern void do_longjmp(void *p, int val); | 238 | extern void do_longjmp(void *p, int val); |
237 | 239 | ||
240 | /* util.c */ | ||
241 | extern void stack_protections(unsigned long address); | ||
242 | extern void task_protections(unsigned long address); | ||
243 | extern int raw(int fd); | ||
244 | extern void setup_machinename(char *machine_out); | ||
245 | extern void setup_hostinfo(void); | ||
246 | extern int setjmp_wrapper(void (*proc)(void *, void *), ...); | ||
247 | |||
238 | #endif | 248 | #endif |
diff --git a/arch/um/include/user_util.h b/arch/um/include/user_util.h index c1dbd77b073f..a6f1f176cf84 100644 --- a/arch/um/include/user_util.h +++ b/arch/um/include/user_util.h | |||
@@ -44,10 +44,6 @@ extern unsigned long brk_start; | |||
44 | extern int pty_output_sigio; | 44 | extern int pty_output_sigio; |
45 | extern int pty_close_sigio; | 45 | extern int pty_close_sigio; |
46 | 46 | ||
47 | extern void stop(void); | ||
48 | extern void stack_protections(unsigned long address); | ||
49 | extern void task_protections(unsigned long address); | ||
50 | extern int wait_for_stop(int pid, int sig, int cont_type, void *relay); | ||
51 | extern void *add_signal_handler(int sig, void (*handler)(int)); | 47 | extern void *add_signal_handler(int sig, void (*handler)(int)); |
52 | extern int linux_main(int argc, char **argv); | 48 | extern int linux_main(int argc, char **argv); |
53 | extern void set_cmdline(char *cmd); | 49 | extern void set_cmdline(char *cmd); |
@@ -55,8 +51,6 @@ extern void input_cb(void (*proc)(void *), void *arg, int arg_len); | |||
55 | extern int get_pty(void); | 51 | extern int get_pty(void); |
56 | extern void *um_kmalloc(int size); | 52 | extern void *um_kmalloc(int size); |
57 | extern int switcheroo(int fd, int prot, void *from, void *to, int size); | 53 | extern int switcheroo(int fd, int prot, void *from, void *to, int size); |
58 | extern void setup_machinename(char *machine_out); | ||
59 | extern void setup_hostinfo(void); | ||
60 | extern void do_exec(int old_pid, int new_pid); | 54 | extern void do_exec(int old_pid, int new_pid); |
61 | extern void tracer_panic(char *msg, ...); | 55 | extern void tracer_panic(char *msg, ...); |
62 | extern int detach(int pid, int sig); | 56 | extern int detach(int pid, int sig); |
@@ -70,18 +64,6 @@ extern int cpu_feature(char *what, char *buf, int len); | |||
70 | extern int arch_handle_signal(int sig, union uml_pt_regs *regs); | 64 | extern int arch_handle_signal(int sig, union uml_pt_regs *regs); |
71 | extern int arch_fixup(unsigned long address, void *sc_ptr); | 65 | extern int arch_fixup(unsigned long address, void *sc_ptr); |
72 | extern void arch_init_thread(void); | 66 | extern void arch_init_thread(void); |
73 | extern int setjmp_wrapper(void (*proc)(void *, void *), ...); | ||
74 | extern int raw(int fd); | 67 | extern int raw(int fd); |
75 | 68 | ||
76 | #endif | 69 | #endif |
77 | |||
78 | /* | ||
79 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
80 | * Emacs will notice this stuff at the end of the file and automatically | ||
81 | * adjust the settings for this buffer only. This must remain at the end | ||
82 | * of the file. | ||
83 | * --------------------------------------------------------------------------- | ||
84 | * Local variables: | ||
85 | * c-file-style: "linux" | ||
86 | * End: | ||
87 | */ | ||
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index 193cc2b7448d..165c8639c9f6 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile | |||
@@ -10,8 +10,7 @@ obj-y = config.o exec_kern.o exitcode.o \ | |||
10 | init_task.o irq.o irq_user.o ksyms.o mem.o physmem.o \ | 10 | init_task.o irq.o irq_user.o ksyms.o mem.o physmem.o \ |
11 | process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \ | 11 | process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \ |
12 | signal_kern.o smp.o syscall_kern.o sysrq.o time.o \ | 12 | signal_kern.o smp.o syscall_kern.o sysrq.o time.o \ |
13 | time_kern.o tlb.o trap_kern.o uaccess.o um_arch.o umid.o \ | 13 | time_kern.o tlb.o trap_kern.o uaccess.o um_arch.o umid.o |
14 | user_util.o | ||
15 | 14 | ||
16 | obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o | 15 | obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o |
17 | obj-$(CONFIG_GPROF) += gprof_syms.o | 16 | obj-$(CONFIG_GPROF) += gprof_syms.o |
@@ -24,7 +23,7 @@ obj-$(CONFIG_MODE_SKAS) += skas/ | |||
24 | 23 | ||
25 | user-objs-$(CONFIG_TTY_LOG) += tty_log.o | 24 | user-objs-$(CONFIG_TTY_LOG) += tty_log.o |
26 | 25 | ||
27 | USER_OBJS := $(user-objs-y) config.o time.o tty_log.o user_util.o | 26 | USER_OBJS := $(user-objs-y) config.o time.o tty_log.o |
28 | 27 | ||
29 | include arch/um/scripts/Makefile.rules | 28 | include arch/um/scripts/Makefile.rules |
30 | 29 | ||
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c index a5a47528dec7..5992c3257167 100644 --- a/arch/um/kernel/skas/uaccess.c +++ b/arch/um/kernel/skas/uaccess.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include "asm/pgtable.h" | 13 | #include "asm/pgtable.h" |
14 | #include "asm/uaccess.h" | 14 | #include "asm/uaccess.h" |
15 | #include "kern_util.h" | 15 | #include "kern_util.h" |
16 | #include "user_util.h" | 16 | #include "os.h" |
17 | 17 | ||
18 | extern void *um_virt_to_phys(struct task_struct *task, unsigned long addr, | 18 | extern void *um_virt_to_phys(struct task_struct *task, unsigned long addr, |
19 | pte_t *pte_out); | 19 | pte_t *pte_out); |
diff --git a/arch/um/kernel/tt/gdb.c b/arch/um/kernel/tt/gdb.c index 37e22d71a0d9..786e4edd86c5 100644 --- a/arch/um/kernel/tt/gdb.c +++ b/arch/um/kernel/tt/gdb.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "user_util.h" | 20 | #include "user_util.h" |
21 | #include "tt.h" | 21 | #include "tt.h" |
22 | #include "sysdep/thread.h" | 22 | #include "sysdep/thread.h" |
23 | #include "os.h" | ||
23 | 24 | ||
24 | extern int debugger_pid; | 25 | extern int debugger_pid; |
25 | extern int debugger_fd; | 26 | extern int debugger_fd; |
diff --git a/arch/um/kernel/tt/ptproxy/ptrace.c b/arch/um/kernel/tt/ptproxy/ptrace.c index 528a5fc8d887..03774427d468 100644 --- a/arch/um/kernel/tt/ptproxy/ptrace.c +++ b/arch/um/kernel/tt/ptproxy/ptrace.c | |||
@@ -20,6 +20,7 @@ Jeff Dike (jdike@karaya.com) : Modified for integration into uml | |||
20 | #include "kern_util.h" | 20 | #include "kern_util.h" |
21 | #include "ptrace_user.h" | 21 | #include "ptrace_user.h" |
22 | #include "tt.h" | 22 | #include "tt.h" |
23 | #include "os.h" | ||
23 | 24 | ||
24 | long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, | 25 | long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, |
25 | long arg3, long arg4, pid_t child, int *ret) | 26 | long arg3, long arg4, pid_t child, int *ret) |
diff --git a/arch/um/kernel/tt/ptproxy/sysdep.c b/arch/um/kernel/tt/ptproxy/sysdep.c index a5f0e01e214e..99f178319d03 100644 --- a/arch/um/kernel/tt/ptproxy/sysdep.c +++ b/arch/um/kernel/tt/ptproxy/sysdep.c | |||
@@ -15,6 +15,7 @@ terms and conditions. | |||
15 | #include "ptrace_user.h" | 15 | #include "ptrace_user.h" |
16 | #include "user_util.h" | 16 | #include "user_util.h" |
17 | #include "user.h" | 17 | #include "user.h" |
18 | #include "os.h" | ||
18 | 19 | ||
19 | int get_syscall(pid_t pid, long *arg1, long *arg2, long *arg3, long *arg4, | 20 | int get_syscall(pid_t pid, long *arg1, long *arg2, long *arg3, long *arg4, |
20 | long *arg5) | 21 | long *arg5) |
diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile index 40c7d6b1df68..08a4e628b24c 100644 --- a/arch/um/os-Linux/Makefile +++ b/arch/um/os-Linux/Makefile | |||
@@ -5,12 +5,12 @@ | |||
5 | 5 | ||
6 | obj-y = aio.o elf_aux.o file.o helper.o main.o mem.o process.o signal.o \ | 6 | obj-y = aio.o elf_aux.o file.o helper.o main.o mem.o process.o signal.o \ |
7 | start_up.o time.o trap.o tt.o tty.o uaccess.o umid.o user_syms.o \ | 7 | start_up.o time.o trap.o tt.o tty.o uaccess.o umid.o user_syms.o \ |
8 | drivers/ sys-$(SUBARCH)/ | 8 | util.o drivers/ sys-$(SUBARCH)/ |
9 | 9 | ||
10 | obj-$(CONFIG_MODE_SKAS) += skas/ | 10 | obj-$(CONFIG_MODE_SKAS) += skas/ |
11 | 11 | ||
12 | USER_OBJS := aio.o elf_aux.o file.o helper.o main.o mem.o process.o signal.o \ | 12 | USER_OBJS := aio.o elf_aux.o file.o helper.o main.o mem.o process.o signal.o \ |
13 | start_up.o time.o trap.o tt.o tty.o uaccess.o umid.o | 13 | start_up.o time.o trap.o tt.o tty.o uaccess.o umid.o util.o |
14 | 14 | ||
15 | elf_aux.o: $(ARCH_DIR)/kernel-offsets.h | 15 | elf_aux.o: $(ARCH_DIR)/kernel-offsets.h |
16 | CFLAGS_elf_aux.o += -I$(objtree)/arch/um | 16 | CFLAGS_elf_aux.o += -I$(objtree)/arch/um |
diff --git a/arch/um/os-Linux/tt.c b/arch/um/os-Linux/tt.c index cb2648b79d0f..404bb63a74a9 100644 --- a/arch/um/os-Linux/tt.c +++ b/arch/um/os-Linux/tt.c | |||
@@ -63,6 +63,54 @@ void kill_child_dead(int pid) | |||
63 | } while(1); | 63 | } while(1); |
64 | } | 64 | } |
65 | 65 | ||
66 | void stop(void) | ||
67 | { | ||
68 | while(1) sleep(1000000); | ||
69 | } | ||
70 | |||
71 | int wait_for_stop(int pid, int sig, int cont_type, void *relay) | ||
72 | { | ||
73 | sigset_t *relay_signals = relay; | ||
74 | int status, ret; | ||
75 | |||
76 | while(1){ | ||
77 | CATCH_EINTR(ret = waitpid(pid, &status, WUNTRACED)); | ||
78 | if((ret < 0) || | ||
79 | !WIFSTOPPED(status) || (WSTOPSIG(status) != sig)){ | ||
80 | if(ret < 0){ | ||
81 | printk("wait failed, errno = %d\n", | ||
82 | errno); | ||
83 | } | ||
84 | else if(WIFEXITED(status)) | ||
85 | printk("process %d exited with status %d\n", | ||
86 | pid, WEXITSTATUS(status)); | ||
87 | else if(WIFSIGNALED(status)) | ||
88 | printk("process %d exited with signal %d\n", | ||
89 | pid, WTERMSIG(status)); | ||
90 | else if((WSTOPSIG(status) == SIGVTALRM) || | ||
91 | (WSTOPSIG(status) == SIGALRM) || | ||
92 | (WSTOPSIG(status) == SIGIO) || | ||
93 | (WSTOPSIG(status) == SIGPROF) || | ||
94 | (WSTOPSIG(status) == SIGCHLD) || | ||
95 | (WSTOPSIG(status) == SIGWINCH) || | ||
96 | (WSTOPSIG(status) == SIGINT)){ | ||
97 | ptrace(cont_type, pid, 0, WSTOPSIG(status)); | ||
98 | continue; | ||
99 | } | ||
100 | else if((relay_signals != NULL) && | ||
101 | sigismember(relay_signals, WSTOPSIG(status))){ | ||
102 | ptrace(cont_type, pid, 0, WSTOPSIG(status)); | ||
103 | continue; | ||
104 | } | ||
105 | else printk("process %d stopped with signal %d\n", | ||
106 | pid, WSTOPSIG(status)); | ||
107 | panic("wait_for_stop failed to wait for %d to stop " | ||
108 | "with %d\n", pid, sig); | ||
109 | } | ||
110 | return(status); | ||
111 | } | ||
112 | } | ||
113 | |||
66 | /* | 114 | /* |
67 | *------------------------- | 115 | *------------------------- |
68 | * only for tt mode (will be deleted in future...) | 116 | * only for tt mode (will be deleted in future...) |
diff --git a/arch/um/kernel/user_util.c b/arch/um/os-Linux/util.c index 4c231161f257..d224434d5610 100644 --- a/arch/um/kernel/user_util.c +++ b/arch/um/os-Linux/util.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
@@ -29,17 +29,13 @@ | |||
29 | #include "init.h" | 29 | #include "init.h" |
30 | #include "ptrace_user.h" | 30 | #include "ptrace_user.h" |
31 | #include "uml-config.h" | 31 | #include "uml-config.h" |
32 | 32 | #include "os.h" | |
33 | void stop(void) | ||
34 | { | ||
35 | while(1) sleep(1000000); | ||
36 | } | ||
37 | 33 | ||
38 | void stack_protections(unsigned long address) | 34 | void stack_protections(unsigned long address) |
39 | { | 35 | { |
40 | int prot = PROT_READ | PROT_WRITE | PROT_EXEC; | 36 | int prot = PROT_READ | PROT_WRITE | PROT_EXEC; |
41 | 37 | ||
42 | if(mprotect((void *) address, page_size(), prot) < 0) | 38 | if(mprotect((void *) address, page_size(), prot) < 0) |
43 | panic("protecting stack failed, errno = %d", errno); | 39 | panic("protecting stack failed, errno = %d", errno); |
44 | } | 40 | } |
45 | 41 | ||
@@ -59,49 +55,6 @@ void task_protections(unsigned long address) | |||
59 | panic("protecting stack failed, errno = %d", errno); | 55 | panic("protecting stack failed, errno = %d", errno); |
60 | } | 56 | } |
61 | 57 | ||
62 | int wait_for_stop(int pid, int sig, int cont_type, void *relay) | ||
63 | { | ||
64 | sigset_t *relay_signals = relay; | ||
65 | int status, ret; | ||
66 | |||
67 | while(1){ | ||
68 | CATCH_EINTR(ret = waitpid(pid, &status, WUNTRACED)); | ||
69 | if((ret < 0) || | ||
70 | !WIFSTOPPED(status) || (WSTOPSIG(status) != sig)){ | ||
71 | if(ret < 0){ | ||
72 | printk("wait failed, errno = %d\n", | ||
73 | errno); | ||
74 | } | ||
75 | else if(WIFEXITED(status)) | ||
76 | printk("process %d exited with status %d\n", | ||
77 | pid, WEXITSTATUS(status)); | ||
78 | else if(WIFSIGNALED(status)) | ||
79 | printk("process %d exited with signal %d\n", | ||
80 | pid, WTERMSIG(status)); | ||
81 | else if((WSTOPSIG(status) == SIGVTALRM) || | ||
82 | (WSTOPSIG(status) == SIGALRM) || | ||
83 | (WSTOPSIG(status) == SIGIO) || | ||
84 | (WSTOPSIG(status) == SIGPROF) || | ||
85 | (WSTOPSIG(status) == SIGCHLD) || | ||
86 | (WSTOPSIG(status) == SIGWINCH) || | ||
87 | (WSTOPSIG(status) == SIGINT)){ | ||
88 | ptrace(cont_type, pid, 0, WSTOPSIG(status)); | ||
89 | continue; | ||
90 | } | ||
91 | else if((relay_signals != NULL) && | ||
92 | sigismember(relay_signals, WSTOPSIG(status))){ | ||
93 | ptrace(cont_type, pid, 0, WSTOPSIG(status)); | ||
94 | continue; | ||
95 | } | ||
96 | else printk("process %d stopped with signal %d\n", | ||
97 | pid, WSTOPSIG(status)); | ||
98 | panic("wait_for_stop failed to wait for %d to stop " | ||
99 | "with %d\n", pid, sig); | ||
100 | } | ||
101 | return(status); | ||
102 | } | ||
103 | } | ||
104 | |||
105 | int raw(int fd) | 58 | int raw(int fd) |
106 | { | 59 | { |
107 | struct termios tt; | 60 | struct termios tt; |
@@ -113,7 +66,7 @@ int raw(int fd) | |||
113 | 66 | ||
114 | cfmakeraw(&tt); | 67 | cfmakeraw(&tt); |
115 | 68 | ||
116 | CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt)); | 69 | CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt)); |
117 | if(err < 0) | 70 | if(err < 0) |
118 | return -errno; | 71 | return -errno; |
119 | 72 | ||
@@ -149,7 +102,7 @@ void setup_hostinfo(void) | |||
149 | 102 | ||
150 | int setjmp_wrapper(void (*proc)(void *, void *), ...) | 103 | int setjmp_wrapper(void (*proc)(void *, void *), ...) |
151 | { | 104 | { |
152 | va_list args; | 105 | va_list args; |
153 | sigjmp_buf buf; | 106 | sigjmp_buf buf; |
154 | int n; | 107 | int n; |
155 | 108 | ||
@@ -161,14 +114,3 @@ int setjmp_wrapper(void (*proc)(void *, void *), ...) | |||
161 | va_end(args); | 114 | va_end(args); |
162 | return(n); | 115 | return(n); |
163 | } | 116 | } |
164 | |||
165 | /* | ||
166 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
167 | * Emacs will notice this stuff at the end of the file and automatically | ||
168 | * adjust the settings for this buffer only. This must remain at the end | ||
169 | * of the file. | ||
170 | * --------------------------------------------------------------------------- | ||
171 | * Local variables: | ||
172 | * c-file-style: "linux" | ||
173 | * End: | ||
174 | */ | ||