diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /arch/um/include | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'arch/um/include')
48 files changed, 957 insertions, 0 deletions
diff --git a/arch/um/include/asm/apic.h b/arch/um/include/asm/apic.h new file mode 100644 index 00000000000..876dee84ab1 --- /dev/null +++ b/arch/um/include/asm/apic.h | |||
@@ -0,0 +1,4 @@ | |||
1 | #ifndef __UM_APIC_H | ||
2 | #define __UM_APIC_H | ||
3 | |||
4 | #endif | ||
diff --git a/arch/um/include/asm/arch_hweight.h b/arch/um/include/asm/arch_hweight.h new file mode 100644 index 00000000000..c656cf443f4 --- /dev/null +++ b/arch/um/include/asm/arch_hweight.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _ASM_UM_HWEIGHT_H | ||
2 | #define _ASM_UM_HWEIGHT_H | ||
3 | |||
4 | #include <asm-generic/bitops/arch_hweight.h> | ||
5 | |||
6 | #endif | ||
diff --git a/arch/um/include/asm/auxvec.h b/arch/um/include/asm/auxvec.h new file mode 100644 index 00000000000..1e5e1c2fc9b --- /dev/null +++ b/arch/um/include/asm/auxvec.h | |||
@@ -0,0 +1,4 @@ | |||
1 | #ifndef __UM_AUXVEC_H | ||
2 | #define __UM_AUXVEC_H | ||
3 | |||
4 | #endif | ||
diff --git a/arch/um/include/asm/bug.h b/arch/um/include/asm/bug.h new file mode 100644 index 00000000000..9e33b864c35 --- /dev/null +++ b/arch/um/include/asm/bug.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __UM_BUG_H | ||
2 | #define __UM_BUG_H | ||
3 | |||
4 | #include <asm-generic/bug.h> | ||
5 | |||
6 | #endif | ||
diff --git a/arch/um/include/asm/checksum.h b/arch/um/include/asm/checksum.h new file mode 100644 index 00000000000..5b501361e36 --- /dev/null +++ b/arch/um/include/asm/checksum.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __UM_CHECKSUM_H | ||
2 | #define __UM_CHECKSUM_H | ||
3 | |||
4 | #include "sysdep/checksum.h" | ||
5 | |||
6 | #endif | ||
diff --git a/arch/um/include/asm/cputime.h b/arch/um/include/asm/cputime.h new file mode 100644 index 00000000000..c84acbadfa2 --- /dev/null +++ b/arch/um/include/asm/cputime.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __UM_CPUTIME_H | ||
2 | #define __UM_CPUTIME_H | ||
3 | |||
4 | #include <asm-generic/cputime.h> | ||
5 | |||
6 | #endif /* __UM_CPUTIME_H */ | ||
diff --git a/arch/um/include/asm/current.h b/arch/um/include/asm/current.h new file mode 100644 index 00000000000..c2191d9aa03 --- /dev/null +++ b/arch/um/include/asm/current.h | |||
@@ -0,0 +1,13 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __UM_CURRENT_H | ||
7 | #define __UM_CURRENT_H | ||
8 | |||
9 | #include "linux/thread_info.h" | ||
10 | |||
11 | #define current (current_thread_info()->task) | ||
12 | |||
13 | #endif | ||
diff --git a/arch/um/include/asm/delay.h b/arch/um/include/asm/delay.h new file mode 100644 index 00000000000..8a5576d8eda --- /dev/null +++ b/arch/um/include/asm/delay.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #ifndef __UM_DELAY_H | ||
2 | #define __UM_DELAY_H | ||
3 | |||
4 | /* Undefined on purpose */ | ||
5 | extern void __bad_udelay(void); | ||
6 | extern void __bad_ndelay(void); | ||
7 | |||
8 | extern void __udelay(unsigned long usecs); | ||
9 | extern void __ndelay(unsigned long usecs); | ||
10 | extern void __delay(unsigned long loops); | ||
11 | |||
12 | #define udelay(n) ((__builtin_constant_p(n) && (n) > 20000) ? \ | ||
13 | __bad_udelay() : __udelay(n)) | ||
14 | |||
15 | #define ndelay(n) ((__builtin_constant_p(n) && (n) > 20000) ? \ | ||
16 | __bad_ndelay() : __ndelay(n)) | ||
17 | |||
18 | #endif | ||
diff --git a/arch/um/include/asm/desc.h b/arch/um/include/asm/desc.h new file mode 100644 index 00000000000..4ec34a51b62 --- /dev/null +++ b/arch/um/include/asm/desc.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef __UM_DESC_H | ||
2 | #define __UM_DESC_H | ||
3 | |||
4 | /* Taken from asm-i386/desc.h, it's the only thing we need. The rest wouldn't | ||
5 | * compile, and has never been used. */ | ||
6 | #define LDT_empty(info) (\ | ||
7 | (info)->base_addr == 0 && \ | ||
8 | (info)->limit == 0 && \ | ||
9 | (info)->contents == 0 && \ | ||
10 | (info)->read_exec_only == 1 && \ | ||
11 | (info)->seg_32bit == 0 && \ | ||
12 | (info)->limit_in_pages == 0 && \ | ||
13 | (info)->seg_not_present == 1 && \ | ||
14 | (info)->useable == 0 ) | ||
15 | |||
16 | #endif | ||
diff --git a/arch/um/include/asm/device.h b/arch/um/include/asm/device.h new file mode 100644 index 00000000000..d8f9872b0e2 --- /dev/null +++ b/arch/um/include/asm/device.h | |||
@@ -0,0 +1,7 @@ | |||
1 | /* | ||
2 | * Arch specific extensions to struct device | ||
3 | * | ||
4 | * This file is released under the GPLv2 | ||
5 | */ | ||
6 | #include <asm-generic/device.h> | ||
7 | |||
diff --git a/arch/um/include/asm/emergency-restart.h b/arch/um/include/asm/emergency-restart.h new file mode 100644 index 00000000000..108d8c48e42 --- /dev/null +++ b/arch/um/include/asm/emergency-restart.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _ASM_EMERGENCY_RESTART_H | ||
2 | #define _ASM_EMERGENCY_RESTART_H | ||
3 | |||
4 | #include <asm-generic/emergency-restart.h> | ||
5 | |||
6 | #endif /* _ASM_EMERGENCY_RESTART_H */ | ||
diff --git a/arch/um/include/asm/ftrace.h b/arch/um/include/asm/ftrace.h new file mode 100644 index 00000000000..40a8c178f10 --- /dev/null +++ b/arch/um/include/asm/ftrace.h | |||
@@ -0,0 +1 @@ | |||
/* empty */ | |||
diff --git a/arch/um/include/asm/futex.h b/arch/um/include/asm/futex.h new file mode 100644 index 00000000000..6a332a9f099 --- /dev/null +++ b/arch/um/include/asm/futex.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _ASM_FUTEX_H | ||
2 | #define _ASM_FUTEX_H | ||
3 | |||
4 | #include <asm-generic/futex.h> | ||
5 | |||
6 | #endif | ||
diff --git a/arch/um/include/asm/hardirq.h b/arch/um/include/asm/hardirq.h new file mode 100644 index 00000000000..fb3c05a0cbb --- /dev/null +++ b/arch/um/include/asm/hardirq.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/hardirq.h> | |||
diff --git a/arch/um/include/asm/hw_irq.h b/arch/um/include/asm/hw_irq.h new file mode 100644 index 00000000000..1cf84cf5f21 --- /dev/null +++ b/arch/um/include/asm/hw_irq.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef _ASM_UM_HW_IRQ_H | ||
2 | #define _ASM_UM_HW_IRQ_H | ||
3 | |||
4 | #include "asm/irq.h" | ||
5 | #include "asm/archparam.h" | ||
6 | |||
7 | #endif | ||
diff --git a/arch/um/include/asm/io.h b/arch/um/include/asm/io.h new file mode 100644 index 00000000000..44e8b8c772a --- /dev/null +++ b/arch/um/include/asm/io.h | |||
@@ -0,0 +1,57 @@ | |||
1 | #ifndef __UM_IO_H | ||
2 | #define __UM_IO_H | ||
3 | |||
4 | #include "asm/page.h" | ||
5 | |||
6 | #define IO_SPACE_LIMIT 0xdeadbeef /* Sure hope nothing uses this */ | ||
7 | |||
8 | static inline int inb(unsigned long i) { return(0); } | ||
9 | static inline void outb(char c, unsigned long i) { } | ||
10 | |||
11 | /* | ||
12 | * Change virtual addresses to physical addresses and vv. | ||
13 | * These are pretty trivial | ||
14 | */ | ||
15 | static inline unsigned long virt_to_phys(volatile void * address) | ||
16 | { | ||
17 | return __pa((void *) address); | ||
18 | } | ||
19 | |||
20 | static inline void * phys_to_virt(unsigned long address) | ||
21 | { | ||
22 | return __va(address); | ||
23 | } | ||
24 | |||
25 | /* | ||
26 | * Convert a physical pointer to a virtual kernel pointer for /dev/mem | ||
27 | * access | ||
28 | */ | ||
29 | #define xlate_dev_mem_ptr(p) __va(p) | ||
30 | |||
31 | /* | ||
32 | * Convert a virtual cached pointer to an uncached pointer | ||
33 | */ | ||
34 | #define xlate_dev_kmem_ptr(p) p | ||
35 | |||
36 | static inline void writeb(unsigned char b, volatile void __iomem *addr) | ||
37 | { | ||
38 | *(volatile unsigned char __force *) addr = b; | ||
39 | } | ||
40 | static inline void writew(unsigned short b, volatile void __iomem *addr) | ||
41 | { | ||
42 | *(volatile unsigned short __force *) addr = b; | ||
43 | } | ||
44 | static inline void writel(unsigned int b, volatile void __iomem *addr) | ||
45 | { | ||
46 | *(volatile unsigned int __force *) addr = b; | ||
47 | } | ||
48 | static inline void writeq(unsigned int b, volatile void __iomem *addr) | ||
49 | { | ||
50 | *(volatile unsigned long long __force *) addr = b; | ||
51 | } | ||
52 | #define __raw_writeb writeb | ||
53 | #define __raw_writew writew | ||
54 | #define __raw_writel writel | ||
55 | #define __raw_writeq writeq | ||
56 | |||
57 | #endif | ||
diff --git a/arch/um/include/asm/irq_regs.h b/arch/um/include/asm/irq_regs.h new file mode 100644 index 00000000000..3dd9c0b7027 --- /dev/null +++ b/arch/um/include/asm/irq_regs.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/irq_regs.h> | |||
diff --git a/arch/um/include/asm/irq_vectors.h b/arch/um/include/asm/irq_vectors.h new file mode 100644 index 00000000000..272a81e0ce1 --- /dev/null +++ b/arch/um/include/asm/irq_vectors.h | |||
@@ -0,0 +1,10 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __UM_IRQ_VECTORS_H | ||
7 | #define __UM_IRQ_VECTORS_H | ||
8 | |||
9 | #endif | ||
10 | |||
diff --git a/arch/um/include/asm/kdebug.h b/arch/um/include/asm/kdebug.h new file mode 100644 index 00000000000..6ece1b03766 --- /dev/null +++ b/arch/um/include/asm/kdebug.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/kdebug.h> | |||
diff --git a/arch/um/include/asm/mutex.h b/arch/um/include/asm/mutex.h new file mode 100644 index 00000000000..458c1f7fbc1 --- /dev/null +++ b/arch/um/include/asm/mutex.h | |||
@@ -0,0 +1,9 @@ | |||
1 | /* | ||
2 | * Pull in the generic implementation for the mutex fastpath. | ||
3 | * | ||
4 | * TODO: implement optimized primitives instead, or leave the generic | ||
5 | * implementation in place, or pick the atomic_xchg() based generic | ||
6 | * implementation. (see asm-generic/mutex-xchg.h for details) | ||
7 | */ | ||
8 | |||
9 | #include <asm-generic/mutex-dec.h> | ||
diff --git a/arch/um/include/asm/page_offset.h b/arch/um/include/asm/page_offset.h new file mode 100644 index 00000000000..1c168dfbf35 --- /dev/null +++ b/arch/um/include/asm/page_offset.h | |||
@@ -0,0 +1 @@ | |||
#define PAGE_OFFSET_RAW (uml_physmem) | |||
diff --git a/arch/um/include/asm/param.h b/arch/um/include/asm/param.h new file mode 100644 index 00000000000..e44f4e60d16 --- /dev/null +++ b/arch/um/include/asm/param.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef _UM_PARAM_H | ||
2 | #define _UM_PARAM_H | ||
3 | |||
4 | #define EXEC_PAGESIZE 4096 | ||
5 | |||
6 | #ifndef NOGROUP | ||
7 | #define NOGROUP (-1) | ||
8 | #endif | ||
9 | |||
10 | #define MAXHOSTNAMELEN 64 /* max length of hostname */ | ||
11 | |||
12 | #ifdef __KERNEL__ | ||
13 | #define HZ CONFIG_HZ | ||
14 | #define USER_HZ 100 /* .. some user interfaces are in "ticks" */ | ||
15 | #define CLOCKS_PER_SEC (USER_HZ) /* frequency at which times() counts */ | ||
16 | #else | ||
17 | #define HZ 100 | ||
18 | #endif | ||
19 | |||
20 | #endif | ||
diff --git a/arch/um/include/asm/pci.h b/arch/um/include/asm/pci.h new file mode 100644 index 00000000000..b44cf59ede1 --- /dev/null +++ b/arch/um/include/asm/pci.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __UM_PCI_H | ||
2 | #define __UM_PCI_H | ||
3 | |||
4 | #define PCI_DMA_BUS_IS_PHYS (1) | ||
5 | |||
6 | #endif | ||
diff --git a/arch/um/include/asm/pda.h b/arch/um/include/asm/pda.h new file mode 100644 index 00000000000..ddcd774fc2a --- /dev/null +++ b/arch/um/include/asm/pda.h | |||
@@ -0,0 +1,21 @@ | |||
1 | /* | ||
2 | * Copyright 2003 PathScale, Inc. | ||
3 | * | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #ifndef __UM_PDA_X86_64_H | ||
8 | #define __UM_PDA_X86_64_H | ||
9 | |||
10 | /* XXX */ | ||
11 | struct foo { | ||
12 | unsigned int __softirq_pending; | ||
13 | unsigned int __nmi_count; | ||
14 | }; | ||
15 | |||
16 | extern struct foo me; | ||
17 | |||
18 | #define read_pda(me) (&me) | ||
19 | |||
20 | #endif | ||
21 | |||
diff --git a/arch/um/include/asm/percpu.h b/arch/um/include/asm/percpu.h new file mode 100644 index 00000000000..efe7508d8ab --- /dev/null +++ b/arch/um/include/asm/percpu.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __UM_PERCPU_H | ||
2 | #define __UM_PERCPU_H | ||
3 | |||
4 | #include <asm-generic/percpu.h> | ||
5 | |||
6 | #endif /* __UM_PERCPU_H */ | ||
diff --git a/arch/um/include/asm/required-features.h b/arch/um/include/asm/required-features.h new file mode 100644 index 00000000000..dfb967b2d2f --- /dev/null +++ b/arch/um/include/asm/required-features.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef __UM_REQUIRED_FEATURES_H | ||
2 | #define __UM_REQUIRED_FEATURES_H | ||
3 | |||
4 | /* | ||
5 | * Nothing to see, just need something for the i386 and x86_64 asm | ||
6 | * headers to include. | ||
7 | */ | ||
8 | |||
9 | #endif | ||
diff --git a/arch/um/include/asm/sections.h b/arch/um/include/asm/sections.h new file mode 100644 index 00000000000..6b0231eefea --- /dev/null +++ b/arch/um/include/asm/sections.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef _UM_SECTIONS_H | ||
2 | #define _UM_SECTIONS_H | ||
3 | |||
4 | /* nothing to see, move along */ | ||
5 | #include <asm-generic/sections.h> | ||
6 | |||
7 | #endif | ||
diff --git a/arch/um/include/asm/segment.h b/arch/um/include/asm/segment.h new file mode 100644 index 00000000000..45183fcd10b --- /dev/null +++ b/arch/um/include/asm/segment.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef __UM_SEGMENT_H | ||
2 | #define __UM_SEGMENT_H | ||
3 | |||
4 | extern int host_gdt_entry_tls_min; | ||
5 | |||
6 | #define GDT_ENTRY_TLS_ENTRIES 3 | ||
7 | #define GDT_ENTRY_TLS_MIN host_gdt_entry_tls_min | ||
8 | #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1) | ||
9 | |||
10 | #endif | ||
diff --git a/arch/um/include/asm/system.h b/arch/um/include/asm/system.h new file mode 100644 index 00000000000..68a90ecd145 --- /dev/null +++ b/arch/um/include/asm/system.h | |||
@@ -0,0 +1,47 @@ | |||
1 | #ifndef __UM_SYSTEM_GENERIC_H | ||
2 | #define __UM_SYSTEM_GENERIC_H | ||
3 | |||
4 | #include "sysdep/system.h" | ||
5 | |||
6 | extern int get_signals(void); | ||
7 | extern int set_signals(int enable); | ||
8 | extern void block_signals(void); | ||
9 | extern void unblock_signals(void); | ||
10 | |||
11 | static inline unsigned long arch_local_save_flags(void) | ||
12 | { | ||
13 | return get_signals(); | ||
14 | } | ||
15 | |||
16 | static inline void arch_local_irq_restore(unsigned long flags) | ||
17 | { | ||
18 | set_signals(flags); | ||
19 | } | ||
20 | |||
21 | static inline void arch_local_irq_enable(void) | ||
22 | { | ||
23 | unblock_signals(); | ||
24 | } | ||
25 | |||
26 | static inline void arch_local_irq_disable(void) | ||
27 | { | ||
28 | block_signals(); | ||
29 | } | ||
30 | |||
31 | static inline unsigned long arch_local_irq_save(void) | ||
32 | { | ||
33 | unsigned long flags; | ||
34 | flags = arch_local_save_flags(); | ||
35 | arch_local_irq_disable(); | ||
36 | return flags; | ||
37 | } | ||
38 | |||
39 | static inline bool arch_irqs_disabled(void) | ||
40 | { | ||
41 | return arch_local_save_flags() == 0; | ||
42 | } | ||
43 | |||
44 | extern void *_switch_to(void *prev, void *next, void *last); | ||
45 | #define switch_to(prev, next, last) prev = _switch_to(prev, next, last) | ||
46 | |||
47 | #endif | ||
diff --git a/arch/um/include/asm/topology.h b/arch/um/include/asm/topology.h new file mode 100644 index 00000000000..0905e4f21d4 --- /dev/null +++ b/arch/um/include/asm/topology.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef _ASM_UM_TOPOLOGY_H | ||
2 | #define _ASM_UM_TOPOLOGY_H | ||
3 | |||
4 | #include <asm-generic/topology.h> | ||
5 | |||
6 | #endif | ||
diff --git a/arch/um/include/asm/xor.h b/arch/um/include/asm/xor.h new file mode 100644 index 00000000000..a19db3e1724 --- /dev/null +++ b/arch/um/include/asm/xor.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __UM_XOR_H | ||
2 | #define __UM_XOR_H | ||
3 | |||
4 | #include "asm-generic/xor.h" | ||
5 | |||
6 | #endif | ||
diff --git a/arch/um/include/shared/chan_kern.h b/arch/um/include/shared/chan_kern.h new file mode 100644 index 00000000000..1e651457e04 --- /dev/null +++ b/arch/um/include/shared/chan_kern.h | |||
@@ -0,0 +1,50 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __CHAN_KERN_H__ | ||
7 | #define __CHAN_KERN_H__ | ||
8 | |||
9 | #include "linux/tty.h" | ||
10 | #include "linux/list.h" | ||
11 | #include "linux/console.h" | ||
12 | #include "chan_user.h" | ||
13 | #include "line.h" | ||
14 | |||
15 | struct chan { | ||
16 | struct list_head list; | ||
17 | struct list_head free_list; | ||
18 | struct line *line; | ||
19 | char *dev; | ||
20 | unsigned int primary:1; | ||
21 | unsigned int input:1; | ||
22 | unsigned int output:1; | ||
23 | unsigned int opened:1; | ||
24 | unsigned int enabled:1; | ||
25 | int fd; | ||
26 | const struct chan_ops *ops; | ||
27 | void *data; | ||
28 | }; | ||
29 | |||
30 | extern void chan_interrupt(struct list_head *chans, struct delayed_work *task, | ||
31 | struct tty_struct *tty, int irq); | ||
32 | extern int parse_chan_pair(char *str, struct line *line, int device, | ||
33 | const struct chan_opts *opts, char **error_out); | ||
34 | extern int write_chan(struct list_head *chans, const char *buf, int len, | ||
35 | int write_irq); | ||
36 | extern int console_write_chan(struct list_head *chans, const char *buf, | ||
37 | int len); | ||
38 | extern int console_open_chan(struct line *line, struct console *co); | ||
39 | extern void deactivate_chan(struct list_head *chans, int irq); | ||
40 | extern void reactivate_chan(struct list_head *chans, int irq); | ||
41 | extern void chan_enable_winch(struct list_head *chans, struct tty_struct *tty); | ||
42 | extern int enable_chan(struct line *line); | ||
43 | extern void close_chan(struct list_head *chans, int delay_free_irq); | ||
44 | extern int chan_window_size(struct list_head *chans, | ||
45 | unsigned short *rows_out, | ||
46 | unsigned short *cols_out); | ||
47 | extern int chan_config_string(struct list_head *chans, char *str, int size, | ||
48 | char **error_out); | ||
49 | |||
50 | #endif | ||
diff --git a/arch/um/include/shared/chan_user.h b/arch/um/include/shared/chan_user.h new file mode 100644 index 00000000000..9b9ced85b70 --- /dev/null +++ b/arch/um/include/shared/chan_user.h | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __CHAN_USER_H__ | ||
7 | #define __CHAN_USER_H__ | ||
8 | |||
9 | #include "init.h" | ||
10 | |||
11 | struct chan_opts { | ||
12 | void (*const announce)(char *dev_name, int dev); | ||
13 | char *xterm_title; | ||
14 | const int raw; | ||
15 | }; | ||
16 | |||
17 | enum chan_init_pri { INIT_STATIC, INIT_ALL, INIT_ONE }; | ||
18 | |||
19 | struct chan_ops { | ||
20 | char *type; | ||
21 | void *(*init)(char *, int, const struct chan_opts *); | ||
22 | int (*open)(int, int, int, void *, char **); | ||
23 | void (*close)(int, void *); | ||
24 | int (*read)(int, char *, void *); | ||
25 | int (*write)(int, const char *, int, void *); | ||
26 | int (*console_write)(int, const char *, int); | ||
27 | int (*window_size)(int, void *, unsigned short *, unsigned short *); | ||
28 | void (*free)(void *); | ||
29 | int winch; | ||
30 | }; | ||
31 | |||
32 | extern const struct chan_ops fd_ops, null_ops, port_ops, pts_ops, pty_ops, | ||
33 | tty_ops, xterm_ops; | ||
34 | |||
35 | extern void generic_close(int fd, void *unused); | ||
36 | extern int generic_read(int fd, char *c_out, void *unused); | ||
37 | extern int generic_write(int fd, const char *buf, int n, void *unused); | ||
38 | extern int generic_console_write(int fd, const char *buf, int n); | ||
39 | extern int generic_window_size(int fd, void *unused, unsigned short *rows_out, | ||
40 | unsigned short *cols_out); | ||
41 | extern void generic_free(void *data); | ||
42 | |||
43 | struct tty_struct; | ||
44 | extern void register_winch(int fd, struct tty_struct *tty); | ||
45 | extern void register_winch_irq(int fd, int tty_fd, int pid, | ||
46 | struct tty_struct *tty, unsigned long stack); | ||
47 | |||
48 | #define __channel_help(fn, prefix) \ | ||
49 | __uml_help(fn, prefix "[0-9]*=<channel description>\n" \ | ||
50 | " Attach a console or serial line to a host channel. See\n" \ | ||
51 | " http://user-mode-linux.sourceforge.net/old/input.html for a complete\n" \ | ||
52 | " description of this switch.\n\n" \ | ||
53 | ); | ||
54 | |||
55 | #endif | ||
diff --git a/arch/um/include/shared/initrd.h b/arch/um/include/shared/initrd.h new file mode 100644 index 00000000000..22673bcc273 --- /dev/null +++ b/arch/um/include/shared/initrd.h | |||
@@ -0,0 +1,12 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __INITRD_USER_H__ | ||
7 | #define __INITRD_USER_H__ | ||
8 | |||
9 | extern int load_initrd(char *filename, void *buf, int size); | ||
10 | |||
11 | #endif | ||
12 | |||
diff --git a/arch/um/include/shared/ldt.h b/arch/um/include/shared/ldt.h new file mode 100644 index 00000000000..a7f999a5877 --- /dev/null +++ b/arch/um/include/shared/ldt.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 Fujitsu Siemens Computers GmbH | ||
3 | * Licensed under the GPL | ||
4 | * | ||
5 | * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com> | ||
6 | */ | ||
7 | |||
8 | #ifndef __ASM_LDT_H | ||
9 | #define __ASM_LDT_H | ||
10 | |||
11 | #include <linux/mutex.h> | ||
12 | #include <sysdep/host_ldt.h> | ||
13 | |||
14 | extern void ldt_host_info(void); | ||
15 | |||
16 | #define LDT_PAGES_MAX \ | ||
17 | ((LDT_ENTRIES * LDT_ENTRY_SIZE)/PAGE_SIZE) | ||
18 | #define LDT_ENTRIES_PER_PAGE \ | ||
19 | (PAGE_SIZE/LDT_ENTRY_SIZE) | ||
20 | #define LDT_DIRECT_ENTRIES \ | ||
21 | ((LDT_PAGES_MAX*sizeof(void *))/LDT_ENTRY_SIZE) | ||
22 | |||
23 | struct ldt_entry { | ||
24 | __u32 a; | ||
25 | __u32 b; | ||
26 | }; | ||
27 | |||
28 | typedef struct uml_ldt { | ||
29 | int entry_count; | ||
30 | struct mutex lock; | ||
31 | union { | ||
32 | struct ldt_entry * pages[LDT_PAGES_MAX]; | ||
33 | struct ldt_entry entries[LDT_DIRECT_ENTRIES]; | ||
34 | } u; | ||
35 | } uml_ldt_t; | ||
36 | |||
37 | #endif | ||
diff --git a/arch/um/include/shared/line.h b/arch/um/include/shared/line.h new file mode 100644 index 00000000000..63df3ca02ac --- /dev/null +++ b/arch/um/include/shared/line.h | |||
@@ -0,0 +1,106 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __LINE_H__ | ||
7 | #define __LINE_H__ | ||
8 | |||
9 | #include "linux/list.h" | ||
10 | #include "linux/workqueue.h" | ||
11 | #include "linux/tty.h" | ||
12 | #include "linux/interrupt.h" | ||
13 | #include "linux/spinlock.h" | ||
14 | #include "linux/mutex.h" | ||
15 | #include "chan_user.h" | ||
16 | #include "mconsole_kern.h" | ||
17 | |||
18 | /* There's only one modifiable field in this - .mc.list */ | ||
19 | struct line_driver { | ||
20 | const char *name; | ||
21 | const char *device_name; | ||
22 | const short major; | ||
23 | const short minor_start; | ||
24 | const short type; | ||
25 | const short subtype; | ||
26 | const int read_irq; | ||
27 | const char *read_irq_name; | ||
28 | const int write_irq; | ||
29 | const char *write_irq_name; | ||
30 | struct mc_device mc; | ||
31 | }; | ||
32 | |||
33 | struct line { | ||
34 | struct tty_struct *tty; | ||
35 | spinlock_t count_lock; | ||
36 | unsigned long count; | ||
37 | int valid; | ||
38 | |||
39 | char *init_str; | ||
40 | int init_pri; | ||
41 | struct list_head chan_list; | ||
42 | |||
43 | /*This lock is actually, mostly, local to*/ | ||
44 | spinlock_t lock; | ||
45 | int throttled; | ||
46 | /* Yes, this is a real circular buffer. | ||
47 | * XXX: And this should become a struct kfifo! | ||
48 | * | ||
49 | * buffer points to a buffer allocated on demand, of length | ||
50 | * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/ | ||
51 | char *buffer; | ||
52 | char *head; | ||
53 | char *tail; | ||
54 | |||
55 | int sigio; | ||
56 | struct delayed_work task; | ||
57 | const struct line_driver *driver; | ||
58 | int have_irq; | ||
59 | }; | ||
60 | |||
61 | #define LINE_INIT(str, d) \ | ||
62 | { .count_lock = __SPIN_LOCK_UNLOCKED((str).count_lock), \ | ||
63 | .init_str = str, \ | ||
64 | .init_pri = INIT_STATIC, \ | ||
65 | .valid = 1, \ | ||
66 | .lock = __SPIN_LOCK_UNLOCKED((str).lock), \ | ||
67 | .driver = d } | ||
68 | |||
69 | extern void line_close(struct tty_struct *tty, struct file * filp); | ||
70 | extern int line_open(struct line *lines, struct tty_struct *tty); | ||
71 | extern int line_setup(struct line *lines, unsigned int sizeof_lines, | ||
72 | char *init, char **error_out); | ||
73 | extern int line_write(struct tty_struct *tty, const unsigned char *buf, | ||
74 | int len); | ||
75 | extern int line_put_char(struct tty_struct *tty, unsigned char ch); | ||
76 | extern void line_set_termios(struct tty_struct *tty, struct ktermios * old); | ||
77 | extern int line_chars_in_buffer(struct tty_struct *tty); | ||
78 | extern void line_flush_buffer(struct tty_struct *tty); | ||
79 | extern void line_flush_chars(struct tty_struct *tty); | ||
80 | extern int line_write_room(struct tty_struct *tty); | ||
81 | extern int line_ioctl(struct tty_struct *tty, unsigned int cmd, | ||
82 | unsigned long arg); | ||
83 | extern void line_throttle(struct tty_struct *tty); | ||
84 | extern void line_unthrottle(struct tty_struct *tty); | ||
85 | |||
86 | extern char *add_xterm_umid(char *base); | ||
87 | extern int line_setup_irq(int fd, int input, int output, struct line *line, | ||
88 | void *data); | ||
89 | extern void line_close_chan(struct line *line); | ||
90 | extern struct tty_driver *register_lines(struct line_driver *line_driver, | ||
91 | const struct tty_operations *driver, | ||
92 | struct line *lines, int nlines); | ||
93 | extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts); | ||
94 | extern void close_lines(struct line *lines, int nlines); | ||
95 | |||
96 | extern int line_config(struct line *lines, unsigned int sizeof_lines, | ||
97 | char *str, const struct chan_opts *opts, | ||
98 | char **error_out); | ||
99 | extern int line_id(char **str, int *start_out, int *end_out); | ||
100 | extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n, | ||
101 | char **error_out); | ||
102 | extern int line_get_config(char *dev, struct line *lines, | ||
103 | unsigned int sizeof_lines, char *str, | ||
104 | int size, char **error_out); | ||
105 | |||
106 | #endif | ||
diff --git a/arch/um/include/shared/mconsole.h b/arch/um/include/shared/mconsole.h new file mode 100644 index 00000000000..c139ae1d682 --- /dev/null +++ b/arch/um/include/shared/mconsole.h | |||
@@ -0,0 +1,98 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) | ||
3 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #ifndef __MCONSOLE_H__ | ||
8 | #define __MCONSOLE_H__ | ||
9 | |||
10 | #ifndef __KERNEL__ | ||
11 | #include <stdint.h> | ||
12 | #define u32 uint32_t | ||
13 | #endif | ||
14 | |||
15 | #include "sysdep/ptrace.h" | ||
16 | |||
17 | #define MCONSOLE_MAGIC (0xcafebabe) | ||
18 | #define MCONSOLE_MAX_DATA (512) | ||
19 | #define MCONSOLE_VERSION 2 | ||
20 | |||
21 | struct mconsole_request { | ||
22 | u32 magic; | ||
23 | u32 version; | ||
24 | u32 len; | ||
25 | char data[MCONSOLE_MAX_DATA]; | ||
26 | }; | ||
27 | |||
28 | struct mconsole_reply { | ||
29 | u32 err; | ||
30 | u32 more; | ||
31 | u32 len; | ||
32 | char data[MCONSOLE_MAX_DATA]; | ||
33 | }; | ||
34 | |||
35 | struct mconsole_notify { | ||
36 | u32 magic; | ||
37 | u32 version; | ||
38 | enum { MCONSOLE_SOCKET, MCONSOLE_PANIC, MCONSOLE_HANG, | ||
39 | MCONSOLE_USER_NOTIFY } type; | ||
40 | u32 len; | ||
41 | char data[MCONSOLE_MAX_DATA]; | ||
42 | }; | ||
43 | |||
44 | struct mc_request; | ||
45 | |||
46 | enum mc_context { MCONSOLE_INTR, MCONSOLE_PROC }; | ||
47 | |||
48 | struct mconsole_command | ||
49 | { | ||
50 | char *command; | ||
51 | void (*handler)(struct mc_request *req); | ||
52 | enum mc_context context; | ||
53 | }; | ||
54 | |||
55 | struct mc_request | ||
56 | { | ||
57 | int len; | ||
58 | int as_interrupt; | ||
59 | |||
60 | int originating_fd; | ||
61 | unsigned int originlen; | ||
62 | unsigned char origin[128]; /* sockaddr_un */ | ||
63 | |||
64 | struct mconsole_request request; | ||
65 | struct mconsole_command *cmd; | ||
66 | struct uml_pt_regs regs; | ||
67 | }; | ||
68 | |||
69 | extern char mconsole_socket_name[]; | ||
70 | |||
71 | extern int mconsole_unlink_socket(void); | ||
72 | extern int mconsole_reply_len(struct mc_request *req, const char *reply, | ||
73 | int len, int err, int more); | ||
74 | extern int mconsole_reply(struct mc_request *req, const char *str, int err, | ||
75 | int more); | ||
76 | |||
77 | extern void mconsole_version(struct mc_request *req); | ||
78 | extern void mconsole_help(struct mc_request *req); | ||
79 | extern void mconsole_halt(struct mc_request *req); | ||
80 | extern void mconsole_reboot(struct mc_request *req); | ||
81 | extern void mconsole_config(struct mc_request *req); | ||
82 | extern void mconsole_remove(struct mc_request *req); | ||
83 | extern void mconsole_sysrq(struct mc_request *req); | ||
84 | extern void mconsole_cad(struct mc_request *req); | ||
85 | extern void mconsole_stop(struct mc_request *req); | ||
86 | extern void mconsole_go(struct mc_request *req); | ||
87 | extern void mconsole_log(struct mc_request *req); | ||
88 | extern void mconsole_proc(struct mc_request *req); | ||
89 | extern void mconsole_stack(struct mc_request *req); | ||
90 | |||
91 | extern int mconsole_get_request(int fd, struct mc_request *req); | ||
92 | extern int mconsole_notify(char *sock_name, int type, const void *data, | ||
93 | int len); | ||
94 | extern char *mconsole_notify_socket(void); | ||
95 | extern void lock_notify(void); | ||
96 | extern void unlock_notify(void); | ||
97 | |||
98 | #endif | ||
diff --git a/arch/um/include/shared/mconsole_kern.h b/arch/um/include/shared/mconsole_kern.h new file mode 100644 index 00000000000..d2fe07e7895 --- /dev/null +++ b/arch/um/include/shared/mconsole_kern.h | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __MCONSOLE_KERN_H__ | ||
7 | #define __MCONSOLE_KERN_H__ | ||
8 | |||
9 | #include "linux/list.h" | ||
10 | #include "mconsole.h" | ||
11 | |||
12 | struct mconsole_entry { | ||
13 | struct list_head list; | ||
14 | struct mc_request request; | ||
15 | }; | ||
16 | |||
17 | /* All these methods are called in process context. */ | ||
18 | struct mc_device { | ||
19 | struct list_head list; | ||
20 | char *name; | ||
21 | int (*config)(char *, char **); | ||
22 | int (*get_config)(char *, char *, int, char **); | ||
23 | int (*id)(char **, int *, int *); | ||
24 | int (*remove)(int, char **); | ||
25 | }; | ||
26 | |||
27 | #define CONFIG_CHUNK(str, size, current, chunk, end) \ | ||
28 | do { \ | ||
29 | current += strlen(chunk); \ | ||
30 | if(current >= size) \ | ||
31 | str = NULL; \ | ||
32 | if(str != NULL){ \ | ||
33 | strcpy(str, chunk); \ | ||
34 | str += strlen(chunk); \ | ||
35 | } \ | ||
36 | if(end) \ | ||
37 | current++; \ | ||
38 | } while(0) | ||
39 | |||
40 | #ifdef CONFIG_MCONSOLE | ||
41 | |||
42 | extern void mconsole_register_dev(struct mc_device *new); | ||
43 | |||
44 | #else | ||
45 | |||
46 | static inline void mconsole_register_dev(struct mc_device *new) | ||
47 | { | ||
48 | } | ||
49 | |||
50 | #endif | ||
51 | |||
52 | #endif | ||
diff --git a/arch/um/include/shared/mem_kern.h b/arch/um/include/shared/mem_kern.h new file mode 100644 index 00000000000..69be0fd0ce4 --- /dev/null +++ b/arch/um/include/shared/mem_kern.h | |||
@@ -0,0 +1,20 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2003 Jeff Dike (jdike@addtoit.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __MEM_KERN_H__ | ||
7 | #define __MEM_KERN_H__ | ||
8 | |||
9 | #include "linux/list.h" | ||
10 | #include "linux/types.h" | ||
11 | |||
12 | struct remapper { | ||
13 | struct list_head list; | ||
14 | int (*proc)(int, unsigned long, int, __u64); | ||
15 | }; | ||
16 | |||
17 | extern void register_remapper(struct remapper *info); | ||
18 | |||
19 | #endif | ||
20 | |||
diff --git a/arch/um/include/shared/process.h b/arch/um/include/shared/process.h new file mode 100644 index 00000000000..bb873a51262 --- /dev/null +++ b/arch/um/include/shared/process.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __PROCESS_H__ | ||
7 | #define __PROCESS_H__ | ||
8 | |||
9 | #include <signal.h> | ||
10 | |||
11 | /* Copied from linux/compiler-gcc.h since we can't include it directly */ | ||
12 | #define barrier() __asm__ __volatile__("": : :"memory") | ||
13 | |||
14 | extern void sig_handler(int sig, struct sigcontext *sc); | ||
15 | extern void alarm_handler(int sig, struct sigcontext *sc); | ||
16 | |||
17 | #endif | ||
diff --git a/arch/um/include/shared/skas_ptregs.h b/arch/um/include/shared/skas_ptregs.h new file mode 100644 index 00000000000..73db19e9c07 --- /dev/null +++ b/arch/um/include/shared/skas_ptregs.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __SKAS_PT_REGS_ | ||
2 | #define __SKAS_PT_REGS_ | ||
3 | |||
4 | #include <user_constants.h> | ||
5 | |||
6 | #endif | ||
diff --git a/arch/um/include/shared/syscall.h b/arch/um/include/shared/syscall.h new file mode 100644 index 00000000000..dda1df901a0 --- /dev/null +++ b/arch/um/include/shared/syscall.h | |||
@@ -0,0 +1,12 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYSCALL_USER_H | ||
7 | #define __SYSCALL_USER_H | ||
8 | |||
9 | extern int record_syscall_start(int syscall); | ||
10 | extern void record_syscall_end(int index, long result); | ||
11 | |||
12 | #endif | ||
diff --git a/arch/um/include/shared/sysrq.h b/arch/um/include/shared/sysrq.h new file mode 100644 index 00000000000..c8d332b56b9 --- /dev/null +++ b/arch/um/include/shared/sysrq.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef __UM_SYSRQ_H | ||
2 | #define __UM_SYSRQ_H | ||
3 | |||
4 | struct task_struct; | ||
5 | extern void show_trace(struct task_struct* task, unsigned long *stack); | ||
6 | |||
7 | #endif | ||
diff --git a/arch/um/include/shared/task.h b/arch/um/include/shared/task.h new file mode 100644 index 00000000000..3fe726b3cf4 --- /dev/null +++ b/arch/um/include/shared/task.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef __TASK_H | ||
2 | #define __TASK_H | ||
3 | |||
4 | #include <kern_constants.h> | ||
5 | |||
6 | #define TASK_REGS(task) ((struct uml_pt_regs *) &(((char *) (task))[HOST_TASK_REGS])) | ||
7 | #define TASK_PID(task) *((int *) &(((char *) (task))[HOST_TASK_PID])) | ||
8 | |||
9 | #endif | ||
diff --git a/arch/um/include/shared/tlb.h b/arch/um/include/shared/tlb.h new file mode 100644 index 00000000000..ecd2265b301 --- /dev/null +++ b/arch/um/include/shared/tlb.h | |||
@@ -0,0 +1,15 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __TLB_H__ | ||
7 | #define __TLB_H__ | ||
8 | |||
9 | #include "um_mmu.h" | ||
10 | |||
11 | extern void force_flush_all(void); | ||
12 | extern int flush_tlb_kernel_range_common(unsigned long start, | ||
13 | unsigned long end); | ||
14 | |||
15 | #endif | ||
diff --git a/arch/um/include/shared/ubd_user.h b/arch/um/include/shared/ubd_user.h new file mode 100644 index 00000000000..3845051f1b1 --- /dev/null +++ b/arch/um/include/shared/ubd_user.h | |||
@@ -0,0 +1,16 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Copyright (C) 2001 RidgeRun, Inc (glonnon@ridgerun.com) | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #ifndef __UM_UBD_USER_H | ||
8 | #define __UM_UBD_USER_H | ||
9 | |||
10 | extern void ignore_sigwinch_sig(void); | ||
11 | extern int start_io_thread(unsigned long sp, int *fds_out); | ||
12 | extern int io_thread(void *arg); | ||
13 | extern int kernel_fd; | ||
14 | |||
15 | #endif | ||
16 | |||
diff --git a/arch/um/include/shared/um_mmu.h b/arch/um/include/shared/um_mmu.h new file mode 100644 index 00000000000..b1a7e47d102 --- /dev/null +++ b/arch/um/include/shared/um_mmu.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __ARCH_UM_MMU_H | ||
7 | #define __ARCH_UM_MMU_H | ||
8 | |||
9 | #include "mm_id.h" | ||
10 | #include "ldt.h" | ||
11 | |||
12 | typedef struct mm_context { | ||
13 | struct mm_id id; | ||
14 | struct uml_ldt ldt; | ||
15 | struct page **stub_pages; | ||
16 | } mm_context_t; | ||
17 | |||
18 | extern void __switch_mm(struct mm_id * mm_idp); | ||
19 | |||
20 | /* Avoid tangled inclusion with asm/ldt.h */ | ||
21 | extern long init_new_ldt(struct mm_context *to_mm, struct mm_context *from_mm); | ||
22 | extern void free_ldt(struct mm_context *mm); | ||
23 | |||
24 | #endif | ||
diff --git a/arch/um/include/shared/um_uaccess.h b/arch/um/include/shared/um_uaccess.h new file mode 100644 index 00000000000..45c04999d67 --- /dev/null +++ b/arch/um/include/shared/um_uaccess.h | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __ARCH_UM_UACCESS_H | ||
7 | #define __ARCH_UM_UACCESS_H | ||
8 | |||
9 | #include <asm/elf.h> | ||
10 | #include <asm/fixmap.h> | ||
11 | #include "sysdep/archsetjmp.h" | ||
12 | |||
13 | #define __under_task_size(addr, size) \ | ||
14 | (((unsigned long) (addr) < TASK_SIZE) && \ | ||
15 | (((unsigned long) (addr) + (size)) < TASK_SIZE)) | ||
16 | |||
17 | #define __access_ok_vsyscall(type, addr, size) \ | ||
18 | ((type == VERIFY_READ) && \ | ||
19 | ((unsigned long) (addr) >= FIXADDR_USER_START) && \ | ||
20 | ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \ | ||
21 | ((unsigned long) (addr) + (size) >= (unsigned long)(addr))) | ||
22 | |||
23 | #define __addr_range_nowrap(addr, size) \ | ||
24 | ((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) | ||
25 | |||
26 | #define access_ok(type, addr, size) \ | ||
27 | (__addr_range_nowrap(addr, size) && \ | ||
28 | (__under_task_size(addr, size) || \ | ||
29 | __access_ok_vsyscall(type, addr, size) || \ | ||
30 | segment_eq(get_fs(), KERNEL_DS))) | ||
31 | |||
32 | extern int copy_from_user(void *to, const void __user *from, int n); | ||
33 | extern int copy_to_user(void __user *to, const void *from, int n); | ||
34 | |||
35 | extern int __do_copy_to_user(void *to, const void *from, int n, | ||
36 | void **fault_addr, jmp_buf **fault_catcher); | ||
37 | |||
38 | /* | ||
39 | * strncpy_from_user: - Copy a NUL terminated string from userspace. | ||
40 | * @dst: Destination address, in kernel space. This buffer must be at | ||
41 | * least @count bytes long. | ||
42 | * @src: Source address, in user space. | ||
43 | * @count: Maximum number of bytes to copy, including the trailing NUL. | ||
44 | * | ||
45 | * Copies a NUL-terminated string from userspace to kernel space. | ||
46 | * | ||
47 | * On success, returns the length of the string (not including the trailing | ||
48 | * NUL). | ||
49 | * | ||
50 | * If access to userspace fails, returns -EFAULT (some data may have been | ||
51 | * copied). | ||
52 | * | ||
53 | * If @count is smaller than the length of the string, copies @count bytes | ||
54 | * and returns @count. | ||
55 | */ | ||
56 | |||
57 | extern int strncpy_from_user(char *dst, const char __user *src, int count); | ||
58 | |||
59 | /* | ||
60 | * __clear_user: - Zero a block of memory in user space, with less checking. | ||
61 | * @to: Destination address, in user space. | ||
62 | * @n: Number of bytes to zero. | ||
63 | * | ||
64 | * Zero a block of memory in user space. Caller must check | ||
65 | * the specified block with access_ok() before calling this function. | ||
66 | * | ||
67 | * Returns number of bytes that could not be cleared. | ||
68 | * On success, this will be zero. | ||
69 | */ | ||
70 | extern int __clear_user(void __user *mem, int len); | ||
71 | |||
72 | /* | ||
73 | * clear_user: - Zero a block of memory in user space. | ||
74 | * @to: Destination address, in user space. | ||
75 | * @n: Number of bytes to zero. | ||
76 | * | ||
77 | * Zero a block of memory in user space. | ||
78 | * | ||
79 | * Returns number of bytes that could not be cleared. | ||
80 | * On success, this will be zero. | ||
81 | */ | ||
82 | extern int clear_user(void __user *mem, int len); | ||
83 | |||
84 | /* | ||
85 | * strlen_user: - Get the size of a string in user space. | ||
86 | * @str: The string to measure. | ||
87 | * @n: The maximum valid length | ||
88 | * | ||
89 | * Get the size of a NUL-terminated string in user space. | ||
90 | * | ||
91 | * Returns the size of the string INCLUDING the terminating NUL. | ||
92 | * On exception, returns 0. | ||
93 | * If the string is too long, returns a value greater than @n. | ||
94 | */ | ||
95 | extern int strnlen_user(const void __user *str, int len); | ||
96 | |||
97 | #endif | ||