blob: 8d7f7c1cb9c64e40dd96cd17f8e65fe3b9a323da [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
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include "sysdep/ptrace.h"
Bodo Stroesserc5784552005-05-05 16:15:31 -070010#include "sysdep/faultinfo.h"
Jeff Dike6e21aec2007-05-06 14:51:21 -070011#include "uml-config.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;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027extern char *gdb_init;
28extern int kmalloc_ok;
Linus Torvalds1da177e2005-04-16 15:20:36 -070029extern int jail;
30extern int nsyscalls;
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#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
36extern int kernel_fork(unsigned long flags, int (*fn)(void *), void * arg);
Jeff Dike6e21aec2007-05-06 14:51:21 -070037#ifdef UML_CONFIG_MODE_TT
Linus Torvalds1da177e2005-04-16 15:20:36 -070038extern unsigned long stack_sp(unsigned long page);
Jeff Dike6e21aec2007-05-06 14:51:21 -070039#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070040extern int kernel_thread_proc(void *data);
41extern void syscall_segv(int sig);
42extern int current_pid(void);
43extern unsigned long alloc_stack(int order, int atomic);
44extern int do_signal(void);
45extern int is_stack_fault(unsigned long sp);
Bodo Stroesserc5784552005-05-05 16:15:31 -070046extern unsigned long segv(struct faultinfo fi, unsigned long ip,
Jeff Dike5d864562007-05-06 14:51:24 -070047 int is_user, union uml_pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070048extern int handle_page_fault(unsigned long address, unsigned long ip,
49 int is_write, int is_user, int *code_out);
50extern void syscall_ready(void);
51extern void set_tracing(void *t, int tracing);
52extern int is_tracing(void *task);
53extern int segv_syscall(void);
54extern void kern_finish_exec(void *task, int new_pid, unsigned long stack);
Linus Torvalds1da177e2005-04-16 15:20:36 -070055extern 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);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062extern int pid_to_processor_id(int pid);
Linus Torvalds1da177e2005-04-16 15:20:36 -070063extern void deliver_signals(void *t);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064extern int next_trap_index(int max);
65extern void default_idle(void);
66extern void finish_fork(void);
67extern void paging_init(void);
68extern void init_flush_vm(void);
69extern void *syscall_sp(void *t);
70extern void syscall_trace(union uml_pt_regs *regs, int entryexit);
71extern int hz(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072extern unsigned int do_IRQ(int irq, union uml_pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073extern void interrupt_end(void);
74extern void initial_thread_cb(void (*proc)(void *), void *arg);
75extern int debugger_signal(int status, int pid);
76extern void debugger_parent_signal(int status, int pid);
77extern void child_signal(int pid, int status);
78extern int init_ptrace_proxy(int idle_pid, int startup, int stop);
79extern int init_parent_proxy(int pid);
80extern int singlestepping(void *t);
81extern void check_stack_overflow(void *ptr);
82extern void relay_signal(int sig, union uml_pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083extern int user_context(unsigned long sp);
84extern void timer_irq(union uml_pt_regs *regs);
85extern void unprotect_stack(unsigned long stack);
86extern void do_uml_exitcalls(void);
87extern int attach_debugger(int idle_pid, int pid, int stop);
Linus Torvalds1da177e2005-04-16 15:20:36 -070088extern int config_gdb(char *str);
89extern int remove_gdb(void);
90extern char *uml_strdup(char *string);
91extern void unprotect_kernel_mem(void);
92extern void protect_kernel_mem(void);
93extern void uml_cleanup(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094extern void lock_signalled_task(void *t);
95extern void IPI_handler(int cpu);
96extern int jail_setup(char *line, int *add);
97extern void *get_init_task(void);
98extern int clear_user_proc(void *buf, int size);
99extern int copy_to_user_proc(void *to, void *from, int size);
100extern int copy_from_user_proc(void *to, void *from, int size);
101extern int strlen_user_proc(char *str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102extern long execute_syscall(void *r);
103extern int smp_sigio_handler(void);
104extern void *get_current(void);
105extern struct task_struct *get_task(int pid, int require);
106extern void machine_halt(void);
107extern int is_syscall(unsigned long addr);
Paolo 'Blaisorblade' Giarrusso972410b2006-03-31 02:30:21 -0800108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109extern void free_irq(unsigned int, void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110extern int cpu(void);
Paolo 'Blaisorblade' Giarrussob6316292006-01-18 17:42:58 -0800111
Jeff Dike5cb38bc2006-06-04 02:51:46 -0700112extern void time_init_kern(void);
113
Paolo 'Blaisorblade' Giarrussob6316292006-01-18 17:42:58 -0800114/* Are we disallowed to sleep? Used to choose between GFP_KERNEL and GFP_ATOMIC. */
115extern int __cant_sleep(void);
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -0800116extern void sigio_handler(int sig, union uml_pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
Jeff Dike377fad32007-05-06 14:51:25 -0700118extern void copy_sc(union uml_pt_regs *regs, void *from);
119
Jeff Dikec14b8492007-05-10 22:22:34 -0700120unsigned long to_irq_stack(int sig, unsigned long *mask_out);
121unsigned long from_irq_stack(int nested);
122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123#endif