2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
6 #ifndef __KERN_UTIL_H__
7 #define __KERN_UTIL_H__
9 #include "linux/threads.h"
10 #include "sysdep/ptrace.h"
11 #include "sysdep/faultinfo.h"
13 typedef void (*kern_hndl
)(int, union uml_pt_regs
*);
15 struct kern_handlers
{
16 kern_hndl relay_signal
;
18 kern_hndl bus_handler
;
20 kern_hndl sigio_handler
;
21 kern_hndl timer_handler
;
24 extern struct kern_handlers handlinfo_kern
;
27 extern char *linux_prog
;
28 extern char *gdb_init
;
29 extern int kmalloc_ok
;
30 extern int timer_irq_inited
;
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)
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
);
46 extern unsigned long segv(struct faultinfo fi
, unsigned long ip
,
47 int is_user
, void *sc
);
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
);
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
);
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
);
95 extern void bad_segv(struct faultinfo fi
, unsigned long ip
);
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
);
119 extern void arch_switch(void);
120 extern void free_irq(unsigned int, void *);
121 extern int cpu(void);
123 /* Are we disallowed to sleep? Used to choose between GFP_KERNEL and GFP_ATOMIC. */
124 extern int __cant_sleep(void);
125 extern void segv_handler(int sig
, union uml_pt_regs
*regs
);
126 extern void sigio_handler(int sig
, union uml_pt_regs
*regs
);
131 * Overrides for Emacs so that we follow Linus's tabbing style.
132 * Emacs will notice this stuff at the end of the file and automatically
133 * adjust the settings for this buffer only. This must remain at the end
135 * ---------------------------------------------------------------------------
137 * c-file-style: "linux"