aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-m32r
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2006-04-29 01:11:23 -0400
committerDmitry Torokhov <dtor_core@ameritech.net>2006-04-29 01:11:23 -0400
commit7b7e394185014e0f3bd8989cac937003f20ef9ce (patch)
tree3beda5f979bba0aa9822534e239cf1b45f3be69c /include/asm-m32r
parentddc5d3414593e4d7ad7fbd33e7f7517fcc234544 (diff)
parent693f7d362055261882659475d2ef022e32edbff1 (diff)
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'include/asm-m32r')
-rw-r--r--include/asm-m32r/assembler.h5
-rw-r--r--include/asm-m32r/mappi3/mappi3_pld.h22
-rw-r--r--include/asm-m32r/numnodes.h15
-rw-r--r--include/asm-m32r/ptrace.h25
-rw-r--r--include/asm-m32r/semaphore.h64
-rw-r--r--include/asm-m32r/sigcontext.h2
-rw-r--r--include/asm-m32r/smp.h3
-rw-r--r--include/asm-m32r/system.h71
-rw-r--r--include/asm-m32r/uaccess.h266
-rw-r--r--include/asm-m32r/unistd.h2
10 files changed, 173 insertions, 302 deletions
diff --git a/include/asm-m32r/assembler.h b/include/asm-m32r/assembler.h
index b7f4d8aaeb46..1a1aa17edd33 100644
--- a/include/asm-m32r/assembler.h
+++ b/include/asm-m32r/assembler.h
@@ -109,6 +109,9 @@
109 push r13 109 push r13
110 mvfachi r13 110 mvfachi r13
111 push r13 111 push r13
112 ldi r13, #0
113 push r13 ; dummy push acc1h
114 push r13 ; dummy push acc1l
112#else 115#else
113#error unknown isa configuration 116#error unknown isa configuration
114#endif 117#endif
@@ -156,6 +159,8 @@
156 pop r13 159 pop r13
157 mvtaclo r13, a1 160 mvtaclo r13, a1
158#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R) 161#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
162 pop r13 ; dummy pop acc1h
163 pop r13 ; dummy pop acc1l
159 pop r13 164 pop r13
160 mvtachi r13 165 mvtachi r13
161 pop r13 166 pop r13
diff --git a/include/asm-m32r/mappi3/mappi3_pld.h b/include/asm-m32r/mappi3/mappi3_pld.h
index 1d3c25d61bcb..031369a7afc8 100644
--- a/include/asm-m32r/mappi3/mappi3_pld.h
+++ b/include/asm-m32r/mappi3/mappi3_pld.h
@@ -53,16 +53,14 @@
53/* Power Control of MMC and CF */ 53/* Power Control of MMC and CF */
54#define PLD_CPCR __reg16(PLD_BASE + 0x14000) 54#define PLD_CPCR __reg16(PLD_BASE + 0x14000)
55 55
56 56/* ICU */
57/*==== ICU ====*/ 57#define M32R_IRQ_PC104 (5) /* INT4(PC/104) */
58#define M32R_IRQ_PC104 (5) /* INT4(PC/104) */ 58#define M32R_IRQ_I2C (28) /* I2C-BUS */
59#define M32R_IRQ_I2C (28) /* I2C-BUS */ 59#define PLD_IRQ_CFIREQ (6) /* INT5 CFC Card Interrupt */
60#define PLD_IRQ_CFIREQ (6) /* INT5 CFC Card Interrupt */ 60#define PLD_IRQ_CFC_INSERT (7) /* INT6 CFC Card Insert & Eject */
61#define PLD_IRQ_CFC_INSERT (7) /* INT6 CFC Card Insert */ 61#define PLD_IRQ_IDEIREQ (8) /* INT7 IDE Interrupt */
62#define PLD_IRQ_IDEIREQ (8) /* INT7 IDE Interrupt */ 62#define PLD_IRQ_MMCCARD (43) /* MMC Card Insert */
63#define PLD_IRQ_MMCCARD (43) /* MMC Card Insert */ 63#define PLD_IRQ_MMCIRQ (44) /* MMC Transfer Done */
64#define PLD_IRQ_MMCIRQ (44) /* MMC Transfer Done */
65
66 64
67#if 0 65#if 0
68/* LED Control 66/* LED Control
@@ -97,7 +95,6 @@
97#define PLD_CRC16ADATA __reg16(PLD_BASE + 0x18008) 95#define PLD_CRC16ADATA __reg16(PLD_BASE + 0x18008)
98#define PLD_CRC16AINDATA __reg16(PLD_BASE + 0x1800a) 96#define PLD_CRC16AINDATA __reg16(PLD_BASE + 0x1800a)
99 97
100
101#if 0 98#if 0
102/* RTC */ 99/* RTC */
103#define PLD_RTCCR __reg16(PLD_BASE + 0x1c000) 100#define PLD_RTCCR __reg16(PLD_BASE + 0x1c000)
@@ -140,4 +137,7 @@
140 137
141#endif 138#endif
142 139
140/* Reset Control */
141#define PLD_REBOOT __reg16(PLD_BASE + 0x38000)
142
143#endif /* _MAPPI3_PLD.H */ 143#endif /* _MAPPI3_PLD.H */
diff --git a/include/asm-m32r/numnodes.h b/include/asm-m32r/numnodes.h
deleted file mode 100644
index 479a39d49f83..000000000000
--- a/include/asm-m32r/numnodes.h
+++ /dev/null
@@ -1,15 +0,0 @@
1#ifndef _ASM_NUMNODES_H_
2#define _ASM_NUMNODES_H_
3
4#include <linux/config.h>
5
6#ifdef CONFIG_DISCONTIGMEM
7
8#if defined(CONFIG_CHIP_M32700)
9#define NODES_SHIFT 1 /* Max 2 Nodes */
10#endif /* CONFIG_CHIP_M32700 */
11
12#endif /* CONFIG_DISCONTIGMEM */
13
14#endif /* _ASM_NUMNODES_H_ */
15
diff --git a/include/asm-m32r/ptrace.h b/include/asm-m32r/ptrace.h
index 0d058b2d844e..53c792452dfc 100644
--- a/include/asm-m32r/ptrace.h
+++ b/include/asm-m32r/ptrace.h
@@ -43,6 +43,14 @@
43#define PT_ACC1L 18 43#define PT_ACC1L 18
44#define PT_ACCH PT_ACC0H 44#define PT_ACCH PT_ACC0H
45#define PT_ACCL PT_ACC0L 45#define PT_ACCL PT_ACC0L
46#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
47#define PT_ACCH 15
48#define PT_ACCL 16
49#define PT_DUMMY_ACC1H 17
50#define PT_DUMMY_ACC1L 18
51#else
52#error unknown isa conifiguration
53#endif
46#define PT_PSW 19 54#define PT_PSW 19
47#define PT_BPC 20 55#define PT_BPC 20
48#define PT_BBPSW 21 56#define PT_BBPSW 21
@@ -52,21 +60,6 @@
52#define PT_LR 25 60#define PT_LR 25
53#define PT_SPI 26 61#define PT_SPI 26
54#define PT_ORIGR0 27 62#define PT_ORIGR0 27
55#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
56#define PT_ACCH 15
57#define PT_ACCL 16
58#define PT_PSW 17
59#define PT_BPC 18
60#define PT_BBPSW 19
61#define PT_BBPC 20
62#define PT_SPU 21
63#define PT_FP 22
64#define PT_LR 23
65#define PT_SPI 24
66#define PT_ORIGR0 25
67#else
68#error unknown isa conifiguration
69#endif
70 63
71/* virtual pt_reg entry for gdb */ 64/* virtual pt_reg entry for gdb */
72#define PT_PC 30 65#define PT_PC 30
@@ -121,6 +114,8 @@ struct pt_regs {
121#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R) 114#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
122 unsigned long acch; 115 unsigned long acch;
123 unsigned long accl; 116 unsigned long accl;
117 unsigned long dummy_acc1h;
118 unsigned long dummy_acc1l;
124#else 119#else
125#error unknown isa configuration 120#error unknown isa configuration
126#endif 121#endif
diff --git a/include/asm-m32r/semaphore.h b/include/asm-m32r/semaphore.h
index bf447c52a0a1..81750edc8916 100644
--- a/include/asm-m32r/semaphore.h
+++ b/include/asm-m32r/semaphore.h
@@ -9,7 +9,7 @@
9 * SMP- and interrupt-safe semaphores.. 9 * SMP- and interrupt-safe semaphores..
10 * 10 *
11 * Copyright (C) 1996 Linus Torvalds 11 * Copyright (C) 1996 Linus Torvalds
12 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org> 12 * Copyright (C) 2004, 2006 Hirokazu Takata <takata at linux-m32r.org>
13 */ 13 */
14 14
15#include <linux/config.h> 15#include <linux/config.h>
@@ -77,27 +77,8 @@ asmlinkage void __up(struct semaphore * sem);
77 */ 77 */
78static inline void down(struct semaphore * sem) 78static inline void down(struct semaphore * sem)
79{ 79{
80 unsigned long flags;
81 long count;
82
83 might_sleep(); 80 might_sleep();
84 local_irq_save(flags); 81 if (unlikely(atomic_dec_return(&sem->count) < 0))
85 __asm__ __volatile__ (
86 "# down \n\t"
87 DCACHE_CLEAR("%0", "r4", "%1")
88 M32R_LOCK" %0, @%1; \n\t"
89 "addi %0, #-1; \n\t"
90 M32R_UNLOCK" %0, @%1; \n\t"
91 : "=&r" (count)
92 : "r" (&sem->count)
93 : "memory"
94#ifdef CONFIG_CHIP_M32700_TS1
95 , "r4"
96#endif /* CONFIG_CHIP_M32700_TS1 */
97 );
98 local_irq_restore(flags);
99
100 if (unlikely(count < 0))
101 __down(sem); 82 __down(sem);
102} 83}
103 84
@@ -107,28 +88,10 @@ static inline void down(struct semaphore * sem)
107 */ 88 */
108static inline int down_interruptible(struct semaphore * sem) 89static inline int down_interruptible(struct semaphore * sem)
109{ 90{
110 unsigned long flags;
111 long count;
112 int result = 0; 91 int result = 0;
113 92
114 might_sleep(); 93 might_sleep();
115 local_irq_save(flags); 94 if (unlikely(atomic_dec_return(&sem->count) < 0))
116 __asm__ __volatile__ (
117 "# down_interruptible \n\t"
118 DCACHE_CLEAR("%0", "r4", "%1")
119 M32R_LOCK" %0, @%1; \n\t"
120 "addi %0, #-1; \n\t"
121 M32R_UNLOCK" %0, @%1; \n\t"
122 : "=&r" (count)
123 : "r" (&sem->count)
124 : "memory"
125#ifdef CONFIG_CHIP_M32700_TS1
126 , "r4"
127#endif /* CONFIG_CHIP_M32700_TS1 */
128 );
129 local_irq_restore(flags);
130
131 if (unlikely(count < 0))
132 result = __down_interruptible(sem); 95 result = __down_interruptible(sem);
133 96
134 return result; 97 return result;
@@ -174,26 +137,7 @@ static inline int down_trylock(struct semaphore * sem)
174 */ 137 */
175static inline void up(struct semaphore * sem) 138static inline void up(struct semaphore * sem)
176{ 139{
177 unsigned long flags; 140 if (unlikely(atomic_inc_return(&sem->count) <= 0))
178 long count;
179
180 local_irq_save(flags);
181 __asm__ __volatile__ (
182 "# up \n\t"
183 DCACHE_CLEAR("%0", "r4", "%1")
184 M32R_LOCK" %0, @%1; \n\t"
185 "addi %0, #1; \n\t"
186 M32R_UNLOCK" %0, @%1; \n\t"
187 : "=&r" (count)
188 : "r" (&sem->count)
189 : "memory"
190#ifdef CONFIG_CHIP_M32700_TS1
191 , "r4"
192#endif /* CONFIG_CHIP_M32700_TS1 */
193 );
194 local_irq_restore(flags);
195
196 if (unlikely(count <= 0))
197 __up(sem); 141 __up(sem);
198} 142}
199 143
diff --git a/include/asm-m32r/sigcontext.h b/include/asm-m32r/sigcontext.h
index c233e2def2a3..942b8a30937d 100644
--- a/include/asm-m32r/sigcontext.h
+++ b/include/asm-m32r/sigcontext.h
@@ -32,6 +32,8 @@ struct sigcontext {
32#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R) 32#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
33 unsigned long sc_acch; 33 unsigned long sc_acch;
34 unsigned long sc_accl; 34 unsigned long sc_accl;
35 unsigned long sc_dummy_acc1h;
36 unsigned long sc_dummy_acc1l;
35#else 37#else
36#error unknown isa configuration 38#error unknown isa configuration
37#endif 39#endif
diff --git a/include/asm-m32r/smp.h b/include/asm-m32r/smp.h
index 7885b7df84a2..1184293e5712 100644
--- a/include/asm-m32r/smp.h
+++ b/include/asm-m32r/smp.h
@@ -67,7 +67,8 @@ extern volatile int cpu_2_physid[NR_CPUS];
67#define raw_smp_processor_id() (current_thread_info()->cpu) 67#define raw_smp_processor_id() (current_thread_info()->cpu)
68 68
69extern cpumask_t cpu_callout_map; 69extern cpumask_t cpu_callout_map;
70#define cpu_possible_map cpu_callout_map 70extern cpumask_t cpu_possible_map;
71extern cpumask_t cpu_present_map;
71 72
72static __inline__ int hard_smp_processor_id(void) 73static __inline__ int hard_smp_processor_id(void)
73{ 74{
diff --git a/include/asm-m32r/system.h b/include/asm-m32r/system.h
index d6a2c613be68..e55013f378e5 100644
--- a/include/asm-m32r/system.h
+++ b/include/asm-m32r/system.h
@@ -6,8 +6,8 @@
6 * License. See the file "COPYING" in the main directory of this archive 6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details. 7 * for more details.
8 * 8 *
9 * Copyright (C) 2001 by Hiroyuki Kondo, Hirokazu Takata, and Hitoshi Yamamoto 9 * Copyright (C) 2001 Hiroyuki Kondo, Hirokazu Takata, and Hitoshi Yamamoto
10 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org> 10 * Copyright (C) 2004, 2006 Hirokazu Takata <takata at linux-m32r.org>
11 */ 11 */
12 12
13#include <linux/config.h> 13#include <linux/config.h>
@@ -19,53 +19,28 @@
19 * switch_to(prev, next) should switch from task `prev' to `next' 19 * switch_to(prev, next) should switch from task `prev' to `next'
20 * `prev' will never be the same as `next'. 20 * `prev' will never be the same as `next'.
21 * 21 *
22 * `next' and `prev' should be struct task_struct, but it isn't always defined 22 * `next' and `prev' should be task_t, but it isn't always defined
23 */ 23 */
24 24
25#ifndef CONFIG_SMP
26#define prepare_to_switch() do { } while(0)
27#endif /* not CONFIG_SMP */
28
29#define switch_to(prev, next, last) do { \ 25#define switch_to(prev, next, last) do { \
30 register unsigned long arg0 __asm__ ("r0") = (unsigned long)prev; \
31 register unsigned long arg1 __asm__ ("r1") = (unsigned long)next; \
32 register unsigned long *oldsp __asm__ ("r2") = &(prev->thread.sp); \
33 register unsigned long *newsp __asm__ ("r3") = &(next->thread.sp); \
34 register unsigned long *oldlr __asm__ ("r4") = &(prev->thread.lr); \
35 register unsigned long *newlr __asm__ ("r5") = &(next->thread.lr); \
36 register struct task_struct *__last __asm__ ("r6"); \
37 __asm__ __volatile__ ( \ 26 __asm__ __volatile__ ( \
38 "st r8, @-r15 \n\t" \ 27 " seth lr, #high(1f) \n" \
39 "st r9, @-r15 \n\t" \ 28 " or3 lr, lr, #low(1f) \n" \
40 "st r10, @-r15 \n\t" \ 29 " st lr, @%4 ; store old LR \n" \
41 "st r11, @-r15 \n\t" \ 30 " ld lr, @%5 ; load new LR \n" \
42 "st r12, @-r15 \n\t" \ 31 " st sp, @%2 ; store old SP \n" \
43 "st r13, @-r15 \n\t" \ 32 " ld sp, @%3 ; load new SP \n" \
44 "st r14, @-r15 \n\t" \ 33 " push %1 ; store `prev' on new stack \n" \
45 "seth r14, #high(1f) \n\t" \ 34 " jmp lr \n" \
46 "or3 r14, r14, #low(1f) \n\t" \ 35 " .fillinsn \n" \
47 "st r14, @r4 ; store old LR \n\t" \ 36 "1: \n" \
48 "st r15, @r2 ; store old SP \n\t" \ 37 " pop %0 ; restore `__last' from new stack \n" \
49 "ld r15, @r3 ; load new SP \n\t" \ 38 : "=r" (last) \
50 "st r0, @-r15 ; store 'prev' onto new stack \n\t" \ 39 : "0" (prev), \
51 "ld r14, @r5 ; load new LR \n\t" \ 40 "r" (&(prev->thread.sp)), "r" (&(next->thread.sp)), \
52 "jmp r14 \n\t" \ 41 "r" (&(prev->thread.lr)), "r" (&(next->thread.lr)) \
53 ".fillinsn \n " \ 42 : "memory", "lr" \
54 "1: \n\t" \
55 "ld r6, @r15+ ; load 'prev' from new stack \n\t" \
56 "ld r14, @r15+ \n\t" \
57 "ld r13, @r15+ \n\t" \
58 "ld r12, @r15+ \n\t" \
59 "ld r11, @r15+ \n\t" \
60 "ld r10, @r15+ \n\t" \
61 "ld r9, @r15+ \n\t" \
62 "ld r8, @r15+ \n\t" \
63 : "=&r" (__last) \
64 : "r" (arg0), "r" (arg1), "r" (oldsp), "r" (newsp), \
65 "r" (oldlr), "r" (newlr) \
66 : "memory" \
67 ); \ 43 ); \
68 last = __last; \
69} while(0) 44} while(0)
70 45
71/* 46/*
@@ -171,8 +146,8 @@ extern void __xchg_called_with_bad_pointer(void);
171#define DCACHE_CLEAR(reg0, reg1, addr) 146#define DCACHE_CLEAR(reg0, reg1, addr)
172#endif /* CONFIG_CHIP_M32700_TS1 */ 147#endif /* CONFIG_CHIP_M32700_TS1 */
173 148
174static __inline__ unsigned long __xchg(unsigned long x, volatile void * ptr, 149static inline unsigned long
175 int size) 150__xchg(unsigned long x, volatile void * ptr, int size)
176{ 151{
177 unsigned long flags; 152 unsigned long flags;
178 unsigned long tmp = 0; 153 unsigned long tmp = 0;
@@ -224,7 +199,7 @@ static __inline__ unsigned long __xchg(unsigned long x, volatile void * ptr,
224 199
225#define __HAVE_ARCH_CMPXCHG 1 200#define __HAVE_ARCH_CMPXCHG 1
226 201
227static __inline__ unsigned long 202static inline unsigned long
228__cmpxchg_u32(volatile unsigned int *p, unsigned int old, unsigned int new) 203__cmpxchg_u32(volatile unsigned int *p, unsigned int old, unsigned int new)
229{ 204{
230 unsigned long flags; 205 unsigned long flags;
@@ -258,7 +233,7 @@ __cmpxchg_u32(volatile unsigned int *p, unsigned int old, unsigned int new)
258 if something tries to do an invalid cmpxchg(). */ 233 if something tries to do an invalid cmpxchg(). */
259extern void __cmpxchg_called_with_bad_pointer(void); 234extern void __cmpxchg_called_with_bad_pointer(void);
260 235
261static __inline__ unsigned long 236static inline unsigned long
262__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) 237__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
263{ 238{
264 switch (size) { 239 switch (size) {
diff --git a/include/asm-m32r/uaccess.h b/include/asm-m32r/uaccess.h
index e8ae61956a51..819cc28a94f7 100644
--- a/include/asm-m32r/uaccess.h
+++ b/include/asm-m32r/uaccess.h
@@ -5,17 +5,9 @@
5 * linux/include/asm-m32r/uaccess.h 5 * linux/include/asm-m32r/uaccess.h
6 * 6 *
7 * M32R version. 7 * M32R version.
8 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org> 8 * Copyright (C) 2004, 2006 Hirokazu Takata <takata at linux-m32r.org>
9 */ 9 */
10 10
11#undef UACCESS_DEBUG
12
13#ifdef UACCESS_DEBUG
14#define UAPRINTK(args...) printk(args)
15#else
16#define UAPRINTK(args...)
17#endif /* UACCESS_DEBUG */
18
19/* 11/*
20 * User space memory access functions 12 * User space memory access functions
21 */ 13 */
@@ -38,27 +30,29 @@
38#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) 30#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
39 31
40#ifdef CONFIG_MMU 32#ifdef CONFIG_MMU
33
41#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF) 34#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
42#define USER_DS MAKE_MM_SEG(PAGE_OFFSET) 35#define USER_DS MAKE_MM_SEG(PAGE_OFFSET)
43#else
44#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
45#define USER_DS MAKE_MM_SEG(0xFFFFFFFF)
46#endif /* CONFIG_MMU */
47
48#define get_ds() (KERNEL_DS) 36#define get_ds() (KERNEL_DS)
49#ifdef CONFIG_MMU
50#define get_fs() (current_thread_info()->addr_limit) 37#define get_fs() (current_thread_info()->addr_limit)
51#define set_fs(x) (current_thread_info()->addr_limit = (x)) 38#define set_fs(x) (current_thread_info()->addr_limit = (x))
52#else 39
40#else /* not CONFIG_MMU */
41
42#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
43#define USER_DS MAKE_MM_SEG(0xFFFFFFFF)
44#define get_ds() (KERNEL_DS)
45
53static inline mm_segment_t get_fs(void) 46static inline mm_segment_t get_fs(void)
54{ 47{
55 return USER_DS; 48 return USER_DS;
56} 49}
57 50
58static inline void set_fs(mm_segment_t s) 51static inline void set_fs(mm_segment_t s)
59{ 52{
60} 53}
61#endif /* CONFIG_MMU */ 54
55#endif /* not CONFIG_MMU */
62 56
63#define segment_eq(a,b) ((a).seg == (b).seg) 57#define segment_eq(a,b) ((a).seg == (b).seg)
64 58
@@ -83,9 +77,9 @@ static inline void set_fs(mm_segment_t s)
83 " subx %0, %0\n" \ 77 " subx %0, %0\n" \
84 " cmpu %4, %1\n" \ 78 " cmpu %4, %1\n" \
85 " subx %0, %5\n" \ 79 " subx %0, %5\n" \
86 : "=&r"(flag), "=r"(sum) \ 80 : "=&r" (flag), "=r" (sum) \
87 : "1"(addr), "r"((int)(size)), \ 81 : "1" (addr), "r" ((int)(size)), \
88 "r"(current_thread_info()->addr_limit.seg), "r"(0) \ 82 "r" (current_thread_info()->addr_limit.seg), "r" (0) \
89 : "cbit" ); \ 83 : "cbit" ); \
90 flag; }) 84 flag; })
91 85
@@ -113,10 +107,10 @@ static inline void set_fs(mm_segment_t s)
113#else 107#else
114static inline int access_ok(int type, const void *addr, unsigned long size) 108static inline int access_ok(int type, const void *addr, unsigned long size)
115{ 109{
116 extern unsigned long memory_start, memory_end; 110 extern unsigned long memory_start, memory_end;
117 unsigned long val = (unsigned long)addr; 111 unsigned long val = (unsigned long)addr;
118 112
119 return ((val >= memory_start) && ((val + size) < memory_end)); 113 return ((val >= memory_start) && ((val + size) < memory_end));
120} 114}
121#endif /* CONFIG_MMU */ 115#endif /* CONFIG_MMU */
122 116
@@ -155,39 +149,6 @@ extern int fixup_exception(struct pt_regs *regs);
155 * accesses to the same area of user memory). 149 * accesses to the same area of user memory).
156 */ 150 */
157 151
158extern void __get_user_1(void);
159extern void __get_user_2(void);
160extern void __get_user_4(void);
161
162#ifndef MODULE
163#define __get_user_x(size,ret,x,ptr) \
164 __asm__ __volatile__( \
165 " mv r0, %0\n" \
166 " mv r1, %1\n" \
167 " bl __get_user_" #size "\n" \
168 " mv %0, r0\n" \
169 " mv %1, r1\n" \
170 : "=r"(ret), "=r"(x) \
171 : "0"(ptr) \
172 : "r0", "r1", "r14" )
173#else /* MODULE */
174/*
175 * Use "jl" instead of "bl" for MODULE
176 */
177#define __get_user_x(size,ret,x,ptr) \
178 __asm__ __volatile__( \
179 " mv r0, %0\n" \
180 " mv r1, %1\n" \
181 " seth lr, #high(__get_user_" #size ")\n" \
182 " or3 lr, lr, #low(__get_user_" #size ")\n" \
183 " jl lr\n" \
184 " mv %0, r0\n" \
185 " mv %1, r1\n" \
186 : "=r"(ret), "=r"(x) \
187 : "0"(ptr) \
188 : "r0", "r1", "r14" )
189#endif
190
191/* Careful: we have to cast the result to the type of the pointer for sign 152/* Careful: we have to cast the result to the type of the pointer for sign
192 reasons */ 153 reasons */
193/** 154/**
@@ -208,20 +169,7 @@ extern void __get_user_4(void);
208 * On error, the variable @x is set to zero. 169 * On error, the variable @x is set to zero.
209 */ 170 */
210#define get_user(x,ptr) \ 171#define get_user(x,ptr) \
211({ int __ret_gu; \ 172 __get_user_check((x),(ptr),sizeof(*(ptr)))
212 unsigned long __val_gu; \
213 __chk_user_ptr(ptr); \
214 switch(sizeof (*(ptr))) { \
215 case 1: __get_user_x(1,__ret_gu,__val_gu,ptr); break; \
216 case 2: __get_user_x(2,__ret_gu,__val_gu,ptr); break; \
217 case 4: __get_user_x(4,__ret_gu,__val_gu,ptr); break; \
218 default: __get_user_x(X,__ret_gu,__val_gu,ptr); break; \
219 } \
220 (x) = (__typeof__(*(ptr)))__val_gu; \
221 __ret_gu; \
222})
223
224extern void __put_user_bad(void);
225 173
226/** 174/**
227 * put_user: - Write a simple value into user space. 175 * put_user: - Write a simple value into user space.
@@ -240,8 +188,7 @@ extern void __put_user_bad(void);
240 * Returns zero on success, or -EFAULT on error. 188 * Returns zero on success, or -EFAULT on error.
241 */ 189 */
242#define put_user(x,ptr) \ 190#define put_user(x,ptr) \
243 __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) 191 __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
244
245 192
246/** 193/**
247 * __get_user: - Get a simple variable from user space, with less checking. 194 * __get_user: - Get a simple variable from user space, with less checking.
@@ -264,8 +211,64 @@ extern void __put_user_bad(void);
264 * On error, the variable @x is set to zero. 211 * On error, the variable @x is set to zero.
265 */ 212 */
266#define __get_user(x,ptr) \ 213#define __get_user(x,ptr) \
267 __get_user_nocheck((x),(ptr),sizeof(*(ptr))) 214 __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
268 215
216#define __get_user_nocheck(x,ptr,size) \
217({ \
218 long __gu_err = 0; \
219 unsigned long __gu_val; \
220 might_sleep(); \
221 __get_user_size(__gu_val,(ptr),(size),__gu_err); \
222 (x) = (__typeof__(*(ptr)))__gu_val; \
223 __gu_err; \
224})
225
226#define __get_user_check(x,ptr,size) \
227({ \
228 long __gu_err = -EFAULT; \
229 unsigned long __gu_val = 0; \
230 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
231 might_sleep(); \
232 if (access_ok(VERIFY_READ,__gu_addr,size)) \
233 __get_user_size(__gu_val,__gu_addr,(size),__gu_err); \
234 (x) = (__typeof__(*(ptr)))__gu_val; \
235 __gu_err; \
236})
237
238extern long __get_user_bad(void);
239
240#define __get_user_size(x,ptr,size,retval) \
241do { \
242 retval = 0; \
243 __chk_user_ptr(ptr); \
244 switch (size) { \
245 case 1: __get_user_asm(x,ptr,retval,"ub"); break; \
246 case 2: __get_user_asm(x,ptr,retval,"uh"); break; \
247 case 4: __get_user_asm(x,ptr,retval,""); break; \
248 default: (x) = __get_user_bad(); \
249 } \
250} while (0)
251
252#define __get_user_asm(x, addr, err, itype) \
253 __asm__ __volatile__( \
254 " .fillinsn\n" \
255 "1: ld"itype" %1,@%2\n" \
256 " .fillinsn\n" \
257 "2:\n" \
258 ".section .fixup,\"ax\"\n" \
259 " .balign 4\n" \
260 "3: ldi %0,%3\n" \
261 " seth r14,#high(2b)\n" \
262 " or3 r14,r14,#low(2b)\n" \
263 " jmp r14\n" \
264 ".previous\n" \
265 ".section __ex_table,\"a\"\n" \
266 " .balign 4\n" \
267 " .long 1b,3b\n" \
268 ".previous" \
269 : "=&r" (err), "=&r" (x) \
270 : "r" (addr), "i" (-EFAULT), "0" (err) \
271 : "r14", "memory")
269 272
270/** 273/**
271 * __put_user: - Write a simple value into user space, with less checking. 274 * __put_user: - Write a simple value into user space, with less checking.
@@ -287,11 +290,13 @@ extern void __put_user_bad(void);
287 * Returns zero on success, or -EFAULT on error. 290 * Returns zero on success, or -EFAULT on error.
288 */ 291 */
289#define __put_user(x,ptr) \ 292#define __put_user(x,ptr) \
290 __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) 293 __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
294
291 295
292#define __put_user_nocheck(x,ptr,size) \ 296#define __put_user_nocheck(x,ptr,size) \
293({ \ 297({ \
294 long __pu_err; \ 298 long __pu_err; \
299 might_sleep(); \
295 __put_user_size((x),(ptr),(size),__pu_err); \ 300 __put_user_size((x),(ptr),(size),__pu_err); \
296 __pu_err; \ 301 __pu_err; \
297}) 302})
@@ -308,28 +313,28 @@ extern void __put_user_bad(void);
308}) 313})
309 314
310#if defined(__LITTLE_ENDIAN__) 315#if defined(__LITTLE_ENDIAN__)
311#define __put_user_u64(x, addr, err) \ 316#define __put_user_u64(x, addr, err) \
312 __asm__ __volatile__( \ 317 __asm__ __volatile__( \
313 " .fillinsn\n" \ 318 " .fillinsn\n" \
314 "1: st %L1,@%2\n" \ 319 "1: st %L1,@%2\n" \
315 " .fillinsn\n" \ 320 " .fillinsn\n" \
316 "2: st %H1,@(4,%2)\n" \ 321 "2: st %H1,@(4,%2)\n" \
317 " .fillinsn\n" \ 322 " .fillinsn\n" \
318 "3:\n" \ 323 "3:\n" \
319 ".section .fixup,\"ax\"\n" \ 324 ".section .fixup,\"ax\"\n" \
320 " .balign 4\n" \ 325 " .balign 4\n" \
321 "4: ldi %0,%3\n" \ 326 "4: ldi %0,%3\n" \
322 " seth r14,#high(3b)\n" \ 327 " seth r14,#high(3b)\n" \
323 " or3 r14,r14,#low(3b)\n" \ 328 " or3 r14,r14,#low(3b)\n" \
324 " jmp r14\n" \ 329 " jmp r14\n" \
325 ".previous\n" \ 330 ".previous\n" \
326 ".section __ex_table,\"a\"\n" \ 331 ".section __ex_table,\"a\"\n" \
327 " .balign 4\n" \ 332 " .balign 4\n" \
328 " .long 1b,4b\n" \ 333 " .long 1b,4b\n" \
329 " .long 2b,4b\n" \ 334 " .long 2b,4b\n" \
330 ".previous" \ 335 ".previous" \
331 : "=&r"(err) \ 336 : "=&r" (err) \
332 : "r"(x), "r"(addr), "i"(-EFAULT), "0"(err) \ 337 : "r" (x), "r" (addr), "i" (-EFAULT), "0" (err) \
333 : "r14", "memory") 338 : "r14", "memory")
334 339
335#elif defined(__BIG_ENDIAN__) 340#elif defined(__BIG_ENDIAN__)
@@ -353,13 +358,15 @@ extern void __put_user_bad(void);
353 " .long 1b,4b\n" \ 358 " .long 1b,4b\n" \
354 " .long 2b,4b\n" \ 359 " .long 2b,4b\n" \
355 ".previous" \ 360 ".previous" \
356 : "=&r"(err) \ 361 : "=&r" (err) \
357 : "r"(x), "r"(addr), "i"(-EFAULT), "0"(err) \ 362 : "r" (x), "r" (addr), "i" (-EFAULT), "0" (err) \
358 : "r14", "memory") 363 : "r14", "memory")
359#else 364#else
360#error no endian defined 365#error no endian defined
361#endif 366#endif
362 367
368extern void __put_user_bad(void);
369
363#define __put_user_size(x,ptr,size,retval) \ 370#define __put_user_size(x,ptr,size,retval) \
364do { \ 371do { \
365 retval = 0; \ 372 retval = 0; \
@@ -398,52 +405,8 @@ struct __large_struct { unsigned long buf[100]; };
398 " .balign 4\n" \ 405 " .balign 4\n" \
399 " .long 1b,3b\n" \ 406 " .long 1b,3b\n" \
400 ".previous" \ 407 ".previous" \
401 : "=&r"(err) \ 408 : "=&r" (err) \
402 : "r"(x), "r"(addr), "i"(-EFAULT), "0"(err) \ 409 : "r" (x), "r" (addr), "i" (-EFAULT), "0" (err) \
403 : "r14", "memory")
404
405#define __get_user_nocheck(x,ptr,size) \
406({ \
407 long __gu_err; \
408 unsigned long __gu_val; \
409 __get_user_size(__gu_val,(ptr),(size),__gu_err); \
410 (x) = (__typeof__(*(ptr)))__gu_val; \
411 __gu_err; \
412})
413
414extern long __get_user_bad(void);
415
416#define __get_user_size(x,ptr,size,retval) \
417do { \
418 retval = 0; \
419 __chk_user_ptr(ptr); \
420 switch (size) { \
421 case 1: __get_user_asm(x,ptr,retval,"ub"); break; \
422 case 2: __get_user_asm(x,ptr,retval,"uh"); break; \
423 case 4: __get_user_asm(x,ptr,retval,""); break; \
424 default: (x) = __get_user_bad(); \
425 } \
426} while (0)
427
428#define __get_user_asm(x, addr, err, itype) \
429 __asm__ __volatile__( \
430 " .fillinsn\n" \
431 "1: ld"itype" %1,@%2\n" \
432 " .fillinsn\n" \
433 "2:\n" \
434 ".section .fixup,\"ax\"\n" \
435 " .balign 4\n" \
436 "3: ldi %0,%3\n" \
437 " seth r14,#high(2b)\n" \
438 " or3 r14,r14,#low(2b)\n" \
439 " jmp r14\n" \
440 ".previous\n" \
441 ".section __ex_table,\"a\"\n" \
442 " .balign 4\n" \
443 " .long 1b,3b\n" \
444 ".previous" \
445 : "=&r"(err), "=&r"(x) \
446 : "r"(addr), "i"(-EFAULT), "0"(err) \
447 : "r14", "memory") 410 : "r14", "memory")
448 411
449/* 412/*
@@ -453,7 +416,6 @@ do { \
453 * anything, so this is accurate. 416 * anything, so this is accurate.
454 */ 417 */
455 418
456
457/* 419/*
458 * Copy To/From Userspace 420 * Copy To/From Userspace
459 */ 421 */
@@ -511,8 +473,9 @@ do { \
511 " .long 2b,9b\n" \ 473 " .long 2b,9b\n" \
512 " .long 3b,9b\n" \ 474 " .long 3b,9b\n" \
513 ".previous\n" \ 475 ".previous\n" \
514 : "=&r"(__dst), "=&r"(__src), "=&r"(size), "=&r"(__c) \ 476 : "=&r" (__dst), "=&r" (__src), "=&r" (size), \
515 : "0"(to), "1"(from), "2"(size), "3"(size / 4) \ 477 "=&r" (__c) \
478 : "0" (to), "1" (from), "2" (size), "3" (size / 4) \
516 : "r14", "memory"); \ 479 : "r14", "memory"); \
517} while (0) 480} while (0)
518 481
@@ -573,8 +536,9 @@ do { \
573 " .long 2b,7b\n" \ 536 " .long 2b,7b\n" \
574 " .long 3b,7b\n" \ 537 " .long 3b,7b\n" \
575 ".previous\n" \ 538 ".previous\n" \
576 : "=&r"(__dst), "=&r"(__src), "=&r"(size), "=&r"(__c) \ 539 : "=&r" (__dst), "=&r" (__src), "=&r" (size), \
577 : "0"(to), "1"(from), "2"(size), "3"(size / 4) \ 540 "=&r" (__c) \
541 : "0" (to), "1" (from), "2" (size), "3" (size / 4) \
578 : "r14", "memory"); \ 542 : "r14", "memory"); \
579} while (0) 543} while (0)
580 544
@@ -676,7 +640,7 @@ unsigned long __generic_copy_from_user(void *, const void __user *, unsigned lon
676#define copy_from_user(to,from,n) \ 640#define copy_from_user(to,from,n) \
677({ \ 641({ \
678 might_sleep(); \ 642 might_sleep(); \
679__generic_copy_from_user((to),(from),(n)); \ 643 __generic_copy_from_user((to),(from),(n)); \
680}) 644})
681 645
682long __must_check strncpy_from_user(char *dst, const char __user *src, 646long __must_check strncpy_from_user(char *dst, const char __user *src,
diff --git a/include/asm-m32r/unistd.h b/include/asm-m32r/unistd.h
index 39be87ca2a5a..be0eb014c3b0 100644
--- a/include/asm-m32r/unistd.h
+++ b/include/asm-m32r/unistd.h
@@ -292,7 +292,7 @@
292#define __NR_mq_timedreceive (__NR_mq_open+3) 292#define __NR_mq_timedreceive (__NR_mq_open+3)
293#define __NR_mq_notify (__NR_mq_open+4) 293#define __NR_mq_notify (__NR_mq_open+4)
294#define __NR_mq_getsetattr (__NR_mq_open+5) 294#define __NR_mq_getsetattr (__NR_mq_open+5)
295#define __NR_sys_kexec_load 283 295#define __NR_kexec_load 283
296#define __NR_waitid 284 296#define __NR_waitid 284
297 297
298#define NR_syscalls 285 298#define NR_syscalls 285