Gennady Sharapov | ea2ba7d | 2006-01-08 01:01:31 -0800 | [diff] [blame] | 1 | /* |
Jeff Dike | ba180fd | 2007-10-16 01:27:00 -0700 | [diff] [blame^] | 2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * Licensed under the GPL |
| 4 | */ |
| 5 | |
| 6 | #ifndef __KERN_UTIL_H__ |
| 7 | #define __KERN_UTIL_H__ |
| 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include "sysdep/ptrace.h" |
Bodo Stroesser | c578455 | 2005-05-05 16:15:31 -0700 | [diff] [blame] | 10 | #include "sysdep/faultinfo.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 12 | typedef void (*kern_hndl)(int, struct uml_pt_regs *); |
Gennady Sharapov | ea2ba7d | 2006-01-08 01:01:31 -0800 | [diff] [blame] | 13 | |
| 14 | struct kern_handlers { |
| 15 | kern_hndl relay_signal; |
| 16 | kern_hndl winch; |
| 17 | kern_hndl bus_handler; |
| 18 | kern_hndl page_fault; |
| 19 | kern_hndl sigio_handler; |
| 20 | kern_hndl timer_handler; |
| 21 | }; |
| 22 | |
Jeff Dike | 5e7672e | 2006-09-27 01:50:33 -0700 | [diff] [blame] | 23 | extern const struct kern_handlers handlinfo_kern; |
Gennady Sharapov | ea2ba7d | 2006-01-08 01:01:31 -0800 | [diff] [blame] | 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | extern int ncpus; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | extern char *gdb_init; |
| 27 | extern int kmalloc_ok; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | extern int jail; |
| 29 | extern int nsyscalls; |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #define UML_ROUND_DOWN(addr) ((void *)(((unsigned long) addr) & PAGE_MASK)) |
| 32 | #define UML_ROUND_UP(addr) \ |
| 33 | UML_ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1) |
| 34 | |
| 35 | extern int kernel_fork(unsigned long flags, int (*fn)(void *), void * arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | extern int kernel_thread_proc(void *data); |
| 37 | extern void syscall_segv(int sig); |
| 38 | extern int current_pid(void); |
| 39 | extern unsigned long alloc_stack(int order, int atomic); |
| 40 | extern int do_signal(void); |
| 41 | extern int is_stack_fault(unsigned long sp); |
Bodo Stroesser | c578455 | 2005-05-05 16:15:31 -0700 | [diff] [blame] | 42 | extern unsigned long segv(struct faultinfo fi, unsigned long ip, |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 43 | int is_user, struct uml_pt_regs *regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | extern int handle_page_fault(unsigned long address, unsigned long ip, |
| 45 | int is_write, int is_user, int *code_out); |
| 46 | extern void syscall_ready(void); |
| 47 | extern void set_tracing(void *t, int tracing); |
| 48 | extern int is_tracing(void *task); |
| 49 | extern int segv_syscall(void); |
| 50 | extern void kern_finish_exec(void *task, int new_pid, unsigned long stack); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | extern unsigned long page_mask(void); |
| 52 | extern int need_finish_fork(void); |
| 53 | extern void free_stack(unsigned long stack, int order); |
| 54 | extern void add_input_request(int op, void (*proc)(int), void *arg); |
| 55 | extern char *current_cmd(void); |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 56 | extern void timer_handler(int sig, struct uml_pt_regs *regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | extern int set_signals(int enable); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | extern int pid_to_processor_id(int pid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | extern void deliver_signals(void *t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | extern int next_trap_index(int max); |
| 61 | extern void default_idle(void); |
| 62 | extern void finish_fork(void); |
| 63 | extern void paging_init(void); |
| 64 | extern void init_flush_vm(void); |
| 65 | extern void *syscall_sp(void *t); |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 66 | extern void syscall_trace(struct uml_pt_regs *regs, int entryexit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | extern int hz(void); |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 68 | extern unsigned int do_IRQ(int irq, struct uml_pt_regs *regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | extern void interrupt_end(void); |
| 70 | extern void initial_thread_cb(void (*proc)(void *), void *arg); |
| 71 | extern int debugger_signal(int status, int pid); |
| 72 | extern void debugger_parent_signal(int status, int pid); |
| 73 | extern void child_signal(int pid, int status); |
| 74 | extern int init_ptrace_proxy(int idle_pid, int startup, int stop); |
| 75 | extern int init_parent_proxy(int pid); |
| 76 | extern int singlestepping(void *t); |
| 77 | extern void check_stack_overflow(void *ptr); |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 78 | extern void relay_signal(int sig, struct uml_pt_regs *regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | extern int user_context(unsigned long sp); |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 80 | extern void timer_irq(struct uml_pt_regs *regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | extern void do_uml_exitcalls(void); |
| 82 | extern int attach_debugger(int idle_pid, int pid, int stop); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | extern int config_gdb(char *str); |
| 84 | extern int remove_gdb(void); |
| 85 | extern char *uml_strdup(char *string); |
| 86 | extern void unprotect_kernel_mem(void); |
| 87 | extern void protect_kernel_mem(void); |
| 88 | extern void uml_cleanup(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | extern void lock_signalled_task(void *t); |
| 90 | extern void IPI_handler(int cpu); |
| 91 | extern int jail_setup(char *line, int *add); |
| 92 | extern void *get_init_task(void); |
| 93 | extern int clear_user_proc(void *buf, int size); |
| 94 | extern int copy_to_user_proc(void *to, void *from, int size); |
| 95 | extern int copy_from_user_proc(void *to, void *from, int size); |
| 96 | extern int strlen_user_proc(char *str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | extern long execute_syscall(void *r); |
| 98 | extern int smp_sigio_handler(void); |
| 99 | extern void *get_current(void); |
| 100 | extern struct task_struct *get_task(int pid, int require); |
| 101 | extern void machine_halt(void); |
| 102 | extern int is_syscall(unsigned long addr); |
Paolo 'Blaisorblade' Giarrusso | 972410b | 2006-03-31 02:30:21 -0800 | [diff] [blame] | 103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | extern void free_irq(unsigned int, void *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | extern int cpu(void); |
Paolo 'Blaisorblade' Giarrusso | b631629 | 2006-01-18 17:42:58 -0800 | [diff] [blame] | 106 | |
Jeff Dike | 5cb38bc | 2006-06-04 02:51:46 -0700 | [diff] [blame] | 107 | extern void time_init_kern(void); |
| 108 | |
Paolo 'Blaisorblade' Giarrusso | b631629 | 2006-01-18 17:42:58 -0800 | [diff] [blame] | 109 | /* Are we disallowed to sleep? Used to choose between GFP_KERNEL and GFP_ATOMIC. */ |
| 110 | extern int __cant_sleep(void); |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 111 | extern void sigio_handler(int sig, struct uml_pt_regs *regs); |
| 112 | extern void copy_sc(struct uml_pt_regs *regs, void *from); |
Jeff Dike | 508a927 | 2007-09-18 22:46:49 -0700 | [diff] [blame] | 113 | extern unsigned long to_irq_stack(unsigned long *mask_out); |
Jeff Dike | c14b849 | 2007-05-10 22:22:34 -0700 | [diff] [blame] | 114 | unsigned long from_irq_stack(int nested); |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 115 | extern int start_uml(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | #endif |