blob: 7e7e84e4bc539af51bde71b0ee301620a5fc6feb [file] [log] [blame]
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -08001/*
Jeff Dikeba180fd2007-10-16 01:27:00 -07002 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Licensed under the GPL
4 */
5
6#ifndef __KERN_UTIL_H__
7#define __KERN_UTIL_H__
8
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include "sysdep/ptrace.h"
Bodo Stroesserc5784552005-05-05 16:15:31 -070010#include "sysdep/faultinfo.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Jeff Dike77bf4402007-10-16 01:26:58 -070012typedef void (*kern_hndl)(int, struct uml_pt_regs *);
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -080013
14struct 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 Dike5e7672e2006-09-27 01:50:33 -070023extern const struct kern_handlers handlinfo_kern;
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -080024
Linus Torvalds1da177e2005-04-16 15:20:36 -070025extern int ncpus;
Linus Torvalds1da177e2005-04-16 15:20:36 -070026extern char *gdb_init;
27extern int kmalloc_ok;
Linus Torvalds1da177e2005-04-16 15:20:36 -070028extern int jail;
29extern int nsyscalls;
30
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#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
35extern int kernel_fork(unsigned long flags, int (*fn)(void *), void * arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -070036extern int kernel_thread_proc(void *data);
37extern void syscall_segv(int sig);
38extern int current_pid(void);
39extern unsigned long alloc_stack(int order, int atomic);
40extern int do_signal(void);
41extern int is_stack_fault(unsigned long sp);
Bodo Stroesserc5784552005-05-05 16:15:31 -070042extern unsigned long segv(struct faultinfo fi, unsigned long ip,
Jeff Dike77bf4402007-10-16 01:26:58 -070043 int is_user, struct uml_pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044extern int handle_page_fault(unsigned long address, unsigned long ip,
45 int is_write, int is_user, int *code_out);
46extern void syscall_ready(void);
47extern void set_tracing(void *t, int tracing);
48extern int is_tracing(void *task);
49extern int segv_syscall(void);
50extern void kern_finish_exec(void *task, int new_pid, unsigned long stack);
Linus Torvalds1da177e2005-04-16 15:20:36 -070051extern unsigned long page_mask(void);
52extern int need_finish_fork(void);
53extern void free_stack(unsigned long stack, int order);
54extern void add_input_request(int op, void (*proc)(int), void *arg);
55extern char *current_cmd(void);
Jeff Dike77bf4402007-10-16 01:26:58 -070056extern void timer_handler(int sig, struct uml_pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070057extern int set_signals(int enable);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058extern int pid_to_processor_id(int pid);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059extern void deliver_signals(void *t);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060extern int next_trap_index(int max);
61extern void default_idle(void);
62extern void finish_fork(void);
63extern void paging_init(void);
64extern void init_flush_vm(void);
65extern void *syscall_sp(void *t);
Jeff Dike77bf4402007-10-16 01:26:58 -070066extern void syscall_trace(struct uml_pt_regs *regs, int entryexit);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067extern int hz(void);
Jeff Dike77bf4402007-10-16 01:26:58 -070068extern unsigned int do_IRQ(int irq, struct uml_pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069extern void interrupt_end(void);
70extern void initial_thread_cb(void (*proc)(void *), void *arg);
71extern int debugger_signal(int status, int pid);
72extern void debugger_parent_signal(int status, int pid);
73extern void child_signal(int pid, int status);
74extern int init_ptrace_proxy(int idle_pid, int startup, int stop);
75extern int init_parent_proxy(int pid);
76extern int singlestepping(void *t);
77extern void check_stack_overflow(void *ptr);
Jeff Dike77bf4402007-10-16 01:26:58 -070078extern void relay_signal(int sig, struct uml_pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070079extern int user_context(unsigned long sp);
Jeff Dike77bf4402007-10-16 01:26:58 -070080extern void timer_irq(struct uml_pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081extern void do_uml_exitcalls(void);
82extern int attach_debugger(int idle_pid, int pid, int stop);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083extern int config_gdb(char *str);
84extern int remove_gdb(void);
85extern char *uml_strdup(char *string);
86extern void unprotect_kernel_mem(void);
87extern void protect_kernel_mem(void);
88extern void uml_cleanup(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089extern void lock_signalled_task(void *t);
90extern void IPI_handler(int cpu);
91extern int jail_setup(char *line, int *add);
92extern void *get_init_task(void);
93extern int clear_user_proc(void *buf, int size);
94extern int copy_to_user_proc(void *to, void *from, int size);
95extern int copy_from_user_proc(void *to, void *from, int size);
96extern int strlen_user_proc(char *str);
Linus Torvalds1da177e2005-04-16 15:20:36 -070097extern long execute_syscall(void *r);
98extern int smp_sigio_handler(void);
99extern void *get_current(void);
100extern struct task_struct *get_task(int pid, int require);
101extern void machine_halt(void);
102extern int is_syscall(unsigned long addr);
Paolo 'Blaisorblade' Giarrusso972410b2006-03-31 02:30:21 -0800103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104extern void free_irq(unsigned int, void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105extern int cpu(void);
Paolo 'Blaisorblade' Giarrussob6316292006-01-18 17:42:58 -0800106
Jeff Dike5cb38bc2006-06-04 02:51:46 -0700107extern void time_init_kern(void);
108
Paolo 'Blaisorblade' Giarrussob6316292006-01-18 17:42:58 -0800109/* Are we disallowed to sleep? Used to choose between GFP_KERNEL and GFP_ATOMIC. */
110extern int __cant_sleep(void);
Jeff Dike77bf4402007-10-16 01:26:58 -0700111extern void sigio_handler(int sig, struct uml_pt_regs *regs);
112extern void copy_sc(struct uml_pt_regs *regs, void *from);
Jeff Dike508a9272007-09-18 22:46:49 -0700113extern unsigned long to_irq_stack(unsigned long *mask_out);
Jeff Dikec14b8492007-05-10 22:22:34 -0700114unsigned long from_irq_stack(int nested);
Jeff Dike77bf4402007-10-16 01:26:58 -0700115extern int start_uml(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116#endif