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 | |
| 9 | #include "linux/threads.h" |
| 10 | #include "sysdep/ptrace.h" |
Bodo Stroesser | c578455 | 2005-05-05 16:15:31 -0700 | [diff] [blame] | 11 | #include "sysdep/faultinfo.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 | |
| 24 | extern struct kern_handlers handlinfo_kern; |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | extern int ncpus; |
| 27 | extern char *linux_prog; |
| 28 | extern char *gdb_init; |
| 29 | extern int kmalloc_ok; |
| 30 | extern int timer_irq_inited; |
| 31 | extern int jail; |
| 32 | extern int nsyscalls; |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #define UML_ROUND_DOWN(addr) ((void *)(((unsigned long) addr) & PAGE_MASK)) |
| 35 | #define UML_ROUND_UP(addr) \ |
| 36 | UML_ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1) |
| 37 | |
| 38 | extern int kernel_fork(unsigned long flags, int (*fn)(void *), void * arg); |
| 39 | extern unsigned long stack_sp(unsigned long page); |
| 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, |
| 47 | int is_user, void *sc); |
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); |
| 55 | extern int page_size(void); |
| 56 | extern unsigned long page_mask(void); |
| 57 | extern int need_finish_fork(void); |
| 58 | extern void free_stack(unsigned long stack, int order); |
| 59 | extern void add_input_request(int op, void (*proc)(int), void *arg); |
| 60 | extern char *current_cmd(void); |
| 61 | extern void timer_handler(int sig, union uml_pt_regs *regs); |
| 62 | extern int set_signals(int enable); |
| 63 | extern void force_sigbus(void); |
| 64 | extern int pid_to_processor_id(int pid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | extern void deliver_signals(void *t); |
| 66 | extern int next_syscall_index(int max); |
| 67 | extern int next_trap_index(int max); |
| 68 | extern void default_idle(void); |
| 69 | extern void finish_fork(void); |
| 70 | extern void paging_init(void); |
| 71 | extern void init_flush_vm(void); |
| 72 | extern void *syscall_sp(void *t); |
| 73 | extern void syscall_trace(union uml_pt_regs *regs, int entryexit); |
| 74 | extern int hz(void); |
| 75 | extern void uml_idle_timer(void); |
| 76 | extern unsigned int do_IRQ(int irq, union uml_pt_regs *regs); |
| 77 | extern int external_pid(void *t); |
| 78 | extern void boot_timer_handler(int sig); |
| 79 | extern void interrupt_end(void); |
| 80 | extern void initial_thread_cb(void (*proc)(void *), void *arg); |
| 81 | extern int debugger_signal(int status, int pid); |
| 82 | extern void debugger_parent_signal(int status, int pid); |
| 83 | extern void child_signal(int pid, int status); |
| 84 | extern int init_ptrace_proxy(int idle_pid, int startup, int stop); |
| 85 | extern int init_parent_proxy(int pid); |
| 86 | extern int singlestepping(void *t); |
| 87 | extern void check_stack_overflow(void *ptr); |
| 88 | extern void relay_signal(int sig, union uml_pt_regs *regs); |
| 89 | extern void not_implemented(void); |
| 90 | extern int user_context(unsigned long sp); |
| 91 | extern void timer_irq(union uml_pt_regs *regs); |
| 92 | extern void unprotect_stack(unsigned long stack); |
| 93 | extern void do_uml_exitcalls(void); |
| 94 | extern int attach_debugger(int idle_pid, int pid, int stop); |
Bodo Stroesser | c578455 | 2005-05-05 16:15:31 -0700 | [diff] [blame] | 95 | extern void bad_segv(struct faultinfo fi, unsigned long ip); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | extern int config_gdb(char *str); |
| 97 | extern int remove_gdb(void); |
| 98 | extern char *uml_strdup(char *string); |
| 99 | extern void unprotect_kernel_mem(void); |
| 100 | extern void protect_kernel_mem(void); |
| 101 | extern void uml_cleanup(void); |
| 102 | extern void set_current(void *t); |
| 103 | extern void lock_signalled_task(void *t); |
| 104 | extern void IPI_handler(int cpu); |
| 105 | extern int jail_setup(char *line, int *add); |
| 106 | extern void *get_init_task(void); |
| 107 | extern int clear_user_proc(void *buf, int size); |
| 108 | extern int copy_to_user_proc(void *to, void *from, int size); |
| 109 | extern int copy_from_user_proc(void *to, void *from, int size); |
| 110 | extern int strlen_user_proc(char *str); |
| 111 | extern void bus_handler(int sig, union uml_pt_regs *regs); |
| 112 | extern void winch(int sig, union uml_pt_regs *regs); |
| 113 | extern long execute_syscall(void *r); |
| 114 | extern int smp_sigio_handler(void); |
| 115 | extern void *get_current(void); |
| 116 | extern struct task_struct *get_task(int pid, int require); |
| 117 | extern void machine_halt(void); |
| 118 | extern int is_syscall(unsigned long addr); |
Paolo 'Blaisorblade' Giarrusso | 972410b | 2006-03-31 02:30:21 -0800 | [diff] [blame] | 119 | |
| 120 | extern void arch_switch_to_tt(struct task_struct *from, struct task_struct *to); |
| 121 | |
| 122 | extern void arch_switch_to_skas(struct task_struct *from, struct task_struct *to); |
| 123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | extern void free_irq(unsigned int, void *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | extern int cpu(void); |
Paolo 'Blaisorblade' Giarrusso | b631629 | 2006-01-18 17:42:58 -0800 | [diff] [blame] | 126 | |
| 127 | /* Are we disallowed to sleep? Used to choose between GFP_KERNEL and GFP_ATOMIC. */ |
| 128 | extern int __cant_sleep(void); |
Gennady Sharapov | ea2ba7d | 2006-01-08 01:01:31 -0800 | [diff] [blame] | 129 | extern void segv_handler(int sig, union uml_pt_regs *regs); |
| 130 | extern void sigio_handler(int sig, union uml_pt_regs *regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | |
| 132 | #endif |
| 133 | |
| 134 | /* |
| 135 | * Overrides for Emacs so that we follow Linus's tabbing style. |
| 136 | * Emacs will notice this stuff at the end of the file and automatically |
| 137 | * adjust the settings for this buffer only. This must remain at the end |
| 138 | * of the file. |
| 139 | * --------------------------------------------------------------------------- |
| 140 | * Local variables: |
| 141 | * c-file-style: "linux" |
| 142 | * End: |
| 143 | */ |