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 | 0983a88 | 2008-02-04 22:31:08 -0800 | [diff] [blame] | 12 | extern int uml_exitcode; |
| 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | extern int ncpus; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | extern int kmalloc_ok; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #define UML_ROUND_UP(addr) \ |
Jeff Dike | edea138 | 2008-02-04 22:30:46 -0800 | [diff] [blame] | 18 | ((((unsigned long) addr) + PAGE_SIZE - 1) & PAGE_MASK) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | extern unsigned long alloc_stack(int order, int atomic); |
Jeff Dike | edea138 | 2008-02-04 22:30:46 -0800 | [diff] [blame] | 21 | extern void free_stack(unsigned long stack, int order); |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | extern int do_signal(void); |
Jeff Dike | edea138 | 2008-02-04 22:30:46 -0800 | [diff] [blame] | 24 | extern void copy_sc(struct uml_pt_regs *regs, void *from); |
| 25 | extern void interrupt_end(void); |
| 26 | extern void relay_signal(int sig, struct uml_pt_regs *regs); |
| 27 | |
Bodo Stroesser | c578455 | 2005-05-05 16:15:31 -0700 | [diff] [blame] | 28 | extern unsigned long segv(struct faultinfo fi, unsigned long ip, |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 29 | int is_user, struct uml_pt_regs *regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | extern int handle_page_fault(unsigned long address, unsigned long ip, |
| 31 | int is_write, int is_user, int *code_out); |
Jeff Dike | edea138 | 2008-02-04 22:30:46 -0800 | [diff] [blame] | 32 | |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 33 | extern unsigned int do_IRQ(int irq, struct uml_pt_regs *regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | extern int smp_sigio_handler(void); |
Jeff Dike | edea138 | 2008-02-04 22:30:46 -0800 | [diff] [blame] | 35 | extern void initial_thread_cb(void (*proc)(void *), void *arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | extern int is_syscall(unsigned long addr); |
Jeff Dike | edea138 | 2008-02-04 22:30:46 -0800 | [diff] [blame] | 37 | extern void timer_handler(int sig, struct uml_pt_regs *regs); |
Paolo 'Blaisorblade' Giarrusso | 972410b | 2006-03-31 02:30:21 -0800 | [diff] [blame] | 38 | |
Jeff Dike | edea138 | 2008-02-04 22:30:46 -0800 | [diff] [blame] | 39 | extern void timer_handler(int sig, struct uml_pt_regs *regs); |
Paolo 'Blaisorblade' Giarrusso | b631629 | 2006-01-18 17:42:58 -0800 | [diff] [blame] | 40 | |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 41 | extern int start_uml(void); |
Jeff Dike | edea138 | 2008-02-04 22:30:46 -0800 | [diff] [blame] | 42 | extern void paging_init(void); |
| 43 | |
| 44 | extern void uml_cleanup(void); |
| 45 | extern void do_uml_exitcalls(void); |
| 46 | |
| 47 | /* |
| 48 | * Are we disallowed to sleep? Used to choose between GFP_KERNEL and |
| 49 | * GFP_ATOMIC. |
| 50 | */ |
| 51 | extern int __cant_sleep(void); |
| 52 | extern void *get_current(void); |
| 53 | extern int copy_from_user_proc(void *to, void *from, int size); |
| 54 | extern int cpu(void); |
| 55 | extern char *uml_strdup(const char *string); |
| 56 | |
| 57 | extern unsigned long to_irq_stack(unsigned long *mask_out); |
| 58 | extern unsigned long from_irq_stack(int nested); |
| 59 | |
| 60 | extern void syscall_trace(struct uml_pt_regs *regs, int entryexit); |
| 61 | extern int singlestepping(void *t); |
| 62 | |
| 63 | extern void segv_handler(int sig, struct uml_pt_regs *regs); |
| 64 | extern void bus_handler(int sig, struct uml_pt_regs *regs); |
| 65 | extern void winch(int sig, struct uml_pt_regs *regs); |
Jeff Dike | 3e6f2ac | 2008-02-04 22:30:58 -0800 | [diff] [blame] | 66 | extern void fatal_sigsegv(void) __attribute__ ((noreturn)); |
Jeff Dike | edea138 | 2008-02-04 22:30:46 -0800 | [diff] [blame] | 67 | |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | #endif |