blob: 59cfa9e0cad034739c3add89720269c01f0177c2 [file] [log] [blame]
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -08001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * 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 Stroesserc5784552005-05-05 16:15:31 -070011#include "sysdep/faultinfo.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -080013typedef void (*kern_hndl)(int, union uml_pt_regs *);
14
15struct 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 Dike5e7672e2006-09-27 01:50:33 -070024extern const struct kern_handlers handlinfo_kern;
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -080025
Linus Torvalds1da177e2005-04-16 15:20:36 -070026extern int ncpus;
27extern char *linux_prog;
28extern char *gdb_init;
29extern int kmalloc_ok;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030extern int jail;
31extern int nsyscalls;
32
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#define UML_ROUND_DOWN(addr) ((void *)(((unsigned long) addr) & PAGE_MASK))
34#define UML_ROUND_UP(addr) \
35 UML_ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1)
36
37extern int kernel_fork(unsigned long flags, int (*fn)(void *), void * arg);
38extern unsigned long stack_sp(unsigned long page);
39extern int kernel_thread_proc(void *data);
40extern void syscall_segv(int sig);
41extern int current_pid(void);
42extern unsigned long alloc_stack(int order, int atomic);
43extern int do_signal(void);
44extern int is_stack_fault(unsigned long sp);
Bodo Stroesserc5784552005-05-05 16:15:31 -070045extern unsigned long segv(struct faultinfo fi, unsigned long ip,
46 int is_user, void *sc);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047extern int handle_page_fault(unsigned long address, unsigned long ip,
48 int is_write, int is_user, int *code_out);
49extern void syscall_ready(void);
50extern void set_tracing(void *t, int tracing);
51extern int is_tracing(void *task);
52extern int segv_syscall(void);
53extern void kern_finish_exec(void *task, int new_pid, unsigned long stack);
54extern int page_size(void);
55extern unsigned long page_mask(void);
56extern int need_finish_fork(void);
57extern void free_stack(unsigned long stack, int order);
58extern void add_input_request(int op, void (*proc)(int), void *arg);
59extern char *current_cmd(void);
60extern void timer_handler(int sig, union uml_pt_regs *regs);
61extern int set_signals(int enable);
62extern void force_sigbus(void);
63extern int pid_to_processor_id(int pid);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064extern void deliver_signals(void *t);
65extern int next_syscall_index(int max);
66extern int next_trap_index(int max);
67extern void default_idle(void);
68extern void finish_fork(void);
69extern void paging_init(void);
70extern void init_flush_vm(void);
71extern void *syscall_sp(void *t);
72extern void syscall_trace(union uml_pt_regs *regs, int entryexit);
73extern int hz(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074extern unsigned int do_IRQ(int irq, union uml_pt_regs *regs);
75extern int external_pid(void *t);
Linus Torvalds1da177e2005-04-16 15:20:36 -070076extern void interrupt_end(void);
77extern void initial_thread_cb(void (*proc)(void *), void *arg);
78extern int debugger_signal(int status, int pid);
79extern void debugger_parent_signal(int status, int pid);
80extern void child_signal(int pid, int status);
81extern int init_ptrace_proxy(int idle_pid, int startup, int stop);
82extern int init_parent_proxy(int pid);
83extern int singlestepping(void *t);
84extern void check_stack_overflow(void *ptr);
85extern void relay_signal(int sig, union uml_pt_regs *regs);
86extern void not_implemented(void);
87extern int user_context(unsigned long sp);
88extern void timer_irq(union uml_pt_regs *regs);
89extern void unprotect_stack(unsigned long stack);
90extern void do_uml_exitcalls(void);
91extern int attach_debugger(int idle_pid, int pid, int stop);
Bodo Stroesserc5784552005-05-05 16:15:31 -070092extern void bad_segv(struct faultinfo fi, unsigned long ip);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093extern int config_gdb(char *str);
94extern int remove_gdb(void);
95extern char *uml_strdup(char *string);
96extern void unprotect_kernel_mem(void);
97extern void protect_kernel_mem(void);
98extern void uml_cleanup(void);
99extern void set_current(void *t);
100extern void lock_signalled_task(void *t);
101extern void IPI_handler(int cpu);
102extern int jail_setup(char *line, int *add);
103extern void *get_init_task(void);
104extern int clear_user_proc(void *buf, int size);
105extern int copy_to_user_proc(void *to, void *from, int size);
106extern int copy_from_user_proc(void *to, void *from, int size);
107extern int strlen_user_proc(char *str);
108extern void bus_handler(int sig, union uml_pt_regs *regs);
109extern void winch(int sig, union uml_pt_regs *regs);
110extern long execute_syscall(void *r);
111extern int smp_sigio_handler(void);
112extern void *get_current(void);
113extern struct task_struct *get_task(int pid, int require);
114extern void machine_halt(void);
115extern int is_syscall(unsigned long addr);
Paolo 'Blaisorblade' Giarrusso972410b2006-03-31 02:30:21 -0800116
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117extern void free_irq(unsigned int, void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118extern int cpu(void);
Paolo 'Blaisorblade' Giarrussob6316292006-01-18 17:42:58 -0800119
Jeff Dike5cb38bc2006-06-04 02:51:46 -0700120extern void time_init_kern(void);
121
Paolo 'Blaisorblade' Giarrussob6316292006-01-18 17:42:58 -0800122/* Are we disallowed to sleep? Used to choose between GFP_KERNEL and GFP_ATOMIC. */
123extern int __cant_sleep(void);
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -0800124extern void segv_handler(int sig, union uml_pt_regs *regs);
125extern void sigio_handler(int sig, union uml_pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
127#endif