]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
uml: tidy kern_util.h
authorJeff Dike <jdike@addtoit.com>
Tue, 5 Feb 2008 06:30:46 +0000 (22:30 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 5 Feb 2008 17:44:26 +0000 (09:44 -0800)
Tidy kern_util.h.  It turns out that most of the function declarations
aren't used, so they can go away.  os.h no longer includes
kern_util.h, so files which got it through os.h now need to include it
directly.  A number of other files never needed it, so these includes
are deleted.

The structure which was used to pass signal handlers from the kernel
side to the userspace side is gone.  Instead, the handlers are
declared here, and used directly from libc code.  This allows
arch/um/os-Linux/trap.c to be deleted, with its remnants being moved
to arch/um/os-Linux/skas/trap.c.

arch/um/os-Linux/tty.c had its inclusions changed, and it needed some
style attention, so it got tidied.

Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
25 files changed:
arch/um/drivers/line.c
arch/um/drivers/ssl.c
arch/um/drivers/stdio_console.c
arch/um/drivers/ubd_kern.c
arch/um/drivers/ubd_user.c
arch/um/include/kern_util.h
arch/um/include/os.h
arch/um/kernel/initrd.c
arch/um/kernel/reboot.c
arch/um/kernel/smp.c
arch/um/kernel/trap.c
arch/um/kernel/um_arch.c
arch/um/os-Linux/Makefile
arch/um/os-Linux/aio.c
arch/um/os-Linux/drivers/tuntap_user.c
arch/um/os-Linux/file.c
arch/um/os-Linux/irq.c
arch/um/os-Linux/mem.c
arch/um/os-Linux/signal.c
arch/um/os-Linux/skas/process.c
arch/um/os-Linux/skas/trap.c
arch/um/os-Linux/trap.c [deleted file]
arch/um/os-Linux/tty.c
arch/um/os-Linux/tty_log.c
arch/um/sys-i386/bugs.c

index 5cff6536a8435ad0a5a407054c31956285bb7a8b..fac058b49282924e641c298954001eb648c682aa 100644 (file)
@@ -8,6 +8,7 @@
 #include "chan_kern.h"
 #include "irq_kern.h"
 #include "irq_user.h"
+#include "kern_util.h"
 #include "os.h"
 
 #define LINE_BUFSIZE 4096
index 875d60d0c6a25da5ab3694378dfe22fec4bf1004..f1786e64607f11d785ab333bbe46e6ba3c8d7f0e 100644 (file)
@@ -15,7 +15,6 @@
 #include "line.h"
 #include "ssl.h"
 #include "chan_kern.h"
-#include "kern_util.h"
 #include "kern.h"
 #include "init.h"
 #include "irq_user.h"
index 656036e90b196958d13e593bcff3180ebb4a25cd..cec0c33cdd395d6461783c2793a74e18acfc07b6 100644 (file)
@@ -22,7 +22,6 @@
 #include "stdio_console.h"
 #include "line.h"
 #include "chan_kern.h"
-#include "kern_util.h"
 #include "irq_user.h"
 #include "mconsole_kern.h"
 #include "init.h"
index 7a252abbfeade5711072fc94135010d8f5837355..4fe4d6b7307067d93c3b963d4c61be3e22590c41 100644 (file)
@@ -49,6 +49,7 @@
 #include "irq_user.h"
 #include "irq_kern.h"
 #include "ubd_user.h"
+#include "kern_util.h"
 #include "os.h"
 #include "mem.h"
 #include "mem_kern.h"
index 48fc7452bc1d11e3f3aad9c40c6983dac8526fc9..b591bb9c41dd83f4b72152c42c8ae70c60218698 100644 (file)
@@ -16,7 +16,6 @@
 #include <sys/mman.h>
 #include <sys/param.h>
 #include "asm/types.h"
-#include "kern_util.h"
 #include "user.h"
 #include "ubd_user.h"
 #include "os.h"
index aa27eb0f4586424e7f23fee92f4a6ee8b89d2ea7..8fadf8962e3e4db09e43dd81eb0638308ad6a207 100644 (file)
 #include "sysdep/ptrace.h"
 #include "sysdep/faultinfo.h"
 
-typedef void (*kern_hndl)(int, struct uml_pt_regs *);
-
-struct kern_handlers {
-       kern_hndl relay_signal;
-       kern_hndl winch;
-       kern_hndl bus_handler;
-       kern_hndl page_fault;
-       kern_hndl sigio_handler;
-       kern_hndl timer_handler;
-};
-
-extern const struct kern_handlers handlinfo_kern;
-
 extern int ncpus;
-extern char *gdb_init;
 extern int kmalloc_ok;
-extern int jail;
 extern int nsyscalls;
 
-#define UML_ROUND_DOWN(addr) ((void *)(((unsigned long) addr) & PAGE_MASK))
 #define UML_ROUND_UP(addr) \
-       UML_ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1)
+       ((((unsigned long) addr) + PAGE_SIZE - 1) & PAGE_MASK)
 
-extern int kernel_fork(unsigned long flags, int (*fn)(void *), void * arg);
-extern int kernel_thread_proc(void *data);
-extern void syscall_segv(int sig);
-extern int current_pid(void);
 extern unsigned long alloc_stack(int order, int atomic);
+extern void free_stack(unsigned long stack, int order);
+
 extern int do_signal(void);
-extern int is_stack_fault(unsigned long sp);
+extern void copy_sc(struct uml_pt_regs *regs, void *from);
+extern void interrupt_end(void);
+extern void relay_signal(int sig, struct uml_pt_regs *regs);
+
 extern unsigned long segv(struct faultinfo fi, unsigned long ip,
                          int is_user, struct uml_pt_regs *regs);
 extern int handle_page_fault(unsigned long address, unsigned long ip,
                             int is_write, int is_user, int *code_out);
-extern void syscall_ready(void);
-extern void set_tracing(void *t, int tracing);
-extern int is_tracing(void *task);
-extern int segv_syscall(void);
-extern void kern_finish_exec(void *task, int new_pid, unsigned long stack);
-extern unsigned long page_mask(void);
-extern int need_finish_fork(void);
-extern void free_stack(unsigned long stack, int order);
-extern void add_input_request(int op, void (*proc)(int), void *arg);
-extern char *current_cmd(void);
-extern void timer_handler(int sig, struct uml_pt_regs *regs);
-extern int set_signals(int enable);
-extern int pid_to_processor_id(int pid);
-extern void deliver_signals(void *t);
-extern int next_trap_index(int max);
-extern void default_idle(void);
-extern void finish_fork(void);
-extern void paging_init(void);
-extern void init_flush_vm(void);
-extern void *syscall_sp(void *t);
-extern void syscall_trace(struct uml_pt_regs *regs, int entryexit);
+
 extern unsigned int do_IRQ(int irq, struct uml_pt_regs *regs);
-extern void interrupt_end(void);
-extern void initial_thread_cb(void (*proc)(void *), void *arg);
-extern int debugger_signal(int status, int pid);
-extern void debugger_parent_signal(int status, int pid);
-extern void child_signal(int pid, int status);
-extern int init_ptrace_proxy(int idle_pid, int startup, int stop);
-extern int init_parent_proxy(int pid);
-extern int singlestepping(void *t);
-extern void check_stack_overflow(void *ptr);
-extern void relay_signal(int sig, struct uml_pt_regs *regs);
-extern int user_context(unsigned long sp);
-extern void timer_irq(struct uml_pt_regs *regs);
-extern void do_uml_exitcalls(void);
-extern int attach_debugger(int idle_pid, int pid, int stop);
-extern int config_gdb(char *str);
-extern int remove_gdb(void);
-extern char *uml_strdup(const char *string);
-extern void unprotect_kernel_mem(void);
-extern void protect_kernel_mem(void);
-extern void uml_cleanup(void);
-extern void lock_signalled_task(void *t);
-extern void IPI_handler(int cpu);
-extern int jail_setup(char *line, int *add);
-extern void *get_init_task(void);
-extern int clear_user_proc(void *buf, int size);
-extern int copy_to_user_proc(void *to, void *from, int size);
-extern int copy_from_user_proc(void *to, void *from, int size);
-extern int strlen_user_proc(char *str);
-extern long execute_syscall(void *r);
 extern int smp_sigio_handler(void);
-extern void *get_current(void);
-extern struct task_struct *get_task(int pid, int require);
-extern void machine_halt(void);
+extern void initial_thread_cb(void (*proc)(void *), void *arg);
 extern int is_syscall(unsigned long addr);
+extern void timer_handler(int sig, struct uml_pt_regs *regs);
 
-extern void free_irq(unsigned int, void *);
-extern int cpu(void);
+extern void timer_handler(int sig, struct uml_pt_regs *regs);
+
+extern int start_uml(void);
+extern void paging_init(void);
 
-extern void time_init_kern(void);
+extern void uml_cleanup(void);
+extern void do_uml_exitcalls(void);
 
-/* Are we disallowed to sleep? Used to choose between GFP_KERNEL and GFP_ATOMIC. */
+/*
+ * Are we disallowed to sleep? Used to choose between GFP_KERNEL and
+ * GFP_ATOMIC.
+ */
 extern int __cant_sleep(void);
-extern void sigio_handler(int sig, struct uml_pt_regs *regs);
-extern void copy_sc(struct uml_pt_regs *regs, void *from);
+extern void *get_current(void);
+extern int copy_from_user_proc(void *to, void *from, int size);
+extern int cpu(void);
+extern char *uml_strdup(const char *string);
+
 extern unsigned long to_irq_stack(unsigned long *mask_out);
-unsigned long from_irq_stack(int nested);
-extern int start_uml(void);
+extern unsigned long from_irq_stack(int nested);
+
+extern void syscall_trace(struct uml_pt_regs *regs, int entryexit);
+extern int singlestepping(void *t);
+
+extern void segv_handler(int sig, struct uml_pt_regs *regs);
+extern void bus_handler(int sig, struct uml_pt_regs *regs);
+extern void winch(int sig, struct uml_pt_regs *regs);
+
+
 #endif
index 82e5aeae2b8497e846d00df50fbf6fa9087ce6b8..55ca073589dcd25aa953241b7e228b2c62ce7396 100644 (file)
@@ -8,7 +8,6 @@
 
 #include <stdarg.h>
 #include "irq_user.h"
-#include "kern_util.h"
 #include "longjmp.h"
 #include "mm_id.h"
 #include "sysdep/tls.h"
@@ -237,9 +236,6 @@ extern void unblock_signals(void);
 extern int get_signals(void);
 extern int set_signals(int enable);
 
-/* trap.c */
-extern void os_fill_handlinfo(struct kern_handlers h);
-
 /* util.c */
 extern void stack_protections(unsigned long address);
 extern int raw(int fd);
index 16dc43e9d940e305bfe2f42a9a5c35be05eb0a9c..ae31c62f03230c1151cf9868cb07e65726b33c54 100644 (file)
@@ -7,7 +7,6 @@
 #include "linux/bootmem.h"
 #include "linux/initrd.h"
 #include "asm/types.h"
-#include "kern_util.h"
 #include "initrd.h"
 #include "init.h"
 #include "os.h"
index 04cebcf0679ff90e590b9374ed5c8a8b041acc1e..1ce49cd8aca37cb92fbc560a848774a4b8d9c242 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include "linux/sched.h"
+#include "kern_util.h"
 #include "os.h"
 #include "skas.h"
 
index 36d89cf8d20b2b223bb04f08a5735cd2a76e08af..a12e5bd15790d2d56131fb01c1e87d5b4ee058db 100644 (file)
@@ -21,7 +21,6 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
 #include "asm/smp.h"
 #include "asm/processor.h"
 #include "asm/spinlock.h"
-#include "kern_util.h"
 #include "kern.h"
 #include "irq_user.h"
 #include "os.h"
index e3a3ab8f86358d929c76ee1575f11a07d1faa7b0..ff405a446d15b7346269b0107d80997afba50ff1 100644 (file)
@@ -128,7 +128,7 @@ static void bad_segv(struct faultinfo fi, unsigned long ip)
        force_sig_info(SIGSEGV, &si, current);
 }
 
-static void segv_handler(int sig, struct uml_pt_regs *regs)
+void segv_handler(int sig, struct uml_pt_regs *regs)
 {
        struct faultinfo * fi = UPT_FAULTINFO(regs);
 
@@ -229,27 +229,18 @@ void relay_signal(int sig, struct uml_pt_regs *regs)
        force_sig(sig, current);
 }
 
-static void bus_handler(int sig, struct uml_pt_regs *regs)
+void bus_handler(int sig, struct uml_pt_regs *regs)
 {
        if (current->thread.fault_catcher != NULL)
                UML_LONGJMP(current->thread.fault_catcher, 1);
        else relay_signal(sig, regs);
 }
 
-static void winch(int sig, struct uml_pt_regs *regs)
+void winch(int sig, struct uml_pt_regs *regs)
 {
        do_IRQ(WINCH_IRQ, regs);
 }
 
-const struct kern_handlers handlinfo_kern = {
-       .relay_signal = relay_signal,
-       .winch = winch,
-       .bus_handler = bus_handler,
-       .page_fault = segv_handler,
-       .sigio_handler = sigio_handler,
-       .timer_handler = timer_handler
-};
-
 void trap_init(void)
 {
 }
index f1c71393f57810feb8368b256f7dab7bf5111a43..9b5d2cdb621ce26f9dd179607018515c9dd5ac4f 100644 (file)
@@ -16,6 +16,7 @@
 #include "as-layout.h"
 #include "init.h"
 #include "kern.h"
+#include "kern_util.h"
 #include "mem_user.h"
 #include "os.h"
 #include "skas.h"
@@ -280,11 +281,6 @@ int __init linux_main(int argc, char **argv)
 
        host_task_size = set_task_sizes_skas(&task_size);
 
-       /*
-        * Setting up handlers to 'sig_info' struct
-        */
-       os_fill_handlinfo(handlinfo_kern);
-
        brk_start = (unsigned long) sbrk(0);
 
        /*
index 8e129af8170d2b7d7af03aee3e70957dc0f5835f..8a48d6a30064139fa28bcfc53a0897b046988a3b 100644 (file)
@@ -4,7 +4,7 @@
 #
 
 obj-y = aio.o elf_aux.o execvp.o file.o helper.o irq.o main.o mem.o process.o \
-       registers.o sigio.o signal.o start_up.o time.o trap.o tty.o uaccess.o \
+       registers.o sigio.o signal.o start_up.o time.o tty.o uaccess.o \
        umid.o tls.o user_syms.o util.o drivers/ sys-$(SUBARCH)/ skas/
 
 obj-$(CONFIG_TTY_LOG) += tty_log.o
@@ -12,7 +12,7 @@ user-objs-$(CONFIG_TTY_LOG) += tty_log.o
 
 USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \
        main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \
-       trap.o tty.o tls.o uaccess.o umid.o util.o
+       tty.o tls.o uaccess.o umid.o util.o
 
 CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH)
 
index 93dc0c80ebaf7d128f08125185a8ba65c5f6f770..b8d8c9ca8d4afa48d3374520615fc5fdf8c2d8df 100644 (file)
@@ -12,6 +12,7 @@
 #include "aio.h"
 #include "init.h"
 #include "kern_constants.h"
+#include "kern_util.h"
 #include "os.h"
 #include "user.h"
 
index 1d847959d1d66dbb496999637bbe26255bdab444..7739e29cf341b44d09e7df3c0d09de4421bde6cc 100644 (file)
@@ -14,6 +14,7 @@
 #include <sys/wait.h>
 #include <sys/uio.h>
 #include "kern_constants.h"
+#include "kern_util.h"
 #include "os.h"
 #include "tuntap.h"
 #include "user.h"
index c3bb5ce70c95280e0fe65896d16f2dfb18546074..9387cb11c0ad21aaf2dd3d26161251d35fcd3515 100644 (file)
@@ -17,7 +17,6 @@
 #include <sys/uio.h>
 #include "os.h"
 #include "user.h"
-#include "kern_util.h"
 
 static void copy_stat(struct uml_stat *dst, const struct stat64 *src)
 {
index 6aa6f95d652491ab4e1161247febeaa1c91856c1..a26e0662aa123dacdec44ead98cef1a15f191c30 100644 (file)
@@ -11,7 +11,6 @@
 #include <sys/poll.h>
 #include <sys/types.h>
 #include <sys/time.h>
-#include "kern_util.h"
 #include "user.h"
 #include "process.h"
 #include "sigio.h"
index 9674ed1bef2f7142748f5eee3934c5039cbab772..eedc2d88ef8a5a3d6b00e87e88a8a05e7c77ab89 100644 (file)
@@ -9,7 +9,6 @@
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <sys/statfs.h>
-#include "kern_util.h"
 #include "user.h"
 #include "mem_user.h"
 #include "init.h"
index 37302e86fda0d335296a4db47c02dda226bf3758..7ff8f57b7150c56fcce0495466fb98e8580d5810 100644 (file)
@@ -9,6 +9,7 @@
 #include <errno.h>
 #include <signal.h>
 #include <strings.h>
+#include "kern_util.h"
 #include "os.h"
 #include "sysdep/barrier.h"
 #include "sysdep/sigcontext.h"
index e8b7a97e83d3eb8d75785b6a44e29492ae81efcf..765cfa6ddbcd9a49bff5301fc668f245dae0a703 100644 (file)
@@ -15,6 +15,7 @@
 #include "as-layout.h"
 #include "chan_user.h"
 #include "kern_constants.h"
+#include "kern_util.h"
 #include "mem.h"
 #include "os.h"
 #include "process.h"
index 3b1b9244f468d4a4d54808b61d5e655e54c1bcb3..a19a74f08fa99e505b5278345541f102b5022ddc 100644 (file)
@@ -3,22 +3,26 @@
  * Licensed under the GPL
  */
 
-#if 0
-#include "kern_util.h"
-#include "skas.h"
-#include "ptrace_user.h"
-#include "sysdep/ptrace_user.h"
-#endif
-
 #include <errno.h>
 #include <signal.h>
 #include "sysdep/ptrace.h"
 #include "kern_constants.h"
 #include "as-layout.h"
+#include "kern_util.h"
 #include "os.h"
 #include "sigcontext.h"
 #include "task.h"
 
+void (*sig_info[NSIG])(int, struct uml_pt_regs *) = {
+       [SIGTRAP]       = relay_signal,
+       [SIGFPE]        = relay_signal,
+       [SIGILL]        = relay_signal,
+       [SIGWINCH]      = winch,
+       [SIGBUS]        = bus_handler,
+       [SIGSEGV]       = segv_handler,
+       [SIGIO]         = sigio_handler,
+       [SIGVTALRM]     = timer_handler };
+
 static struct uml_pt_regs ksig_regs[UM_NR_CPUS];
 
 void sig_handler_common_skas(int sig, void *sc_ptr)
diff --git a/arch/um/os-Linux/trap.c b/arch/um/os-Linux/trap.c
deleted file mode 100644 (file)
index 2a1c984..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
- * Licensed under the GPL
- */
-
-#include <signal.h>
-#include "os.h"
-#include "sysdep/ptrace.h"
-
-/* Initialized from linux_main() */
-void (*sig_info[NSIG])(int, struct uml_pt_regs *);
-
-void os_fill_handlinfo(struct kern_handlers h)
-{
-       sig_info[SIGTRAP] = h.relay_signal;
-       sig_info[SIGFPE] = h.relay_signal;
-       sig_info[SIGILL] = h.relay_signal;
-       sig_info[SIGWINCH] = h.winch;
-       sig_info[SIGBUS] = h.bus_handler;
-       sig_info[SIGSEGV] = h.page_fault;
-       sig_info[SIGIO] = h.sigio_handler;
-       sig_info[SIGVTALRM] = h.timer_handler;
-}
index 4cfdd18ea1efdd383e44405a4ddcf98642f0c43d..b09ff66a77eeaf7578d84df8839e2a2961813cd3 100644 (file)
@@ -1,13 +1,16 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+/*
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
 #include <stdlib.h>
+#include <unistd.h>
 #include <errno.h>
+#include <fcntl.h>
+#include "kern_constants.h"
+#include "kern_util.h"
 #include "os.h"
 #include "user.h"
-#include "kern_util.h"
 
 struct grantpt_info {
        int fd;
@@ -26,36 +29,34 @@ static void grantpt_cb(void *arg)
 int get_pty(void)
 {
        struct grantpt_info info;
-       int fd;
-
-       fd = os_open_file("/dev/ptmx", of_rdwr(OPENFLAGS()), 0);
-       if(fd < 0){
-               printk("get_pty : Couldn't open /dev/ptmx - err = %d\n", -fd);
-               return(fd);
+       int fd, err;
+
+       fd = open("/dev/ptmx", O_RDWR);
+       if (fd < 0) {
+               err = -errno;
+               printk(UM_KERN_ERR "get_pty : Couldn't open /dev/ptmx - "
+                      "err = %d\n", errno);
+               return err;
        }
 
        info.fd = fd;
        initial_thread_cb(grantpt_cb, &info);
 
-       if(info.res < 0){
-               printk("get_pty : Couldn't grant pty - errno = %d\n", 
-                      -info.err);
-               return(-1);
+       if (info.res < 0) {
+               err = -info.err;
+               printk(UM_KERN_ERR "get_pty : Couldn't grant pty - "
+                      "errno = %d\n", -info.err);
+               goto out;
        }
-       if(unlockpt(fd) < 0){
-               printk("get_pty : Couldn't unlock pty - errno = %d\n", errno);
-               return(-1);
+
+       if (unlockpt(fd) < 0) {
+               err = -errno;
+               printk(UM_KERN_ERR "get_pty : Couldn't unlock pty - "
+                      "errno = %d\n", errno);
+               goto out;
        }
-       return(fd);
+       return fd;
+out:
+       close(fd);
+       return err;
 }
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index d11a55baa6bd59800860bd0acc822adf89b7ef6b..cc648e6fd3a2c1ecaa92196eeee145b65cc8c47f 100644 (file)
@@ -12,7 +12,6 @@
 #include <sys/time.h>
 #include "init.h"
 #include "user.h"
-#include "kern_util.h"
 #include "os.h"
 
 #define TTY_LOG_DIR "./"
index b0cb05228a97edfcdd202b23b9fd6452f40d5966..a74442d1376213bc5ad41bf3eb11772a743cdeaa 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <signal.h>
 #include "kern_constants.h"
+#include "kern_util.h"
 #include "longjmp.h"
 #include "task.h"
 #include "user.h"