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