xref: /openbmc/linux/arch/um/include/shared/kern_util.h (revision 8938c48f)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
4  */
5 
6 #ifndef __KERN_UTIL_H__
7 #define __KERN_UTIL_H__
8 
9 #include <sysdep/ptrace.h>
10 #include <sysdep/faultinfo.h>
11 
12 struct siginfo;
13 
14 extern int uml_exitcode;
15 
16 extern int ncpus;
17 extern int kmalloc_ok;
18 
19 #define UML_ROUND_UP(addr) \
20 	((((unsigned long) addr) + PAGE_SIZE - 1) & PAGE_MASK)
21 
22 extern unsigned long alloc_stack(int order, int atomic);
23 extern void free_stack(unsigned long stack, int order);
24 
25 struct pt_regs;
26 extern void do_signal(struct pt_regs *regs);
27 extern void interrupt_end(void);
28 extern void relay_signal(int sig, struct siginfo *si, struct uml_pt_regs *regs);
29 
30 extern unsigned long segv(struct faultinfo fi, unsigned long ip,
31 			  int is_user, struct uml_pt_regs *regs);
32 extern int handle_page_fault(unsigned long address, unsigned long ip,
33 			     int is_write, int is_user, int *code_out);
34 
35 extern unsigned int do_IRQ(int irq, struct uml_pt_regs *regs);
36 extern int smp_sigio_handler(void);
37 extern void initial_thread_cb(void (*proc)(void *), void *arg);
38 extern int is_syscall(unsigned long addr);
39 
40 extern void timer_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs);
41 
42 extern void uml_pm_wake(void);
43 
44 extern int start_uml(void);
45 extern void paging_init(void);
46 
47 extern void uml_cleanup(void);
48 extern void do_uml_exitcalls(void);
49 
50 /*
51  * Are we disallowed to sleep? Used to choose between GFP_KERNEL and
52  * GFP_ATOMIC.
53  */
54 extern int __cant_sleep(void);
55 extern int get_current_pid(void);
56 extern int copy_from_user_proc(void *to, void *from, int size);
57 extern int cpu(void);
58 extern char *uml_strdup(const char *string);
59 
60 extern unsigned long to_irq_stack(unsigned long *mask_out);
61 extern unsigned long from_irq_stack(int nested);
62 
63 extern void syscall_trace(struct uml_pt_regs *regs, int entryexit);
64 extern int singlestepping(void *t);
65 
66 extern void segv_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs);
67 extern void bus_handler(int sig, struct siginfo *si, struct uml_pt_regs *regs);
68 extern void winch(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs);
69 extern void fatal_sigsegv(void) __attribute__ ((noreturn));
70 
71 void um_idle_sleep(void);
72 
73 #endif
74