aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-frv
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-frv
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/asm-frv')
-rw-r--r--include/asm-frv/a.out.h5
-rw-r--r--include/asm-frv/atomic.h417
-rw-r--r--include/asm-frv/ax88796.h22
-rw-r--r--include/asm-frv/bitops.h341
-rw-r--r--include/asm-frv/bug.h51
-rw-r--r--include/asm-frv/bugs.h14
-rw-r--r--include/asm-frv/busctl-regs.h41
-rw-r--r--include/asm-frv/byteorder.h13
-rw-r--r--include/asm-frv/cache.h24
-rw-r--r--include/asm-frv/cacheflush.h91
-rw-r--r--include/asm-frv/checksum.h183
-rw-r--r--include/asm-frv/cpu-irqs.h87
-rw-r--r--include/asm-frv/cpumask.h6
-rw-r--r--include/asm-frv/cputime.h6
-rw-r--r--include/asm-frv/current.h30
-rw-r--r--include/asm-frv/delay.h50
-rw-r--r--include/asm-frv/div64.h1
-rw-r--r--include/asm-frv/dm9000.h37
-rw-r--r--include/asm-frv/dma-mapping.h184
-rw-r--r--include/asm-frv/dma.h129
-rw-r--r--include/asm-frv/elf.h147
-rw-r--r--include/asm-frv/errno.h7
-rw-r--r--include/asm-frv/fcntl.h88
-rw-r--r--include/asm-frv/fpu.h12
-rw-r--r--include/asm-frv/gdb-stub.h118
-rw-r--r--include/asm-frv/gpio-regs.h116
-rw-r--r--include/asm-frv/hardirq.h30
-rw-r--r--include/asm-frv/highmem.h181
-rw-r--r--include/asm-frv/hw_irq.h16
-rw-r--r--include/asm-frv/ide.h43
-rw-r--r--include/asm-frv/init.h12
-rw-r--r--include/asm-frv/io.h290
-rw-r--r--include/asm-frv/ioctl.h80
-rw-r--r--include/asm-frv/ioctls.h82
-rw-r--r--include/asm-frv/ipc.h1
-rw-r--r--include/asm-frv/ipcbuf.h30
-rw-r--r--include/asm-frv/irc-regs.h53
-rw-r--r--include/asm-frv/irq-routing.h70
-rw-r--r--include/asm-frv/irq.h44
-rw-r--r--include/asm-frv/kmap_types.h29
-rw-r--r--include/asm-frv/linkage.h7
-rw-r--r--include/asm-frv/local.h6
-rw-r--r--include/asm-frv/math-emu.h301
-rw-r--r--include/asm-frv/mb-regs.h185
-rw-r--r--include/asm-frv/mb86943a.h39
-rw-r--r--include/asm-frv/mb93091-fpga-irqs.h44
-rw-r--r--include/asm-frv/mb93093-fpga-irqs.h31
-rw-r--r--include/asm-frv/mb93493-irqs.h52
-rw-r--r--include/asm-frv/mb93493-regs.h279
-rw-r--r--include/asm-frv/mem-layout.h78
-rw-r--r--include/asm-frv/mman.h44
-rw-r--r--include/asm-frv/mmu.h42
-rw-r--r--include/asm-frv/mmu_context.h50
-rw-r--r--include/asm-frv/module.h20
-rw-r--r--include/asm-frv/msgbuf.h32
-rw-r--r--include/asm-frv/namei.h18
-rw-r--r--include/asm-frv/page.h105
-rw-r--r--include/asm-frv/param.h23
-rw-r--r--include/asm-frv/pci.h108
-rw-r--r--include/asm-frv/percpu.h6
-rw-r--r--include/asm-frv/pgalloc.h64
-rw-r--r--include/asm-frv/pgtable.h555
-rw-r--r--include/asm-frv/poll.h23
-rw-r--r--include/asm-frv/posix_types.h66
-rw-r--r--include/asm-frv/processor.h153
-rw-r--r--include/asm-frv/ptrace.h86
-rw-r--r--include/asm-frv/registers.h255
-rw-r--r--include/asm-frv/resource.h7
-rw-r--r--include/asm-frv/scatterlist.h32
-rw-r--r--include/asm-frv/sections.h46
-rw-r--r--include/asm-frv/segment.h46
-rw-r--r--include/asm-frv/semaphore.h161
-rw-r--r--include/asm-frv/sembuf.h26
-rw-r--r--include/asm-frv/serial-regs.h44
-rw-r--r--include/asm-frv/serial.h19
-rw-r--r--include/asm-frv/setup.h25
-rw-r--r--include/asm-frv/shmbuf.h43
-rw-r--r--include/asm-frv/shmparam.h7
-rw-r--r--include/asm-frv/sigcontext.h26
-rw-r--r--include/asm-frv/siginfo.h12
-rw-r--r--include/asm-frv/signal.h187
-rw-r--r--include/asm-frv/smp.h10
-rw-r--r--include/asm-frv/socket.h51
-rw-r--r--include/asm-frv/sockios.h13
-rw-r--r--include/asm-frv/spinlock.h17
-rw-r--r--include/asm-frv/spr-regs.h401
-rw-r--r--include/asm-frv/stat.h100
-rw-r--r--include/asm-frv/statfs.h7
-rw-r--r--include/asm-frv/string.h51
-rw-r--r--include/asm-frv/suspend.h20
-rw-r--r--include/asm-frv/system.h128
-rw-r--r--include/asm-frv/termbits.h177
-rw-r--r--include/asm-frv/termios.h74
-rw-r--r--include/asm-frv/thread_info.h159
-rw-r--r--include/asm-frv/timer-regs.h106
-rw-r--r--include/asm-frv/timex.h25
-rw-r--r--include/asm-frv/tlb.h23
-rw-r--r--include/asm-frv/tlbflush.h77
-rw-r--r--include/asm-frv/topology.h14
-rw-r--r--include/asm-frv/types.h74
-rw-r--r--include/asm-frv/uaccess.h318
-rw-r--r--include/asm-frv/ucontext.h12
-rw-r--r--include/asm-frv/unaligned.h203
-rw-r--r--include/asm-frv/unistd.h501
-rw-r--r--include/asm-frv/user.h80
-rw-r--r--include/asm-frv/virtconvert.h42
106 files changed, 9217 insertions, 0 deletions
diff --git a/include/asm-frv/a.out.h b/include/asm-frv/a.out.h
new file mode 100644
index 000000000000..dd3b7e5754c9
--- /dev/null
+++ b/include/asm-frv/a.out.h
@@ -0,0 +1,5 @@
1/*
2 * FRV doesn't do AOUT format. This header file should be removed as
3 * soon as fs/exec.c and fs/proc/kcore.c and the archs that require
4 * them to include linux/a.out.h are fixed.
5 */
diff --git a/include/asm-frv/atomic.h b/include/asm-frv/atomic.h
new file mode 100644
index 000000000000..e75968463428
--- /dev/null
+++ b/include/asm-frv/atomic.h
@@ -0,0 +1,417 @@
1/* atomic.h: atomic operation emulation for FR-V
2 *
3 * For an explanation of how atomic ops work in this arch, see:
4 * Documentation/fujitsu/frv/atomic-ops.txt
5 *
6 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
7 * Written by David Howells (dhowells@redhat.com)
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14#ifndef _ASM_ATOMIC_H
15#define _ASM_ATOMIC_H
16
17#include <linux/config.h>
18#include <linux/types.h>
19#include <asm/spr-regs.h>
20
21#ifdef CONFIG_SMP
22#error not SMP safe
23#endif
24
25/*
26 * Atomic operations that C can't guarantee us. Useful for
27 * resource counting etc..
28 *
29 * We do not have SMP systems, so we don't have to deal with that.
30 */
31
32/* Atomic operations are already serializing */
33#define smp_mb__before_atomic_dec() barrier()
34#define smp_mb__after_atomic_dec() barrier()
35#define smp_mb__before_atomic_inc() barrier()
36#define smp_mb__after_atomic_inc() barrier()
37
38typedef struct {
39 int counter;
40} atomic_t;
41
42#define ATOMIC_INIT(i) { (i) }
43#define atomic_read(v) ((v)->counter)
44#define atomic_set(v, i) (((v)->counter) = (i))
45
46#ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS
47static inline int atomic_add_return(int i, atomic_t *v)
48{
49 unsigned long val;
50
51 asm("0: \n"
52 " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */
53 " ckeq icc3,cc7 \n"
54 " ld.p %M0,%1 \n" /* LD.P/ORCR must be atomic */
55 " orcr cc7,cc7,cc3 \n" /* set CC3 to true */
56 " add%I2 %1,%2,%1 \n"
57 " cst.p %1,%M0 ,cc3,#1 \n"
58 " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* clear ICC3.Z if store happens */
59 " beq icc3,#0,0b \n"
60 : "+U"(v->counter), "=&r"(val)
61 : "NPr"(i)
62 : "memory", "cc7", "cc3", "icc3"
63 );
64
65 return val;
66}
67
68static inline int atomic_sub_return(int i, atomic_t *v)
69{
70 unsigned long val;
71
72 asm("0: \n"
73 " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */
74 " ckeq icc3,cc7 \n"
75 " ld.p %M0,%1 \n" /* LD.P/ORCR must be atomic */
76 " orcr cc7,cc7,cc3 \n" /* set CC3 to true */
77 " sub%I2 %1,%2,%1 \n"
78 " cst.p %1,%M0 ,cc3,#1 \n"
79 " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* clear ICC3.Z if store happens */
80 " beq icc3,#0,0b \n"
81 : "+U"(v->counter), "=&r"(val)
82 : "NPr"(i)
83 : "memory", "cc7", "cc3", "icc3"
84 );
85
86 return val;
87}
88
89#else
90
91extern int atomic_add_return(int i, atomic_t *v);
92extern int atomic_sub_return(int i, atomic_t *v);
93
94#endif
95
96static inline int atomic_add_negative(int i, atomic_t *v)
97{
98 return atomic_add_return(i, v) < 0;
99}
100
101static inline void atomic_add(int i, atomic_t *v)
102{
103 atomic_add_return(i, v);
104}
105
106static inline void atomic_sub(int i, atomic_t *v)
107{
108 atomic_sub_return(i, v);
109}
110
111static inline void atomic_inc(atomic_t *v)
112{
113 atomic_add_return(1, v);
114}
115
116static inline void atomic_dec(atomic_t *v)
117{
118 atomic_sub_return(1, v);
119}
120
121#define atomic_dec_return(v) atomic_sub_return(1, (v))
122#define atomic_inc_return(v) atomic_add_return(1, (v))
123
124#define atomic_sub_and_test(i,v) (atomic_sub_return((i), (v)) == 0)
125#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
126#define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0)
127
128#ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS
129static inline
130unsigned long atomic_test_and_ANDNOT_mask(unsigned long mask, volatile unsigned long *v)
131{
132 unsigned long old, tmp;
133
134 asm volatile(
135 "0: \n"
136 " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */
137 " ckeq icc3,cc7 \n"
138 " ld.p %M0,%1 \n" /* LD.P/ORCR are atomic */
139 " orcr cc7,cc7,cc3 \n" /* set CC3 to true */
140 " and%I3 %1,%3,%2 \n"
141 " cst.p %2,%M0 ,cc3,#1 \n" /* if store happens... */
142 " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* ... clear ICC3.Z */
143 " beq icc3,#0,0b \n"
144 : "+U"(*v), "=&r"(old), "=r"(tmp)
145 : "NPr"(~mask)
146 : "memory", "cc7", "cc3", "icc3"
147 );
148
149 return old;
150}
151
152static inline
153unsigned long atomic_test_and_OR_mask(unsigned long mask, volatile unsigned long *v)
154{
155 unsigned long old, tmp;
156
157 asm volatile(
158 "0: \n"
159 " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */
160 " ckeq icc3,cc7 \n"
161 " ld.p %M0,%1 \n" /* LD.P/ORCR are atomic */
162 " orcr cc7,cc7,cc3 \n" /* set CC3 to true */
163 " or%I3 %1,%3,%2 \n"
164 " cst.p %2,%M0 ,cc3,#1 \n" /* if store happens... */
165 " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* ... clear ICC3.Z */
166 " beq icc3,#0,0b \n"
167 : "+U"(*v), "=&r"(old), "=r"(tmp)
168 : "NPr"(mask)
169 : "memory", "cc7", "cc3", "icc3"
170 );
171
172 return old;
173}
174
175static inline
176unsigned long atomic_test_and_XOR_mask(unsigned long mask, volatile unsigned long *v)
177{
178 unsigned long old, tmp;
179
180 asm volatile(
181 "0: \n"
182 " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */
183 " ckeq icc3,cc7 \n"
184 " ld.p %M0,%1 \n" /* LD.P/ORCR are atomic */
185 " orcr cc7,cc7,cc3 \n" /* set CC3 to true */
186 " xor%I3 %1,%3,%2 \n"
187 " cst.p %2,%M0 ,cc3,#1 \n" /* if store happens... */
188 " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* ... clear ICC3.Z */
189 " beq icc3,#0,0b \n"
190 : "+U"(*v), "=&r"(old), "=r"(tmp)
191 : "NPr"(mask)
192 : "memory", "cc7", "cc3", "icc3"
193 );
194
195 return old;
196}
197
198#else
199
200extern unsigned long atomic_test_and_ANDNOT_mask(unsigned long mask, volatile unsigned long *v);
201extern unsigned long atomic_test_and_OR_mask(unsigned long mask, volatile unsigned long *v);
202extern unsigned long atomic_test_and_XOR_mask(unsigned long mask, volatile unsigned long *v);
203
204#endif
205
206#define atomic_clear_mask(mask, v) atomic_test_and_ANDNOT_mask((mask), (v))
207#define atomic_set_mask(mask, v) atomic_test_and_OR_mask((mask), (v))
208
209/*****************************************************************************/
210/*
211 * exchange value with memory
212 */
213#ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS
214
215#define xchg(ptr, x) \
216({ \
217 __typeof__(ptr) __xg_ptr = (ptr); \
218 __typeof__(*(ptr)) __xg_orig; \
219 \
220 switch (sizeof(__xg_orig)) { \
221 case 1: \
222 asm volatile( \
223 "0: \n" \
224 " orcc gr0,gr0,gr0,icc3 \n" \
225 " ckeq icc3,cc7 \n" \
226 " ldub.p %M0,%1 \n" \
227 " orcr cc7,cc7,cc3 \n" \
228 " cstb.p %2,%M0 ,cc3,#1 \n" \
229 " corcc gr29,gr29,gr0 ,cc3,#1 \n" \
230 " beq icc3,#0,0b \n" \
231 : "+U"(*__xg_ptr), "=&r"(__xg_orig) \
232 : "r"(x) \
233 : "memory", "cc7", "cc3", "icc3" \
234 ); \
235 break; \
236 \
237 case 2: \
238 asm volatile( \
239 "0: \n" \
240 " orcc gr0,gr0,gr0,icc3 \n" \
241 " ckeq icc3,cc7 \n" \
242 " lduh.p %M0,%1 \n" \
243 " orcr cc7,cc7,cc3 \n" \
244 " csth.p %2,%M0 ,cc3,#1 \n" \
245 " corcc gr29,gr29,gr0 ,cc3,#1 \n" \
246 " beq icc3,#0,0b \n" \
247 : "+U"(*__xg_ptr), "=&r"(__xg_orig) \
248 : "r"(x) \
249 : "memory", "cc7", "cc3", "icc3" \
250 ); \
251 break; \
252 \
253 case 4: \
254 asm volatile( \
255 "0: \n" \
256 " orcc gr0,gr0,gr0,icc3 \n" \
257 " ckeq icc3,cc7 \n" \
258 " ld.p %M0,%1 \n" \
259 " orcr cc7,cc7,cc3 \n" \
260 " cst.p %2,%M0 ,cc3,#1 \n" \
261 " corcc gr29,gr29,gr0 ,cc3,#1 \n" \
262 " beq icc3,#0,0b \n" \
263 : "+U"(*__xg_ptr), "=&r"(__xg_orig) \
264 : "r"(x) \
265 : "memory", "cc7", "cc3", "icc3" \
266 ); \
267 break; \
268 \
269 default: \
270 __xg_orig = 0; \
271 asm volatile("break"); \
272 break; \
273 } \
274 \
275 __xg_orig; \
276})
277
278#else
279
280extern uint8_t __xchg_8 (uint8_t i, volatile void *v);
281extern uint16_t __xchg_16(uint16_t i, volatile void *v);
282extern uint32_t __xchg_32(uint32_t i, volatile void *v);
283
284#define xchg(ptr, x) \
285({ \
286 __typeof__(ptr) __xg_ptr = (ptr); \
287 __typeof__(*(ptr)) __xg_orig; \
288 \
289 switch (sizeof(__xg_orig)) { \
290 case 1: __xg_orig = (__typeof__(*(ptr))) __xchg_8 ((uint8_t) x, __xg_ptr); break; \
291 case 2: __xg_orig = (__typeof__(*(ptr))) __xchg_16((uint16_t) x, __xg_ptr); break; \
292 case 4: __xg_orig = (__typeof__(*(ptr))) __xchg_32((uint32_t) x, __xg_ptr); break; \
293 default: \
294 __xg_orig = 0; \
295 asm volatile("break"); \
296 break; \
297 } \
298 __xg_orig; \
299})
300
301#endif
302
303#define tas(ptr) (xchg((ptr), 1))
304
305/*****************************************************************************/
306/*
307 * compare and conditionally exchange value with memory
308 * - if (*ptr == test) then orig = *ptr; *ptr = test;
309 * - if (*ptr != test) then orig = *ptr;
310 */
311#ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS
312
313#define cmpxchg(ptr, test, new) \
314({ \
315 __typeof__(ptr) __xg_ptr = (ptr); \
316 __typeof__(*(ptr)) __xg_orig, __xg_tmp; \
317 __typeof__(*(ptr)) __xg_test = (test); \
318 __typeof__(*(ptr)) __xg_new = (new); \
319 \
320 switch (sizeof(__xg_orig)) { \
321 case 1: \
322 asm volatile( \
323 "0: \n" \
324 " orcc gr0,gr0,gr0,icc3 \n" \
325 " ckeq icc3,cc7 \n" \
326 " ldub.p %M0,%1 \n" \
327 " orcr cc7,cc7,cc3 \n" \
328 " sub%I4 %1,%4,%2 \n" \
329 " sllcc %2,#24,gr0,icc0 \n" \
330 " bne icc0,#0,1f \n" \
331 " cstb.p %3,%M0 ,cc3,#1 \n" \
332 " corcc gr29,gr29,gr0 ,cc3,#1 \n" \
333 " beq icc3,#0,0b \n" \
334 "1: \n" \
335 : "+U"(*__xg_ptr), "=&r"(__xg_orig), "=&r"(__xg_tmp) \
336 : "r"(__xg_new), "NPr"(__xg_test) \
337 : "memory", "cc7", "cc3", "icc3", "icc0" \
338 ); \
339 break; \
340 \
341 case 2: \
342 asm volatile( \
343 "0: \n" \
344 " orcc gr0,gr0,gr0,icc3 \n" \
345 " ckeq icc3,cc7 \n" \
346 " lduh.p %M0,%1 \n" \
347 " orcr cc7,cc7,cc3 \n" \
348 " sub%I4 %1,%4,%2 \n" \
349 " sllcc %2,#16,gr0,icc0 \n" \
350 " bne icc0,#0,1f \n" \
351 " csth.p %3,%M0 ,cc3,#1 \n" \
352 " corcc gr29,gr29,gr0 ,cc3,#1 \n" \
353 " beq icc3,#0,0b \n" \
354 "1: \n" \
355 : "+U"(*__xg_ptr), "=&r"(__xg_orig), "=&r"(__xg_tmp) \
356 : "r"(__xg_new), "NPr"(__xg_test) \
357 : "memory", "cc7", "cc3", "icc3", "icc0" \
358 ); \
359 break; \
360 \
361 case 4: \
362 asm volatile( \
363 "0: \n" \
364 " orcc gr0,gr0,gr0,icc3 \n" \
365 " ckeq icc3,cc7 \n" \
366 " ld.p %M0,%1 \n" \
367 " orcr cc7,cc7,cc3 \n" \
368 " sub%I4cc %1,%4,%2,icc0 \n" \
369 " bne icc0,#0,1f \n" \
370 " cst.p %3,%M0 ,cc3,#1 \n" \
371 " corcc gr29,gr29,gr0 ,cc3,#1 \n" \
372 " beq icc3,#0,0b \n" \
373 "1: \n" \
374 : "+U"(*__xg_ptr), "=&r"(__xg_orig), "=&r"(__xg_tmp) \
375 : "r"(__xg_new), "NPr"(__xg_test) \
376 : "memory", "cc7", "cc3", "icc3", "icc0" \
377 ); \
378 break; \
379 \
380 default: \
381 __xg_orig = 0; \
382 asm volatile("break"); \
383 break; \
384 } \
385 \
386 __xg_orig; \
387})
388
389#else
390
391extern uint8_t __cmpxchg_8 (uint8_t *v, uint8_t test, uint8_t new);
392extern uint16_t __cmpxchg_16(uint16_t *v, uint16_t test, uint16_t new);
393extern uint32_t __cmpxchg_32(uint32_t *v, uint32_t test, uint32_t new);
394
395#define cmpxchg(ptr, test, new) \
396({ \
397 __typeof__(ptr) __xg_ptr = (ptr); \
398 __typeof__(*(ptr)) __xg_orig; \
399 __typeof__(*(ptr)) __xg_test = (test); \
400 __typeof__(*(ptr)) __xg_new = (new); \
401 \
402 switch (sizeof(__xg_orig)) { \
403 case 1: __xg_orig = __cmpxchg_8 (__xg_ptr, __xg_test, __xg_new); break; \
404 case 2: __xg_orig = __cmpxchg_16(__xg_ptr, __xg_test, __xg_new); break; \
405 case 4: __xg_orig = __cmpxchg_32(__xg_ptr, __xg_test, __xg_new); break; \
406 default: \
407 __xg_orig = 0; \
408 asm volatile("break"); \
409 break; \
410 } \
411 \
412 __xg_orig; \
413})
414
415#endif
416
417#endif /* _ASM_ATOMIC_H */
diff --git a/include/asm-frv/ax88796.h b/include/asm-frv/ax88796.h
new file mode 100644
index 000000000000..637e980393c5
--- /dev/null
+++ b/include/asm-frv/ax88796.h
@@ -0,0 +1,22 @@
1/* ax88796.h: access points to the driver for the AX88796 NE2000 clone
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_AX88796_H
13#define _ASM_AX88796_H
14
15#include <asm/mb-regs.h>
16
17#define AX88796_IOADDR (__region_CS1 + 0x200)
18#define AX88796_IRQ IRQ_CPU_EXTERNAL7
19#define AX88796_FULL_DUPLEX 0 /* force full duplex */
20#define AX88796_BUS_INFO "CS1#+0x200" /* bus info for ethtool */
21
22#endif /* _ASM_AX88796_H */
diff --git a/include/asm-frv/bitops.h b/include/asm-frv/bitops.h
new file mode 100644
index 000000000000..b664bd5b6663
--- /dev/null
+++ b/include/asm-frv/bitops.h
@@ -0,0 +1,341 @@
1/* bitops.h: bit operations for the Fujitsu FR-V CPUs
2 *
3 * For an explanation of how atomic ops work in this arch, see:
4 * Documentation/fujitsu/frv/atomic-ops.txt
5 *
6 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
7 * Written by David Howells (dhowells@redhat.com)
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14#ifndef _ASM_BITOPS_H
15#define _ASM_BITOPS_H
16
17#include <linux/config.h>
18#include <linux/compiler.h>
19#include <asm/byteorder.h>
20#include <asm/system.h>
21#include <asm/atomic.h>
22
23#ifdef __KERNEL__
24
25/*
26 * ffz = Find First Zero in word. Undefined if no zero exists,
27 * so code should check against ~0UL first..
28 */
29static inline unsigned long ffz(unsigned long word)
30{
31 unsigned long result = 0;
32
33 while (word & 1) {
34 result++;
35 word >>= 1;
36 }
37 return result;
38}
39
40/*
41 * clear_bit() doesn't provide any barrier for the compiler.
42 */
43#define smp_mb__before_clear_bit() barrier()
44#define smp_mb__after_clear_bit() barrier()
45
46static inline int test_and_clear_bit(int nr, volatile void *addr)
47{
48 volatile unsigned long *ptr = addr;
49 unsigned long mask = 1UL << (nr & 31);
50 ptr += nr >> 5;
51 return (atomic_test_and_ANDNOT_mask(mask, ptr) & mask) != 0;
52}
53
54static inline int test_and_set_bit(int nr, volatile void *addr)
55{
56 volatile unsigned long *ptr = addr;
57 unsigned long mask = 1UL << (nr & 31);
58 ptr += nr >> 5;
59 return (atomic_test_and_OR_mask(mask, ptr) & mask) != 0;
60}
61
62static inline int test_and_change_bit(int nr, volatile void *addr)
63{
64 volatile unsigned long *ptr = addr;
65 unsigned long mask = 1UL << (nr & 31);
66 ptr += nr >> 5;
67 return (atomic_test_and_XOR_mask(mask, ptr) & mask) != 0;
68}
69
70static inline void clear_bit(int nr, volatile void *addr)
71{
72 test_and_clear_bit(nr, addr);
73}
74
75static inline void set_bit(int nr, volatile void *addr)
76{
77 test_and_set_bit(nr, addr);
78}
79
80static inline void change_bit(int nr, volatile void * addr)
81{
82 test_and_change_bit(nr, addr);
83}
84
85static inline void __clear_bit(int nr, volatile void * addr)
86{
87 volatile unsigned long *a = addr;
88 int mask;
89
90 a += nr >> 5;
91 mask = 1 << (nr & 31);
92 *a &= ~mask;
93}
94
95static inline void __set_bit(int nr, volatile void * addr)
96{
97 volatile unsigned long *a = addr;
98 int mask;
99
100 a += nr >> 5;
101 mask = 1 << (nr & 31);
102 *a |= mask;
103}
104
105static inline void __change_bit(int nr, volatile void *addr)
106{
107 volatile unsigned long *a = addr;
108 int mask;
109
110 a += nr >> 5;
111 mask = 1 << (nr & 31);
112 *a ^= mask;
113}
114
115static inline int __test_and_clear_bit(int nr, volatile void * addr)
116{
117 volatile unsigned long *a = addr;
118 int mask, retval;
119
120 a += nr >> 5;
121 mask = 1 << (nr & 31);
122 retval = (mask & *a) != 0;
123 *a &= ~mask;
124 return retval;
125}
126
127static inline int __test_and_set_bit(int nr, volatile void * addr)
128{
129 volatile unsigned long *a = addr;
130 int mask, retval;
131
132 a += nr >> 5;
133 mask = 1 << (nr & 31);
134 retval = (mask & *a) != 0;
135 *a |= mask;
136 return retval;
137}
138
139static inline int __test_and_change_bit(int nr, volatile void * addr)
140{
141 volatile unsigned long *a = addr;
142 int mask, retval;
143
144 a += nr >> 5;
145 mask = 1 << (nr & 31);
146 retval = (mask & *a) != 0;
147 *a ^= mask;
148 return retval;
149}
150
151/*
152 * This routine doesn't need to be atomic.
153 */
154static inline int __constant_test_bit(int nr, const volatile void * addr)
155{
156 return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
157}
158
159static inline int __test_bit(int nr, const volatile void * addr)
160{
161 int * a = (int *) addr;
162 int mask;
163
164 a += nr >> 5;
165 mask = 1 << (nr & 0x1f);
166 return ((mask & *a) != 0);
167}
168
169#define test_bit(nr,addr) \
170(__builtin_constant_p(nr) ? \
171 __constant_test_bit((nr),(addr)) : \
172 __test_bit((nr),(addr)))
173
174extern int find_next_bit(const unsigned long *addr, int size, int offset);
175
176#define find_first_bit(addr, size) find_next_bit(addr, size, 0)
177
178#define find_first_zero_bit(addr, size) \
179 find_next_zero_bit((addr), (size), 0)
180
181static inline int find_next_zero_bit(const void *addr, int size, int offset)
182{
183 const unsigned long *p = ((const unsigned long *) addr) + (offset >> 5);
184 unsigned long result = offset & ~31UL;
185 unsigned long tmp;
186
187 if (offset >= size)
188 return size;
189 size -= result;
190 offset &= 31UL;
191 if (offset) {
192 tmp = *(p++);
193 tmp |= ~0UL >> (32-offset);
194 if (size < 32)
195 goto found_first;
196 if (~tmp)
197 goto found_middle;
198 size -= 32;
199 result += 32;
200 }
201 while (size & ~31UL) {
202 if (~(tmp = *(p++)))
203 goto found_middle;
204 result += 32;
205 size -= 32;
206 }
207 if (!size)
208 return result;
209 tmp = *p;
210
211found_first:
212 tmp |= ~0UL >> size;
213found_middle:
214 return result + ffz(tmp);
215}
216
217#define ffs(x) generic_ffs(x)
218#define __ffs(x) (ffs(x) - 1)
219
220/*
221 * fls: find last bit set.
222 */
223#define fls(x) \
224({ \
225 int bit; \
226 \
227 asm("scan %1,gr0,%0" : "=r"(bit) : "r"(x)); \
228 \
229 bit ? 33 - bit : bit; \
230})
231
232/*
233 * Every architecture must define this function. It's the fastest
234 * way of searching a 140-bit bitmap where the first 100 bits are
235 * unlikely to be set. It's guaranteed that at least one of the 140
236 * bits is cleared.
237 */
238static inline int sched_find_first_bit(const unsigned long *b)
239{
240 if (unlikely(b[0]))
241 return __ffs(b[0]);
242 if (unlikely(b[1]))
243 return __ffs(b[1]) + 32;
244 if (unlikely(b[2]))
245 return __ffs(b[2]) + 64;
246 if (b[3])
247 return __ffs(b[3]) + 96;
248 return __ffs(b[4]) + 128;
249}
250
251
252/*
253 * hweightN: returns the hamming weight (i.e. the number
254 * of bits set) of a N-bit word
255 */
256
257#define hweight32(x) generic_hweight32(x)
258#define hweight16(x) generic_hweight16(x)
259#define hweight8(x) generic_hweight8(x)
260
261#define ext2_set_bit(nr, addr) test_and_set_bit ((nr) ^ 0x18, (addr))
262#define ext2_clear_bit(nr, addr) test_and_clear_bit((nr) ^ 0x18, (addr))
263
264#define ext2_set_bit_atomic(lock,nr,addr) ext2_set_bit((nr), addr)
265#define ext2_clear_bit_atomic(lock,nr,addr) ext2_clear_bit((nr), addr)
266
267static inline int ext2_test_bit(int nr, const volatile void * addr)
268{
269 const volatile unsigned char *ADDR = (const unsigned char *) addr;
270 int mask;
271
272 ADDR += nr >> 3;
273 mask = 1 << (nr & 0x07);
274 return ((mask & *ADDR) != 0);
275}
276
277#define ext2_find_first_zero_bit(addr, size) \
278 ext2_find_next_zero_bit((addr), (size), 0)
279
280static inline unsigned long ext2_find_next_zero_bit(const void *addr,
281 unsigned long size,
282 unsigned long offset)
283{
284 const unsigned long *p = ((const unsigned long *) addr) + (offset >> 5);
285 unsigned long result = offset & ~31UL;
286 unsigned long tmp;
287
288 if (offset >= size)
289 return size;
290 size -= result;
291 offset &= 31UL;
292 if(offset) {
293 /* We hold the little endian value in tmp, but then the
294 * shift is illegal. So we could keep a big endian value
295 * in tmp, like this:
296 *
297 * tmp = __swab32(*(p++));
298 * tmp |= ~0UL >> (32-offset);
299 *
300 * but this would decrease preformance, so we change the
301 * shift:
302 */
303 tmp = *(p++);
304 tmp |= __swab32(~0UL >> (32-offset));
305 if(size < 32)
306 goto found_first;
307 if(~tmp)
308 goto found_middle;
309 size -= 32;
310 result += 32;
311 }
312 while(size & ~31UL) {
313 if(~(tmp = *(p++)))
314 goto found_middle;
315 result += 32;
316 size -= 32;
317 }
318 if(!size)
319 return result;
320 tmp = *p;
321
322found_first:
323 /* tmp is little endian, so we would have to swab the shift,
324 * see above. But then we have to swab tmp below for ffz, so
325 * we might as well do this here.
326 */
327 return result + ffz(__swab32(tmp) | (~0UL << size));
328found_middle:
329 return result + ffz(__swab32(tmp));
330}
331
332/* Bitmap functions for the minix filesystem. */
333#define minix_test_and_set_bit(nr,addr) ext2_set_bit(nr,addr)
334#define minix_set_bit(nr,addr) ext2_set_bit(nr,addr)
335#define minix_test_and_clear_bit(nr,addr) ext2_clear_bit(nr,addr)
336#define minix_test_bit(nr,addr) ext2_test_bit(nr,addr)
337#define minix_find_first_zero_bit(addr,size) ext2_find_first_zero_bit(addr,size)
338
339#endif /* __KERNEL__ */
340
341#endif /* _ASM_BITOPS_H */
diff --git a/include/asm-frv/bug.h b/include/asm-frv/bug.h
new file mode 100644
index 000000000000..011860b28818
--- /dev/null
+++ b/include/asm-frv/bug.h
@@ -0,0 +1,51 @@
1/* bug.h: FRV bug trapping
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#ifndef _ASM_BUG_H
12#define _ASM_BUG_H
13
14#include <linux/config.h>
15
16/*
17 * Tell the user there is some problem.
18 */
19extern asmlinkage void __debug_bug_trap(int signr);
20
21#ifdef CONFIG_NO_KERNEL_MSG
22#define _debug_bug_printk()
23#else
24extern void __debug_bug_printk(const char *file, unsigned line);
25#define _debug_bug_printk() __debug_bug_printk(__FILE__, __LINE__)
26#endif
27
28#define _debug_bug_trap(signr) \
29do { \
30 __debug_bug_trap(signr); \
31 asm volatile("nop"); \
32} while(0)
33
34#define HAVE_ARCH_BUG
35#define BUG() \
36do { \
37 _debug_bug_printk(); \
38 _debug_bug_trap(6 /*SIGABRT*/); \
39} while (0)
40
41#ifdef CONFIG_GDBSTUB
42#define HAVE_ARCH_KGDB_RAISE
43#define kgdb_raise(signr) do { _debug_bug_trap(signr); } while(0)
44
45#define HAVE_ARCH_KGDB_BAD_PAGE
46#define kgdb_bad_page(page) do { kgdb_raise(SIGABRT); } while(0)
47#endif
48
49#include <asm-generic/bug.h>
50
51#endif
diff --git a/include/asm-frv/bugs.h b/include/asm-frv/bugs.h
new file mode 100644
index 000000000000..f2382be2b46c
--- /dev/null
+++ b/include/asm-frv/bugs.h
@@ -0,0 +1,14 @@
1/* bugs.h: arch bug checking entry
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12static inline void check_bugs(void)
13{
14}
diff --git a/include/asm-frv/busctl-regs.h b/include/asm-frv/busctl-regs.h
new file mode 100644
index 000000000000..bb0ff4816e27
--- /dev/null
+++ b/include/asm-frv/busctl-regs.h
@@ -0,0 +1,41 @@
1/* busctl-regs.h: FR400-series CPU bus controller registers
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_BUSCTL_REGS_H
13#define _ASM_BUSCTL_REGS_H
14
15/* bus controller registers */
16#define __get_LGCR() ({ *(volatile unsigned long *)(0xfe000010); })
17#define __get_LMAICR() ({ *(volatile unsigned long *)(0xfe000030); })
18#define __get_LEMBR() ({ *(volatile unsigned long *)(0xfe000040); })
19#define __get_LEMAM() ({ *(volatile unsigned long *)(0xfe000048); })
20#define __get_LCR(R) ({ *(volatile unsigned long *)(0xfe000100 + 8*(R)); })
21#define __get_LSBR(R) ({ *(volatile unsigned long *)(0xfe000c00 + 8*(R)); })
22#define __get_LSAM(R) ({ *(volatile unsigned long *)(0xfe000d00 + 8*(R)); })
23
24#define __set_LGCR(V) do { *(volatile unsigned long *)(0xfe000010) = (V); } while(0)
25#define __set_LMAICR(V) do { *(volatile unsigned long *)(0xfe000030) = (V); } while(0)
26#define __set_LEMBR(V) do { *(volatile unsigned long *)(0xfe000040) = (V); } while(0)
27#define __set_LEMAM(V) do { *(volatile unsigned long *)(0xfe000048) = (V); } while(0)
28#define __set_LCR(R,V) do { *(volatile unsigned long *)(0xfe000100 + 8*(R)) = (V); } while(0)
29#define __set_LSBR(R,V) do { *(volatile unsigned long *)(0xfe000c00 + 8*(R)) = (V); } while(0)
30#define __set_LSAM(R,V) do { *(volatile unsigned long *)(0xfe000d00 + 8*(R)) = (V); } while(0)
31
32/* FR401 SDRAM controller registers */
33#define __get_DBR(R) ({ *(volatile unsigned long *)(0xfe000e00 + 8*(R)); })
34#define __get_DAM(R) ({ *(volatile unsigned long *)(0xfe000f00 + 8*(R)); })
35
36/* FR551 SDRAM controller registers */
37#define __get_DARS(R) ({ *(volatile unsigned long *)(0xfeff0100 + 8*(R)); })
38#define __get_DAMK(R) ({ *(volatile unsigned long *)(0xfeff0110 + 8*(R)); })
39
40
41#endif /* _ASM_BUSCTL_REGS_H */
diff --git a/include/asm-frv/byteorder.h b/include/asm-frv/byteorder.h
new file mode 100644
index 000000000000..411bec3cc1fc
--- /dev/null
+++ b/include/asm-frv/byteorder.h
@@ -0,0 +1,13 @@
1#ifndef _ASM_BYTEORDER_H
2#define _ASM_BYTEORDER_H
3
4#include <asm/types.h>
5
6#if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__)
7# define __BYTEORDER_HAS_U64__
8# define __SWAB_64_THRU_32__
9#endif
10
11#include <linux/byteorder/big_endian.h>
12
13#endif /* _ASM_BYTEORDER_H */
diff --git a/include/asm-frv/cache.h b/include/asm-frv/cache.h
new file mode 100644
index 000000000000..cf69b6373b34
--- /dev/null
+++ b/include/asm-frv/cache.h
@@ -0,0 +1,24 @@
1/* cache.h: FRV cache definitions
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef __ASM_CACHE_H
13#define __ASM_CACHE_H
14
15#include <linux/config.h>
16
17/* bytes per L1 cache line */
18#define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
19#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
20
21#define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
22#define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
23
24#endif
diff --git a/include/asm-frv/cacheflush.h b/include/asm-frv/cacheflush.h
new file mode 100644
index 000000000000..3007deccb490
--- /dev/null
+++ b/include/asm-frv/cacheflush.h
@@ -0,0 +1,91 @@
1/* cacheflush.h: FRV cache flushing routines
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_CACHEFLUSH_H
13#define _ASM_CACHEFLUSH_H
14
15/* Keep includes the same across arches. */
16#include <linux/mm.h>
17
18/*
19 * virtually-indexed cache management (our cache is physically indexed)
20 */
21#define flush_cache_all() do {} while(0)
22#define flush_cache_mm(mm) do {} while(0)
23#define flush_cache_range(mm, start, end) do {} while(0)
24#define flush_cache_page(vma, vmaddr, pfn) do {} while(0)
25#define flush_cache_vmap(start, end) do {} while(0)
26#define flush_cache_vunmap(start, end) do {} while(0)
27#define flush_dcache_mmap_lock(mapping) do {} while(0)
28#define flush_dcache_mmap_unlock(mapping) do {} while(0)
29
30/*
31 * physically-indexed cache managment
32 * - see arch/frv/lib/cache.S
33 */
34extern void frv_dcache_writeback(unsigned long start, unsigned long size);
35extern void frv_cache_invalidate(unsigned long start, unsigned long size);
36extern void frv_icache_invalidate(unsigned long start, unsigned long size);
37extern void frv_cache_wback_inv(unsigned long start, unsigned long size);
38
39static inline void __flush_cache_all(void)
40{
41 asm volatile(" dcef @(gr0,gr0),#1 \n"
42 " icei @(gr0,gr0),#1 \n"
43 " membar \n"
44 : : : "memory"
45 );
46}
47
48/* dcache/icache coherency... */
49#ifdef CONFIG_MMU
50extern void flush_dcache_page(struct page *page);
51#else
52static inline void flush_dcache_page(struct page *page)
53{
54 unsigned long addr = page_to_phys(page);
55 frv_dcache_writeback(addr, addr + PAGE_SIZE);
56}
57#endif
58
59static inline void flush_page_to_ram(struct page *page)
60{
61 flush_dcache_page(page);
62}
63
64static inline void flush_icache(void)
65{
66 __flush_cache_all();
67}
68
69static inline void flush_icache_range(unsigned long start, unsigned long end)
70{
71 frv_cache_wback_inv(start, end);
72}
73
74#ifdef CONFIG_MMU
75extern void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
76 unsigned long start, unsigned long len);
77#else
78static inline void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
79 unsigned long start, unsigned long len)
80{
81 frv_cache_wback_inv(start, start + len);
82}
83#endif
84
85static inline void flush_icache_page(struct vm_area_struct *vma, struct page *page)
86{
87 flush_icache_user_range(vma, page, page_to_phys(page), PAGE_SIZE);
88}
89
90
91#endif /* _ASM_CACHEFLUSH_H */
diff --git a/include/asm-frv/checksum.h b/include/asm-frv/checksum.h
new file mode 100644
index 000000000000..10236f6802db
--- /dev/null
+++ b/include/asm-frv/checksum.h
@@ -0,0 +1,183 @@
1/* checksum.h: FRV checksumming
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_CHECKSUM_H
13#define _ASM_CHECKSUM_H
14
15#include <linux/in6.h>
16
17/*
18 * computes the checksum of a memory block at buff, length len,
19 * and adds in "sum" (32-bit)
20 *
21 * returns a 32-bit number suitable for feeding into itself
22 * or csum_tcpudp_magic
23 *
24 * this function must be called with even lengths, except
25 * for the last fragment, which may be odd
26 *
27 * it's best to have buff aligned on a 32-bit boundary
28 */
29unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum);
30
31/*
32 * the same as csum_partial, but copies from src while it
33 * checksums
34 *
35 * here even more important to align src and dst on a 32-bit (or even
36 * better 64-bit) boundary
37 */
38unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum);
39
40/*
41 * the same as csum_partial_copy, but copies from user space.
42 *
43 * here even more important to align src and dst on a 32-bit (or even
44 * better 64-bit) boundary
45 */
46extern unsigned int csum_partial_copy_from_user(const char *src, char *dst,
47 int len, int sum, int *csum_err);
48
49#define csum_partial_copy_nocheck(src, dst, len, sum) \
50 csum_partial_copy((src), (dst), (len), (sum))
51
52/*
53 * This is a version of ip_compute_csum() optimized for IP headers,
54 * which always checksum on 4 octet boundaries.
55 *
56 */
57static inline
58unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl)
59{
60 unsigned int tmp, inc, sum = 0;
61
62 asm(" addcc gr0,gr0,gr0,icc0\n" /* clear icc0.C */
63 " subi %1,#4,%1 \n"
64 "0: \n"
65 " ldu.p @(%1,%3),%4 \n"
66 " subicc %2,#1,%2,icc1 \n"
67 " addxcc.p %4,%0,%0,icc0 \n"
68 " bhi icc1,#2,0b \n"
69
70 /* fold the 33-bit result into 16-bits */
71 " addxcc gr0,%0,%0,icc0 \n"
72 " srli %0,#16,%1 \n"
73 " sethi #0,%0 \n"
74 " add %1,%0,%0 \n"
75 " srli %0,#16,%1 \n"
76 " add %1,%0,%0 \n"
77
78 : "=r" (sum), "=r" (iph), "=r" (ihl), "=r" (inc), "=&r"(tmp)
79 : "0" (sum), "1" (iph), "2" (ihl), "3" (4),
80 "m"(*(volatile struct { int _[100]; } *)iph)
81 : "icc0", "icc1"
82 );
83
84 return ~sum;
85}
86
87/*
88 * Fold a partial checksum
89 */
90static inline unsigned int csum_fold(unsigned int sum)
91{
92 unsigned int tmp;
93
94 asm(" srli %0,#16,%1 \n"
95 " sethi #0,%0 \n"
96 " add %1,%0,%0 \n"
97 " srli %0,#16,%1 \n"
98 " add %1,%0,%0 \n"
99 : "=r"(sum), "=&r"(tmp)
100 : "0"(sum)
101 );
102
103 return ~sum;
104}
105
106/*
107 * computes the checksum of the TCP/UDP pseudo-header
108 * returns a 16-bit checksum, already complemented
109 */
110static inline unsigned int
111csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len,
112 unsigned short proto, unsigned int sum)
113{
114 asm(" addcc %1,%0,%0,icc0 \n"
115 " addxcc %2,%0,%0,icc0 \n"
116 " addxcc %3,%0,%0,icc0 \n"
117 " addxcc gr0,%0,%0,icc0 \n"
118 : "=r" (sum)
119 : "r" (daddr), "r" (saddr), "r" (len + proto), "0"(sum)
120 : "icc0"
121 );
122 return sum;
123}
124
125static inline unsigned short int
126csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len,
127 unsigned short proto, unsigned int sum)
128{
129 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
130}
131
132/*
133 * this routine is used for miscellaneous IP-like checksums, mainly
134 * in icmp.c
135 */
136extern unsigned short ip_compute_csum(const unsigned char * buff, int len);
137
138#define _HAVE_ARCH_IPV6_CSUM
139static inline unsigned short int
140csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr,
141 __u32 len, unsigned short proto, unsigned int sum)
142{
143 unsigned long tmp, tmp2;
144
145 asm(" addcc %2,%0,%0,icc0 \n"
146
147 /* add up the source addr */
148 " ldi @(%3,0),%1 \n"
149 " addxcc %1,%0,%0,icc0 \n"
150 " ldi @(%3,4),%2 \n"
151 " addxcc %2,%0,%0,icc0 \n"
152 " ldi @(%3,8),%1 \n"
153 " addxcc %1,%0,%0,icc0 \n"
154 " ldi @(%3,12),%2 \n"
155 " addxcc %2,%0,%0,icc0 \n"
156
157 /* add up the dest addr */
158 " ldi @(%4,0),%1 \n"
159 " addxcc %1,%0,%0,icc0 \n"
160 " ldi @(%4,4),%2 \n"
161 " addxcc %2,%0,%0,icc0 \n"
162 " ldi @(%4,8),%1 \n"
163 " addxcc %1,%0,%0,icc0 \n"
164 " ldi @(%4,12),%2 \n"
165 " addxcc %2,%0,%0,icc0 \n"
166
167 /* fold the 33-bit result into 16-bits */
168 " addxcc gr0,%0,%0,icc0 \n"
169 " srli %0,#16,%1 \n"
170 " sethi #0,%0 \n"
171 " add %1,%0,%0 \n"
172 " srli %0,#16,%1 \n"
173 " add %1,%0,%0 \n"
174
175 : "=r" (sum), "=&r" (tmp), "=r" (tmp2)
176 : "r" (saddr), "r" (daddr), "0" (sum), "2" (len + proto)
177 : "icc0"
178 );
179
180 return ~sum;
181}
182
183#endif /* _ASM_CHECKSUM_H */
diff --git a/include/asm-frv/cpu-irqs.h b/include/asm-frv/cpu-irqs.h
new file mode 100644
index 000000000000..5cd691e1f8c4
--- /dev/null
+++ b/include/asm-frv/cpu-irqs.h
@@ -0,0 +1,87 @@
1/* cpu-irqs.h: on-CPU peripheral irqs
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_CPU_IRQS_H
13#define _ASM_CPU_IRQS_H
14
15#ifndef __ASSEMBLY__
16
17#include <asm/irq-routing.h>
18
19#define IRQ_BASE_CPU (NR_IRQ_ACTIONS_PER_GROUP * 0)
20
21/* IRQ IDs presented to drivers */
22enum {
23 IRQ_CPU__UNUSED = IRQ_BASE_CPU,
24 IRQ_CPU_UART0,
25 IRQ_CPU_UART1,
26 IRQ_CPU_TIMER0,
27 IRQ_CPU_TIMER1,
28 IRQ_CPU_TIMER2,
29 IRQ_CPU_DMA0,
30 IRQ_CPU_DMA1,
31 IRQ_CPU_DMA2,
32 IRQ_CPU_DMA3,
33 IRQ_CPU_DMA4,
34 IRQ_CPU_DMA5,
35 IRQ_CPU_DMA6,
36 IRQ_CPU_DMA7,
37 IRQ_CPU_EXTERNAL0,
38 IRQ_CPU_EXTERNAL1,
39 IRQ_CPU_EXTERNAL2,
40 IRQ_CPU_EXTERNAL3,
41 IRQ_CPU_EXTERNAL4,
42 IRQ_CPU_EXTERNAL5,
43 IRQ_CPU_EXTERNAL6,
44 IRQ_CPU_EXTERNAL7,
45};
46
47/* IRQ to level mappings */
48#define IRQ_GDBSTUB_LEVEL 15
49#define IRQ_UART_LEVEL 13
50
51#ifdef CONFIG_GDBSTUB_UART0
52#define IRQ_UART0_LEVEL IRQ_GDBSTUB_LEVEL
53#else
54#define IRQ_UART0_LEVEL IRQ_UART_LEVEL
55#endif
56
57#ifdef CONFIG_GDBSTUB_UART1
58#define IRQ_UART1_LEVEL IRQ_GDBSTUB_LEVEL
59#else
60#define IRQ_UART1_LEVEL IRQ_UART_LEVEL
61#endif
62
63#define IRQ_DMA0_LEVEL 14
64#define IRQ_DMA1_LEVEL 14
65#define IRQ_DMA2_LEVEL 14
66#define IRQ_DMA3_LEVEL 14
67#define IRQ_DMA4_LEVEL 14
68#define IRQ_DMA5_LEVEL 14
69#define IRQ_DMA6_LEVEL 14
70#define IRQ_DMA7_LEVEL 14
71
72#define IRQ_TIMER0_LEVEL 12
73#define IRQ_TIMER1_LEVEL 11
74#define IRQ_TIMER2_LEVEL 10
75
76#define IRQ_XIRQ0_LEVEL 1
77#define IRQ_XIRQ1_LEVEL 2
78#define IRQ_XIRQ2_LEVEL 3
79#define IRQ_XIRQ3_LEVEL 4
80#define IRQ_XIRQ4_LEVEL 5
81#define IRQ_XIRQ5_LEVEL 6
82#define IRQ_XIRQ6_LEVEL 7
83#define IRQ_XIRQ7_LEVEL 8
84
85#endif /* !__ASSEMBLY__ */
86
87#endif /* _ASM_CPU_IRQS_H */
diff --git a/include/asm-frv/cpumask.h b/include/asm-frv/cpumask.h
new file mode 100644
index 000000000000..d999c20c84d2
--- /dev/null
+++ b/include/asm-frv/cpumask.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_CPUMASK_H
2#define _ASM_CPUMASK_H
3
4#include <asm-generic/cpumask.h>
5
6#endif /* _ASM_CPUMASK_H */
diff --git a/include/asm-frv/cputime.h b/include/asm-frv/cputime.h
new file mode 100644
index 000000000000..f6c373ad2b80
--- /dev/null
+++ b/include/asm-frv/cputime.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_CPUTIME_H
2#define _ASM_CPUTIME_H
3
4#include <asm-generic/cputime.h>
5
6#endif /* _ASM_CPUTIME_H */
diff --git a/include/asm-frv/current.h b/include/asm-frv/current.h
new file mode 100644
index 000000000000..86b027491b08
--- /dev/null
+++ b/include/asm-frv/current.h
@@ -0,0 +1,30 @@
1/* current.h: FRV current task pointer
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_CURRENT_H
13#define _ASM_CURRENT_H
14
15#ifndef __ASSEMBLY__
16
17/*
18 * dedicate GR29 to keeping the current task pointer
19 */
20register struct task_struct *current asm("gr29");
21
22#define get_current() current
23
24#else
25
26#define CURRENT gr29
27
28#endif
29
30#endif /* _ASM_CURRENT_H */
diff --git a/include/asm-frv/delay.h b/include/asm-frv/delay.h
new file mode 100644
index 000000000000..597b4ebf03b4
--- /dev/null
+++ b/include/asm-frv/delay.h
@@ -0,0 +1,50 @@
1/* delay.h: FRV delay code
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_DELAY_H
13#define _ASM_DELAY_H
14
15#include <asm/param.h>
16#include <asm/timer-regs.h>
17
18/*
19 * delay loop - runs at __core_clock_speed_HZ / 2 [there are 2 insns in the loop]
20 */
21extern unsigned long __delay_loops_MHz;
22
23static inline void __delay(unsigned long loops)
24{
25 asm volatile("1: subicc %0,#1,%0,icc0 \n"
26 " bnc icc0,#2,1b \n"
27 : "=r" (loops)
28 : "0" (loops)
29 : "icc0"
30 );
31}
32
33/*
34 * Use only for very small delays ( < 1 msec). Should probably use a
35 * lookup table, really, as the multiplications take much too long with
36 * short delays. This is a "reasonable" implementation, though (and the
37 * first constant multiplications gets optimized away if the delay is
38 * a constant)
39 */
40
41extern unsigned long loops_per_jiffy;
42
43static inline void udelay(unsigned long usecs)
44{
45 __delay(usecs * __delay_loops_MHz);
46}
47
48#define ndelay(n) udelay((n) * 5)
49
50#endif /* _ASM_DELAY_H */
diff --git a/include/asm-frv/div64.h b/include/asm-frv/div64.h
new file mode 100644
index 000000000000..6cd978cefb28
--- /dev/null
+++ b/include/asm-frv/div64.h
@@ -0,0 +1 @@
#include <asm-generic/div64.h>
diff --git a/include/asm-frv/dm9000.h b/include/asm-frv/dm9000.h
new file mode 100644
index 000000000000..f6f48fd9ec6e
--- /dev/null
+++ b/include/asm-frv/dm9000.h
@@ -0,0 +1,37 @@
1/* dm9000.h: Davicom DM9000 adapter configuration
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_DM9000_H
13#define _ASM_DM9000_H
14
15#include <asm/mb-regs.h>
16
17#define DM9000_ARCH_IOBASE (__region_CS6 + 0x300)
18#define DM9000_ARCH_IRQ IRQ_CPU_EXTERNAL3 /* XIRQ #3 (shared with FPGA) */
19#undef DM9000_ARCH_IRQ_ACTLOW /* IRQ pin active high */
20#define DM9000_ARCH_BUS_INFO "CS6#+0x300" /* bus info for ethtool */
21
22#undef __is_PCI_IO
23#define __is_PCI_IO(addr) 0 /* not PCI */
24
25#undef inl
26#define inl(addr) \
27({ \
28 unsigned long __ioaddr = (unsigned long) addr; \
29 uint32_t x = readl(__ioaddr); \
30 ((x & 0xff) << 24) | ((x & 0xff00) << 8) | ((x >> 8) & 0xff00) | ((x >> 24) & 0xff); \
31})
32
33#undef insl
34#define insl(a,b,l) __insl(a,b,l,0) /* don't byte-swap */
35
36
37#endif /* _ASM_DM9000_H */
diff --git a/include/asm-frv/dma-mapping.h b/include/asm-frv/dma-mapping.h
new file mode 100644
index 000000000000..0206ab35eae0
--- /dev/null
+++ b/include/asm-frv/dma-mapping.h
@@ -0,0 +1,184 @@
1#ifndef _ASM_DMA_MAPPING_H
2#define _ASM_DMA_MAPPING_H
3
4#include <linux/device.h>
5#include <asm/cache.h>
6#include <asm/cacheflush.h>
7#include <asm/scatterlist.h>
8#include <asm/io.h>
9
10#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
11#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
12
13extern unsigned long __nongprelbss dma_coherent_mem_start;
14extern unsigned long __nongprelbss dma_coherent_mem_end;
15
16void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, int gfp);
17void dma_free_coherent(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle);
18
19/*
20 * These macros should be used after a pci_map_sg call has been done
21 * to get bus addresses of each of the SG entries and their lengths.
22 * You should only work with the number of sg entries pci_map_sg
23 * returns, or alternatively stop on the first sg_dma_len(sg) which
24 * is 0.
25 */
26#define sg_dma_address(sg) ((unsigned long) (page_to_phys((sg)->page) + (sg)->offset))
27#define sg_dma_len(sg) ((sg)->length)
28
29/*
30 * Map a single buffer of the indicated size for DMA in streaming mode.
31 * The 32-bit bus address to use is returned.
32 *
33 * Once the device is given the dma address, the device owns this memory
34 * until either pci_unmap_single or pci_dma_sync_single is performed.
35 */
36extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
37 enum dma_data_direction direction);
38
39/*
40 * Unmap a single streaming mode DMA translation. The dma_addr and size
41 * must match what was provided for in a previous pci_map_single call. All
42 * other usages are undefined.
43 *
44 * After this call, reads by the cpu to the buffer are guarenteed to see
45 * whatever the device wrote there.
46 */
47static inline
48void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
49 enum dma_data_direction direction)
50{
51 BUG_ON(direction == DMA_NONE);
52}
53
54/*
55 * Map a set of buffers described by scatterlist in streaming
56 * mode for DMA. This is the scather-gather version of the
57 * above pci_map_single interface. Here the scatter gather list
58 * elements are each tagged with the appropriate dma address
59 * and length. They are obtained via sg_dma_{address,length}(SG).
60 *
61 * NOTE: An implementation may be able to use a smaller number of
62 * DMA address/length pairs than there are SG table elements.
63 * (for example via virtual mapping capabilities)
64 * The routine returns the number of addr/length pairs actually
65 * used, at most nents.
66 *
67 * Device ownership issues as mentioned above for pci_map_single are
68 * the same here.
69 */
70extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
71 enum dma_data_direction direction);
72
73/*
74 * Unmap a set of streaming mode DMA translations.
75 * Again, cpu read rules concerning calls here are the same as for
76 * pci_unmap_single() above.
77 */
78static inline
79void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
80 enum dma_data_direction direction)
81{
82 BUG_ON(direction == DMA_NONE);
83}
84
85extern
86dma_addr_t dma_map_page(struct device *dev, struct page *page, unsigned long offset,
87 size_t size, enum dma_data_direction direction);
88
89static inline
90void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
91 enum dma_data_direction direction)
92{
93 BUG_ON(direction == DMA_NONE);
94}
95
96
97static inline
98void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
99 enum dma_data_direction direction)
100{
101}
102
103static inline
104void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
105 enum dma_data_direction direction)
106{
107 flush_write_buffers();
108}
109
110static inline
111void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
112 unsigned long offset, size_t size,
113 enum dma_data_direction direction)
114{
115}
116
117static inline
118void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
119 unsigned long offset, size_t size,
120 enum dma_data_direction direction)
121{
122 flush_write_buffers();
123}
124
125static inline
126void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
127 enum dma_data_direction direction)
128{
129}
130
131static inline
132void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
133 enum dma_data_direction direction)
134{
135 flush_write_buffers();
136}
137
138static inline
139int dma_mapping_error(dma_addr_t dma_addr)
140{
141 return 0;
142}
143
144static inline
145int dma_supported(struct device *dev, u64 mask)
146{
147 /*
148 * we fall back to GFP_DMA when the mask isn't all 1s,
149 * so we can't guarantee allocations that must be
150 * within a tighter range than GFP_DMA..
151 */
152 if (mask < 0x00ffffff)
153 return 0;
154
155 return 1;
156}
157
158static inline
159int dma_set_mask(struct device *dev, u64 mask)
160{
161 if (!dev->dma_mask || !dma_supported(dev, mask))
162 return -EIO;
163
164 *dev->dma_mask = mask;
165
166 return 0;
167}
168
169static inline
170int dma_get_cache_alignment(void)
171{
172 return 1 << L1_CACHE_SHIFT;
173}
174
175#define dma_is_consistent(d) (1)
176
177static inline
178void dma_cache_sync(void *vaddr, size_t size,
179 enum dma_data_direction direction)
180{
181 flush_write_buffers();
182}
183
184#endif /* _ASM_DMA_MAPPING_H */
diff --git a/include/asm-frv/dma.h b/include/asm-frv/dma.h
new file mode 100644
index 000000000000..d8f9a2f21521
--- /dev/null
+++ b/include/asm-frv/dma.h
@@ -0,0 +1,129 @@
1/* dma.h: FRV DMA controller management
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_DMA_H
13#define _ASM_DMA_H
14
15//#define DMA_DEBUG 1
16
17#include <linux/config.h>
18#include <linux/interrupt.h>
19
20#undef MAX_DMA_CHANNELS /* don't use kernel/dma.c */
21
22/* under 2.4 this is actually needed by the new bootmem allocator */
23#define MAX_DMA_ADDRESS PAGE_OFFSET
24
25/*
26 * FRV DMA controller management
27 */
28struct pt_regs;
29
30typedef irqreturn_t (*dma_irq_handler_t)(int dmachan, unsigned long cstr, void *data,
31 struct pt_regs *regs);
32
33extern void frv_dma_init(void);
34
35extern int frv_dma_open(const char *devname,
36 unsigned long dmamask,
37 int dmacap,
38 dma_irq_handler_t handler,
39 unsigned long irq_flags,
40 void *data);
41
42/* channels required */
43#define FRV_DMA_MASK_ANY ULONG_MAX /* any channel */
44
45/* capabilities required */
46#define FRV_DMA_CAP_DREQ 0x01 /* DMA request pin */
47#define FRV_DMA_CAP_DACK 0x02 /* DMA ACK pin */
48#define FRV_DMA_CAP_DONE 0x04 /* DMA done pin */
49
50extern void frv_dma_close(int dma);
51
52extern void frv_dma_config(int dma, unsigned long ccfr, unsigned long cctr, unsigned long apr);
53
54extern void frv_dma_start(int dma,
55 unsigned long sba, unsigned long dba,
56 unsigned long pix, unsigned long six, unsigned long bcl);
57
58extern void frv_dma_restart_circular(int dma, unsigned long six);
59
60extern void frv_dma_stop(int dma);
61
62extern int is_frv_dma_interrupting(int dma);
63
64extern void frv_dma_dump(int dma);
65
66extern void frv_dma_status_clear(int dma);
67
68#define FRV_DMA_NCHANS 8
69#define FRV_DMA_4CHANS 4
70#define FRV_DMA_8CHANS 8
71
72#define DMAC_CCFRx 0x00 /* channel configuration reg */
73#define DMAC_CCFRx_CM_SHIFT 16
74#define DMAC_CCFRx_CM_DA 0x00000000
75#define DMAC_CCFRx_CM_SCA 0x00010000
76#define DMAC_CCFRx_CM_DCA 0x00020000
77#define DMAC_CCFRx_CM_2D 0x00030000
78#define DMAC_CCFRx_ATS_SHIFT 8
79#define DMAC_CCFRx_RS_INTERN 0x00000000
80#define DMAC_CCFRx_RS_EXTERN 0x00000001
81#define DMAC_CCFRx_RS_SHIFT 0
82
83#define DMAC_CSTRx 0x08 /* channel status reg */
84#define DMAC_CSTRx_FS 0x0000003f
85#define DMAC_CSTRx_NE 0x00000100
86#define DMAC_CSTRx_FED 0x00000200
87#define DMAC_CSTRx_WER 0x00000800
88#define DMAC_CSTRx_RER 0x00001000
89#define DMAC_CSTRx_CE 0x00002000
90#define DMAC_CSTRx_INT 0x00800000
91#define DMAC_CSTRx_BUSY 0x80000000
92
93#define DMAC_CCTRx 0x10 /* channel control reg */
94#define DMAC_CCTRx_DSIZ_1 0x00000000
95#define DMAC_CCTRx_DSIZ_2 0x00000001
96#define DMAC_CCTRx_DSIZ_4 0x00000002
97#define DMAC_CCTRx_DSIZ_32 0x00000005
98#define DMAC_CCTRx_DAU_HOLD 0x00000000
99#define DMAC_CCTRx_DAU_INC 0x00000010
100#define DMAC_CCTRx_DAU_DEC 0x00000020
101#define DMAC_CCTRx_SSIZ_1 0x00000000
102#define DMAC_CCTRx_SSIZ_2 0x00000100
103#define DMAC_CCTRx_SSIZ_4 0x00000200
104#define DMAC_CCTRx_SSIZ_32 0x00000500
105#define DMAC_CCTRx_SAU_HOLD 0x00000000
106#define DMAC_CCTRx_SAU_INC 0x00001000
107#define DMAC_CCTRx_SAU_DEC 0x00002000
108#define DMAC_CCTRx_FC 0x08000000
109#define DMAC_CCTRx_ICE 0x10000000
110#define DMAC_CCTRx_IE 0x40000000
111#define DMAC_CCTRx_ACT 0x80000000
112
113#define DMAC_SBAx 0x18 /* source base address reg */
114#define DMAC_DBAx 0x20 /* data base address reg */
115#define DMAC_PIXx 0x28 /* primary index reg */
116#define DMAC_SIXx 0x30 /* secondary index reg */
117#define DMAC_BCLx 0x38 /* byte count limit reg */
118#define DMAC_APRx 0x40 /* alternate pointer reg */
119
120/*
121 * required for PCI + MODULES
122 */
123#ifdef CONFIG_PCI
124extern int isa_dma_bridge_buggy;
125#else
126#define isa_dma_bridge_buggy (0)
127#endif
128
129#endif /* _ASM_DMA_H */
diff --git a/include/asm-frv/elf.h b/include/asm-frv/elf.h
new file mode 100644
index 000000000000..7d2098f0476b
--- /dev/null
+++ b/include/asm-frv/elf.h
@@ -0,0 +1,147 @@
1/* elf.h: FR-V ELF definitions
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 * - Derived from include/asm-m68knommu/elf.h
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12#ifndef __ASM_ELF_H
13#define __ASM_ELF_H
14
15#include <linux/config.h>
16#include <asm/ptrace.h>
17#include <asm/user.h>
18
19struct elf32_hdr;
20
21/*
22 * ELF header e_flags defines.
23 */
24#define EF_FRV_GPR_MASK 0x00000003 /* mask for # of gprs */
25#define EF_FRV_GPR32 0x00000001 /* Only uses GR on 32-register */
26#define EF_FRV_GPR64 0x00000002 /* Only uses GR on 64-register */
27#define EF_FRV_FPR_MASK 0x0000000c /* mask for # of fprs */
28#define EF_FRV_FPR32 0x00000004 /* Only uses FR on 32-register */
29#define EF_FRV_FPR64 0x00000008 /* Only uses FR on 64-register */
30#define EF_FRV_FPR_NONE 0x0000000C /* Uses software floating-point */
31#define EF_FRV_DWORD_MASK 0x00000030 /* mask for dword support */
32#define EF_FRV_DWORD_YES 0x00000010 /* Assumes stack aligned to 8-byte boundaries. */
33#define EF_FRV_DWORD_NO 0x00000020 /* Assumes stack aligned to 4-byte boundaries. */
34#define EF_FRV_DOUBLE 0x00000040 /* Uses double instructions. */
35#define EF_FRV_MEDIA 0x00000080 /* Uses media instructions. */
36#define EF_FRV_PIC 0x00000100 /* Uses position independent code. */
37#define EF_FRV_NON_PIC_RELOCS 0x00000200 /* Does not use position Independent code. */
38#define EF_FRV_MULADD 0x00000400 /* -mmuladd */
39#define EF_FRV_BIGPIC 0x00000800 /* -fPIC */
40#define EF_FRV_LIBPIC 0x00001000 /* -mlibrary-pic */
41#define EF_FRV_G0 0x00002000 /* -G 0, no small data ptr */
42#define EF_FRV_NOPACK 0x00004000 /* -mnopack */
43#define EF_FRV_FDPIC 0x00008000 /* -mfdpic */
44#define EF_FRV_CPU_MASK 0xff000000 /* specific cpu bits */
45#define EF_FRV_CPU_GENERIC 0x00000000 /* Set CPU type is FR-V */
46#define EF_FRV_CPU_FR500 0x01000000 /* Set CPU type is FR500 */
47#define EF_FRV_CPU_FR300 0x02000000 /* Set CPU type is FR300 */
48#define EF_FRV_CPU_SIMPLE 0x03000000 /* SIMPLE */
49#define EF_FRV_CPU_TOMCAT 0x04000000 /* Tomcat, FR500 prototype */
50#define EF_FRV_CPU_FR400 0x05000000 /* Set CPU type is FR400 */
51#define EF_FRV_CPU_FR550 0x06000000 /* Set CPU type is FR550 */
52#define EF_FRV_CPU_FR405 0x07000000 /* Set CPU type is FR405 */
53#define EF_FRV_CPU_FR450 0x08000000 /* Set CPU type is FR450 */
54
55/*
56 * FR-V ELF relocation types
57 */
58
59
60/*
61 * ELF register definitions..
62 */
63typedef unsigned long elf_greg_t;
64
65#define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t))
66typedef elf_greg_t elf_gregset_t[ELF_NGREG];
67
68typedef struct fpmedia_struct elf_fpregset_t;
69
70/*
71 * This is used to ensure we don't load something for the wrong architecture.
72 */
73extern int elf_check_arch(const struct elf32_hdr *hdr);
74
75#define elf_check_fdpic(x) ((x)->e_flags & EF_FRV_FDPIC && !((x)->e_flags & EF_FRV_NON_PIC_RELOCS))
76#define elf_check_const_displacement(x) ((x)->e_flags & EF_FRV_PIC)
77
78/*
79 * These are used to set parameters in the core dumps.
80 */
81#define ELF_CLASS ELFCLASS32
82#define ELF_DATA ELFDATA2MSB
83#define ELF_ARCH EM_FRV
84
85#define ELF_PLAT_INIT(_r) \
86do { \
87 __kernel_frame0_ptr->gr16 = 0; \
88 __kernel_frame0_ptr->gr17 = 0; \
89 __kernel_frame0_ptr->gr18 = 0; \
90 __kernel_frame0_ptr->gr19 = 0; \
91 __kernel_frame0_ptr->gr20 = 0; \
92 __kernel_frame0_ptr->gr21 = 0; \
93 __kernel_frame0_ptr->gr22 = 0; \
94 __kernel_frame0_ptr->gr23 = 0; \
95 __kernel_frame0_ptr->gr24 = 0; \
96 __kernel_frame0_ptr->gr25 = 0; \
97 __kernel_frame0_ptr->gr26 = 0; \
98 __kernel_frame0_ptr->gr27 = 0; \
99 __kernel_frame0_ptr->gr29 = 0; \
100} while(0)
101
102#define ELF_FDPIC_PLAT_INIT(_regs, _exec_map_addr, _interp_map_addr, _dynamic_addr) \
103do { \
104 __kernel_frame0_ptr->gr16 = _exec_map_addr; \
105 __kernel_frame0_ptr->gr17 = _interp_map_addr; \
106 __kernel_frame0_ptr->gr18 = _dynamic_addr; \
107 __kernel_frame0_ptr->gr19 = 0; \
108 __kernel_frame0_ptr->gr20 = 0; \
109 __kernel_frame0_ptr->gr21 = 0; \
110 __kernel_frame0_ptr->gr22 = 0; \
111 __kernel_frame0_ptr->gr23 = 0; \
112 __kernel_frame0_ptr->gr24 = 0; \
113 __kernel_frame0_ptr->gr25 = 0; \
114 __kernel_frame0_ptr->gr26 = 0; \
115 __kernel_frame0_ptr->gr27 = 0; \
116 __kernel_frame0_ptr->gr29 = 0; \
117} while(0)
118
119#define USE_ELF_CORE_DUMP
120#define ELF_EXEC_PAGESIZE 16384
121
122/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
123 use of this is to invoke "./ld.so someprog" to test out a new version of
124 the loader. We need to make sure that it is out of the way of the program
125 that it will "exec", and that there is sufficient room for the brk. */
126
127#define ELF_ET_DYN_BASE 0x08000000UL
128
129#define ELF_CORE_COPY_REGS(pr_reg, regs) \
130 memcpy(&pr_reg[0], &regs->sp, 31 * sizeof(uint32_t));
131
132/* This yields a mask that user programs can use to figure out what
133 instruction set this cpu supports. */
134
135#define ELF_HWCAP (0)
136
137/* This yields a string that ld.so will use to load implementation
138 specific libraries for optimization. This is more specific in
139 intent than poking at uname or /proc/cpuinfo. */
140
141#define ELF_PLATFORM (NULL)
142
143#ifdef __KERNEL__
144#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
145#endif
146
147#endif
diff --git a/include/asm-frv/errno.h b/include/asm-frv/errno.h
new file mode 100644
index 000000000000..d010795ceefe
--- /dev/null
+++ b/include/asm-frv/errno.h
@@ -0,0 +1,7 @@
1#ifndef _ASM_ERRNO_H
2#define _ASM_ERRNO_H
3
4#include <asm-generic/errno.h>
5
6#endif /* _ASM_ERRNO_H */
7
diff --git a/include/asm-frv/fcntl.h b/include/asm-frv/fcntl.h
new file mode 100644
index 000000000000..d61b999f9973
--- /dev/null
+++ b/include/asm-frv/fcntl.h
@@ -0,0 +1,88 @@
1#ifndef _ASM_FCNTL_H
2#define _ASM_FCNTL_H
3
4/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
5 located on an ext2 file system */
6#define O_ACCMODE 0003
7#define O_RDONLY 00
8#define O_WRONLY 01
9#define O_RDWR 02
10#define O_CREAT 0100 /* not fcntl */
11#define O_EXCL 0200 /* not fcntl */
12#define O_NOCTTY 0400 /* not fcntl */
13#define O_TRUNC 01000 /* not fcntl */
14#define O_APPEND 02000
15#define O_NONBLOCK 04000
16#define O_NDELAY O_NONBLOCK
17#define O_SYNC 010000
18#define FASYNC 020000 /* fcntl, for BSD compatibility */
19#define O_DIRECT 040000 /* direct disk access hint */
20#define O_LARGEFILE 0100000
21#define O_DIRECTORY 0200000 /* must be a directory */
22#define O_NOFOLLOW 0400000 /* don't follow links */
23#define O_NOATIME 01000000
24
25#define F_DUPFD 0 /* dup */
26#define F_GETFD 1 /* get close_on_exec */
27#define F_SETFD 2 /* set/clear close_on_exec */
28#define F_GETFL 3 /* get file->f_flags */
29#define F_SETFL 4 /* set file->f_flags */
30#define F_GETLK 5
31#define F_SETLK 6
32#define F_SETLKW 7
33
34#define F_SETOWN 8 /* for sockets. */
35#define F_GETOWN 9 /* for sockets. */
36#define F_SETSIG 10 /* for sockets. */
37#define F_GETSIG 11 /* for sockets. */
38
39#define F_GETLK64 12 /* using 'struct flock64' */
40#define F_SETLK64 13
41#define F_SETLKW64 14
42
43/* for F_[GET|SET]FL */
44#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
45
46/* for posix fcntl() and lockf() */
47#define F_RDLCK 0
48#define F_WRLCK 1
49#define F_UNLCK 2
50
51/* for old implementation of bsd flock () */
52#define F_EXLCK 4 /* or 3 */
53#define F_SHLCK 8 /* or 4 */
54
55/* for leases */
56#define F_INPROGRESS 16
57
58/* operations for bsd flock(), also used by the kernel implementation */
59#define LOCK_SH 1 /* shared lock */
60#define LOCK_EX 2 /* exclusive lock */
61#define LOCK_NB 4 /* or'd with one of the above to prevent
62 blocking */
63#define LOCK_UN 8 /* remove lock */
64
65#define LOCK_MAND 32 /* This is a mandatory flock */
66#define LOCK_READ 64 /* ... Which allows concurrent read operations */
67#define LOCK_WRITE 128 /* ... Which allows concurrent write operations */
68#define LOCK_RW 192 /* ... Which allows concurrent read & write ops */
69
70struct flock {
71 short l_type;
72 short l_whence;
73 off_t l_start;
74 off_t l_len;
75 pid_t l_pid;
76};
77
78struct flock64 {
79 short l_type;
80 short l_whence;
81 loff_t l_start;
82 loff_t l_len;
83 pid_t l_pid;
84};
85
86#define F_LINUX_SPECIFIC_BASE 1024
87#endif /* _ASM_FCNTL_H */
88
diff --git a/include/asm-frv/fpu.h b/include/asm-frv/fpu.h
new file mode 100644
index 000000000000..b1178f8ca5ce
--- /dev/null
+++ b/include/asm-frv/fpu.h
@@ -0,0 +1,12 @@
1#ifndef __ASM_FPU_H
2#define __ASM_FPU_H
3
4#include <linux/config.h>
5
6/*
7 * MAX floating point unit state size (FSAVE/FRESTORE)
8 */
9
10#define kernel_fpu_end() do { asm volatile("bar":::"memory"); preempt_enable(); } while(0)
11
12#endif /* __ASM_FPU_H */
diff --git a/include/asm-frv/gdb-stub.h b/include/asm-frv/gdb-stub.h
new file mode 100644
index 000000000000..c58479a4be99
--- /dev/null
+++ b/include/asm-frv/gdb-stub.h
@@ -0,0 +1,118 @@
1/* gdb-stub.h: FRV GDB stub
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 * - Derived from asm-mips/gdb-stub.h (c) 1995 Andreas Busse
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12#ifndef __ASM_GDB_STUB_H
13#define __ASM_GDB_STUB_H
14
15#undef GDBSTUB_DEBUG_PROTOCOL
16
17#include <asm/ptrace.h>
18
19/*
20 * important register numbers in GDB protocol
21 * - GR0, GR1, GR2, GR3, GR4, GR5, GR6, GR7,
22 * - GR8, GR9, GR10, GR11, GR12, GR13, GR14, GR15,
23 * - GR16, GR17, GR18, GR19, GR20, GR21, GR22, GR23,
24 * - GR24, GR25, GR26, GR27, GR28, GR29, GR30, GR31,
25 * - GR32, GR33, GR34, GR35, GR36, GR37, GR38, GR39,
26 * - GR40, GR41, GR42, GR43, GR44, GR45, GR46, GR47,
27 * - GR48, GR49, GR50, GR51, GR52, GR53, GR54, GR55,
28 * - GR56, GR57, GR58, GR59, GR60, GR61, GR62, GR63,
29 * - FR0, FR1, FR2, FR3, FR4, FR5, FR6, FR7,
30 * - FR8, FR9, FR10, FR11, FR12, FR13, FR14, FR15,
31 * - FR16, FR17, FR18, FR19, FR20, FR21, FR22, FR23,
32 * - FR24, FR25, FR26, FR27, FR28, FR29, FR30, FR31,
33 * - FR32, FR33, FR34, FR35, FR36, FR37, FR38, FR39,
34 * - FR40, FR41, FR42, FR43, FR44, FR45, FR46, FR47,
35 * - FR48, FR49, FR50, FR51, FR52, FR53, FR54, FR55,
36 * - FR56, FR57, FR58, FR59, FR60, FR61, FR62, FR63,
37 * - PC, PSR, CCR, CCCR,
38 * - _X132, _X133, _X134
39 * - TBR, BRR, DBAR0, DBAR1, DBAR2, DBAR3,
40 * - SCR0, SCR1, SCR2, SCR3,
41 * - LR, LCR,
42 * - IACC0H, IACC0L,
43 * - FSR0,
44 * - ACC0, ACC1, ACC2, ACC3, ACC4, ACC5, ACC6, ACC7,
45 * - ACCG0123, ACCG4567,
46 * - MSR0, MSR1,
47 * - GNER0, GNER1,
48 * - FNER0, FNER1,
49 */
50#define GDB_REG_GR(N) (N)
51#define GDB_REG_FR(N) (64+(N))
52#define GDB_REG_PC 128
53#define GDB_REG_PSR 129
54#define GDB_REG_CCR 130
55#define GDB_REG_CCCR 131
56#define GDB_REG_TBR 135
57#define GDB_REG_BRR 136
58#define GDB_REG_DBAR(N) (137+(N))
59#define GDB_REG_SCR(N) (141+(N))
60#define GDB_REG_LR 145
61#define GDB_REG_LCR 146
62#define GDB_REG_FSR0 149
63#define GDB_REG_ACC(N) (150+(N))
64#define GDB_REG_ACCG(N) (158+(N)/4)
65#define GDB_REG_MSR(N) (160+(N))
66#define GDB_REG_GNER(N) (162+(N))
67#define GDB_REG_FNER(N) (164+(N))
68
69#define GDB_REG_SP GDB_REG_GR(1)
70#define GDB_REG_FP GDB_REG_GR(2)
71
72#ifndef _LANGUAGE_ASSEMBLY
73
74/*
75 * Prototypes
76 */
77extern void show_registers_only(struct pt_regs *regs);
78
79extern void gdbstub_init(void);
80extern void gdbstub(int type);
81extern void gdbstub_exit(int status);
82
83extern void gdbstub_io_init(void);
84extern void gdbstub_set_baud(unsigned baud);
85extern int gdbstub_rx_char(unsigned char *_ch, int nonblock);
86extern void gdbstub_tx_char(unsigned char ch);
87extern void gdbstub_tx_flush(void);
88extern void gdbstub_do_rx(void);
89
90extern asmlinkage void __debug_stub_init_break(void);
91extern asmlinkage void __break_hijack_kernel_event(void);
92extern asmlinkage void start_kernel(void);
93
94extern asmlinkage void gdbstub_rx_handler(void);
95extern asmlinkage void gdbstub_rx_irq(void);
96extern asmlinkage void gdbstub_intercept(void);
97
98extern uint32_t __entry_usertrap_table[];
99extern uint32_t __entry_kerneltrap_table[];
100
101extern volatile u8 gdbstub_rx_buffer[PAGE_SIZE];
102extern volatile u32 gdbstub_rx_inp;
103extern volatile u32 gdbstub_rx_outp;
104extern volatile u8 gdbstub_rx_overflow;
105extern u8 gdbstub_rx_unget;
106
107extern void gdbstub_printk(const char *fmt, ...);
108extern void debug_to_serial(const char *p, int n);
109extern void console_set_baud(unsigned baud);
110
111#ifdef GDBSTUB_DEBUG_PROTOCOL
112#define gdbstub_proto(FMT,...) gdbstub_printk(FMT,##__VA_ARGS__)
113#else
114#define gdbstub_proto(FMT,...) ({ 0; })
115#endif
116
117#endif /* _LANGUAGE_ASSEMBLY */
118#endif /* __ASM_GDB_STUB_H */
diff --git a/include/asm-frv/gpio-regs.h b/include/asm-frv/gpio-regs.h
new file mode 100644
index 000000000000..9edf5d5d4d3f
--- /dev/null
+++ b/include/asm-frv/gpio-regs.h
@@ -0,0 +1,116 @@
1/* gpio-regs.h: on-chip general purpose I/O registers
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_GPIO_REGS
13#define _ASM_GPIO_REGS
14
15#define __reg(ADDR) (*(volatile unsigned long *)(ADDR))
16
17#define __get_PDR() ({ __reg(0xfeff0400); })
18#define __set_PDR(V) do { __reg(0xfeff0400) = (V); mb(); } while(0)
19
20#define __get_GPDR() ({ __reg(0xfeff0408); })
21#define __set_GPDR(V) do { __reg(0xfeff0408) = (V); mb(); } while(0)
22
23#define __get_SIR() ({ __reg(0xfeff0410); })
24#define __set_SIR(V) do { __reg(0xfeff0410) = (V); mb(); } while(0)
25
26#define __get_SOR() ({ __reg(0xfeff0418); })
27#define __set_SOR(V) do { __reg(0xfeff0418) = (V); mb(); } while(0)
28
29#define __set_PDSR(V) do { __reg(0xfeff0420) = (V); mb(); } while(0)
30
31#define __set_PDCR(V) do { __reg(0xfeff0428) = (V); mb(); } while(0)
32
33#define __get_RSTR() ({ __reg(0xfeff0500); })
34#define __set_RSTR(V) do { __reg(0xfeff0500) = (V); mb(); } while(0)
35
36
37
38/* PDR definitions */
39#define PDR_GPIO_DATA(X) (1 << (X))
40
41/* GPDR definitions */
42#define GPDR_INPUT 0
43#define GPDR_OUTPUT 1
44#define GPDR_DREQ0_BIT 0x00001000
45#define GPDR_DREQ1_BIT 0x00008000
46#define GPDR_DREQ2_BIT 0x00040000
47#define GPDR_DREQ3_BIT 0x00080000
48#define GPDR_DREQ4_BIT 0x00004000
49#define GPDR_DREQ5_BIT 0x00020000
50#define GPDR_DREQ6_BIT 0x00100000
51#define GPDR_DREQ7_BIT 0x00200000
52#define GPDR_DACK0_BIT 0x00002000
53#define GPDR_DACK1_BIT 0x00010000
54#define GPDR_DACK2_BIT 0x00100000
55#define GPDR_DACK3_BIT 0x00200000
56#define GPDR_DONE0_BIT 0x00004000
57#define GPDR_DONE1_BIT 0x00020000
58#define GPDR_GPIO_DIR(X,D) ((D) << (X))
59
60/* SIR definitions */
61#define SIR_GPIO_INPUT 0
62#define SIR_DREQ7_INPUT 0x00200000
63#define SIR_DREQ6_INPUT 0x00100000
64#define SIR_DREQ3_INPUT 0x00080000
65#define SIR_DREQ2_INPUT 0x00040000
66#define SIR_DREQ5_INPUT 0x00020000
67#define SIR_DREQ1_INPUT 0x00008000
68#define SIR_DREQ4_INPUT 0x00004000
69#define SIR_DREQ0_INPUT 0x00001000
70#define SIR_RXD1_INPUT 0x00000400
71#define SIR_CTS0_INPUT 0x00000100
72#define SIR_RXD0_INPUT 0x00000040
73#define SIR_GATE1_INPUT 0x00000020
74#define SIR_GATE0_INPUT 0x00000010
75#define SIR_IRQ3_INPUT 0x00000008
76#define SIR_IRQ2_INPUT 0x00000004
77#define SIR_IRQ1_INPUT 0x00000002
78#define SIR_IRQ0_INPUT 0x00000001
79#define SIR_DREQ_BITS (SIR_DREQ0_INPUT | SIR_DREQ1_INPUT | \
80 SIR_DREQ2_INPUT | SIR_DREQ3_INPUT | \
81 SIR_DREQ4_INPUT | SIR_DREQ5_INPUT | \
82 SIR_DREQ6_INPUT | SIR_DREQ7_INPUT)
83
84/* SOR definitions */
85#define SOR_GPIO_OUTPUT 0
86#define SOR_DACK3_OUTPUT 0x00200000
87#define SOR_DACK2_OUTPUT 0x00100000
88#define SOR_DONE1_OUTPUT 0x00020000
89#define SOR_DACK1_OUTPUT 0x00010000
90#define SOR_DONE0_OUTPUT 0x00004000
91#define SOR_DACK0_OUTPUT 0x00002000
92#define SOR_TXD1_OUTPUT 0x00000800
93#define SOR_RTS0_OUTPUT 0x00000200
94#define SOR_TXD0_OUTPUT 0x00000080
95#define SOR_TOUT1_OUTPUT 0x00000020
96#define SOR_TOUT0_OUTPUT 0x00000010
97#define SOR_DONE_BITS (SOR_DONE0_OUTPUT | SOR_DONE1_OUTPUT)
98#define SOR_DACK_BITS (SOR_DACK0_OUTPUT | SOR_DACK1_OUTPUT | \
99 SOR_DACK2_OUTPUT | SOR_DACK3_OUTPUT)
100
101/* PDSR definitions */
102#define PDSR_UNCHANGED 0
103#define PDSR_SET_BIT(X) (1 << (X))
104
105/* PDCR definitions */
106#define PDCR_UNCHANGED 0
107#define PDCR_CLEAR_BIT(X) (1 << (X))
108
109/* RSTR definitions */
110/* Read Only */
111#define RSTR_POWERON 0x00000400
112#define RSTR_SOFTRESET_STATUS 0x00000100
113/* Write Only */
114#define RSTR_SOFTRESET 0x00000001
115
116#endif /* _ASM_GPIO_REGS */
diff --git a/include/asm-frv/hardirq.h b/include/asm-frv/hardirq.h
new file mode 100644
index 000000000000..5248ca054909
--- /dev/null
+++ b/include/asm-frv/hardirq.h
@@ -0,0 +1,30 @@
1/* hardirq.h: FRV hardware IRQ management
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef __ASM_HARDIRQ_H
13#define __ASM_HARDIRQ_H
14
15#include <linux/config.h>
16#include <linux/threads.h>
17
18typedef struct {
19 unsigned int __softirq_pending;
20 unsigned long idle_timestamp;
21} ____cacheline_aligned irq_cpustat_t;
22
23#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
24
25#ifdef CONFIG_SMP
26#error SMP not available on FR-V
27#endif /* CONFIG_SMP */
28
29
30#endif
diff --git a/include/asm-frv/highmem.h b/include/asm-frv/highmem.h
new file mode 100644
index 000000000000..295f74a57f22
--- /dev/null
+++ b/include/asm-frv/highmem.h
@@ -0,0 +1,181 @@
1/* highmem.h: virtual kernel memory mappings for high memory
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 * - Derived from include/asm-i386/highmem.h
6 *
7 * See Documentation/fujitsu/frv/mmu-layout.txt for more information.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15#ifndef _ASM_HIGHMEM_H
16#define _ASM_HIGHMEM_H
17
18#ifdef __KERNEL__
19
20#include <linux/config.h>
21#include <linux/init.h>
22#include <asm/mem-layout.h>
23#include <asm/spr-regs.h>
24#include <asm/mb-regs.h>
25
26#define NR_TLB_LINES 64 /* number of lines in the TLB */
27
28#ifndef __ASSEMBLY__
29
30#include <linux/interrupt.h>
31#include <asm/kmap_types.h>
32#include <asm/pgtable.h>
33
34#ifdef CONFIG_DEBUG_HIGHMEM
35#define HIGHMEM_DEBUG 1
36#else
37#define HIGHMEM_DEBUG 0
38#endif
39
40/* declarations for highmem.c */
41extern unsigned long highstart_pfn, highend_pfn;
42
43#define kmap_prot PAGE_KERNEL
44#define kmap_pte ______kmap_pte_in_TLB
45extern pte_t *pkmap_page_table;
46
47#define flush_cache_kmaps() do { } while (0)
48
49/*
50 * Right now we initialize only a single pte table. It can be extended
51 * easily, subsequent pte tables have to be allocated in one physical
52 * chunk of RAM.
53 */
54#define LAST_PKMAP PTRS_PER_PTE
55#define LAST_PKMAP_MASK (LAST_PKMAP - 1)
56#define PKMAP_NR(virt) ((virt - PKMAP_BASE) >> PAGE_SHIFT)
57#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
58
59extern void *kmap_high(struct page *page);
60extern void kunmap_high(struct page *page);
61
62extern void *kmap(struct page *page);
63extern void kunmap(struct page *page);
64
65extern struct page *kmap_atomic_to_page(void *ptr);
66
67#endif /* !__ASSEMBLY__ */
68
69/*
70 * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap
71 * gives a more generic (and caching) interface. But kmap_atomic can
72 * be used in IRQ contexts, so in some (very limited) cases we need
73 * it.
74 */
75#define KMAP_ATOMIC_CACHE_DAMR 8
76
77#ifndef __ASSEMBLY__
78
79#define __kmap_atomic_primary(type, paddr, ampr) \
80({ \
81 unsigned long damlr, dampr; \
82 \
83 dampr = paddr | xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V; \
84 \
85 if (type != __KM_CACHE) \
86 asm volatile("movgs %0,dampr"#ampr :: "r"(dampr)); \
87 else \
88 asm volatile("movgs %0,iampr"#ampr"\n" \
89 "movgs %0,dampr"#ampr"\n" \
90 :: "r"(dampr) \
91 ); \
92 \
93 asm("movsg damlr"#ampr",%0" : "=r"(damlr)); \
94 \
95 /*printk("DAMR"#ampr": PRIM sl=%d L=%08lx P=%08lx\n", type, damlr, dampr);*/ \
96 \
97 (void *) damlr; \
98})
99
100#define __kmap_atomic_secondary(slot, paddr) \
101({ \
102 unsigned long damlr = KMAP_ATOMIC_SECONDARY_FRAME + (slot) * PAGE_SIZE; \
103 unsigned long dampr = paddr | xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V; \
104 \
105 asm volatile("movgs %0,tplr \n" \
106 "movgs %1,tppr \n" \
107 "tlbpr %0,gr0,#2,#1" \
108 : : "r"(damlr), "r"(dampr)); \
109 \
110 /*printk("TLB: SECN sl=%d L=%08lx P=%08lx\n", slot, damlr, dampr);*/ \
111 \
112 (void *) damlr; \
113})
114
115static inline void *kmap_atomic(struct page *page, enum km_type type)
116{
117 unsigned long paddr;
118
119 preempt_disable();
120 paddr = page_to_phys(page);
121
122 switch (type) {
123 case 0: return __kmap_atomic_primary(0, paddr, 2);
124 case 1: return __kmap_atomic_primary(1, paddr, 3);
125 case 2: return __kmap_atomic_primary(2, paddr, 4);
126 case 3: return __kmap_atomic_primary(3, paddr, 5);
127 case 4: return __kmap_atomic_primary(4, paddr, 6);
128 case 5: return __kmap_atomic_primary(5, paddr, 7);
129 case 6: return __kmap_atomic_primary(6, paddr, 8);
130 case 7: return __kmap_atomic_primary(7, paddr, 9);
131 case 8: return __kmap_atomic_primary(8, paddr, 10);
132
133 case 9 ... 9 + NR_TLB_LINES - 1:
134 return __kmap_atomic_secondary(type - 9, paddr);
135
136 default:
137 BUG();
138 return 0;
139 }
140}
141
142#define __kunmap_atomic_primary(type, ampr) \
143do { \
144 asm volatile("movgs gr0,dampr"#ampr"\n"); \
145 if (type == __KM_CACHE) \
146 asm volatile("movgs gr0,iampr"#ampr"\n"); \
147} while(0)
148
149#define __kunmap_atomic_secondary(slot, vaddr) \
150do { \
151 asm volatile("tlbpr %0,gr0,#4,#1" : : "r"(vaddr)); \
152} while(0)
153
154static inline void kunmap_atomic(void *kvaddr, enum km_type type)
155{
156 switch (type) {
157 case 0: __kunmap_atomic_primary(0, 2); break;
158 case 1: __kunmap_atomic_primary(1, 3); break;
159 case 2: __kunmap_atomic_primary(2, 4); break;
160 case 3: __kunmap_atomic_primary(3, 5); break;
161 case 4: __kunmap_atomic_primary(4, 6); break;
162 case 5: __kunmap_atomic_primary(5, 7); break;
163 case 6: __kunmap_atomic_primary(6, 8); break;
164 case 7: __kunmap_atomic_primary(7, 9); break;
165 case 8: __kunmap_atomic_primary(8, 10); break;
166
167 case 9 ... 9 + NR_TLB_LINES - 1:
168 __kunmap_atomic_secondary(type - 9, kvaddr);
169 break;
170
171 default:
172 BUG();
173 }
174 preempt_enable();
175}
176
177#endif /* !__ASSEMBLY__ */
178
179#endif /* __KERNEL__ */
180
181#endif /* _ASM_HIGHMEM_H */
diff --git a/include/asm-frv/hw_irq.h b/include/asm-frv/hw_irq.h
new file mode 100644
index 000000000000..522ad37923d8
--- /dev/null
+++ b/include/asm-frv/hw_irq.h
@@ -0,0 +1,16 @@
1/* hw_irq.h: FR-V specific h/w IRQ stuff
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_HW_IRQ_H
13#define _ASM_HW_IRQ_H
14
15
16#endif /* _ASM_HW_IRQ_H */
diff --git a/include/asm-frv/ide.h b/include/asm-frv/ide.h
new file mode 100644
index 000000000000..f9caecf7e3c0
--- /dev/null
+++ b/include/asm-frv/ide.h
@@ -0,0 +1,43 @@
1/* ide.h: FRV IDE declarations
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_IDE_H
13#define _ASM_IDE_H
14
15#ifdef __KERNEL__
16
17#include <linux/config.h>
18#include <asm/setup.h>
19#include <asm/io.h>
20#include <asm/irq.h>
21
22#undef SUPPORT_SLOW_DATA_PORTS
23#define SUPPORT_SLOW_DATA_PORTS 0
24
25#undef SUPPORT_VLB_SYNC
26#define SUPPORT_VLB_SYNC 0
27
28#ifndef MAX_HWIFS
29#define MAX_HWIFS 8
30#endif
31
32/****************************************************************************/
33/*
34 * some bits needed for parts of the IDE subsystem to compile
35 */
36#define __ide_mm_insw(port, addr, n) insw(port, addr, n)
37#define __ide_mm_insl(port, addr, n) insl(port, addr, n)
38#define __ide_mm_outsw(port, addr, n) outsw(port, addr, n)
39#define __ide_mm_outsl(port, addr, n) outsl(port, addr, n)
40
41
42#endif /* __KERNEL__ */
43#endif /* _ASM_IDE_H */
diff --git a/include/asm-frv/init.h b/include/asm-frv/init.h
new file mode 100644
index 000000000000..8b15838de216
--- /dev/null
+++ b/include/asm-frv/init.h
@@ -0,0 +1,12 @@
1#ifndef _ASM_INIT_H
2#define _ASM_INIT_H
3
4#define __init __attribute__ ((__section__ (".text.init")))
5#define __initdata __attribute__ ((__section__ (".data.init")))
6/* For assembly routines */
7#define __INIT .section ".text.init",#alloc,#execinstr
8#define __FINIT .previous
9#define __INITDATA .section ".data.init",#alloc,#write
10
11#endif
12
diff --git a/include/asm-frv/io.h b/include/asm-frv/io.h
new file mode 100644
index 000000000000..48829f727242
--- /dev/null
+++ b/include/asm-frv/io.h
@@ -0,0 +1,290 @@
1/* io.h: FRV I/O operations
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 * This gets interesting when talking to the PCI bus - the CPU is in big endian
12 * mode, the PCI bus is little endian and the hardware in the middle can do
13 * byte swapping
14 */
15#ifndef _ASM_IO_H
16#define _ASM_IO_H
17
18#ifdef __KERNEL__
19
20#include <linux/config.h>
21#include <asm/virtconvert.h>
22#include <asm/string.h>
23#include <asm/mb-regs.h>
24#include <linux/delay.h>
25
26/*
27 * swap functions are sometimes needed to interface little-endian hardware
28 */
29
30static inline unsigned short _swapw(unsigned short v)
31{
32 return ((v << 8) | (v >> 8));
33}
34
35static inline unsigned long _swapl(unsigned long v)
36{
37 return ((v << 24) | ((v & 0xff00) << 8) | ((v & 0xff0000) >> 8) | (v >> 24));
38}
39
40//#define __iormb() asm volatile("membar")
41//#define __iowmb() asm volatile("membar")
42
43#define __raw_readb(addr) __builtin_read8((void *) (addr))
44#define __raw_readw(addr) __builtin_read16((void *) (addr))
45#define __raw_readl(addr) __builtin_read32((void *) (addr))
46
47#define __raw_writeb(datum, addr) __builtin_write8((void *) (addr), datum)
48#define __raw_writew(datum, addr) __builtin_write16((void *) (addr), datum)
49#define __raw_writel(datum, addr) __builtin_write32((void *) (addr), datum)
50
51static inline void io_outsb(unsigned int addr, const void *buf, int len)
52{
53 unsigned long __ioaddr = (unsigned long) addr;
54 const uint8_t *bp = buf;
55
56 while (len--)
57 __builtin_write8((volatile void __iomem *) __ioaddr, *bp++);
58}
59
60static inline void io_outsw(unsigned int addr, const void *buf, int len)
61{
62 unsigned long __ioaddr = (unsigned long) addr;
63 const uint16_t *bp = buf;
64
65 while (len--)
66 __builtin_write16((volatile void __iomem *) __ioaddr, (*bp++));
67}
68
69extern void __outsl_ns(unsigned int addr, const void *buf, int len);
70extern void __outsl_sw(unsigned int addr, const void *buf, int len);
71static inline void __outsl(unsigned int addr, const void *buf, int len, int swap)
72{
73 unsigned long __ioaddr = (unsigned long) addr;
74
75 if (!swap)
76 __outsl_ns(__ioaddr, buf, len);
77 else
78 __outsl_sw(__ioaddr, buf, len);
79}
80
81static inline void io_insb(unsigned long addr, void *buf, int len)
82{
83 uint8_t *bp = buf;
84
85 while (len--)
86 *bp++ = __builtin_read8((volatile void __iomem *) addr);
87}
88
89static inline void io_insw(unsigned long addr, void *buf, int len)
90{
91 uint16_t *bp = buf;
92
93 while (len--)
94 *bp++ = __builtin_read16((volatile void __iomem *) addr);
95}
96
97extern void __insl_ns(unsigned long addr, void *buf, int len);
98extern void __insl_sw(unsigned long addr, void *buf, int len);
99static inline void __insl(unsigned long addr, void *buf, int len, int swap)
100{
101 if (!swap)
102 __insl_ns(addr, buf, len);
103 else
104 __insl_sw(addr, buf, len);
105}
106
107/*
108 * make the short names macros so specific devices
109 * can override them as required
110 */
111
112static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
113{
114 memset((void __force *) addr, val, count);
115}
116
117static inline void memcpy_fromio(void *dst, volatile void __iomem *src, int count)
118{
119 memcpy(dst, (void __force *) src, count);
120}
121
122static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
123{
124 memcpy((void __force *) dst, src, count);
125}
126
127static inline uint8_t inb(unsigned long addr)
128{
129 return __builtin_read8((void *)addr);
130}
131
132static inline uint16_t inw(unsigned long addr)
133{
134 uint16_t ret = __builtin_read16((void *)addr);
135
136 if (__is_PCI_IO(addr))
137 ret = _swapw(ret);
138
139 return ret;
140}
141
142static inline uint32_t inl(unsigned long addr)
143{
144 uint32_t ret = __builtin_read32((void *)addr);
145
146 if (__is_PCI_IO(addr))
147 ret = _swapl(ret);
148
149 return ret;
150}
151
152static inline void outb(uint8_t datum, unsigned long addr)
153{
154 __builtin_write8((void *)addr, datum);
155}
156
157static inline void outw(uint16_t datum, unsigned long addr)
158{
159 if (__is_PCI_IO(addr))
160 datum = _swapw(datum);
161 __builtin_write16((void *)addr, datum);
162}
163
164static inline void outl(uint32_t datum, unsigned long addr)
165{
166 if (__is_PCI_IO(addr))
167 datum = _swapl(datum);
168 __builtin_write32((void *)addr, datum);
169}
170
171#define inb_p(addr) inb(addr)
172#define inw_p(addr) inw(addr)
173#define inl_p(addr) inl(addr)
174#define outb_p(x,addr) outb(x,addr)
175#define outw_p(x,addr) outw(x,addr)
176#define outl_p(x,addr) outl(x,addr)
177
178#define outsb(a,b,l) io_outsb(a,b,l)
179#define outsw(a,b,l) io_outsw(a,b,l)
180#define outsl(a,b,l) __outsl(a,b,l,0)
181
182#define insb(a,b,l) io_insb(a,b,l)
183#define insw(a,b,l) io_insw(a,b,l)
184#define insl(a,b,l) __insl(a,b,l,0)
185
186#define IO_SPACE_LIMIT 0xffffffff
187
188static inline uint8_t readb(const volatile void __iomem *addr)
189{
190 return __builtin_read8((volatile uint8_t __force *) addr);
191}
192
193static inline uint16_t readw(const volatile void __iomem *addr)
194{
195 uint16_t ret = __builtin_read16((volatile uint16_t __force *)addr);
196
197 if (__is_PCI_MEM(addr))
198 ret = _swapw(ret);
199 return ret;
200}
201
202static inline uint32_t readl(const volatile void __iomem *addr)
203{
204 uint32_t ret = __builtin_read32((volatile uint32_t __force *)addr);
205
206 if (__is_PCI_MEM(addr))
207 ret = _swapl(ret);
208
209 return ret;
210}
211
212static inline void writeb(uint8_t datum, volatile void __iomem *addr)
213{
214 __builtin_write8((volatile uint8_t __force *) addr, datum);
215 if (__is_PCI_MEM(addr))
216 __flush_PCI_writes();
217}
218
219static inline void writew(uint16_t datum, volatile void __iomem *addr)
220{
221 if (__is_PCI_MEM(addr))
222 datum = _swapw(datum);
223
224 __builtin_write16((volatile uint16_t __force *) addr, datum);
225 if (__is_PCI_MEM(addr))
226 __flush_PCI_writes();
227}
228
229static inline void writel(uint32_t datum, volatile void __iomem *addr)
230{
231 if (__is_PCI_MEM(addr))
232 datum = _swapl(datum);
233
234 __builtin_write32((volatile uint32_t __force *) addr, datum);
235 if (__is_PCI_MEM(addr))
236 __flush_PCI_writes();
237}
238
239
240/* Values for nocacheflag and cmode */
241#define IOMAP_FULL_CACHING 0
242#define IOMAP_NOCACHE_SER 1
243#define IOMAP_NOCACHE_NONSER 2
244#define IOMAP_WRITETHROUGH 3
245
246extern void __iomem *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag);
247extern void __iounmap(void __iomem *addr, unsigned long size);
248
249static inline void __iomem *ioremap(unsigned long physaddr, unsigned long size)
250{
251 return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
252}
253
254static inline void __iomem *ioremap_nocache(unsigned long physaddr, unsigned long size)
255{
256 return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
257}
258
259static inline void __iomem *ioremap_writethrough(unsigned long physaddr, unsigned long size)
260{
261 return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
262}
263
264static inline void __iomem *ioremap_fullcache(unsigned long physaddr, unsigned long size)
265{
266 return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
267}
268
269extern void iounmap(void __iomem *addr);
270
271static inline void flush_write_buffers(void)
272{
273 __asm__ __volatile__ ("membar" : : :"memory");
274}
275
276
277/*
278 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
279 * access
280 */
281#define xlate_dev_mem_ptr(p) __va(p)
282
283/*
284 * Convert a virtual cached pointer to an uncached pointer
285 */
286#define xlate_dev_kmem_ptr(p) p
287
288#endif /* __KERNEL__ */
289
290#endif /* _ASM_IO_H */
diff --git a/include/asm-frv/ioctl.h b/include/asm-frv/ioctl.h
new file mode 100644
index 000000000000..8aee76905545
--- /dev/null
+++ b/include/asm-frv/ioctl.h
@@ -0,0 +1,80 @@
1/*
2 * linux/ioctl.h for Linux by H.H. Bergman.
3 */
4
5#ifndef _ASM_IOCTL_H
6#define _ASM_IOCTL_H
7
8/* ioctl command encoding: 32 bits total, command in lower 16 bits,
9 * size of the parameter structure in the lower 14 bits of the
10 * upper 16 bits.
11 * Encoding the size of the parameter structure in the ioctl request
12 * is useful for catching programs compiled with old versions
13 * and to avoid overwriting user space outside the user buffer area.
14 * The highest 2 bits are reserved for indicating the ``access mode''.
15 * NOTE: This limits the max parameter size to 16kB -1 !
16 */
17
18/*
19 * I don't really have any idea about what this should look like, so
20 * for the time being, this is heavily based on the PC definitions.
21 */
22
23/*
24 * The following is for compatibility across the various Linux
25 * platforms. The i386 ioctl numbering scheme doesn't really enforce
26 * a type field. De facto, however, the top 8 bits of the lower 16
27 * bits are indeed used as a type field, so we might just as well make
28 * this explicit here. Please be sure to use the decoding macros
29 * below from now on.
30 */
31#define _IOC_NRBITS 8
32#define _IOC_TYPEBITS 8
33#define _IOC_SIZEBITS 14
34#define _IOC_DIRBITS 2
35
36#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
37#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
38#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
39#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
40
41#define _IOC_NRSHIFT 0
42#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
43#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
44#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
45
46/*
47 * Direction bits.
48 */
49#define _IOC_NONE 0U
50#define _IOC_WRITE 1U
51#define _IOC_READ 2U
52
53#define _IOC(dir,type,nr,size) \
54 (((dir) << _IOC_DIRSHIFT) | \
55 ((type) << _IOC_TYPESHIFT) | \
56 ((nr) << _IOC_NRSHIFT) | \
57 ((size) << _IOC_SIZESHIFT))
58
59/* used to create numbers */
60#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
61#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
62#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
63#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
64
65/* used to decode ioctl numbers.. */
66#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
67#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
68#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
69#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
70
71/* ...and for the drivers/sound files... */
72
73#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
74#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
75#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
76#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
77#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
78
79#endif /* _ASM_IOCTL_H */
80
diff --git a/include/asm-frv/ioctls.h b/include/asm-frv/ioctls.h
new file mode 100644
index 000000000000..341c7ddef2a3
--- /dev/null
+++ b/include/asm-frv/ioctls.h
@@ -0,0 +1,82 @@
1#ifndef __ASM_IOCTLS_H__
2#define __ASM_IOCTLS_H__
3
4#include <asm/ioctl.h>
5
6/* 0x54 is just a magic number to make these relatively unique ('T') */
7
8#define TCGETS 0x5401
9#define TCSETS 0x5402
10#define TCSETSW 0x5403
11#define TCSETSF 0x5404
12#define TCGETA 0x5405
13#define TCSETA 0x5406
14#define TCSETAW 0x5407
15#define TCSETAF 0x5408
16#define TCSBRK 0x5409
17#define TCXONC 0x540A
18#define TCFLSH 0x540B
19#define TIOCEXCL 0x540C
20#define TIOCNXCL 0x540D
21#define TIOCSCTTY 0x540E
22#define TIOCGPGRP 0x540F
23#define TIOCSPGRP 0x5410
24#define TIOCOUTQ 0x5411
25#define TIOCSTI 0x5412
26#define TIOCGWINSZ 0x5413
27#define TIOCSWINSZ 0x5414
28#define TIOCMGET 0x5415
29#define TIOCMBIS 0x5416
30#define TIOCMBIC 0x5417
31#define TIOCMSET 0x5418
32#define TIOCGSOFTCAR 0x5419
33#define TIOCSSOFTCAR 0x541A
34#define FIONREAD 0x541B
35#define TIOCINQ FIONREAD
36#define TIOCLINUX 0x541C
37#define TIOCCONS 0x541D
38#define TIOCGSERIAL 0x541E
39#define TIOCSSERIAL 0x541F
40#define TIOCPKT 0x5420
41#define FIONBIO 0x5421
42#define TIOCNOTTY 0x5422
43#define TIOCSETD 0x5423
44#define TIOCGETD 0x5424
45#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
46#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
47#define TIOCSBRK 0x5427 /* BSD compatibility */
48#define TIOCCBRK 0x5428 /* BSD compatibility */
49#define TIOCGSID 0x5429 /* Return the session ID of FD */
50#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
51#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
52
53#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
54#define FIOCLEX 0x5451
55#define FIOASYNC 0x5452
56#define TIOCSERCONFIG 0x5453
57#define TIOCSERGWILD 0x5454
58#define TIOCSERSWILD 0x5455
59#define TIOCGLCKTRMIOS 0x5456
60#define TIOCSLCKTRMIOS 0x5457
61#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
62#define TIOCSERGETLSR 0x5459 /* Get line status register */
63#define TIOCSERGETMULTI 0x545A /* Get multiport config */
64#define TIOCSERSETMULTI 0x545B /* Set multiport config */
65
66#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
67#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
68#define FIOQSIZE 0x545E
69
70/* Used for packet mode */
71#define TIOCPKT_DATA 0
72#define TIOCPKT_FLUSHREAD 1
73#define TIOCPKT_FLUSHWRITE 2
74#define TIOCPKT_STOP 4
75#define TIOCPKT_START 8
76#define TIOCPKT_NOSTOP 16
77#define TIOCPKT_DOSTOP 32
78
79#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
80
81#endif /* __ASM_IOCTLS_H__ */
82
diff --git a/include/asm-frv/ipc.h b/include/asm-frv/ipc.h
new file mode 100644
index 000000000000..a46e3d9c2a3f
--- /dev/null
+++ b/include/asm-frv/ipc.h
@@ -0,0 +1 @@
#include <asm-generic/ipc.h>
diff --git a/include/asm-frv/ipcbuf.h b/include/asm-frv/ipcbuf.h
new file mode 100644
index 000000000000..b546f67e455f
--- /dev/null
+++ b/include/asm-frv/ipcbuf.h
@@ -0,0 +1,30 @@
1#ifndef __ASM_IPCBUF_H__
2#define __ASM_IPCBUF_H__
3
4/*
5 * The user_ipc_perm structure for FR-V architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 32-bit mode_t and seq
11 * - 2 miscellaneous 32-bit values
12 */
13
14struct ipc64_perm
15{
16 __kernel_key_t key;
17 __kernel_uid32_t uid;
18 __kernel_gid32_t gid;
19 __kernel_uid32_t cuid;
20 __kernel_gid32_t cgid;
21 __kernel_mode_t mode;
22 unsigned short __pad1;
23 unsigned short seq;
24 unsigned short __pad2;
25 unsigned long __unused1;
26 unsigned long __unused2;
27};
28
29#endif /* __ASM_IPCBUF_H__ */
30
diff --git a/include/asm-frv/irc-regs.h b/include/asm-frv/irc-regs.h
new file mode 100644
index 000000000000..afa30aeacc82
--- /dev/null
+++ b/include/asm-frv/irc-regs.h
@@ -0,0 +1,53 @@
1/* irc-regs.h: on-chip interrupt controller registers
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_IRC_REGS
13#define _ASM_IRC_REGS
14
15#define __reg(ADDR) (*(volatile unsigned long *)(ADDR))
16
17#define __get_TM0() ({ __reg(0xfeff9800); })
18#define __get_TM1() ({ __reg(0xfeff9808); })
19#define __set_TM1(V) do { __reg(0xfeff9808) = (V); mb(); } while(0)
20
21#define __set_TM1x(XI,V) \
22do { \
23 int shift = (XI) * 2 + 16; \
24 unsigned long tm1 = __reg(0xfeff9808); \
25 tm1 &= ~(0x3 << shift); \
26 tm1 |= (V) << shift; \
27 __reg(0xfeff9808) = tm1; \
28 mb(); \
29} while(0)
30
31#define __get_RS(C) ({ (__reg(0xfeff9810) >> ((C)+16)) & 1; })
32
33#define __clr_RC(C) do { __reg(0xfeff9818) = 1 << ((C)+16); mb(); } while(0)
34
35#define __get_MASK(C) ({ (__reg(0xfeff9820) >> ((C)+16)) & 1; })
36#define __set_MASK(C) do { __reg(0xfeff9820) |= 1 << ((C)+16); mb(); } while(0)
37#define __clr_MASK(C) do { __reg(0xfeff9820) &= ~(1 << ((C)+16)); mb(); } while(0)
38
39#define __get_MASK_all() __get_MASK(0)
40#define __set_MASK_all() __set_MASK(0)
41#define __clr_MASK_all() __clr_MASK(0)
42
43#define __get_IRL() ({ (__reg(0xfeff9828) >> 16) & 0xf; })
44#define __clr_IRL() do { __reg(0xfeff9828) = 0x100000; mb(); } while(0)
45
46#define __get_IRR(N) ({ __reg(0xfeff9840 + (N) * 8); })
47#define __set_IRR(N,V) do { __reg(0xfeff9840 + (N) * 8) = (V); } while(0)
48
49#define __get_IITMR(N) ({ __reg(0xfeff9880 + (N) * 8); })
50#define __set_IITMR(N,V) do { __reg(0xfeff9880 + (N) * 8) = (V); } while(0)
51
52
53#endif /* _ASM_IRC_REGS */
diff --git a/include/asm-frv/irq-routing.h b/include/asm-frv/irq-routing.h
new file mode 100644
index 000000000000..686fb2b39d6a
--- /dev/null
+++ b/include/asm-frv/irq-routing.h
@@ -0,0 +1,70 @@
1/* irq-routing.h: multiplexed IRQ routing
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_IRQ_ROUTING_H
13#define _ASM_IRQ_ROUTING_H
14
15#ifndef __ASSEMBLY__
16
17#include <linux/spinlock.h>
18#include <asm/irq.h>
19
20struct irq_source;
21struct irq_level;
22
23/*
24 * IRQ action distribution sets
25 */
26struct irq_group {
27 int first_irq; /* first IRQ distributed here */
28 void (*control)(struct irq_group *group, int index, int on);
29
30 struct irqaction *actions[NR_IRQ_ACTIONS_PER_GROUP]; /* IRQ action chains */
31 struct irq_source *sources[NR_IRQ_ACTIONS_PER_GROUP]; /* IRQ sources */
32 int disable_cnt[NR_IRQ_ACTIONS_PER_GROUP]; /* disable counts */
33};
34
35/*
36 * IRQ source manager
37 */
38struct irq_source {
39 struct irq_source *next;
40 struct irq_level *level;
41 const char *muxname;
42 volatile void __iomem *muxdata;
43 unsigned long irqmask;
44
45 void (*doirq)(struct irq_source *source);
46};
47
48/*
49 * IRQ level management (per CPU IRQ priority / entry vector)
50 */
51struct irq_level {
52 int usage;
53 int disable_count;
54 unsigned long flags; /* current SA_INTERRUPT and SA_SHIRQ settings */
55 spinlock_t lock;
56 struct irq_source *sources;
57};
58
59extern struct irq_level frv_irq_levels[16];
60extern struct irq_group *irq_groups[NR_IRQ_GROUPS];
61
62extern void frv_irq_route(struct irq_source *source, int irqlevel);
63extern void frv_irq_route_external(struct irq_source *source, int irq);
64extern void frv_irq_set_group(struct irq_group *group);
65extern void distribute_irqs(struct irq_group *group, unsigned long irqmask);
66extern void route_cpu_irqs(void);
67
68#endif /* !__ASSEMBLY__ */
69
70#endif /* _ASM_IRQ_ROUTING_H */
diff --git a/include/asm-frv/irq.h b/include/asm-frv/irq.h
new file mode 100644
index 000000000000..2c16d8dc02fd
--- /dev/null
+++ b/include/asm-frv/irq.h
@@ -0,0 +1,44 @@
1/* irq.h: FRV IRQ definitions
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_IRQ_H_
13#define _ASM_IRQ_H_
14
15#include <linux/config.h>
16
17/*
18 * the system has an on-CPU PIC and another PIC on the FPGA and other PICs on other peripherals,
19 * so we do some routing in irq-routing.[ch] to reduce the number of false-positives seen by
20 * drivers
21 */
22
23/* this number is used when no interrupt has been assigned */
24#define NO_IRQ (-1)
25
26#define NR_IRQ_LOG2_ACTIONS_PER_GROUP 5
27#define NR_IRQ_ACTIONS_PER_GROUP (1 << NR_IRQ_LOG2_ACTIONS_PER_GROUP)
28#define NR_IRQ_GROUPS 4
29#define NR_IRQS (NR_IRQ_ACTIONS_PER_GROUP * NR_IRQ_GROUPS)
30
31/* probe returns a 32-bit IRQ mask:-/ */
32#define MIN_PROBE_IRQ (NR_IRQS - 32)
33
34static inline int irq_canonicalize(int irq)
35{
36 return irq;
37}
38
39extern void disable_irq_nosync(unsigned int irq);
40extern void disable_irq(unsigned int irq);
41extern void enable_irq(unsigned int irq);
42
43
44#endif /* _ASM_IRQ_H_ */
diff --git a/include/asm-frv/kmap_types.h b/include/asm-frv/kmap_types.h
new file mode 100644
index 000000000000..f8e16b2a5804
--- /dev/null
+++ b/include/asm-frv/kmap_types.h
@@ -0,0 +1,29 @@
1
2#ifndef _ASM_KMAP_TYPES_H
3#define _ASM_KMAP_TYPES_H
4
5enum km_type {
6 /* arch specific kmaps - change the numbers attached to these at your peril */
7 __KM_CACHE, /* cache flush page attachment point */
8 __KM_PGD, /* current page directory */
9 __KM_ITLB_PTD, /* current instruction TLB miss page table lookup */
10 __KM_DTLB_PTD, /* current data TLB miss page table lookup */
11
12 /* general kmaps */
13 KM_BOUNCE_READ,
14 KM_SKB_SUNRPC_DATA,
15 KM_SKB_DATA_SOFTIRQ,
16 KM_USER0,
17 KM_USER1,
18 KM_BIO_SRC_IRQ,
19 KM_BIO_DST_IRQ,
20 KM_PTE0,
21 KM_PTE1,
22 KM_IRQ0,
23 KM_IRQ1,
24 KM_SOFTIRQ0,
25 KM_SOFTIRQ1,
26 KM_TYPE_NR
27};
28
29#endif
diff --git a/include/asm-frv/linkage.h b/include/asm-frv/linkage.h
new file mode 100644
index 000000000000..636c1bced7d4
--- /dev/null
+++ b/include/asm-frv/linkage.h
@@ -0,0 +1,7 @@
1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H
3
4#define __ALIGN .align 4
5#define __ALIGN_STR ".align 4"
6
7#endif
diff --git a/include/asm-frv/local.h b/include/asm-frv/local.h
new file mode 100644
index 000000000000..c27bdf04630e
--- /dev/null
+++ b/include/asm-frv/local.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_LOCAL_H
2#define _ASM_LOCAL_H
3
4#include <asm-generic/local.h>
5
6#endif /* _ASM_LOCAL_H */
diff --git a/include/asm-frv/math-emu.h b/include/asm-frv/math-emu.h
new file mode 100644
index 000000000000..0c8f731b2180
--- /dev/null
+++ b/include/asm-frv/math-emu.h
@@ -0,0 +1,301 @@
1#ifndef _ASM_MATH_EMU_H
2#define _ASM_MATH_EMU_H
3
4#include <asm/setup.h>
5#include <linux/linkage.h>
6
7/* Status Register bits */
8
9/* accrued exception bits */
10#define FPSR_AEXC_INEX 3
11#define FPSR_AEXC_DZ 4
12#define FPSR_AEXC_UNFL 5
13#define FPSR_AEXC_OVFL 6
14#define FPSR_AEXC_IOP 7
15
16/* exception status bits */
17#define FPSR_EXC_INEX1 8
18#define FPSR_EXC_INEX2 9
19#define FPSR_EXC_DZ 10
20#define FPSR_EXC_UNFL 11
21#define FPSR_EXC_OVFL 12
22#define FPSR_EXC_OPERR 13
23#define FPSR_EXC_SNAN 14
24#define FPSR_EXC_BSUN 15
25
26/* quotient byte, assumes big-endian, of course */
27#define FPSR_QUOTIENT(fpsr) (*((signed char *) &(fpsr) + 1))
28
29/* condition code bits */
30#define FPSR_CC_NAN 24
31#define FPSR_CC_INF 25
32#define FPSR_CC_Z 26
33#define FPSR_CC_NEG 27
34
35
36/* Control register bits */
37
38/* rounding mode */
39#define FPCR_ROUND_RN 0 /* round to nearest/even */
40#define FPCR_ROUND_RZ 1 /* round to zero */
41#define FPCR_ROUND_RM 2 /* minus infinity */
42#define FPCR_ROUND_RP 3 /* plus infinity */
43
44/* rounding precision */
45#define FPCR_PRECISION_X 0 /* long double */
46#define FPCR_PRECISION_S 1 /* double */
47#define FPCR_PRECISION_D 2 /* float */
48
49
50/* Flags to select the debugging output */
51#define PDECODE 0
52#define PEXECUTE 1
53#define PCONV 2
54#define PNORM 3
55#define PREGISTER 4
56#define PINSTR 5
57#define PUNIMPL 6
58#define PMOVEM 7
59
60#define PMDECODE (1<<PDECODE)
61#define PMEXECUTE (1<<PEXECUTE)
62#define PMCONV (1<<PCONV)
63#define PMNORM (1<<PNORM)
64#define PMREGISTER (1<<PREGISTER)
65#define PMINSTR (1<<PINSTR)
66#define PMUNIMPL (1<<PUNIMPL)
67#define PMMOVEM (1<<PMOVEM)
68
69#ifndef __ASSEMBLY__
70
71#include <linux/kernel.h>
72#include <linux/sched.h>
73
74union fp_mant64 {
75 unsigned long long m64;
76 unsigned long m32[2];
77};
78
79union fp_mant128 {
80 unsigned long long m64[2];
81 unsigned long m32[4];
82};
83
84/* internal representation of extended fp numbers */
85struct fp_ext {
86 unsigned char lowmant;
87 unsigned char sign;
88 unsigned short exp;
89 union fp_mant64 mant;
90};
91
92/* C representation of FPU registers */
93/* NOTE: if you change this, you have to change the assembler offsets
94 below and the size in <asm/fpu.h>, too */
95struct fp_data {
96 struct fp_ext fpreg[8];
97 unsigned int fpcr;
98 unsigned int fpsr;
99 unsigned int fpiar;
100 unsigned short prec;
101 unsigned short rnd;
102 struct fp_ext temp[2];
103};
104
105#if FPU_EMU_DEBUG
106extern unsigned int fp_debugprint;
107
108#define dprint(bit, fmt, args...) ({ \
109 if (fp_debugprint & (1 << (bit))) \
110 printk(fmt, ## args); \
111})
112#else
113#define dprint(bit, fmt, args...)
114#endif
115
116#define uprint(str) ({ \
117 static int __count = 3; \
118 \
119 if (__count > 0) { \
120 printk("You just hit an unimplemented " \
121 "fpu instruction (%s)\n", str); \
122 printk("Please report this to ....\n"); \
123 __count--; \
124 } \
125})
126
127#define FPDATA ((struct fp_data *)current->thread.fp)
128
129#else /* __ASSEMBLY__ */
130
131#define FPDATA %a2
132
133/* offsets from the base register to the floating point data in the task struct */
134#define FPD_FPREG (TASK_THREAD+THREAD_FPREG+0)
135#define FPD_FPCR (TASK_THREAD+THREAD_FPREG+96)
136#define FPD_FPSR (TASK_THREAD+THREAD_FPREG+100)
137#define FPD_FPIAR (TASK_THREAD+THREAD_FPREG+104)
138#define FPD_PREC (TASK_THREAD+THREAD_FPREG+108)
139#define FPD_RND (TASK_THREAD+THREAD_FPREG+110)
140#define FPD_TEMPFP1 (TASK_THREAD+THREAD_FPREG+112)
141#define FPD_TEMPFP2 (TASK_THREAD+THREAD_FPREG+124)
142#define FPD_SIZEOF (TASK_THREAD+THREAD_FPREG+136)
143
144/* offsets on the stack to access saved registers,
145 * these are only used during instruction decoding
146 * where we always know how deep we're on the stack.
147 */
148#define FPS_DO (PT_D0)
149#define FPS_D1 (PT_D1)
150#define FPS_D2 (PT_D2)
151#define FPS_A0 (PT_A0)
152#define FPS_A1 (PT_A1)
153#define FPS_A2 (PT_A2)
154#define FPS_SR (PT_SR)
155#define FPS_PC (PT_PC)
156#define FPS_EA (PT_PC+6)
157#define FPS_PC2 (PT_PC+10)
158
159.macro fp_get_fp_reg
160 lea (FPD_FPREG,FPDATA,%d0.w*4),%a0
161 lea (%a0,%d0.w*8),%a0
162.endm
163
164/* Macros used to get/put the current program counter.
165 * 020/030 use a different stack frame then 040/060, for the
166 * 040/060 the return pc points already to the next location,
167 * so this only needs to be modified for jump instructions.
168 */
169.macro fp_get_pc dest
170 move.l (FPS_PC+4,%sp),\dest
171.endm
172
173.macro fp_put_pc src,jump=0
174 move.l \src,(FPS_PC+4,%sp)
175.endm
176
177.macro fp_get_instr_data f,s,dest,label
178 getuser \f,%sp@(FPS_PC+4)@(0),\dest,\label,%sp@(FPS_PC+4)
179 addq.l #\s,%sp@(FPS_PC+4)
180.endm
181
182.macro fp_get_instr_word dest,label,addr
183 fp_get_instr_data w,2,\dest,\label,\addr
184.endm
185
186.macro fp_get_instr_long dest,label,addr
187 fp_get_instr_data l,4,\dest,\label,\addr
188.endm
189
190/* These macros are used to read from/write to user space
191 * on error we jump to the fixup section, load the fault
192 * address into %a0 and jump to the exit.
193 * (derived from <asm/uaccess.h>)
194 */
195.macro getuser size,src,dest,label,addr
196| printf ,"[\size<%08x]",1,\addr
197.Lu1\@: moves\size \src,\dest
198
199 .section .fixup,"ax"
200 .even
201.Lu2\@: move.l \addr,%a0
202 jra \label
203 .previous
204
205 .section __ex_table,"a"
206 .align 4
207 .long .Lu1\@,.Lu2\@
208 .previous
209.endm
210
211.macro putuser size,src,dest,label,addr
212| printf ,"[\size>%08x]",1,\addr
213.Lu1\@: moves\size \src,\dest
214.Lu2\@:
215
216 .section .fixup,"ax"
217 .even
218.Lu3\@: move.l \addr,%a0
219 jra \label
220 .previous
221
222 .section __ex_table,"a"
223 .align 4
224 .long .Lu1\@,.Lu3\@
225 .long .Lu2\@,.Lu3\@
226 .previous
227.endm
228
229
230.macro movestack nr,arg1,arg2,arg3,arg4,arg5
231 .if \nr
232 movestack (\nr-1),\arg2,\arg3,\arg4,\arg5
233 move.l \arg1,-(%sp)
234 .endif
235.endm
236
237.macro printf bit=-1,string,nr=0,arg1,arg2,arg3,arg4,arg5
238#ifdef FPU_EMU_DEBUG
239 .data
240.Lpdata\@:
241 .string "\string"
242 .previous
243
244 movem.l %d0/%d1/%a0/%a1,-(%sp)
245 .if \bit+1
246#if 0
247 moveq #\bit,%d0
248 andw #7,%d0
249 btst %d0,fp_debugprint+((31-\bit)/8)
250#else
251 btst #\bit,fp_debugprint+((31-\bit)/8)
252#endif
253 jeq .Lpskip\@
254 .endif
255 movestack \nr,\arg1,\arg2,\arg3,\arg4,\arg5
256 pea .Lpdata\@
257 jsr printk
258 lea ((\nr+1)*4,%sp),%sp
259.Lpskip\@:
260 movem.l (%sp)+,%d0/%d1/%a0/%a1
261#endif
262.endm
263
264.macro printx bit,fp
265#ifdef FPU_EMU_DEBUG
266 movem.l %d0/%a0,-(%sp)
267 lea \fp,%a0
268#if 0
269 moveq #'+',%d0
270 tst.w (%a0)
271 jeq .Lx1\@
272 moveq #'-',%d0
273.Lx1\@: printf \bit," %c",1,%d0
274 move.l (4,%a0),%d0
275 bclr #31,%d0
276 jne .Lx2\@
277 printf \bit,"0."
278 jra .Lx3\@
279.Lx2\@: printf \bit,"1."
280.Lx3\@: printf \bit,"%08x%08x",2,%d0,%a0@(8)
281 move.w (2,%a0),%d0
282 ext.l %d0
283 printf \bit,"E%04x",1,%d0
284#else
285 printf \bit," %08x%08x%08x",3,%a0@,%a0@(4),%a0@(8)
286#endif
287 movem.l (%sp)+,%d0/%a0
288#endif
289.endm
290
291.macro debug instr,args
292#ifdef FPU_EMU_DEBUG
293 \instr \args
294#endif
295.endm
296
297
298#endif /* __ASSEMBLY__ */
299
300#endif /* _ASM_FRV_MATH_EMU_H */
301
diff --git a/include/asm-frv/mb-regs.h b/include/asm-frv/mb-regs.h
new file mode 100644
index 000000000000..c8f575fc42fa
--- /dev/null
+++ b/include/asm-frv/mb-regs.h
@@ -0,0 +1,185 @@
1/* mb-regs.h: motherboard registers
2 *
3 * Copyright (C) 2003, 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_MB_REGS_H
13#define _ASM_MB_REGS_H
14
15#include <asm/cpu-irqs.h>
16#include <asm/sections.h>
17#include <asm/mem-layout.h>
18
19#define __region_IO KERNEL_IO_START /* the region from 0xe0000000 to 0xffffffff has suitable
20 * protection laid over the top for use in memory-mapped
21 * I/O
22 */
23
24#define __region_CS0 0xff000000 /* Boot ROMs area */
25
26#ifdef CONFIG_MB93091_VDK
27/*
28 * VDK motherboard and CPU card specific stuff
29 */
30
31#include <asm/mb93091-fpga-irqs.h>
32
33#define IRQ_CPU_MB93493_0 IRQ_CPU_EXTERNAL0
34#define IRQ_CPU_MB93493_1 IRQ_CPU_EXTERNAL1
35
36#define __region_CS2 0xe0000000 /* SLBUS/PCI I/O space */
37#define __region_CS2_M 0x0fffffff /* mask */
38#define __region_CS2_C 0x00000000 /* control */
39#define __region_CS5 0xf0000000 /* MB93493 CSC area (DAV daughter board) */
40#define __region_CS5_M 0x00ffffff
41#define __region_CS5_C 0x00010000
42#define __region_CS7 0xf1000000 /* CB70 CPU-card PCMCIA port I/O space */
43#define __region_CS7_M 0x00ffffff
44#define __region_CS7_C 0x00410701
45#define __region_CS1 0xfc000000 /* SLBUS/PCI bridge control registers */
46#define __region_CS1_M 0x000fffff
47#define __region_CS1_C 0x00000000
48#define __region_CS6 0xfc100000 /* CB70 CPU-card DM9000 LAN I/O space */
49#define __region_CS6_M 0x000fffff
50#define __region_CS6_C 0x00400707
51#define __region_CS3 0xfc200000 /* MB93493 CSR area (DAV daughter board) */
52#define __region_CS3_M 0x000fffff
53#define __region_CS3_C 0xc8100000
54#define __region_CS4 0xfd000000 /* CB70 CPU-card extra flash space */
55#define __region_CS4_M 0x00ffffff
56#define __region_CS4_C 0x00000f07
57
58#define __region_PCI_IO (__region_CS2 + 0x04000000UL)
59#define __region_PCI_MEM (__region_CS2 + 0x08000000UL)
60#define __flush_PCI_writes() \
61do { \
62 __builtin_write8((volatile void *) __region_PCI_MEM, 0); \
63} while(0)
64
65#define __is_PCI_IO(addr) \
66 (((unsigned long)(addr) >> 24) - (__region_PCI_IO >> 24) < (0x04000000UL >> 24))
67
68#define __is_PCI_MEM(addr) \
69 ((unsigned long)(addr) - __region_PCI_MEM < 0x08000000UL)
70
71#define __get_CLKSW() ({ *(volatile unsigned long *)(__region_CS2 + 0x0130000cUL) & 0xffUL; })
72#define __get_CLKIN() (__get_CLKSW() * 125U * 100000U / 24U)
73
74#ifndef __ASSEMBLY__
75extern int __nongprelbss mb93090_mb00_detected;
76#endif
77
78#define __addr_LEDS() (__region_CS2 + 0x01200004UL)
79#ifdef CONFIG_MB93090_MB00
80#define __set_LEDS(X) \
81do { \
82 if (mb93090_mb00_detected) \
83 __builtin_write32((void *) __addr_LEDS(), ~(X)); \
84} while (0)
85#else
86#define __set_LEDS(X)
87#endif
88
89#define __addr_LCD() (__region_CS2 + 0x01200008UL)
90#define __get_LCD(B) __builtin_read32((volatile void *) (B))
91#define __set_LCD(B,X) __builtin_write32((volatile void *) (B), (X))
92
93#define LCD_D 0x000000ff /* LCD data bus */
94#define LCD_RW 0x00000100 /* LCD R/W signal */
95#define LCD_RS 0x00000200 /* LCD Register Select */
96#define LCD_E 0x00000400 /* LCD Start Enable Signal */
97
98#define LCD_CMD_CLEAR (LCD_E|0x001)
99#define LCD_CMD_HOME (LCD_E|0x002)
100#define LCD_CMD_CURSOR_INC (LCD_E|0x004)
101#define LCD_CMD_SCROLL_INC (LCD_E|0x005)
102#define LCD_CMD_CURSOR_DEC (LCD_E|0x006)
103#define LCD_CMD_SCROLL_DEC (LCD_E|0x007)
104#define LCD_CMD_OFF (LCD_E|0x008)
105#define LCD_CMD_ON(CRSR,BLINK) (LCD_E|0x00c|(CRSR<<1)|BLINK)
106#define LCD_CMD_CURSOR_MOVE_L (LCD_E|0x010)
107#define LCD_CMD_CURSOR_MOVE_R (LCD_E|0x014)
108#define LCD_CMD_DISPLAY_SHIFT_L (LCD_E|0x018)
109#define LCD_CMD_DISPLAY_SHIFT_R (LCD_E|0x01c)
110#define LCD_CMD_FUNCSET(DL,N,F) (LCD_E|0x020|(DL<<4)|(N<<3)|(F<<2))
111#define LCD_CMD_SET_CG_ADDR(X) (LCD_E|0x040|X)
112#define LCD_CMD_SET_DD_ADDR(X) (LCD_E|0x080|X)
113#define LCD_CMD_READ_BUSY (LCD_E|LCD_RW)
114#define LCD_DATA_WRITE(X) (LCD_E|LCD_RS|(X))
115#define LCD_DATA_READ (LCD_E|LCD_RS|LCD_RW)
116
117#else
118/*
119 * PDK unit specific stuff
120 */
121
122#include <asm/mb93093-fpga-irqs.h>
123
124#define IRQ_CPU_MB93493_0 IRQ_CPU_EXTERNAL0
125#define IRQ_CPU_MB93493_1 IRQ_CPU_EXTERNAL1
126
127#define __region_CS5 0xf0000000 /* MB93493 CSC area (DAV daughter board) */
128#define __region_CS5_M 0x00ffffff /* mask */
129#define __region_CS5_C 0x00010000 /* control */
130#define __region_CS2 0x20000000 /* FPGA registers */
131#define __region_CS2_M 0x000fffff
132#define __region_CS2_C 0x00000000
133#define __region_CS1 0xfc100000 /* LAN registers */
134#define __region_CS1_M 0x000fffff
135#define __region_CS1_C 0x00010404
136#define __region_CS3 0xfc200000 /* MB93493 CSR area (DAV daughter board) */
137#define __region_CS3_M 0x000fffff
138#define __region_CS3_C 0xc8000000
139#define __region_CS4 0xfd000000 /* extra ROMs area */
140#define __region_CS4_M 0x00ffffff
141#define __region_CS4_C 0x00000f07
142
143#define __region_CS6 0xfe000000 /* not used - hide behind CPU resource I/O regs */
144#define __region_CS6_M 0x000fffff
145#define __region_CS6_C 0x00000f07
146#define __region_CS7 0xfe000000 /* not used - hide behind CPU resource I/O regs */
147#define __region_CS7_M 0x000fffff
148#define __region_CS7_C 0x00000f07
149
150#define __is_PCI_IO(addr) 0 /* no PCI */
151#define __is_PCI_MEM(addr) 0
152#define __region_PCI_IO 0
153#define __region_PCI_MEM 0
154#define __flush_PCI_writes() do { } while(0)
155
156#define __get_CLKSW() 0UL
157#define __get_CLKIN() 66000000UL
158
159#define __addr_LEDS() (__region_CS2 + 0x00000023UL)
160#define __set_LEDS(X) __builtin_write8((volatile void *) __addr_LEDS(), (X))
161
162#define __addr_FPGATR() (__region_CS2 + 0x00000030UL)
163#define __set_FPGATR(X) __builtin_write32((volatile void *) __addr_FPGATR(), (X))
164#define __get_FPGATR() __builtin_read32((volatile void *) __addr_FPGATR())
165
166#define MB93093_FPGA_FPGATR_AUDIO_CLK 0x00000003
167
168#define __set_FPGATR_AUDIO_CLK(V) \
169 __set_FPGATR((__get_FPGATR() & ~MB93093_FPGA_FPGATR_AUDIO_CLK) | (V))
170
171#define MB93093_FPGA_FPGATR_AUDIO_CLK_OFF 0x0
172#define MB93093_FPGA_FPGATR_AUDIO_CLK_11MHz 0x1
173#define MB93093_FPGA_FPGATR_AUDIO_CLK_12MHz 0x2
174#define MB93093_FPGA_FPGATR_AUDIO_CLK_02MHz 0x3
175
176#define MB93093_FPGA_SWR_PUSHSWMASK (0x1F<<26)
177#define MB93093_FPGA_SWR_PUSHSW4 (1<<29)
178
179#define __addr_FPGA_SWR ((volatile void *)(__region_CS2 + 0x28UL))
180#define __get_FPGA_PUSHSW1_5() (__builtin_read32(__addr_FPGA_SWR) & MB93093_FPGA_SWR_PUSHSWMASK)
181
182
183#endif
184
185#endif /* _ASM_MB_REGS_H */
diff --git a/include/asm-frv/mb86943a.h b/include/asm-frv/mb86943a.h
new file mode 100644
index 000000000000..b89fd0b56bb3
--- /dev/null
+++ b/include/asm-frv/mb86943a.h
@@ -0,0 +1,39 @@
1/* mb86943a.h: MB86943 SPARClite <-> PCI bridge registers
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_MB86943A_H
13#define _ASM_MB86943A_H
14
15#include <asm/mb-regs.h>
16
17#define __reg_MB86943_sl_ctl *(volatile uint32_t *) (__region_CS1 + 0x00)
18
19#define MB86943_SL_CTL_BUS_WIDTH_64 0x00000001
20#define MB86943_SL_CTL_AS_HOST 0x00000002
21#define MB86943_SL_CTL_DRCT_MASTER_SWAP 0x00000004
22#define MB86943_SL_CTL_DRCT_SLAVE_SWAP 0x00000008
23#define MB86943_SL_CTL_PCI_CONFIG_SWAP 0x00000010
24#define MB86943_SL_CTL_ECS0_ENABLE 0x00000020
25#define MB86943_SL_CTL_ECS1_ENABLE 0x00000040
26#define MB86943_SL_CTL_ECS2_ENABLE 0x00000080
27
28#define __reg_MB86943_ecs_ctl(N) *(volatile uint32_t *) (__region_CS1 + 0x08 + (0x08*(N)))
29#define __reg_MB86943_ecs_range(N) *(volatile uint32_t *) (__region_CS1 + 0x20 + (0x10*(N)))
30#define __reg_MB86943_ecs_base(N) *(volatile uint32_t *) (__region_CS1 + 0x28 + (0x10*(N)))
31
32#define __reg_MB86943_sl_pci_io_range *(volatile uint32_t *) (__region_CS1 + 0x50)
33#define __reg_MB86943_sl_pci_io_base *(volatile uint32_t *) (__region_CS1 + 0x58)
34#define __reg_MB86943_sl_pci_mem_range *(volatile uint32_t *) (__region_CS1 + 0x60)
35#define __reg_MB86943_sl_pci_mem_base *(volatile uint32_t *) (__region_CS1 + 0x68)
36#define __reg_MB86943_pci_sl_io_base *(volatile uint32_t *) (__region_CS1 + 0x70)
37#define __reg_MB86943_pci_sl_mem_base *(volatile uint32_t *) (__region_CS1 + 0x78)
38
39#endif /* _ASM_MB86943A_H */
diff --git a/include/asm-frv/mb93091-fpga-irqs.h b/include/asm-frv/mb93091-fpga-irqs.h
new file mode 100644
index 000000000000..341bfc52a0eb
--- /dev/null
+++ b/include/asm-frv/mb93091-fpga-irqs.h
@@ -0,0 +1,44 @@
1/* mb93091-fpga-irqs.h: MB93091 CPU board FPGA IRQs
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_MB93091_FPGA_IRQS_H
13#define _ASM_MB93091_FPGA_IRQS_H
14
15#ifndef __ASSEMBLY__
16
17#include <asm/irq-routing.h>
18
19#define IRQ_BASE_FPGA (NR_IRQ_ACTIONS_PER_GROUP * 1)
20
21/* IRQ IDs presented to drivers */
22enum {
23 IRQ_FPGA__UNUSED = IRQ_BASE_FPGA,
24 IRQ_FPGA_SYSINT_BUS_EXPANSION_1,
25 IRQ_FPGA_SL_BUS_EXPANSION_2,
26 IRQ_FPGA_PCI_INTD,
27 IRQ_FPGA_PCI_INTC,
28 IRQ_FPGA_PCI_INTB,
29 IRQ_FPGA_PCI_INTA,
30 IRQ_FPGA_SL_BUS_EXPANSION_7,
31 IRQ_FPGA_SYSINT_BUS_EXPANSION_8,
32 IRQ_FPGA_SL_BUS_EXPANSION_9,
33 IRQ_FPGA_MB86943_PCI_INTA,
34 IRQ_FPGA_MB86943_SLBUS_SIDE,
35 IRQ_FPGA_RTL8029_INTA,
36 IRQ_FPGA_SYSINT_BUS_EXPANSION_13,
37 IRQ_FPGA_SL_BUS_EXPANSION_14,
38 IRQ_FPGA_NMI,
39};
40
41
42#endif /* !__ASSEMBLY__ */
43
44#endif /* _ASM_MB93091_FPGA_IRQS_H */
diff --git a/include/asm-frv/mb93093-fpga-irqs.h b/include/asm-frv/mb93093-fpga-irqs.h
new file mode 100644
index 000000000000..1e0f11c2fcdb
--- /dev/null
+++ b/include/asm-frv/mb93093-fpga-irqs.h
@@ -0,0 +1,31 @@
1/* mb93093-fpga-irqs.h: MB93093 CPU board FPGA IRQs
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_MB93093_FPGA_IRQS_H
13#define _ASM_MB93093_FPGA_IRQS_H
14
15#ifndef __ASSEMBLY__
16
17#include <asm/irq-routing.h>
18
19#define IRQ_BASE_FPGA (NR_IRQ_ACTIONS_PER_GROUP * 1)
20
21/* IRQ IDs presented to drivers */
22enum {
23 IRQ_FPGA_PUSH_BUTTON_SW1_5 = IRQ_BASE_FPGA + 8,
24 IRQ_FPGA_ROCKER_C_SW8 = IRQ_BASE_FPGA + 9,
25 IRQ_FPGA_ROCKER_C_SW9 = IRQ_BASE_FPGA + 10,
26};
27
28
29#endif /* !__ASSEMBLY__ */
30
31#endif /* _ASM_MB93093_FPGA_IRQS_H */
diff --git a/include/asm-frv/mb93493-irqs.h b/include/asm-frv/mb93493-irqs.h
new file mode 100644
index 000000000000..15096e731325
--- /dev/null
+++ b/include/asm-frv/mb93493-irqs.h
@@ -0,0 +1,52 @@
1/* mb93493-irqs.h: MB93493 companion chip IRQs
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_MB93493_IRQS_H
13#define _ASM_MB93493_IRQS_H
14
15#ifndef __ASSEMBLY__
16
17#include <asm/irq-routing.h>
18
19#define IRQ_BASE_MB93493 (NR_IRQ_ACTIONS_PER_GROUP * 2)
20
21/* IRQ IDs presented to drivers */
22enum {
23 IRQ_MB93493_VDC = IRQ_BASE_MB93493 + 0,
24 IRQ_MB93493_VCC = IRQ_BASE_MB93493 + 1,
25 IRQ_MB93493_AUDIO_OUT = IRQ_BASE_MB93493 + 2,
26 IRQ_MB93493_I2C_0 = IRQ_BASE_MB93493 + 3,
27 IRQ_MB93493_I2C_1 = IRQ_BASE_MB93493 + 4,
28 IRQ_MB93493_USB = IRQ_BASE_MB93493 + 5,
29 IRQ_MB93493_LOCAL_BUS = IRQ_BASE_MB93493 + 7,
30 IRQ_MB93493_PCMCIA = IRQ_BASE_MB93493 + 8,
31 IRQ_MB93493_GPIO = IRQ_BASE_MB93493 + 9,
32 IRQ_MB93493_AUDIO_IN = IRQ_BASE_MB93493 + 10,
33};
34
35/* IRQ multiplexor mappings */
36#define ROUTE_VIA_IRQ0 0 /* route IRQ by way of CPU external IRQ 0 */
37#define ROUTE_VIA_IRQ1 1 /* route IRQ by way of CPU external IRQ 1 */
38
39#define IRQ_MB93493_VDC_ROUTE ROUTE_VIA_IRQ0
40#define IRQ_MB93493_VCC_ROUTE ROUTE_VIA_IRQ1
41#define IRQ_MB93493_AUDIO_OUT_ROUTE ROUTE_VIA_IRQ1
42#define IRQ_MB93493_I2C_0_ROUTE ROUTE_VIA_IRQ1
43#define IRQ_MB93493_I2C_1_ROUTE ROUTE_VIA_IRQ1
44#define IRQ_MB93493_USB_ROUTE ROUTE_VIA_IRQ1
45#define IRQ_MB93493_LOCAL_BUS_ROUTE ROUTE_VIA_IRQ1
46#define IRQ_MB93493_PCMCIA_ROUTE ROUTE_VIA_IRQ1
47#define IRQ_MB93493_GPIO_ROUTE ROUTE_VIA_IRQ1
48#define IRQ_MB93493_AUDIO_IN_ROUTE ROUTE_VIA_IRQ1
49
50#endif /* !__ASSEMBLY__ */
51
52#endif /* _ASM_MB93493_IRQS_H */
diff --git a/include/asm-frv/mb93493-regs.h b/include/asm-frv/mb93493-regs.h
new file mode 100644
index 000000000000..c54aa9d14468
--- /dev/null
+++ b/include/asm-frv/mb93493-regs.h
@@ -0,0 +1,279 @@
1/* mb93493-regs.h: MB93493 companion chip registers
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_MB93493_REGS_H
13#define _ASM_MB93493_REGS_H
14
15#include <asm/mb-regs.h>
16#include <asm/mb93493-irqs.h>
17
18#define __get_MB93493(X) ({ *(volatile unsigned long *)(__region_CS3 + (X)); })
19
20#define __set_MB93493(X,V) \
21do { \
22 *(volatile unsigned long *)(__region_CS3 + (X)) = (V); mb(); \
23} while(0)
24
25#define __get_MB93493_STSR(X) __get_MB93493(0x3c0 + (X) * 4)
26#define __set_MB93493_STSR(X,V) __set_MB93493(0x3c0 + (X) * 4, (V))
27#define MB93493_STSR_EN
28
29#define __get_MB93493_IQSR(X) __get_MB93493(0x3d0 + (X) * 4)
30#define __set_MB93493_IQSR(X,V) __set_MB93493(0x3d0 + (X) * 4, (V))
31
32#define __get_MB93493_DQSR(X) __get_MB93493(0x3e0 + (X) * 4)
33#define __set_MB93493_DQSR(X,V) __set_MB93493(0x3e0 + (X) * 4, (V))
34
35#define __get_MB93493_LBSER() __get_MB93493(0x3f0)
36#define __set_MB93493_LBSER(V) __set_MB93493(0x3f0, (V))
37
38#define MB93493_LBSER_VDC 0x00010000
39#define MB93493_LBSER_VCC 0x00020000
40#define MB93493_LBSER_AUDIO 0x00040000
41#define MB93493_LBSER_I2C_0 0x00080000
42#define MB93493_LBSER_I2C_1 0x00100000
43#define MB93493_LBSER_USB 0x00200000
44#define MB93493_LBSER_GPIO 0x00800000
45#define MB93493_LBSER_PCMCIA 0x01000000
46
47#define __get_MB93493_LBSR() __get_MB93493(0x3fc)
48#define __set_MB93493_LBSR(V) __set_MB93493(0x3fc, (V))
49
50/*
51 * video display controller
52 */
53#define __get_MB93493_VDC(X) __get_MB93493(MB93493_VDC_##X)
54#define __set_MB93493_VDC(X,V) __set_MB93493(MB93493_VDC_##X, (V))
55
56#define MB93493_VDC_RCURSOR 0x140 /* cursor position */
57#define MB93493_VDC_RCT1 0x144 /* cursor colour 1 */
58#define MB93493_VDC_RCT2 0x148 /* cursor colour 2 */
59#define MB93493_VDC_RHDC 0x150 /* horizontal display period */
60#define MB93493_VDC_RH_MARGINS 0x154 /* horizontal margin sizes */
61#define MB93493_VDC_RVDC 0x158 /* vertical display period */
62#define MB93493_VDC_RV_MARGINS 0x15c /* vertical margin sizes */
63#define MB93493_VDC_RC 0x170 /* VDC control */
64#define MB93493_VDC_RCLOCK 0x174 /* clock divider, DMA req delay */
65#define MB93493_VDC_RBLACK 0x178 /* black insert sizes */
66#define MB93493_VDC_RS 0x17c /* VDC status */
67
68#define __addr_MB93493_VDC_BCI(X) ({ (volatile unsigned long *)(__region_CS3 + 0x000 + (X)); })
69#define __addr_MB93493_VDC_TPO(X) (__region_CS3 + 0x1c0 + (X))
70
71#define VDC_TPO_WIDTH 32
72
73#define VDC_RC_DSR 0x00000080 /* VDC master reset */
74
75#define VDC_RS_IT 0x00060000 /* interrupt indicators */
76#define VDC_RS_IT_UNDERFLOW 0x00040000 /* - underflow event */
77#define VDC_RS_IT_VSYNC 0x00020000 /* - VSYNC event */
78#define VDC_RS_DFI 0x00010000 /* current interlace field number */
79#define VDC_RS_DFI_TOP 0x00000000 /* - top field */
80#define VDC_RS_DFI_BOTTOM 0x00010000 /* - bottom field */
81#define VDC_RS_DCSR 0x00000010 /* cursor state */
82#define VDC_RS_DCM 0x00000003 /* display mode */
83#define VDC_RS_DCM_DISABLED 0x00000000 /* - display disabled */
84#define VDC_RS_DCM_STOPPED 0x00000001 /* - VDC stopped */
85#define VDC_RS_DCM_FREERUNNING 0x00000002 /* - VDC free-running */
86#define VDC_RS_DCM_TRANSFERRING 0x00000003 /* - data being transferred to VDC */
87
88/*
89 * video capture controller
90 */
91#define __get_MB93493_VCC(X) __get_MB93493(MB93493_VCC_##X)
92#define __set_MB93493_VCC(X,V) __set_MB93493(MB93493_VCC_##X, (V))
93
94#define MB93493_VCC_RREDUCT 0x104 /* reduction rate */
95#define MB93493_VCC_RHY 0x108 /* horizontal brightness filter coefficients */
96#define MB93493_VCC_RHC 0x10c /* horizontal colour-difference filter coefficients */
97#define MB93493_VCC_RHSIZE 0x110 /* horizontal cycle sizes */
98#define MB93493_VCC_RHBC 0x114 /* horizontal back porch size */
99#define MB93493_VCC_RVCC 0x118 /* vertical capture period */
100#define MB93493_VCC_RVBC 0x11c /* vertical back porch period */
101#define MB93493_VCC_RV 0x120 /* vertical filter coefficients */
102#define MB93493_VCC_RDTS 0x128 /* DMA transfer size */
103#define MB93493_VCC_RDTS_4B 0x01000000 /* 4-byte transfer */
104#define MB93493_VCC_RDTS_32B 0x03000000 /* 32-byte transfer */
105#define MB93493_VCC_RDTS_SHIFT 24
106#define MB93493_VCC_RCC 0x130 /* VCC control */
107#define MB93493_VCC_RIS 0x134 /* VCC interrupt status */
108
109#define __addr_MB93493_VCC_TPI(X) (__region_CS3 + 0x180 + (X))
110
111#define VCC_RHSIZE_RHCC 0x000007ff
112#define VCC_RHSIZE_RHCC_SHIFT 0
113#define VCC_RHSIZE_RHTCC 0x0fff0000
114#define VCC_RHSIZE_RHTCC_SHIFT 16
115
116#define VCC_RVBC_RVBC 0x00003f00
117#define VCC_RVBC_RVBC_SHIFT 8
118
119#define VCC_RREDUCT_RHR 0x07ff0000
120#define VCC_RREDUCT_RHR_SHIFT 16
121#define VCC_RREDUCT_RVR 0x000007ff
122#define VCC_RREDUCT_RVR_SHIFT 0
123
124#define VCC_RCC_CE 0x00000001 /* VCC enable */
125#define VCC_RCC_CS 0x00000002 /* request video capture start */
126#define VCC_RCC_CPF 0x0000000c /* pixel format */
127#define VCC_RCC_CPF_YCBCR_16 0x00000000 /* - YCbCr 4:2:2 16-bit format */
128#define VCC_RCC_CPF_RGB 0x00000004 /* - RGB 4:4:4 format */
129#define VCC_RCC_CPF_YCBCR_24 0x00000008 /* - YCbCr 4:2:2 24-bit format */
130#define VCC_RCC_CPF_BT656 0x0000000c /* - ITU R-BT.656 format */
131#define VCC_RCC_CPF_SHIFT 2
132#define VCC_RCC_CSR 0x00000080 /* request reset */
133#define VCC_RCC_HSIP 0x00000100 /* HSYNC polarity */
134#define VCC_RCC_HSIP_LOACT 0x00000000 /* - low active */
135#define VCC_RCC_HSIP_HIACT 0x00000100 /* - high active */
136#define VCC_RCC_VSIP 0x00000200 /* VSYNC polarity */
137#define VCC_RCC_VSIP_LOACT 0x00000000 /* - low active */
138#define VCC_RCC_VSIP_HIACT 0x00000200 /* - high active */
139#define VCC_RCC_CIE 0x00000800 /* interrupt enable */
140#define VCC_RCC_CFP 0x00001000 /* RGB pixel packing */
141#define VCC_RCC_CFP_4TO3 0x00000000 /* - pack 4 pixels into 3 words */
142#define VCC_RCC_CFP_1TO1 0x00001000 /* - pack 1 pixel into 1 words */
143#define VCC_RCC_CSM 0x00006000 /* interlace specification */
144#define VCC_RCC_CSM_ONEPASS 0x00002000 /* - non-interlaced */
145#define VCC_RCC_CSM_INTERLACE 0x00004000 /* - interlaced */
146#define VCC_RCC_CSM_SHIFT 13
147#define VCC_RCC_ES 0x00008000 /* capture start polarity */
148#define VCC_RCC_ES_NEG 0x00000000 /* - negative edge */
149#define VCC_RCC_ES_POS 0x00008000 /* - positive edge */
150#define VCC_RCC_IFI 0x00080000 /* inferlace field evaluation reverse */
151#define VCC_RCC_FDTS 0x00300000 /* interlace field start */
152#define VCC_RCC_FDTS_3_8 0x00000000 /* - 3/8 of horizontal entire cycle */
153#define VCC_RCC_FDTS_1_4 0x00100000 /* - 1/4 of horizontal entire cycle */
154#define VCC_RCC_FDTS_7_16 0x00200000 /* - 7/16 of horizontal entire cycle */
155#define VCC_RCC_FDTS_SHIFT 20
156#define VCC_RCC_MOV 0x00400000 /* test bit - always set to 1 */
157#define VCC_RCC_STP 0x00800000 /* request video capture stop */
158#define VCC_RCC_TO 0x01000000 /* input during top-field only */
159
160#define VCC_RIS_VSYNC 0x01000000 /* VSYNC interrupt */
161#define VCC_RIS_OV 0x02000000 /* overflow interrupt */
162#define VCC_RIS_BOTTOM 0x08000000 /* interlace bottom field */
163#define VCC_RIS_STARTED 0x10000000 /* capture started */
164
165/*
166 * I2C
167 */
168#define MB93493_I2C_BSR 0x340 /* bus status */
169#define MB93493_I2C_BCR 0x344 /* bus control */
170#define MB93493_I2C_CCR 0x348 /* clock control */
171#define MB93493_I2C_ADR 0x34c /* address */
172#define MB93493_I2C_DTR 0x350 /* data */
173#define MB93493_I2C_BC2R 0x35c /* bus control 2 */
174
175#define __addr_MB93493_I2C(port,X) (__region_CS3 + MB93493_I2C_##X + ((port)*0x20))
176#define __get_MB93493_I2C(port,X) __get_MB93493(MB93493_I2C_##X + ((port)*0x20))
177#define __set_MB93493_I2C(port,X,V) __set_MB93493(MB93493_I2C_##X + ((port)*0x20), (V))
178
179#define I2C_BSR_BB (1 << 7)
180
181/*
182 * audio controller (I2S) registers
183 */
184#define __get_MB93493_I2S(X) __get_MB93493(MB93493_I2S_##X)
185#define __set_MB93493_I2S(X,V) __set_MB93493(MB93493_I2S_##X, (V))
186
187#define MB93493_I2S_ALDR 0x300 /* L-channel data */
188#define MB93493_I2S_ARDR 0x304 /* R-channel data */
189#define MB93493_I2S_APDR 0x308 /* 16-bit packed data */
190#define MB93493_I2S_AISTR 0x310 /* status */
191#define MB93493_I2S_AICR 0x314 /* control */
192
193#define __addr_MB93493_I2S_ALDR(X) (__region_CS3 + MB93493_I2S_ALDR + (X))
194#define __addr_MB93493_I2S_ARDR(X) (__region_CS3 + MB93493_I2S_ARDR + (X))
195#define __addr_MB93493_I2S_APDR(X) (__region_CS3 + MB93493_I2S_APDR + (X))
196#define __addr_MB93493_I2S_ADR(X) (__region_CS3 + 0x320 + (X))
197
198#define I2S_AISTR_OTST 0x00000003 /* status of output data transfer */
199#define I2S_AISTR_OTR 0x00000010 /* output transfer request pending */
200#define I2S_AISTR_OUR 0x00000020 /* output FIFO underrun detected */
201#define I2S_AISTR_OOR 0x00000040 /* output FIFO overrun detected */
202#define I2S_AISTR_ODS 0x00000100 /* output DMA transfer size */
203#define I2S_AISTR_ODE 0x00000400 /* output DMA transfer request enable */
204#define I2S_AISTR_OTRIE 0x00001000 /* output transfer request interrupt enable */
205#define I2S_AISTR_OURIE 0x00002000 /* output FIFO underrun interrupt enable */
206#define I2S_AISTR_OORIE 0x00004000 /* output FIFO overrun interrupt enable */
207#define I2S_AISTR__OUT_MASK 0x00007570
208#define I2S_AISTR_ITST 0x00030000 /* status of input data transfer */
209#define I2S_AISTR_ITST_SHIFT 16
210#define I2S_AISTR_ITR 0x00100000 /* input transfer request pending */
211#define I2S_AISTR_IUR 0x00200000 /* input FIFO underrun detected */
212#define I2S_AISTR_IOR 0x00400000 /* input FIFO overrun detected */
213#define I2S_AISTR_IDS 0x01000000 /* input DMA transfer size */
214#define I2S_AISTR_IDE 0x04000000 /* input DMA transfer request enable */
215#define I2S_AISTR_ITRIE 0x10000000 /* input transfer request interrupt enable */
216#define I2S_AISTR_IURIE 0x20000000 /* input FIFO underrun interrupt enable */
217#define I2S_AISTR_IORIE 0x40000000 /* input FIFO overrun interrupt enable */
218#define I2S_AISTR__IN_MASK 0x75700000
219
220#define I2S_AICR_MI 0x00000001 /* mono input requested */
221#define I2S_AICR_AMI 0x00000002 /* relation between LRCKI/FS1 and SDI */
222#define I2S_AICR_LRI 0x00000004 /* function of LRCKI pin */
223#define I2S_AICR_SDMI 0x00000070 /* format of input audio data */
224#define I2S_AICR_SDMI_SHIFT 4
225#define I2S_AICR_CLI 0x00000080 /* input FIFO clearing control */
226#define I2S_AICR_IM 0x00000300 /* input state control */
227#define I2S_AICR_IM_SHIFT 8
228#define I2S_AICR__IN_MASK 0x000003f7
229#define I2S_AICR_MO 0x00001000 /* mono output requested */
230#define I2S_AICR_AMO 0x00002000 /* relation between LRCKO/FS0 and SDO */
231#define I2S_AICR_AMO_SHIFT 13
232#define I2S_AICR_LRO 0x00004000 /* function of LRCKO pin */
233#define I2S_AICR_SDMO 0x00070000 /* format of output audio data */
234#define I2S_AICR_SDMO_SHIFT 16
235#define I2S_AICR_CLO 0x00080000 /* output FIFO clearing control */
236#define I2S_AICR_OM 0x00100000 /* output state control */
237#define I2S_AICR__OUT_MASK 0x001f7000
238#define I2S_AICR_DIV 0x03000000 /* frequency division rate */
239#define I2S_AICR_DIV_SHIFT 24
240#define I2S_AICR_FL 0x20000000 /* frame length */
241#define I2S_AICR_FS 0x40000000 /* frame sync method */
242#define I2S_AICR_ME 0x80000000 /* master enable */
243
244/*
245 * PCMCIA
246 */
247#define __addr_MB93493_PCMCIA(X) ((volatile unsigned long *)(__region_CS5 + (X)))
248
249/*
250 * GPIO
251 */
252#define __get_MB93493_GPIO_PDR(X) __get_MB93493(0x380 + (X) * 0xc0)
253#define __set_MB93493_GPIO_PDR(X,V) __set_MB93493(0x380 + (X) * 0xc0, (V))
254
255#define __get_MB93493_GPIO_GPDR(X) __get_MB93493(0x384 + (X) * 0xc0)
256#define __set_MB93493_GPIO_GPDR(X,V) __set_MB93493(0x384 + (X) * 0xc0, (V))
257
258#define __get_MB93493_GPIO_SIR(X) __get_MB93493(0x388 + (X) * 0xc0)
259#define __set_MB93493_GPIO_SIR(X,V) __set_MB93493(0x388 + (X) * 0xc0, (V))
260
261#define __get_MB93493_GPIO_SOR(X) __get_MB93493(0x38c + (X) * 0xc0)
262#define __set_MB93493_GPIO_SOR(X,V) __set_MB93493(0x38c + (X) * 0xc0, (V))
263
264#define __get_MB93493_GPIO_PDSR(X) __get_MB93493(0x390 + (X) * 0xc0)
265#define __set_MB93493_GPIO_PDSR(X,V) __set_MB93493(0x390 + (X) * 0xc0, (V))
266
267#define __get_MB93493_GPIO_PDCR(X) __get_MB93493(0x394 + (X) * 0xc0)
268#define __set_MB93493_GPIO_PDCR(X,V) __set_MB93493(0x394 + (X) * 0xc0, (V))
269
270#define __get_MB93493_GPIO_INTST(X) __get_MB93493(0x398 + (X) * 0xc0)
271#define __set_MB93493_GPIO_INTST(X,V) __set_MB93493(0x398 + (X) * 0xc0, (V))
272
273#define __get_MB93493_GPIO_IEHL(X) __get_MB93493(0x39c + (X) * 0xc0)
274#define __set_MB93493_GPIO_IEHL(X,V) __set_MB93493(0x39c + (X) * 0xc0, (V))
275
276#define __get_MB93493_GPIO_IELH(X) __get_MB93493(0x3a0 + (X) * 0xc0)
277#define __set_MB93493_GPIO_IELH(X,V) __set_MB93493(0x3a0 + (X) * 0xc0, (V))
278
279#endif /* _ASM_MB93493_REGS_H */
diff --git a/include/asm-frv/mem-layout.h b/include/asm-frv/mem-layout.h
new file mode 100644
index 000000000000..a025dd4514e7
--- /dev/null
+++ b/include/asm-frv/mem-layout.h
@@ -0,0 +1,78 @@
1/* mem-layout.h: memory layout
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_MEM_LAYOUT_H
13#define _ASM_MEM_LAYOUT_H
14
15#ifndef __ASSEMBLY__
16#define __UL(X) ((unsigned long) (X))
17#else
18#define __UL(X) (X)
19#endif
20
21/*
22 * PAGE_SHIFT determines the page size
23 */
24#define PAGE_SHIFT 14
25
26#ifndef __ASSEMBLY__
27#define PAGE_SIZE (1UL << PAGE_SHIFT)
28#else
29#define PAGE_SIZE (1 << PAGE_SHIFT)
30#endif
31
32#define PAGE_MASK (~(PAGE_SIZE-1))
33
34/*****************************************************************************/
35/*
36 * virtual memory layout from kernel's point of view
37 */
38#define PAGE_OFFSET ((unsigned long) &__page_offset)
39
40#ifdef CONFIG_MMU
41
42/* see Documentation/fujitsu/frv/mmu-layout.txt */
43#define KERNEL_LOWMEM_START __UL(0xc0000000)
44#define KERNEL_LOWMEM_END __UL(0xd0000000)
45#define VMALLOC_START __UL(0xd0000000)
46#define VMALLOC_END __UL(0xd8000000)
47#define PKMAP_BASE __UL(0xd8000000)
48#define PKMAP_END __UL(0xdc000000)
49#define KMAP_ATOMIC_SECONDARY_FRAME __UL(0xdc000000)
50#define KMAP_ATOMIC_PRIMARY_FRAME __UL(0xdd000000)
51
52#endif
53
54#define KERNEL_IO_START __UL(0xe0000000)
55
56
57/*****************************************************************************/
58/*
59 * memory layout from userspace's point of view
60 */
61#define BRK_BASE __UL(2 * 1024 * 1024 + PAGE_SIZE)
62#define STACK_TOP __UL(2 * 1024 * 1024)
63
64/* userspace process size */
65#ifdef CONFIG_MMU
66#define TASK_SIZE (PAGE_OFFSET)
67#else
68#define TASK_SIZE __UL(0xFFFFFFFFUL)
69#endif
70
71/* base of area at which unspecified mmaps will start */
72#ifdef CONFIG_BINFMT_ELF_FDPIC
73#define TASK_UNMAPPED_BASE __UL(16 * 1024 * 1024)
74#else
75#define TASK_UNMAPPED_BASE __UL(TASK_SIZE / 3)
76#endif
77
78#endif /* _ASM_MEM_LAYOUT_H */
diff --git a/include/asm-frv/mman.h b/include/asm-frv/mman.h
new file mode 100644
index 000000000000..c684720dfbdd
--- /dev/null
+++ b/include/asm-frv/mman.h
@@ -0,0 +1,44 @@
1#ifndef __ASM_MMAN_H__
2#define __ASM_MMAN_H__
3
4#define PROT_READ 0x1 /* page can be read */
5#define PROT_WRITE 0x2 /* page can be written */
6#define PROT_EXEC 0x4 /* page can be executed */
7#define PROT_SEM 0x8 /* page may be used for atomic ops */
8#define PROT_NONE 0x0 /* page can not be accessed */
9#define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
10#define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
11
12#define MAP_SHARED 0x01 /* Share changes */
13#define MAP_PRIVATE 0x02 /* Changes are private */
14#define MAP_TYPE 0x0f /* Mask for type of mapping */
15#define MAP_FIXED 0x10 /* Interpret addr exactly */
16#define MAP_ANONYMOUS 0x20 /* don't use a file */
17
18#define MAP_GROWSDOWN 0x0100 /* stack-like segment */
19#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
20#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
21#define MAP_LOCKED 0x2000 /* pages are locked */
22#define MAP_NORESERVE 0x4000 /* don't check for reservations */
23#define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
24#define MAP_NONBLOCK 0x10000 /* do not block on IO */
25
26#define MS_ASYNC 1 /* sync memory asynchronously */
27#define MS_INVALIDATE 2 /* invalidate the caches */
28#define MS_SYNC 4 /* synchronous memory sync */
29
30#define MCL_CURRENT 1 /* lock all current mappings */
31#define MCL_FUTURE 2 /* lock all future mappings */
32
33#define MADV_NORMAL 0x0 /* default page-in behavior */
34#define MADV_RANDOM 0x1 /* page-in minimum required */
35#define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */
36#define MADV_WILLNEED 0x3 /* pre-fault pages */
37#define MADV_DONTNEED 0x4 /* discard these pages */
38
39/* compatibility flags */
40#define MAP_ANON MAP_ANONYMOUS
41#define MAP_FILE 0
42
43#endif /* __ASM_MMAN_H__ */
44
diff --git a/include/asm-frv/mmu.h b/include/asm-frv/mmu.h
new file mode 100644
index 000000000000..22c03714fb14
--- /dev/null
+++ b/include/asm-frv/mmu.h
@@ -0,0 +1,42 @@
1/* mmu.h: memory management context for FR-V with or without MMU support
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#ifndef _ASM_MMU_H
12#define _ASM_MMU_H
13
14typedef struct {
15#ifdef CONFIG_MMU
16 struct list_head id_link; /* link in list of context ID owners */
17 unsigned short id; /* MMU context ID */
18 unsigned short id_busy; /* true if ID is in CXNR */
19 unsigned long itlb_cached_pge; /* [SCR0] PGE cached for insn TLB handler */
20 unsigned long itlb_ptd_mapping; /* [DAMR4] PTD mapping for itlb cached PGE */
21 unsigned long dtlb_cached_pge; /* [SCR1] PGE cached for data TLB handler */
22 unsigned long dtlb_ptd_mapping; /* [DAMR5] PTD mapping for dtlb cached PGE */
23
24#else
25 struct vm_list_struct *vmlist;
26 unsigned long end_brk;
27
28#endif
29
30#ifdef CONFIG_BINFMT_ELF_FDPIC
31 unsigned long exec_fdpic_loadmap;
32 unsigned long interp_fdpic_loadmap;
33#endif
34
35} mm_context_t;
36
37#ifdef CONFIG_MMU
38extern int __nongpreldata cxn_pinned;
39extern int cxn_pin_by_pid(pid_t pid);
40#endif
41
42#endif /* _ASM_MMU_H */
diff --git a/include/asm-frv/mmu_context.h b/include/asm-frv/mmu_context.h
new file mode 100644
index 000000000000..4fb9ea3c5bc9
--- /dev/null
+++ b/include/asm-frv/mmu_context.h
@@ -0,0 +1,50 @@
1/* mmu_context.h: MMU context management routines
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_MMU_CONTEXT_H
13#define _ASM_MMU_CONTEXT_H
14
15#include <linux/config.h>
16#include <asm/setup.h>
17#include <asm/page.h>
18#include <asm/pgalloc.h>
19
20static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
21{
22}
23
24#ifdef CONFIG_MMU
25extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
26extern void change_mm_context(mm_context_t *old, mm_context_t *ctx, pgd_t *_pgd);
27extern void destroy_context(struct mm_struct *mm);
28
29#else
30#define init_new_context(tsk, mm) ({ 0; })
31#define change_mm_context(old, ctx, _pml4) do {} while(0)
32#define destroy_context(mm) do {} while(0)
33#endif
34
35#define switch_mm(prev, next, tsk) \
36do { \
37 if (prev != next) \
38 change_mm_context(&prev->context, &next->context, next->pgd); \
39} while(0)
40
41#define activate_mm(prev, next) \
42do { \
43 change_mm_context(&prev->context, &next->context, next->pgd); \
44} while(0)
45
46#define deactivate_mm(tsk, mm) \
47do { \
48} while(0)
49
50#endif
diff --git a/include/asm-frv/module.h b/include/asm-frv/module.h
new file mode 100644
index 000000000000..3223cfaef743
--- /dev/null
+++ b/include/asm-frv/module.h
@@ -0,0 +1,20 @@
1/* module.h: FRV module stuff
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#ifndef _ASM_MODULE_H
12#define _ASM_MODULE_H
13
14#define module_map(x) vmalloc(x)
15#define module_unmap(x) vfree(x)
16#define module_arch_init(x) (0)
17#define arch_init_modules(x) do { } while (0)
18
19#endif /* _ASM_MODULE_H */
20
diff --git a/include/asm-frv/msgbuf.h b/include/asm-frv/msgbuf.h
new file mode 100644
index 000000000000..97ceb55a06fb
--- /dev/null
+++ b/include/asm-frv/msgbuf.h
@@ -0,0 +1,32 @@
1#ifndef _ASM_MSGBUF_H
2#define _ASM_MSGBUF_H
3
4/*
5 * The msqid64_ds structure for FR-V architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 64-bit time_t to solve y2038 problem
11 * - 2 miscellaneous 32-bit values
12 */
13
14struct msqid64_ds {
15 struct ipc64_perm msg_perm;
16 __kernel_time_t msg_stime; /* last msgsnd time */
17 unsigned long __unused1;
18 __kernel_time_t msg_rtime; /* last msgrcv time */
19 unsigned long __unused2;
20 __kernel_time_t msg_ctime; /* last change time */
21 unsigned long __unused3;
22 unsigned long msg_cbytes; /* current number of bytes on queue */
23 unsigned long msg_qnum; /* number of messages in queue */
24 unsigned long msg_qbytes; /* max number of bytes on queue */
25 __kernel_pid_t msg_lspid; /* pid of last msgsnd */
26 __kernel_pid_t msg_lrpid; /* last receive pid */
27 unsigned long __unused4;
28 unsigned long __unused5;
29};
30
31#endif /* _ASM_MSGBUF_H */
32
diff --git a/include/asm-frv/namei.h b/include/asm-frv/namei.h
new file mode 100644
index 000000000000..84ddd6445f23
--- /dev/null
+++ b/include/asm-frv/namei.h
@@ -0,0 +1,18 @@
1/*
2 * asm/namei.h
3 *
4 * Included from linux/fs/namei.c
5 */
6
7#ifndef __ASM_NAMEI_H
8#define __ASM_NAMEI_H
9
10/* This dummy routine maybe changed to something useful
11 * for /usr/gnemul/ emulation stuff.
12 * Look at asm-sparc/namei.h for details.
13 */
14
15#define __emul_prefix() NULL
16
17#endif
18
diff --git a/include/asm-frv/page.h b/include/asm-frv/page.h
new file mode 100644
index 000000000000..f7914f1782b0
--- /dev/null
+++ b/include/asm-frv/page.h
@@ -0,0 +1,105 @@
1#ifndef _ASM_PAGE_H
2#define _ASM_PAGE_H
3
4#ifdef __KERNEL__
5
6#include <linux/config.h>
7#include <asm/virtconvert.h>
8#include <asm/mem-layout.h>
9#include <asm/sections.h>
10#include <asm/setup.h>
11
12#ifndef __ASSEMBLY__
13
14#define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
15#define free_user_page(page, addr) free_page(addr)
16
17#define clear_page(pgaddr) memset((pgaddr), 0, PAGE_SIZE)
18#define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
19
20#define clear_user_page(pgaddr, vaddr, page) memset((pgaddr), 0, PAGE_SIZE)
21#define copy_user_page(vto, vfrom, vaddr, topg) memcpy((vto), (vfrom), PAGE_SIZE)
22
23/*
24 * These are used to make use of C type-checking..
25 */
26typedef struct { unsigned long pte; } pte_t;
27typedef struct { unsigned long ste[64];} pmd_t;
28typedef struct { pmd_t pue[1]; } pud_t;
29typedef struct { pud_t pge[1]; } pgd_t;
30typedef struct { unsigned long pgprot; } pgprot_t;
31
32#define pte_val(x) ((x).pte)
33#define pmd_val(x) ((x).ste[0])
34#define pud_val(x) ((x).pue[0])
35#define pgd_val(x) ((x).pge[0])
36#define pgprot_val(x) ((x).pgprot)
37
38#define __pte(x) ((pte_t) { (x) } )
39#define __pmd(x) ((pmd_t) { (x) } )
40#define __pud(x) ((pud_t) { (x) } )
41#define __pgd(x) ((pgd_t) { (x) } )
42#define __pgprot(x) ((pgprot_t) { (x) } )
43#define PTE_MASK PAGE_MASK
44
45/* to align the pointer to the (next) page boundary */
46#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
47
48/* Pure 2^n version of get_order */
49static inline int get_order(unsigned long size) __attribute_const__;
50static inline int get_order(unsigned long size)
51{
52 int order;
53
54 size = (size - 1) >> (PAGE_SHIFT - 1);
55 order = -1;
56 do {
57 size >>= 1;
58 order++;
59 } while (size);
60 return order;
61}
62
63#define devmem_is_allowed(pfn) 1
64
65#define __pa(vaddr) virt_to_phys((void *) vaddr)
66#define __va(paddr) phys_to_virt((unsigned long) paddr)
67
68#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
69
70extern unsigned long max_low_pfn;
71extern unsigned long min_low_pfn;
72extern unsigned long max_pfn;
73
74#ifdef CONFIG_MMU
75#define pfn_to_page(pfn) (mem_map + (pfn))
76#define page_to_pfn(page) ((unsigned long) ((page) - mem_map))
77#define pfn_valid(pfn) ((pfn) < max_mapnr)
78
79#else
80#define pfn_to_page(pfn) (&mem_map[(pfn) - (PAGE_OFFSET >> PAGE_SHIFT)])
81#define page_to_pfn(page) ((PAGE_OFFSET >> PAGE_SHIFT) + (unsigned long) ((page) - mem_map))
82#define pfn_valid(pfn) ((pfn) >= min_low_pfn && (pfn) < max_low_pfn)
83
84#endif
85
86#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
87#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
88
89
90#ifdef CONFIG_MMU
91#define VM_DATA_DEFAULT_FLAGS \
92 (VM_READ | VM_WRITE | \
93 ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
94 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
95#endif
96
97#endif /* __ASSEMBLY__ */
98
99#endif /* __KERNEL__ */
100
101#ifdef CONFIG_CONTIGUOUS_PAGE_ALLOC
102#define WANT_PAGE_VIRTUAL 1
103#endif
104
105#endif /* _ASM_PAGE_H */
diff --git a/include/asm-frv/param.h b/include/asm-frv/param.h
new file mode 100644
index 000000000000..168381ebb41a
--- /dev/null
+++ b/include/asm-frv/param.h
@@ -0,0 +1,23 @@
1#ifndef _ASM_PARAM_H
2#define _ASM_PARAM_H
3
4#ifdef __KERNEL__
5#define HZ 1000 /* Internal kernel timer frequency */
6#define USER_HZ 100 /* .. some user interfaces are in "ticks" */
7#define CLOCKS_PER_SEC (USER_HZ) /* like times() */
8#endif
9
10#ifndef HZ
11#define HZ 100
12#endif
13
14#define EXEC_PAGESIZE 16384
15
16#ifndef NOGROUP
17#define NOGROUP (-1)
18#endif
19
20#define MAXHOSTNAMELEN 64 /* max length of hostname */
21#define COMMAND_LINE_SIZE 512
22
23#endif /* _ASM_PARAM_H */
diff --git a/include/asm-frv/pci.h b/include/asm-frv/pci.h
new file mode 100644
index 000000000000..a6a469231f62
--- /dev/null
+++ b/include/asm-frv/pci.h
@@ -0,0 +1,108 @@
1/* pci.h: FR-V specific PCI declarations
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 * - Derived from include/asm-m68k/pci.h
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#ifndef ASM_PCI_H
14#define ASM_PCI_H
15
16#include <linux/config.h>
17#include <linux/mm.h>
18#include <asm/scatterlist.h>
19#include <asm-generic/pci-dma-compat.h>
20#include <asm-generic/pci.h>
21
22struct pci_dev;
23
24#define pcibios_assign_all_busses() 0
25
26static inline void pcibios_add_platform_entries(struct pci_dev *dev)
27{
28}
29
30extern void pcibios_set_master(struct pci_dev *dev);
31
32extern void pcibios_penalize_isa_irq(int irq);
33
34#ifdef CONFIG_MMU
35extern void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle);
36extern void consistent_free(void *vaddr);
37extern void consistent_sync(void *vaddr, size_t size, int direction);
38extern void consistent_sync_page(struct page *page, unsigned long offset,
39 size_t size, int direction);
40#endif
41
42extern void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
43 dma_addr_t *dma_handle);
44
45extern void pci_free_consistent(struct pci_dev *hwdev, size_t size,
46 void *vaddr, dma_addr_t dma_handle);
47
48/* This is always fine. */
49#define pci_dac_dma_supported(pci_dev, mask) (1)
50
51/* Return the index of the PCI controller for device PDEV. */
52#define pci_controller_num(PDEV) (0)
53
54/* The PCI address space does equal the physical memory
55 * address space. The networking and block device layers use
56 * this boolean for bounce buffer decisions.
57 */
58#define PCI_DMA_BUS_IS_PHYS (1)
59
60/*
61 * These are pretty much arbitary with the CoMEM implementation.
62 * We have the whole address space to ourselves.
63 */
64#define PCIBIOS_MIN_IO 0x100
65#define PCIBIOS_MIN_MEM 0x00010000
66
67/* Make physical memory consistent for a single
68 * streaming mode DMA translation after a transfer.
69 *
70 * If you perform a pci_map_single() but wish to interrogate the
71 * buffer using the cpu, yet do not wish to teardown the PCI dma
72 * mapping, you must call this function before doing so. At the
73 * next point you give the PCI dma address back to the card, the
74 * device again owns the buffer.
75 */
76static inline void pci_dma_sync_single(struct pci_dev *hwdev,
77 dma_addr_t dma_handle,
78 size_t size, int direction)
79{
80 if (direction == PCI_DMA_NONE)
81 BUG();
82
83 frv_cache_wback_inv((unsigned long)bus_to_virt(dma_handle),
84 (unsigned long)bus_to_virt(dma_handle) + size);
85}
86
87/* Make physical memory consistent for a set of streaming
88 * mode DMA translations after a transfer.
89 *
90 * The same as pci_dma_sync_single but for a scatter-gather list,
91 * same rules and usage.
92 */
93static inline void pci_dma_sync_sg(struct pci_dev *hwdev,
94 struct scatterlist *sg,
95 int nelems, int direction)
96{
97 int i;
98
99 if (direction == PCI_DMA_NONE)
100 BUG();
101
102 for (i = 0; i < nelems; i++)
103 frv_cache_wback_inv(sg_dma_address(&sg[i]),
104 sg_dma_address(&sg[i])+sg_dma_len(&sg[i]));
105}
106
107
108#endif
diff --git a/include/asm-frv/percpu.h b/include/asm-frv/percpu.h
new file mode 100644
index 000000000000..2cad3f874ded
--- /dev/null
+++ b/include/asm-frv/percpu.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_PERCPU_H
2#define __ASM_PERCPU_H
3
4#include <asm-generic/percpu.h>
5
6#endif /* __ASM_PERCPU_H */
diff --git a/include/asm-frv/pgalloc.h b/include/asm-frv/pgalloc.h
new file mode 100644
index 000000000000..1bd28f41bfa8
--- /dev/null
+++ b/include/asm-frv/pgalloc.h
@@ -0,0 +1,64 @@
1/* pgalloc.h: Page allocation routines for FRV
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 * Derived from:
12 * include/asm-m68knommu/pgalloc.h
13 * include/asm-i386/pgalloc.h
14 */
15#ifndef _ASM_PGALLOC_H
16#define _ASM_PGALLOC_H
17
18#include <linux/config.h>
19#include <asm/setup.h>
20#include <asm/virtconvert.h>
21
22#ifdef CONFIG_MMU
23
24#define pmd_populate_kernel(mm, pmd, pte) __set_pmd(pmd, __pa(pte) | _PAGE_TABLE)
25#define pmd_populate(MM, PMD, PAGE) \
26do { \
27 __set_pmd((PMD), page_to_pfn(PAGE) << PAGE_SHIFT | _PAGE_TABLE); \
28} while(0)
29
30/*
31 * Allocate and free page tables.
32 */
33
34extern pgd_t *pgd_alloc(struct mm_struct *);
35extern void pgd_free(pgd_t *);
36
37extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long);
38
39extern struct page *pte_alloc_one(struct mm_struct *, unsigned long);
40
41static inline void pte_free_kernel(pte_t *pte)
42{
43 free_page((unsigned long)pte);
44}
45
46static inline void pte_free(struct page *pte)
47{
48 __free_page(pte);
49}
50
51#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
52
53/*
54 * allocating and freeing a pmd is trivial: the 1-entry pmd is
55 * inside the pgd, so has no extra memory associated with it.
56 * (In the PAE case we free the pmds as part of the pgd.)
57 */
58#define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *) 2); })
59#define pmd_free(x) do { } while (0)
60#define __pmd_free_tlb(tlb,x) do { } while (0)
61
62#endif /* CONFIG_MMU */
63
64#endif /* _ASM_PGALLOC_H */
diff --git a/include/asm-frv/pgtable.h b/include/asm-frv/pgtable.h
new file mode 100644
index 000000000000..cc1373c4b790
--- /dev/null
+++ b/include/asm-frv/pgtable.h
@@ -0,0 +1,555 @@
1/* pgtable.h: FR-V page table mangling
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 * Derived from:
12 * include/asm-m68knommu/pgtable.h
13 * include/asm-i386/pgtable.h
14 */
15
16#ifndef _ASM_PGTABLE_H
17#define _ASM_PGTABLE_H
18
19#include <linux/config.h>
20#include <asm/mem-layout.h>
21#include <asm/setup.h>
22#include <asm/processor.h>
23
24#ifndef __ASSEMBLY__
25#include <linux/threads.h>
26#include <linux/slab.h>
27#include <linux/list.h>
28#include <linux/spinlock.h>
29#endif
30
31#ifndef __ASSEMBLY__
32#if defined(CONFIG_HIGHPTE)
33typedef unsigned long pte_addr_t;
34#else
35typedef pte_t *pte_addr_t;
36#endif
37#endif
38
39/*****************************************************************************/
40/*
41 * MMU-less operation case first
42 */
43#ifndef CONFIG_MMU
44
45#define pgd_present(pgd) (1) /* pages are always present on NO_MM */
46#define pgd_none(pgd) (0)
47#define pgd_bad(pgd) (0)
48#define pgd_clear(pgdp)
49#define kern_addr_valid(addr) (1)
50#define pmd_offset(a, b) ((void *) 0)
51
52#define PAGE_NONE __pgprot(0) /* these mean nothing to NO_MM */
53#define PAGE_SHARED __pgprot(0) /* these mean nothing to NO_MM */
54#define PAGE_COPY __pgprot(0) /* these mean nothing to NO_MM */
55#define PAGE_READONLY __pgprot(0) /* these mean nothing to NO_MM */
56#define PAGE_KERNEL __pgprot(0) /* these mean nothing to NO_MM */
57
58#define __swp_type(x) (0)
59#define __swp_offset(x) (0)
60#define __swp_entry(typ,off) ((swp_entry_t) { ((typ) | ((off) << 7)) })
61#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
62#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
63
64#ifndef __ASSEMBLY__
65static inline int pte_file(pte_t pte) { return 0; }
66#endif
67
68#define ZERO_PAGE(vaddr) ({ BUG(); NULL; })
69
70#define swapper_pg_dir ((pgd_t *) NULL)
71
72#define pgtable_cache_init() do {} while(0)
73
74#else /* !CONFIG_MMU */
75/*****************************************************************************/
76/*
77 * then MMU operation
78 */
79
80/*
81 * ZERO_PAGE is a global shared page that is always zero: used
82 * for zero-mapped memory areas etc..
83 */
84#ifndef __ASSEMBLY__
85extern unsigned long empty_zero_page;
86#define ZERO_PAGE(vaddr) virt_to_page(empty_zero_page)
87#endif
88
89/*
90 * we use 2-level page tables, folding the PMD (mid-level table) into the PGE (top-level entry)
91 * [see Documentation/fujitsu/frv/mmu-layout.txt]
92 *
93 * Page Directory:
94 * - Size: 16KB
95 * - 64 PGEs per PGD
96 * - Each PGE holds 1 PUD and covers 64MB
97 *
98 * Page Upper Directory:
99 * - Size: 256B
100 * - 1 PUE per PUD
101 * - Each PUE holds 1 PMD and covers 64MB
102 *
103 * Page Mid-Level Directory
104 * - Size: 256B
105 * - 1 PME per PMD
106 * - Each PME holds 64 STEs, all of which point to separate chunks of the same Page Table
107 * - All STEs are instantiated at the same time
108 *
109 * Page Table
110 * - Size: 16KB
111 * - 4096 PTEs per PT
112 * - Each Linux PT is subdivided into 64 FR451 PT's, each of which holds 64 entries
113 *
114 * Pages
115 * - Size: 4KB
116 *
117 * total PTEs
118 * = 1 PML4E * 64 PGEs * 1 PUEs * 1 PMEs * 4096 PTEs
119 * = 1 PML4E * 64 PGEs * 64 STEs * 64 PTEs/FR451-PT
120 * = 262144 (or 256 * 1024)
121 */
122#define PGDIR_SHIFT 26
123#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
124#define PGDIR_MASK (~(PGDIR_SIZE - 1))
125#define PTRS_PER_PGD 64
126
127#define PUD_SHIFT 26
128#define PTRS_PER_PUD 1
129#define PUD_SIZE (1UL << PUD_SHIFT)
130#define PUD_MASK (~(PUD_SIZE - 1))
131#define PUE_SIZE 256
132
133#define PMD_SHIFT 26
134#define PMD_SIZE (1UL << PMD_SHIFT)
135#define PMD_MASK (~(PMD_SIZE - 1))
136#define PTRS_PER_PMD 1
137#define PME_SIZE 256
138
139#define __frv_PT_SIZE 256
140
141#define PTRS_PER_PTE 4096
142
143#define USER_PGDS_IN_LAST_PML4 (TASK_SIZE / PGDIR_SIZE)
144#define FIRST_USER_PGD_NR 0
145
146#define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
147#define KERNEL_PGD_PTRS (PTRS_PER_PGD - USER_PGD_PTRS)
148
149#define TWOLEVEL_PGDIR_SHIFT 26
150#define BOOT_USER_PGD_PTRS (__PAGE_OFFSET >> TWOLEVEL_PGDIR_SHIFT)
151#define BOOT_KERNEL_PGD_PTRS (PTRS_PER_PGD - BOOT_USER_PGD_PTRS)
152
153#ifndef __ASSEMBLY__
154
155extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
156
157#define pte_ERROR(e) \
158 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte)
159#define pmd_ERROR(e) \
160 printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
161#define pud_ERROR(e) \
162 printk("%s:%d: bad pud %08lx.\n", __FILE__, __LINE__, pmd_val(pud_val(e)))
163#define pgd_ERROR(e) \
164 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pmd_val(pud_val(pgd_val(e))))
165
166/*
167 * Certain architectures need to do special things when PTEs
168 * within a page table are directly modified. Thus, the following
169 * hook is made available.
170 */
171#define set_pte(pteptr, pteval) \
172do { \
173 *(pteptr) = (pteval); \
174 asm volatile("dcf %M0" :: "U"(*pteptr)); \
175} while(0)
176#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
177
178#define set_pte_atomic(pteptr, pteval) set_pte((pteptr), (pteval))
179
180/*
181 * pgd_offset() returns a (pgd_t *)
182 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
183 */
184#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
185
186/*
187 * a shortcut which implies the use of the kernel's pgd, instead
188 * of a process's
189 */
190#define pgd_offset_k(address) pgd_offset(&init_mm, address)
191
192/*
193 * The "pgd_xxx()" functions here are trivial for a folded two-level
194 * setup: the pud is never bad, and a pud always exists (as it's folded
195 * into the pgd entry)
196 */
197static inline int pgd_none(pgd_t pgd) { return 0; }
198static inline int pgd_bad(pgd_t pgd) { return 0; }
199static inline int pgd_present(pgd_t pgd) { return 1; }
200static inline void pgd_clear(pgd_t *pgd) { }
201
202#define pgd_populate(mm, pgd, pud) do { } while (0)
203/*
204 * (puds are folded into pgds so this doesn't get actually called,
205 * but the define is needed for a generic inline function.)
206 */
207#define set_pgd(pgdptr, pgdval) \
208do { \
209 memcpy((pgdptr), &(pgdval), sizeof(pgd_t)); \
210 asm volatile("dcf %M0" :: "U"(*(pgdptr))); \
211} while(0)
212
213static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
214{
215 return (pud_t *) pgd;
216}
217
218#define pgd_page(pgd) (pud_page((pud_t){ pgd }))
219#define pgd_page_kernel(pgd) (pud_page_kernel((pud_t){ pgd }))
220
221/*
222 * allocating and freeing a pud is trivial: the 1-entry pud is
223 * inside the pgd, so has no extra memory associated with it.
224 */
225#define pud_alloc_one(mm, address) NULL
226#define pud_free(x) do { } while (0)
227#define __pud_free_tlb(tlb, x) do { } while (0)
228
229/*
230 * The "pud_xxx()" functions here are trivial for a folded two-level
231 * setup: the pmd is never bad, and a pmd always exists (as it's folded
232 * into the pud entry)
233 */
234static inline int pud_none(pud_t pud) { return 0; }
235static inline int pud_bad(pud_t pud) { return 0; }
236static inline int pud_present(pud_t pud) { return 1; }
237static inline void pud_clear(pud_t *pud) { }
238
239#define pud_populate(mm, pmd, pte) do { } while (0)
240
241/*
242 * (pmds are folded into puds so this doesn't get actually called,
243 * but the define is needed for a generic inline function.)
244 */
245#define set_pud(pudptr, pudval) set_pmd((pmd_t *)(pudptr), (pmd_t) { pudval })
246
247#define pud_page(pud) (pmd_page((pmd_t){ pud }))
248#define pud_page_kernel(pud) (pmd_page_kernel((pmd_t){ pud }))
249
250/*
251 * (pmds are folded into pgds so this doesn't get actually called,
252 * but the define is needed for a generic inline function.)
253 */
254extern void __set_pmd(pmd_t *pmdptr, unsigned long __pmd);
255
256#define set_pmd(pmdptr, pmdval) \
257do { \
258 __set_pmd((pmdptr), (pmdval).ste[0]); \
259} while(0)
260
261#define __pmd_index(address) 0
262
263static inline pmd_t *pmd_offset(pud_t *dir, unsigned long address)
264{
265 return (pmd_t *) dir + __pmd_index(address);
266}
267
268#define pte_same(a, b) ((a).pte == (b).pte)
269#define pte_page(x) (mem_map + ((unsigned long)(((x).pte >> PAGE_SHIFT))))
270#define pte_none(x) (!(x).pte)
271#define pte_pfn(x) ((unsigned long)(((x).pte >> PAGE_SHIFT)))
272#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
273#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
274
275#define VMALLOC_VMADDR(x) ((unsigned long) (x))
276
277#endif /* !__ASSEMBLY__ */
278
279/*
280 * control flags in AMPR registers and TLB entries
281 */
282#define _PAGE_BIT_PRESENT xAMPRx_V_BIT
283#define _PAGE_BIT_WP DAMPRx_WP_BIT
284#define _PAGE_BIT_NOCACHE xAMPRx_C_BIT
285#define _PAGE_BIT_SUPER xAMPRx_S_BIT
286#define _PAGE_BIT_ACCESSED xAMPRx_RESERVED8_BIT
287#define _PAGE_BIT_DIRTY xAMPRx_M_BIT
288#define _PAGE_BIT_NOTGLOBAL xAMPRx_NG_BIT
289
290#define _PAGE_PRESENT xAMPRx_V
291#define _PAGE_WP DAMPRx_WP
292#define _PAGE_NOCACHE xAMPRx_C
293#define _PAGE_SUPER xAMPRx_S
294#define _PAGE_ACCESSED xAMPRx_RESERVED8 /* accessed if set */
295#define _PAGE_DIRTY xAMPRx_M
296#define _PAGE_NOTGLOBAL xAMPRx_NG
297
298#define _PAGE_RESERVED_MASK (xAMPRx_RESERVED8 | xAMPRx_RESERVED13)
299
300#define _PAGE_FILE 0x002 /* set:pagecache unset:swap */
301#define _PAGE_PROTNONE 0x000 /* If not present */
302
303#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
304
305#define __PGPROT_BASE \
306 (_PAGE_PRESENT | xAMPRx_SS_16Kb | xAMPRx_D | _PAGE_NOTGLOBAL | _PAGE_ACCESSED)
307
308#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
309#define PAGE_SHARED __pgprot(__PGPROT_BASE)
310#define PAGE_COPY __pgprot(__PGPROT_BASE | _PAGE_WP)
311#define PAGE_READONLY __pgprot(__PGPROT_BASE | _PAGE_WP)
312
313#define __PAGE_KERNEL (__PGPROT_BASE | _PAGE_SUPER | _PAGE_DIRTY)
314#define __PAGE_KERNEL_NOCACHE (__PGPROT_BASE | _PAGE_SUPER | _PAGE_DIRTY | _PAGE_NOCACHE)
315#define __PAGE_KERNEL_RO (__PGPROT_BASE | _PAGE_SUPER | _PAGE_DIRTY | _PAGE_WP)
316
317#define MAKE_GLOBAL(x) __pgprot((x) & ~_PAGE_NOTGLOBAL)
318
319#define PAGE_KERNEL MAKE_GLOBAL(__PAGE_KERNEL)
320#define PAGE_KERNEL_RO MAKE_GLOBAL(__PAGE_KERNEL_RO)
321#define PAGE_KERNEL_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_NOCACHE)
322
323#define _PAGE_TABLE (_PAGE_PRESENT | xAMPRx_SS_16Kb)
324
325#ifndef __ASSEMBLY__
326
327/*
328 * The FR451 can do execute protection by virtue of having separate TLB miss handlers for
329 * instruction access and for data access. However, we don't have enough reserved bits to say
330 * "execute only", so we don't bother. If you can read it, you can execute it and vice versa.
331 */
332#define __P000 PAGE_NONE
333#define __P001 PAGE_READONLY
334#define __P010 PAGE_COPY
335#define __P011 PAGE_COPY
336#define __P100 PAGE_READONLY
337#define __P101 PAGE_READONLY
338#define __P110 PAGE_COPY
339#define __P111 PAGE_COPY
340
341#define __S000 PAGE_NONE
342#define __S001 PAGE_READONLY
343#define __S010 PAGE_SHARED
344#define __S011 PAGE_SHARED
345#define __S100 PAGE_READONLY
346#define __S101 PAGE_READONLY
347#define __S110 PAGE_SHARED
348#define __S111 PAGE_SHARED
349
350/*
351 * Define this to warn about kernel memory accesses that are
352 * done without a 'verify_area(VERIFY_WRITE,..)'
353 */
354#undef TEST_VERIFY_AREA
355
356#define pte_present(x) (pte_val(x) & _PAGE_PRESENT)
357#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
358
359#define pmd_none(x) (!pmd_val(x))
360#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
361#define pmd_bad(x) (pmd_val(x) & xAMPRx_SS)
362#define pmd_clear(xp) do { __set_pmd(xp, 0); } while(0)
363
364#define pmd_page_kernel(pmd) \
365 ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
366
367#ifndef CONFIG_DISCONTIGMEM
368#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
369#endif
370
371#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
372
373/*
374 * The following only work if pte_present() is true.
375 * Undefined behaviour if not..
376 */
377static inline int pte_read(pte_t pte) { return !((pte).pte & _PAGE_SUPER); }
378static inline int pte_exec(pte_t pte) { return !((pte).pte & _PAGE_SUPER); }
379static inline int pte_dirty(pte_t pte) { return (pte).pte & _PAGE_DIRTY; }
380static inline int pte_young(pte_t pte) { return (pte).pte & _PAGE_ACCESSED; }
381static inline int pte_write(pte_t pte) { return !((pte).pte & _PAGE_WP); }
382
383static inline pte_t pte_rdprotect(pte_t pte) { (pte).pte |= _PAGE_SUPER; return pte; }
384static inline pte_t pte_exprotect(pte_t pte) { (pte).pte |= _PAGE_SUPER; return pte; }
385static inline pte_t pte_mkclean(pte_t pte) { (pte).pte &= ~_PAGE_DIRTY; return pte; }
386static inline pte_t pte_mkold(pte_t pte) { (pte).pte &= ~_PAGE_ACCESSED; return pte; }
387static inline pte_t pte_wrprotect(pte_t pte) { (pte).pte |= _PAGE_WP; return pte; }
388static inline pte_t pte_mkread(pte_t pte) { (pte).pte &= ~_PAGE_SUPER; return pte; }
389static inline pte_t pte_mkexec(pte_t pte) { (pte).pte &= ~_PAGE_SUPER; return pte; }
390static inline pte_t pte_mkdirty(pte_t pte) { (pte).pte |= _PAGE_DIRTY; return pte; }
391static inline pte_t pte_mkyoung(pte_t pte) { (pte).pte |= _PAGE_ACCESSED; return pte; }
392static inline pte_t pte_mkwrite(pte_t pte) { (pte).pte &= ~_PAGE_WP; return pte; }
393
394static inline int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
395{
396 int i = test_and_clear_bit(_PAGE_BIT_DIRTY, ptep);
397 asm volatile("dcf %M0" :: "U"(*ptep));
398 return i;
399}
400
401static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
402{
403 int i = test_and_clear_bit(_PAGE_BIT_ACCESSED, ptep);
404 asm volatile("dcf %M0" :: "U"(*ptep));
405 return i;
406}
407
408static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
409{
410 unsigned long x = xchg(&ptep->pte, 0);
411 asm volatile("dcf %M0" :: "U"(*ptep));
412 return __pte(x);
413}
414
415static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
416{
417 set_bit(_PAGE_BIT_WP, ptep);
418 asm volatile("dcf %M0" :: "U"(*ptep));
419}
420
421/*
422 * Conversion functions: convert a page and protection to a page entry,
423 * and a page entry and page directory to the page they refer to.
424 */
425
426#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
427#define mk_pte_huge(entry) ((entry).pte_low |= _PAGE_PRESENT | _PAGE_PSE)
428
429/* This takes a physical page address that is used by the remapping functions */
430#define mk_pte_phys(physpage, pgprot) pfn_pte((physpage) >> PAGE_SHIFT, pgprot)
431
432static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
433{
434 pte.pte &= _PAGE_CHG_MASK;
435 pte.pte |= pgprot_val(newprot);
436 return pte;
437}
438
439#define page_pte(page) page_pte_prot((page), __pgprot(0))
440
441/* to find an entry in a page-table-directory. */
442#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
443#define pgd_index_k(addr) pgd_index(addr)
444
445/* Find an entry in the bottom-level page table.. */
446#define __pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
447
448/*
449 * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE]
450 *
451 * this macro returns the index of the entry in the pte page which would
452 * control the given virtual address
453 */
454#define pte_index(address) \
455 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
456#define pte_offset_kernel(dir, address) \
457 ((pte_t *) pmd_page_kernel(*(dir)) + pte_index(address))
458
459#if defined(CONFIG_HIGHPTE)
460#define pte_offset_map(dir, address) \
461 ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address))
462#define pte_offset_map_nested(dir, address) \
463 ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE1) + pte_index(address))
464#define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0)
465#define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
466#else
467#define pte_offset_map(dir, address) \
468 ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
469#define pte_offset_map_nested(dir, address) pte_offset_map((dir), (address))
470#define pte_unmap(pte) do { } while (0)
471#define pte_unmap_nested(pte) do { } while (0)
472#endif
473
474/*
475 * Handle swap and file entries
476 * - the PTE is encoded in the following format:
477 * bit 0: Must be 0 (!_PAGE_PRESENT)
478 * bit 1: Type: 0 for swap, 1 for file (_PAGE_FILE)
479 * bits 2-7: Swap type
480 * bits 8-31: Swap offset
481 * bits 2-31: File pgoff
482 */
483#define __swp_type(x) (((x).val >> 2) & 0x1f)
484#define __swp_offset(x) ((x).val >> 8)
485#define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 2) | ((offset) << 8) })
486#define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte })
487#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
488
489static inline int pte_file(pte_t pte)
490{
491 return pte.pte & _PAGE_FILE;
492}
493
494#define PTE_FILE_MAX_BITS 29
495
496#define pte_to_pgoff(PTE) ((PTE).pte >> 2)
497#define pgoff_to_pte(off) __pte((off) << 2 | _PAGE_FILE)
498
499/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
500#define PageSkip(page) (0)
501#define kern_addr_valid(addr) (1)
502
503#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
504 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
505
506#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
507 remap_pfn_range(vma, vaddr, pfn, size, prot)
508
509#define MK_IOSPACE_PFN(space, pfn) (pfn)
510#define GET_IOSPACE(pfn) 0
511#define GET_PFN(pfn) (pfn)
512
513#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
514#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
515#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
516#define __HAVE_ARCH_PTEP_SET_WRPROTECT
517#define __HAVE_ARCH_PTE_SAME
518#include <asm-generic/pgtable.h>
519
520/*
521 * preload information about a newly instantiated PTE into the SCR0/SCR1 PGE cache
522 */
523static inline void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t pte)
524{
525 unsigned long ampr;
526 pgd_t *pge = pgd_offset(current->mm, address);
527 pud_t *pue = pud_offset(pge, address);
528 pmd_t *pme = pmd_offset(pue, address);
529
530 ampr = pme->ste[0] & 0xffffff00;
531 ampr |= xAMPRx_L | xAMPRx_SS_16Kb | xAMPRx_S | xAMPRx_C | xAMPRx_V;
532
533 asm volatile("movgs %0,scr0\n"
534 "movgs %0,scr1\n"
535 "movgs %1,dampr4\n"
536 "movgs %1,dampr5\n"
537 :
538 : "r"(address), "r"(ampr)
539 );
540}
541
542#ifdef CONFIG_PROC_FS
543extern char *proc_pid_status_frv_cxnr(struct mm_struct *mm, char *buffer);
544#endif
545
546extern void __init pgtable_cache_init(void);
547
548#endif /* !__ASSEMBLY__ */
549#endif /* !CONFIG_MMU */
550
551#ifndef __ASSEMBLY__
552extern void __init paging_init(void);
553#endif /* !__ASSEMBLY__ */
554
555#endif /* _ASM_PGTABLE_H */
diff --git a/include/asm-frv/poll.h b/include/asm-frv/poll.h
new file mode 100644
index 000000000000..8cbcd60e334f
--- /dev/null
+++ b/include/asm-frv/poll.h
@@ -0,0 +1,23 @@
1#ifndef _ASM_POLL_H
2#define _ASM_POLL_H
3
4#define POLLIN 1
5#define POLLPRI 2
6#define POLLOUT 4
7#define POLLERR 8
8#define POLLHUP 16
9#define POLLNVAL 32
10#define POLLRDNORM 64
11#define POLLWRNORM POLLOUT
12#define POLLRDBAND 128
13#define POLLWRBAND 256
14#define POLLMSG 0x0400
15
16struct pollfd {
17 int fd;
18 short events;
19 short revents;
20};
21
22#endif
23
diff --git a/include/asm-frv/posix_types.h b/include/asm-frv/posix_types.h
new file mode 100644
index 000000000000..73c2ba8d76b4
--- /dev/null
+++ b/include/asm-frv/posix_types.h
@@ -0,0 +1,66 @@
1#ifndef _ASM_POSIX_TYPES_H
2#define _ASM_POSIX_TYPES_H
3
4/*
5 * This file is generally used by user-level software, so you need to
6 * be a little careful about namespace pollution etc. Also, we cannot
7 * assume GCC is being used.
8 */
9
10typedef unsigned long __kernel_ino_t;
11typedef unsigned short __kernel_mode_t;
12typedef unsigned short __kernel_nlink_t;
13typedef long __kernel_off_t;
14typedef int __kernel_pid_t;
15typedef unsigned short __kernel_ipc_pid_t;
16typedef unsigned short __kernel_uid_t;
17typedef unsigned short __kernel_gid_t;
18typedef unsigned int __kernel_size_t;
19typedef int __kernel_ssize_t;
20typedef int __kernel_ptrdiff_t;
21typedef long __kernel_time_t;
22typedef long __kernel_suseconds_t;
23typedef long __kernel_clock_t;
24typedef int __kernel_timer_t;
25typedef int __kernel_clockid_t;
26typedef int __kernel_daddr_t;
27typedef char * __kernel_caddr_t;
28typedef unsigned short __kernel_uid16_t;
29typedef unsigned short __kernel_gid16_t;
30typedef unsigned int __kernel_uid32_t;
31typedef unsigned int __kernel_gid32_t;
32
33typedef unsigned short __kernel_old_uid_t;
34typedef unsigned short __kernel_old_gid_t;
35typedef unsigned short __kernel_old_dev_t;
36
37#ifdef __GNUC__
38typedef long long __kernel_loff_t;
39#endif
40
41typedef struct {
42#if defined(__KERNEL__) || defined(__USE_ALL)
43 int val[2];
44#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
45 int __val[2];
46#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
47} __kernel_fsid_t;
48
49#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
50
51#undef __FD_SET
52#define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
53
54#undef __FD_CLR
55#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
56
57#undef __FD_ISSET
58#define __FD_ISSET(d, set) (!!((set)->fds_bits[__FDELT(d)] & __FDMASK(d)))
59
60#undef __FD_ZERO
61#define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp)))
62
63#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */
64
65#endif
66
diff --git a/include/asm-frv/processor.h b/include/asm-frv/processor.h
new file mode 100644
index 000000000000..5228c18b7f78
--- /dev/null
+++ b/include/asm-frv/processor.h
@@ -0,0 +1,153 @@
1/* processor.h: FRV processor definitions
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_PROCESSOR_H
13#define _ASM_PROCESSOR_H
14
15#include <linux/config.h>
16#include <asm/mem-layout.h>
17
18#ifndef __ASSEMBLY__
19/*
20 * Default implementation of macro that returns current
21 * instruction pointer ("program counter").
22 */
23#define current_text_addr() ({ __label__ _l; _l: &&_l;})
24
25#include <linux/linkage.h>
26#include <asm/sections.h>
27#include <asm/segment.h>
28#include <asm/fpu.h>
29#include <asm/registers.h>
30#include <asm/ptrace.h>
31#include <asm/current.h>
32#include <asm/cache.h>
33
34/* Forward declaration, a strange C thing */
35struct task_struct;
36
37/*
38 * CPU type and hardware bug flags. Kept separately for each CPU.
39 */
40struct cpuinfo_frv {
41#ifdef CONFIG_MMU
42 unsigned long *pgd_quick;
43 unsigned long *pte_quick;
44 unsigned long pgtable_cache_sz;
45#endif
46} __cacheline_aligned;
47
48extern struct cpuinfo_frv __nongprelbss boot_cpu_data;
49
50#define cpu_data (&boot_cpu_data)
51#define current_cpu_data boot_cpu_data
52
53/*
54 * Bus types
55 */
56#define EISA_bus 0
57#define MCA_bus 0
58
59struct thread_struct {
60 struct pt_regs *frame; /* [GR28] exception frame ptr for this thread */
61 struct task_struct *curr; /* [GR29] current pointer for this thread */
62 unsigned long sp; /* [GR1 ] kernel stack pointer */
63 unsigned long fp; /* [GR2 ] kernel frame pointer */
64 unsigned long lr; /* link register */
65 unsigned long pc; /* program counter */
66 unsigned long gr[12]; /* [GR16-GR27] */
67 unsigned long sched_lr; /* LR from schedule() */
68
69 union {
70 struct pt_regs *frame0; /* top (user) stack frame */
71 struct user_context *user; /* userspace context */
72 };
73} __attribute__((aligned(8)));
74
75extern struct pt_regs *__kernel_frame0_ptr;
76extern struct task_struct *__kernel_current_task;
77
78#endif
79
80#ifndef __ASSEMBLY__
81#define INIT_THREAD_FRAME0 \
82 ((struct pt_regs *) \
83 (sizeof(init_stack) + (unsigned long) init_stack - sizeof(struct user_context)))
84
85#define INIT_THREAD { \
86 NULL, \
87 (struct task_struct *) init_stack, \
88 0, 0, 0, 0, \
89 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, \
90 0, \
91 { INIT_THREAD_FRAME0 }, \
92}
93
94/*
95 * do necessary setup to start up a newly executed thread.
96 * - need to discard the frame stacked by init() invoking the execve syscall
97 */
98#define start_thread(_regs, _pc, _usp) \
99do { \
100 set_fs(USER_DS); /* reads from user space */ \
101 __frame = __kernel_frame0_ptr; \
102 __frame->pc = (_pc); \
103 __frame->psr &= ~PSR_S; \
104 __frame->sp = (_usp); \
105} while(0)
106
107extern void prepare_to_copy(struct task_struct *tsk);
108
109/* Free all resources held by a thread. */
110static inline void release_thread(struct task_struct *dead_task)
111{
112}
113
114extern asmlinkage int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
115extern asmlinkage void save_user_regs(struct user_context *target);
116extern asmlinkage void *restore_user_regs(const struct user_context *target, ...);
117
118#define copy_segments(tsk, mm) do { } while (0)
119#define release_segments(mm) do { } while (0)
120#define forget_segments() do { } while (0)
121
122/*
123 * Free current thread data structures etc..
124 */
125static inline void exit_thread(void)
126{
127}
128
129/*
130 * Return saved PC of a blocked thread.
131 */
132extern unsigned long thread_saved_pc(struct task_struct *tsk);
133
134unsigned long get_wchan(struct task_struct *p);
135
136#define KSTK_EIP(tsk) ((tsk)->thread.frame0->pc)
137#define KSTK_ESP(tsk) ((tsk)->thread.frame0->sp)
138
139/* Allocation and freeing of basic task resources. */
140extern struct task_struct *alloc_task_struct(void);
141extern void free_task_struct(struct task_struct *p);
142
143#define cpu_relax() do { } while (0)
144
145/* data cache prefetch */
146#define ARCH_HAS_PREFETCH
147static inline void prefetch(const void *x)
148{
149 asm volatile("dcpl %0,gr0,#0" : : "r"(x));
150}
151
152#endif /* __ASSEMBLY__ */
153#endif /* _ASM_PROCESSOR_H */
diff --git a/include/asm-frv/ptrace.h b/include/asm-frv/ptrace.h
new file mode 100644
index 000000000000..b2cce0718e57
--- /dev/null
+++ b/include/asm-frv/ptrace.h
@@ -0,0 +1,86 @@
1/* ptrace.h: ptrace() relevant definitions
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#ifndef _ASM_PTRACE_H
12#define _ASM_PTRACE_H
13
14#include <asm/registers.h>
15
16#define in_syscall(regs) (((regs)->tbr & TBR_TT) == TBR_TT_TRAP0)
17
18
19#define PT_PSR 0
20#define PT_ISR 1
21#define PT_CCR 2
22#define PT_CCCR 3
23#define PT_LR 4
24#define PT_LCR 5
25#define PT_PC 6
26
27#define PT__STATUS 7 /* exception status */
28#define PT_SYSCALLNO 8 /* syscall number or -1 */
29#define PT_ORIG_GR8 9 /* saved GR8 for signal handling */
30#define PT_GNER0 10
31#define PT_GNER1 11
32#define PT_IACC0H 12
33#define PT_IACC0L 13
34
35#define PT_GR(j) ( 14 + (j)) /* GRj for 0<=j<=63 */
36#define PT_FR(j) ( 78 + (j)) /* FRj for 0<=j<=63 */
37#define PT_FNER(j) (142 + (j)) /* FNERj for 0<=j<=1 */
38#define PT_MSR(j) (144 + (j)) /* MSRj for 0<=j<=2 */
39#define PT_ACC(j) (146 + (j)) /* ACCj for 0<=j<=7 */
40#define PT_ACCG(jklm) (154 + (jklm)) /* ACCGjklm for 0<=jklm<=1 (reads four regs per slot) */
41#define PT_FSR(j) (156 + (j)) /* FSRj for 0<=j<=0 */
42#define PT__GPEND 78
43#define PT__END 157
44
45#define PT_TBR PT_GR(0)
46#define PT_SP PT_GR(1)
47#define PT_FP PT_GR(2)
48#define PT_PREV_FRAME PT_GR(28) /* previous exception frame pointer (old gr28 value) */
49#define PT_CURR_TASK PT_GR(29) /* current task */
50
51
52/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
53#define PTRACE_GETREGS 12
54#define PTRACE_SETREGS 13
55#define PTRACE_GETFPREGS 14
56#define PTRACE_SETFPREGS 15
57#define PTRACE_GETFDPIC 31 /* get the ELF fdpic loadmap address */
58
59#define PTRACE_GETFDPIC_EXEC 0 /* [addr] request the executable loadmap */
60#define PTRACE_GETFDPIC_INTERP 1 /* [addr] request the interpreter loadmap */
61
62#ifndef __ASSEMBLY__
63
64/*
65 * dedicate GR28; to keeping the a pointer to the current exception frame
66 */
67register struct pt_regs *__frame asm("gr28");
68register struct pt_regs *__debug_frame asm("gr31");
69
70#ifndef container_of
71#define container_of(ptr, type, member) ({ \
72 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
73 (type *)( (char *)__mptr - offsetof(type,member) );})
74#endif
75
76#define __debug_regs container_of(__debug_frame, struct pt_debug_regs, normal_regs)
77
78#define user_mode(regs) (!((regs)->psr & PSR_S))
79#define instruction_pointer(regs) ((regs)->pc)
80
81extern unsigned long user_stack(const struct pt_regs *);
82extern void show_regs(struct pt_regs *);
83#define profile_pc(regs) ((regs)->pc)
84
85#endif /* !__ASSEMBLY__ */
86#endif /* _ASM_PTRACE_H */
diff --git a/include/asm-frv/registers.h b/include/asm-frv/registers.h
new file mode 100644
index 000000000000..fccfd95cff68
--- /dev/null
+++ b/include/asm-frv/registers.h
@@ -0,0 +1,255 @@
1/* registers.h: register frame declarations
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12/*
13 * notes:
14 *
15 * (1) that the members of all these structures are carefully aligned to permit
16 * usage of STD/STDF instructions
17 *
18 * (2) if you change these structures, you must change the code in
19 * arch/frvnommu/kernel/{break.S,entry.S,switch_to.S,gdb-stub.c}
20 *
21 *
22 * the kernel stack space block looks like this:
23 *
24 * +0x2000 +----------------------
25 * | union {
26 * | struct user_context
27 * | struct pt_regs [user exception]
28 * | }
29 * +---------------------- <-- __kernel_frame0_ptr (maybe GR28)
30 * |
31 * | kernel stack
32 * |
33 * |......................
34 * | struct pt_regs [kernel exception]
35 * |...................... <-- __kernel_frame0_ptr (maybe GR28)
36 * |
37 * | kernel stack
38 * |
39 * |...................... <-- stack pointer (GR1)
40 * |
41 * | unused stack space
42 * |
43 * +----------------------
44 * | struct thread_info
45 * +0x0000 +---------------------- <-- __current_thread_info (GR15);
46 *
47 * note that GR28 points to the current exception frame
48 */
49
50#ifndef _ASM_REGISTERS_H
51#define _ASM_REGISTERS_H
52
53#ifndef __ASSEMBLY__
54#define __OFFSET(X) (X)
55#define __OFFSETC(X,N) xxxxxxxxxxxxxxxxxxxxxxxx
56#else
57#define __OFFSET(X) ((X)*4)
58#define __OFFSETC(X,N) ((X)*4+(N))
59#endif
60
61/*****************************************************************************/
62/*
63 * Exception/Interrupt frame
64 * - held on kernel stack
65 * - 8-byte aligned on stack (old SP is saved in frame)
66 * - GR0 is fixed 0, so we don't save it
67 */
68#ifndef __ASSEMBLY__
69
70struct pt_regs {
71 unsigned long psr; /* Processor Status Register */
72 unsigned long isr; /* Integer Status Register */
73 unsigned long ccr; /* Condition Code Register */
74 unsigned long cccr; /* Condition Code for Conditional Insns Register */
75 unsigned long lr; /* Link Register */
76 unsigned long lcr; /* Loop Count Register */
77 unsigned long pc; /* Program Counter Register */
78 unsigned long __status; /* exception status */
79 unsigned long syscallno; /* syscall number or -1 */
80 unsigned long orig_gr8; /* original syscall arg #1 */
81 unsigned long gner0;
82 unsigned long gner1;
83 unsigned long long iacc0;
84 unsigned long tbr; /* GR0 is fixed zero, so we use this for TBR */
85 unsigned long sp; /* GR1: USP/KSP */
86 unsigned long fp; /* GR2: FP */
87 unsigned long gr3;
88 unsigned long gr4;
89 unsigned long gr5;
90 unsigned long gr6;
91 unsigned long gr7; /* syscall number */
92 unsigned long gr8; /* 1st syscall param; syscall return */
93 unsigned long gr9; /* 2nd syscall param */
94 unsigned long gr10; /* 3rd syscall param */
95 unsigned long gr11; /* 4th syscall param */
96 unsigned long gr12; /* 5th syscall param */
97 unsigned long gr13; /* 6th syscall param */
98 unsigned long gr14;
99 unsigned long gr15;
100 unsigned long gr16; /* GP pointer */
101 unsigned long gr17; /* small data */
102 unsigned long gr18; /* PIC/PID */
103 unsigned long gr19;
104 unsigned long gr20;
105 unsigned long gr21;
106 unsigned long gr22;
107 unsigned long gr23;
108 unsigned long gr24;
109 unsigned long gr25;
110 unsigned long gr26;
111 unsigned long gr27;
112 struct pt_regs *next_frame; /* GR28 - next exception frame */
113 unsigned long gr29; /* GR29 - OS reserved */
114 unsigned long gr30; /* GR30 - OS reserved */
115 unsigned long gr31; /* GR31 - OS reserved */
116} __attribute__((aligned(8)));
117
118#endif
119
120#define REG_PSR __OFFSET( 0) /* Processor Status Register */
121#define REG_ISR __OFFSET( 1) /* Integer Status Register */
122#define REG_CCR __OFFSET( 2) /* Condition Code Register */
123#define REG_CCCR __OFFSET( 3) /* Condition Code for Conditional Insns Register */
124#define REG_LR __OFFSET( 4) /* Link Register */
125#define REG_LCR __OFFSET( 5) /* Loop Count Register */
126#define REG_PC __OFFSET( 6) /* Program Counter */
127
128#define REG__STATUS __OFFSET( 7) /* exception status */
129#define REG__STATUS_STEP 0x00000001 /* - reenable single stepping on return */
130#define REG__STATUS_STEPPED 0x00000002 /* - single step caused exception */
131#define REG__STATUS_BROKE 0x00000004 /* - BREAK insn caused exception */
132#define REG__STATUS_SYSC_ENTRY 0x40000000 /* - T on syscall entry (ptrace.c only) */
133#define REG__STATUS_SYSC_EXIT 0x80000000 /* - T on syscall exit (ptrace.c only) */
134
135#define REG_SYSCALLNO __OFFSET( 8) /* syscall number or -1 */
136#define REG_ORIG_GR8 __OFFSET( 9) /* saved GR8 for signal handling */
137#define REG_GNER0 __OFFSET(10)
138#define REG_GNER1 __OFFSET(11)
139#define REG_IACC0 __OFFSET(12)
140
141#define REG_TBR __OFFSET(14) /* Trap Vector Register */
142#define REG_GR(R) __OFFSET((14+(R)))
143#define REG__END REG_GR(32)
144
145#define REG_SP REG_GR(1)
146#define REG_FP REG_GR(2)
147#define REG_PREV_FRAME REG_GR(28) /* previous exception frame pointer (old gr28 value) */
148#define REG_CURR_TASK REG_GR(29) /* current task */
149
150/*****************************************************************************/
151/*
152 * extension tacked in front of the exception frame in debug mode
153 */
154#ifndef __ASSEMBLY__
155
156struct pt_debug_regs
157{
158 unsigned long bpsr;
159 unsigned long dcr;
160 unsigned long brr;
161 unsigned long nmar;
162 struct pt_regs normal_regs;
163} __attribute__((aligned(8)));
164
165#endif
166
167#define REG_NMAR __OFFSET(-1)
168#define REG_BRR __OFFSET(-2)
169#define REG_DCR __OFFSET(-3)
170#define REG_BPSR __OFFSET(-4)
171#define REG__DEBUG_XTRA __OFFSET(4)
172
173/*****************************************************************************/
174/*
175 * userspace registers
176 */
177#ifndef __ASSEMBLY__
178
179struct user_int_regs
180{
181 /* integer registers
182 * - up to gr[31] mirror pt_regs
183 * - total size must be multiple of 8 bytes
184 */
185 unsigned long psr; /* Processor Status Register */
186 unsigned long isr; /* Integer Status Register */
187 unsigned long ccr; /* Condition Code Register */
188 unsigned long cccr; /* Condition Code for Conditional Insns Register */
189 unsigned long lr; /* Link Register */
190 unsigned long lcr; /* Loop Count Register */
191 unsigned long pc; /* Program Counter Register */
192 unsigned long __status; /* exception status */
193 unsigned long syscallno; /* syscall number or -1 */
194 unsigned long orig_gr8; /* original syscall arg #1 */
195 unsigned long gner[2];
196 unsigned long long iacc[1];
197
198 union {
199 unsigned long tbr;
200 unsigned long gr[64];
201 };
202};
203
204struct user_fpmedia_regs
205{
206 /* FP/Media registers */
207 unsigned long fr[64];
208 unsigned long fner[2];
209 unsigned long msr[2];
210 unsigned long acc[8];
211 unsigned char accg[8];
212 unsigned long fsr[1];
213};
214
215struct user_context
216{
217 struct user_int_regs i;
218 struct user_fpmedia_regs f;
219
220 /* we provide a context extension so that we can save the regs for CPUs that
221 * implement many more of Fujitsu's lavish register spec
222 */
223 void *extension;
224} __attribute__((aligned(8)));
225
226#endif
227
228#define NR_USER_INT_REGS (14 + 64)
229#define NR_USER_FPMEDIA_REGS (64 + 2 + 2 + 8 + 8/4 + 1)
230#define NR_USER_CONTEXT (NR_USER_INT_REGS + NR_USER_FPMEDIA_REGS + 1)
231
232#define USER_CONTEXT_SIZE (((NR_USER_CONTEXT + 1) & ~1) * 4)
233
234#define __THREAD_FRAME __OFFSET(0)
235#define __THREAD_CURR __OFFSET(1)
236#define __THREAD_SP __OFFSET(2)
237#define __THREAD_FP __OFFSET(3)
238#define __THREAD_LR __OFFSET(4)
239#define __THREAD_PC __OFFSET(5)
240#define __THREAD_GR(R) __OFFSET(6 + (R) - 16)
241#define __THREAD_FRAME0 __OFFSET(19)
242#define __THREAD_USER __OFFSET(19)
243
244#define __USER_INT __OFFSET(0)
245#define __INT_GR(R) __OFFSET(14 + (R))
246
247#define __USER_FPMEDIA __OFFSET(NR_USER_INT_REGS)
248#define __FPMEDIA_FR(R) __OFFSET(NR_USER_INT_REGS + (R))
249#define __FPMEDIA_FNER(R) __OFFSET(NR_USER_INT_REGS + 64 + (R))
250#define __FPMEDIA_MSR(R) __OFFSET(NR_USER_INT_REGS + 66 + (R))
251#define __FPMEDIA_ACC(R) __OFFSET(NR_USER_INT_REGS + 68 + (R))
252#define __FPMEDIA_ACCG(R) __OFFSETC(NR_USER_INT_REGS + 76, (R))
253#define __FPMEDIA_FSR(R) __OFFSET(NR_USER_INT_REGS + 78 + (R))
254
255#endif /* _ASM_REGISTERS_H */
diff --git a/include/asm-frv/resource.h b/include/asm-frv/resource.h
new file mode 100644
index 000000000000..5fc60548fd02
--- /dev/null
+++ b/include/asm-frv/resource.h
@@ -0,0 +1,7 @@
1#ifndef _ASM_RESOURCE_H
2#define _ASM_RESOURCE_H
3
4#include <asm-generic/resource.h>
5
6#endif /* _ASM_RESOURCE_H */
7
diff --git a/include/asm-frv/scatterlist.h b/include/asm-frv/scatterlist.h
new file mode 100644
index 000000000000..fb38fd329a5f
--- /dev/null
+++ b/include/asm-frv/scatterlist.h
@@ -0,0 +1,32 @@
1#ifndef _ASM_SCATTERLIST_H
2#define _ASM_SCATTERLIST_H
3
4/*
5 * Drivers must set either ->address or (preferred) ->page and ->offset
6 * to indicate where data must be transferred to/from.
7 *
8 * Using ->page is recommended since it handles highmem data as well as
9 * low mem. ->address is restricted to data which has a virtual mapping, and
10 * it will go away in the future. Updating to ->page can be automated very
11 * easily -- something like
12 *
13 * sg->address = some_ptr;
14 *
15 * can be rewritten as
16 *
17 * sg->page = virt_to_page(some_ptr);
18 * sg->offset = (unsigned long) some_ptr & ~PAGE_MASK;
19 *
20 * and that's it. There's no excuse for not highmem enabling YOUR driver. /jens
21 */
22struct scatterlist {
23 struct page *page; /* Location for highmem page, if any */
24 unsigned int offset; /* for highmem, page offset */
25
26 dma_addr_t dma_address;
27 unsigned int length;
28};
29
30#define ISA_DMA_THRESHOLD (0xffffffffUL)
31
32#endif /* !_ASM_SCATTERLIST_H */
diff --git a/include/asm-frv/sections.h b/include/asm-frv/sections.h
new file mode 100644
index 000000000000..17d0fb171bba
--- /dev/null
+++ b/include/asm-frv/sections.h
@@ -0,0 +1,46 @@
1/* sections.h: linkage layout variables
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_SECTIONS_H
13#define _ASM_SECTIONS_H
14
15#ifndef __ASSEMBLY__
16
17#include <linux/types.h>
18#include <asm-generic/sections.h>
19
20#ifdef __KERNEL__
21
22/*
23 * we don't want to put variables in the GP-REL section if they're not used very much - that would
24 * be waste since GP-REL addressing is limited to GP16+/-2048
25 */
26#define __nongpreldata __attribute__((section(".data")))
27#define __nongprelbss __attribute__((section(".bss")))
28
29/*
30 * linker symbols
31 */
32extern const void __kernel_image_start, __kernel_image_end, __page_offset;
33
34extern unsigned long __nongprelbss memory_start;
35extern unsigned long __nongprelbss memory_end;
36extern unsigned long __nongprelbss rom_length;
37
38/* determine if we're running from ROM */
39static inline int is_in_rom(unsigned long addr)
40{
41 return 0; /* default case: not in ROM */
42}
43
44#endif
45#endif
46#endif /* _ASM_SECTIONS_H */
diff --git a/include/asm-frv/segment.h b/include/asm-frv/segment.h
new file mode 100644
index 000000000000..61222f00dfc1
--- /dev/null
+++ b/include/asm-frv/segment.h
@@ -0,0 +1,46 @@
1/* segment.h: MMU segment settings
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_SEGMENT_H
13#define _ASM_SEGMENT_H
14
15#include <linux/config.h>
16
17#ifndef __ASSEMBLY__
18
19typedef struct {
20 unsigned long seg;
21} mm_segment_t;
22
23#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
24
25#define KERNEL_DS MAKE_MM_SEG(0xdfffffffUL)
26
27#ifdef CONFIG_MMU
28#define USER_DS MAKE_MM_SEG(TASK_SIZE - 1)
29#else
30#define USER_DS KERNEL_DS
31#endif
32
33#define get_ds() (KERNEL_DS)
34#define get_fs() (__current_thread_info->addr_limit)
35#define segment_eq(a,b) ((a).seg == (b).seg)
36#define __kernel_ds_p() segment_eq(get_fs(), KERNEL_DS)
37#define get_addr_limit() (get_fs().seg)
38
39#define set_fs(_x) \
40do { \
41 __current_thread_info->addr_limit = (_x); \
42} while(0)
43
44
45#endif /* __ASSEMBLY__ */
46#endif /* _ASM_SEGMENT_H */
diff --git a/include/asm-frv/semaphore.h b/include/asm-frv/semaphore.h
new file mode 100644
index 000000000000..393545630806
--- /dev/null
+++ b/include/asm-frv/semaphore.h
@@ -0,0 +1,161 @@
1/* semaphore.h: semaphores for the FR-V
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#ifndef _ASM_SEMAPHORE_H
12#define _ASM_SEMAPHORE_H
13
14#define RW_LOCK_BIAS 0x01000000
15
16#ifndef __ASSEMBLY__
17
18#include <linux/linkage.h>
19#include <linux/wait.h>
20#include <linux/spinlock.h>
21#include <linux/rwsem.h>
22
23#define SEMAPHORE_DEBUG WAITQUEUE_DEBUG
24
25/*
26 * the semaphore definition
27 * - if counter is >0 then there are tokens available on the semaphore for down to collect
28 * - if counter is <=0 then there are no spare tokens, and anyone that wants one must wait
29 * - if wait_list is not empty, then there are processes waiting for the semaphore
30 */
31struct semaphore {
32 unsigned counter;
33 spinlock_t wait_lock;
34 struct list_head wait_list;
35#if SEMAPHORE_DEBUG
36 unsigned __magic;
37#endif
38};
39
40#if SEMAPHORE_DEBUG
41# define __SEM_DEBUG_INIT(name) , (long)&(name).__magic
42#else
43# define __SEM_DEBUG_INIT(name)
44#endif
45
46
47#define __SEMAPHORE_INITIALIZER(name,count) \
48{ count, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) __SEM_DEBUG_INIT(name) }
49
50#define __MUTEX_INITIALIZER(name) \
51 __SEMAPHORE_INITIALIZER(name,1)
52
53#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
54 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
55
56#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
57#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
58
59static inline void sema_init (struct semaphore *sem, int val)
60{
61 *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val);
62}
63
64static inline void init_MUTEX (struct semaphore *sem)
65{
66 sema_init(sem, 1);
67}
68
69static inline void init_MUTEX_LOCKED (struct semaphore *sem)
70{
71 sema_init(sem, 0);
72}
73
74extern void __down(struct semaphore *sem, unsigned long flags);
75extern int __down_interruptible(struct semaphore *sem, unsigned long flags);
76extern void __up(struct semaphore *sem);
77
78static inline void down(struct semaphore *sem)
79{
80 unsigned long flags;
81
82#if SEMAPHORE_DEBUG
83 CHECK_MAGIC(sem->__magic);
84#endif
85
86 spin_lock_irqsave(&sem->wait_lock, flags);
87 if (likely(sem->counter > 0)) {
88 sem->counter--;
89 spin_unlock_irqrestore(&sem->wait_lock, flags);
90 }
91 else {
92 __down(sem, flags);
93 }
94}
95
96static inline int down_interruptible(struct semaphore *sem)
97{
98 unsigned long flags;
99 int ret = 0;
100
101#if SEMAPHORE_DEBUG
102 CHECK_MAGIC(sem->__magic);
103#endif
104
105 spin_lock_irqsave(&sem->wait_lock, flags);
106 if (likely(sem->counter > 0)) {
107 sem->counter--;
108 spin_unlock_irqrestore(&sem->wait_lock, flags);
109 }
110 else {
111 ret = __down_interruptible(sem, flags);
112 }
113 return ret;
114}
115
116/*
117 * non-blockingly attempt to down() a semaphore.
118 * - returns zero if we acquired it
119 */
120static inline int down_trylock(struct semaphore *sem)
121{
122 unsigned long flags;
123 int success = 0;
124
125#if SEMAPHORE_DEBUG
126 CHECK_MAGIC(sem->__magic);
127#endif
128
129 spin_lock_irqsave(&sem->wait_lock, flags);
130 if (sem->counter > 0) {
131 sem->counter--;
132 success = 1;
133 }
134 spin_unlock_irqrestore(&sem->wait_lock, flags);
135 return !success;
136}
137
138static inline void up(struct semaphore *sem)
139{
140 unsigned long flags;
141
142#if SEMAPHORE_DEBUG
143 CHECK_MAGIC(sem->__magic);
144#endif
145
146 spin_lock_irqsave(&sem->wait_lock, flags);
147 if (!list_empty(&sem->wait_list))
148 __up(sem);
149 else
150 sem->counter++;
151 spin_unlock_irqrestore(&sem->wait_lock, flags);
152}
153
154static inline int sem_getcount(struct semaphore *sem)
155{
156 return sem->counter;
157}
158
159#endif /* __ASSEMBLY__ */
160
161#endif
diff --git a/include/asm-frv/sembuf.h b/include/asm-frv/sembuf.h
new file mode 100644
index 000000000000..164b12786d6d
--- /dev/null
+++ b/include/asm-frv/sembuf.h
@@ -0,0 +1,26 @@
1#ifndef _ASM_SEMBUF_H
2#define _ASM_SEMBUF_H
3
4/*
5 * The semid64_ds structure for FR-V architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 64-bit time_t to solve y2038 problem
11 * - 2 miscellaneous 32-bit values
12 */
13
14struct semid64_ds {
15 struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
16 __kernel_time_t sem_otime; /* last semop time */
17 unsigned long __unused1;
18 __kernel_time_t sem_ctime; /* last change time */
19 unsigned long __unused2;
20 unsigned long sem_nsems; /* no. of semaphores in array */
21 unsigned long __unused3;
22 unsigned long __unused4;
23};
24
25#endif /* _ASM_SEMBUF_H */
26
diff --git a/include/asm-frv/serial-regs.h b/include/asm-frv/serial-regs.h
new file mode 100644
index 000000000000..e1286bda00eb
--- /dev/null
+++ b/include/asm-frv/serial-regs.h
@@ -0,0 +1,44 @@
1/* serial-regs.h: serial port registers
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_SERIAL_REGS_H
13#define _ASM_SERIAL_REGS_H
14
15#include <linux/serial_reg.h>
16#include <asm/irc-regs.h>
17
18#define SERIAL_ICLK 33333333 /* the target serial input clock */
19#define UART0_BASE 0xfeff9c00
20#define UART1_BASE 0xfeff9c40
21
22#define __get_UART0(R) ({ __reg(UART0_BASE + (R) * 8) >> 24; })
23#define __get_UART1(R) ({ __reg(UART1_BASE + (R) * 8) >> 24; })
24#define __set_UART0(R,V) do { __reg(UART0_BASE + (R) * 8) = (V) << 24; } while(0)
25#define __set_UART1(R,V) do { __reg(UART1_BASE + (R) * 8) = (V) << 24; } while(0)
26
27#define __get_UART0_LSR() ({ __get_UART0(UART_LSR); })
28#define __get_UART1_LSR() ({ __get_UART1(UART_LSR); })
29
30#define __set_UART0_IER(V) __set_UART0(UART_IER,(V))
31#define __set_UART1_IER(V) __set_UART1(UART_IER,(V))
32
33/* serial prescaler select register */
34#define __get_UCPSR() ({ *(volatile unsigned long *)(0xfeff9c90); })
35#define __set_UCPSR(V) do { *(volatile unsigned long *)(0xfeff9c90) = (V); } while(0)
36#define UCPSR_SELECT0 0x07000000
37#define UCPSR_SELECT1 0x38000000
38
39/* serial prescaler base value register */
40#define __get_UCPVR() ({ *(volatile unsigned long *)(0xfeff9c98); mb(); })
41#define __set_UCPVR(V) do { *(volatile unsigned long *)(0xfeff9c98) = (V) << 24; mb(); } while(0)
42
43
44#endif /* _ASM_SERIAL_REGS_H */
diff --git a/include/asm-frv/serial.h b/include/asm-frv/serial.h
new file mode 100644
index 000000000000..6917d556a1e1
--- /dev/null
+++ b/include/asm-frv/serial.h
@@ -0,0 +1,19 @@
1/*
2 * serial.h
3 *
4 * Copyright (C) 2003 Develer S.r.l. (http://www.develer.com/)
5 * Author: Bernardo Innocenti <bernie@codewiz.org>
6 *
7 * Based on linux/include/asm-i386/serial.h
8 */
9#include <linux/config.h>
10#include <asm/serial-regs.h>
11
12/*
13 * the base baud is derived from the clock speed and so is variable
14 */
15#define BASE_BAUD 0
16
17#define STD_COM_FLAGS ASYNC_BOOT_AUTOCONF
18
19#define SERIAL_PORT_DFNS
diff --git a/include/asm-frv/setup.h b/include/asm-frv/setup.h
new file mode 100644
index 000000000000..0d293b9a5857
--- /dev/null
+++ b/include/asm-frv/setup.h
@@ -0,0 +1,25 @@
1/* setup.h: setup stuff
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_SETUP_H
13#define _ASM_SETUP_H
14
15#include <linux/init.h>
16
17#ifndef __ASSEMBLY__
18
19#ifdef CONFIG_MMU
20extern unsigned long __initdata num_mappedpages;
21#endif
22
23#endif /* !__ASSEMBLY__ */
24
25#endif /* _ASM_SETUP_H */
diff --git a/include/asm-frv/shmbuf.h b/include/asm-frv/shmbuf.h
new file mode 100644
index 000000000000..4c6e711a4779
--- /dev/null
+++ b/include/asm-frv/shmbuf.h
@@ -0,0 +1,43 @@
1#ifndef _ASM_SHMBUF_H
2#define _ASM_SHMBUF_H
3
4/*
5 * The shmid64_ds structure for FR-V architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 64-bit time_t to solve y2038 problem
11 * - 2 miscellaneous 32-bit values
12 */
13
14struct shmid64_ds {
15 struct ipc64_perm shm_perm; /* operation perms */
16 size_t shm_segsz; /* size of segment (bytes) */
17 __kernel_time_t shm_atime; /* last attach time */
18 unsigned long __unused1;
19 __kernel_time_t shm_dtime; /* last detach time */
20 unsigned long __unused2;
21 __kernel_time_t shm_ctime; /* last change time */
22 unsigned long __unused3;
23 __kernel_pid_t shm_cpid; /* pid of creator */
24 __kernel_pid_t shm_lpid; /* pid of last operator */
25 unsigned long shm_nattch; /* no. of current attaches */
26 unsigned long __unused4;
27 unsigned long __unused5;
28};
29
30struct shminfo64 {
31 unsigned long shmmax;
32 unsigned long shmmin;
33 unsigned long shmmni;
34 unsigned long shmseg;
35 unsigned long shmall;
36 unsigned long __unused1;
37 unsigned long __unused2;
38 unsigned long __unused3;
39 unsigned long __unused4;
40};
41
42#endif /* _ASM_SHMBUF_H */
43
diff --git a/include/asm-frv/shmparam.h b/include/asm-frv/shmparam.h
new file mode 100644
index 000000000000..ab711009cfaa
--- /dev/null
+++ b/include/asm-frv/shmparam.h
@@ -0,0 +1,7 @@
1#ifndef _ASM_SHMPARAM_H
2#define _ASM_SHMPARAM_H
3
4#define SHMLBA PAGE_SIZE /* attach addr a multiple of this */
5
6#endif /* _ASM_SHMPARAM_H */
7
diff --git a/include/asm-frv/sigcontext.h b/include/asm-frv/sigcontext.h
new file mode 100644
index 000000000000..3b263f3cc96f
--- /dev/null
+++ b/include/asm-frv/sigcontext.h
@@ -0,0 +1,26 @@
1/* sigcontext.h: FRV signal context
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#ifndef _ASM_SIGCONTEXT_H
12#define _ASM_SIGCONTEXT_H
13
14#include <asm/registers.h>
15
16/*
17 * Signal context structure - contains all info to do with the state
18 * before the signal handler was invoked. Note: only add new entries
19 * to the end of the structure.
20 */
21struct sigcontext {
22 struct user_context sc_context;
23 unsigned long sc_oldmask; /* old sigmask */
24} __attribute__((aligned(8)));
25
26#endif
diff --git a/include/asm-frv/siginfo.h b/include/asm-frv/siginfo.h
new file mode 100644
index 000000000000..d3fd1ca45653
--- /dev/null
+++ b/include/asm-frv/siginfo.h
@@ -0,0 +1,12 @@
1#ifndef _ASM_SIGINFO_H
2#define _ASM_SIGINFO_H
3
4#include <linux/types.h>
5#include <asm-generic/siginfo.h>
6
7#define FPE_MDAOVF (__SI_FAULT|9) /* media overflow */
8#undef NSIGFPE
9#define NSIGFPE 9
10
11#endif
12
diff --git a/include/asm-frv/signal.h b/include/asm-frv/signal.h
new file mode 100644
index 000000000000..f18952f86a80
--- /dev/null
+++ b/include/asm-frv/signal.h
@@ -0,0 +1,187 @@
1#ifndef _ASM_SIGNAL_H
2#define _ASM_SIGNAL_H
3
4#include <linux/types.h>
5
6/* Avoid too many header ordering problems. */
7struct siginfo;
8
9#ifdef __KERNEL__
10/* Most things should be clean enough to redefine this at will, if care
11 is taken to make libc match. */
12
13#define _NSIG 64
14#define _NSIG_BPW 32
15#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
16
17typedef unsigned long old_sigset_t; /* at least 32 bits */
18
19typedef struct {
20 unsigned long sig[_NSIG_WORDS];
21} sigset_t;
22
23#else
24/* Here we must cater to libcs that poke about in kernel headers. */
25
26#define NSIG 32
27typedef unsigned long sigset_t;
28
29#endif /* __KERNEL__ */
30
31#define SIGHUP 1
32#define SIGINT 2
33#define SIGQUIT 3
34#define SIGILL 4
35#define SIGTRAP 5
36#define SIGABRT 6
37#define SIGIOT 6
38#define SIGBUS 7
39#define SIGFPE 8
40#define SIGKILL 9
41#define SIGUSR1 10
42#define SIGSEGV 11
43#define SIGUSR2 12
44#define SIGPIPE 13
45#define SIGALRM 14
46#define SIGTERM 15
47#define SIGSTKFLT 16
48#define SIGCHLD 17
49#define SIGCONT 18
50#define SIGSTOP 19
51#define SIGTSTP 20
52#define SIGTTIN 21
53#define SIGTTOU 22
54#define SIGURG 23
55#define SIGXCPU 24
56#define SIGXFSZ 25
57#define SIGVTALRM 26
58#define SIGPROF 27
59#define SIGWINCH 28
60#define SIGIO 29
61#define SIGPOLL SIGIO
62/*
63#define SIGLOST 29
64*/
65#define SIGPWR 30
66#define SIGSYS 31
67#define SIGUNUSED 31
68
69/* These should not be considered constants from userland. */
70#define SIGRTMIN 32
71#define SIGRTMAX (_NSIG-1)
72
73/*
74 * SA_FLAGS values:
75 *
76 * SA_ONSTACK indicates that a registered stack_t will be used.
77 * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the
78 * SA_RESTART flag to get restarting signals (which were the default long ago)
79 * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
80 * SA_RESETHAND clears the handler when the signal is delivered.
81 * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
82 * SA_NODEFER prevents the current signal from being masked in the handler.
83 *
84 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
85 * Unix names RESETHAND and NODEFER respectively.
86 */
87#define SA_NOCLDSTOP 0x00000001
88#define SA_NOCLDWAIT 0x00000002 /* not supported yet */
89#define SA_SIGINFO 0x00000004
90#define SA_ONSTACK 0x08000000
91#define SA_RESTART 0x10000000
92#define SA_NODEFER 0x40000000
93#define SA_RESETHAND 0x80000000
94
95#define SA_NOMASK SA_NODEFER
96#define SA_ONESHOT SA_RESETHAND
97#define SA_INTERRUPT 0x20000000 /* dummy -- ignored */
98
99#define SA_RESTORER 0x04000000
100
101/*
102 * sigaltstack controls
103 */
104#define SS_ONSTACK 1
105#define SS_DISABLE 2
106
107#define MINSIGSTKSZ 2048
108#define SIGSTKSZ 8192
109
110#ifdef __KERNEL__
111
112/*
113 * These values of sa_flags are used only by the kernel as part of the
114 * irq handling routines.
115 *
116 * SA_INTERRUPT is also used by the irq handling routines.
117 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
118 */
119#define SA_PROBE SA_ONESHOT
120#define SA_SAMPLE_RANDOM SA_RESTART
121#define SA_SHIRQ 0x04000000
122#endif
123
124#define SIG_BLOCK 0 /* for blocking signals */
125#define SIG_UNBLOCK 1 /* for unblocking signals */
126#define SIG_SETMASK 2 /* for setting the signal mask */
127
128/* Type of a signal handler. */
129typedef void (*__sighandler_t)(int);
130
131#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
132#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
133#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
134
135#ifdef __KERNEL__
136struct old_sigaction {
137 __sighandler_t sa_handler;
138 old_sigset_t sa_mask;
139 unsigned long sa_flags;
140 void (*sa_restorer)(void);
141};
142
143struct sigaction {
144 __sighandler_t sa_handler;
145 unsigned long sa_flags;
146 void (*sa_restorer)(void);
147 sigset_t sa_mask; /* mask last for extensibility */
148};
149
150struct k_sigaction {
151 struct sigaction sa;
152};
153#else
154/* Here we must cater to libcs that poke about in kernel headers. */
155
156struct sigaction {
157 union {
158 __sighandler_t _sa_handler;
159 void (*_sa_sigaction)(int, struct siginfo *, void *);
160 } _u;
161 sigset_t sa_mask;
162 unsigned long sa_flags;
163 void (*sa_restorer)(void);
164};
165
166#define sa_handler _u._sa_handler
167#define sa_sigaction _u._sa_sigaction
168
169#endif /* __KERNEL__ */
170
171typedef struct sigaltstack {
172 void *ss_sp;
173 int ss_flags;
174 size_t ss_size;
175} stack_t;
176
177extern int do_signal(struct pt_regs *regs, sigset_t *oldset);
178#define ptrace_signal_deliver(regs, cookie) do { } while (0)
179
180#ifdef __KERNEL__
181
182#include <asm/sigcontext.h>
183#undef __HAVE_ARCH_SIG_BITOPS
184
185#endif /* __KERNEL__ */
186
187#endif /* _ASM_SIGNAL_H */
diff --git a/include/asm-frv/smp.h b/include/asm-frv/smp.h
new file mode 100644
index 000000000000..5ca771631fd8
--- /dev/null
+++ b/include/asm-frv/smp.h
@@ -0,0 +1,10 @@
1#ifndef __ASM_SMP_H
2#define __ASM_SMP_H
3
4#include <linux/config.h>
5
6#ifdef CONFIG_SMP
7#error SMP not supported
8#endif
9
10#endif
diff --git a/include/asm-frv/socket.h b/include/asm-frv/socket.h
new file mode 100644
index 000000000000..c3be17c7de4b
--- /dev/null
+++ b/include/asm-frv/socket.h
@@ -0,0 +1,51 @@
1#ifndef _ASM_SOCKET_H
2#define _ASM_SOCKET_H
3
4#include <asm/sockios.h>
5
6/* For setsockopt(2) */
7#define SOL_SOCKET 1
8
9#define SO_DEBUG 1
10#define SO_REUSEADDR 2
11#define SO_TYPE 3
12#define SO_ERROR 4
13#define SO_DONTROUTE 5
14#define SO_BROADCAST 6
15#define SO_SNDBUF 7
16#define SO_RCVBUF 8
17#define SO_KEEPALIVE 9
18#define SO_OOBINLINE 10
19#define SO_NO_CHECK 11
20#define SO_PRIORITY 12
21#define SO_LINGER 13
22#define SO_BSDCOMPAT 14
23/* To add :#define SO_REUSEPORT 15 */
24#define SO_PASSCRED 16
25#define SO_PEERCRED 17
26#define SO_RCVLOWAT 18
27#define SO_SNDLOWAT 19
28#define SO_RCVTIMEO 20
29#define SO_SNDTIMEO 21
30
31/* Security levels - as per NRL IPv6 - don't actually do anything */
32#define SO_SECURITY_AUTHENTICATION 22
33#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
34#define SO_SECURITY_ENCRYPTION_NETWORK 24
35
36#define SO_BINDTODEVICE 25
37
38/* Socket filtering */
39#define SO_ATTACH_FILTER 26
40#define SO_DETACH_FILTER 27
41
42#define SO_PEERNAME 28
43#define SO_TIMESTAMP 29
44#define SCM_TIMESTAMP SO_TIMESTAMP
45
46#define SO_ACCEPTCONN 30
47
48#define SO_PEERSEC 31
49
50#endif /* _ASM_SOCKET_H */
51
diff --git a/include/asm-frv/sockios.h b/include/asm-frv/sockios.h
new file mode 100644
index 000000000000..8a6e4b2074b7
--- /dev/null
+++ b/include/asm-frv/sockios.h
@@ -0,0 +1,13 @@
1#ifndef _ASM_SOCKIOS__
2#define _ASM_SOCKIOS__
3
4/* Socket-level I/O control calls. */
5#define FIOSETOWN 0x8901
6#define SIOCSPGRP 0x8902
7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */
11
12#endif /* _ASM_SOCKIOS__ */
13
diff --git a/include/asm-frv/spinlock.h b/include/asm-frv/spinlock.h
new file mode 100644
index 000000000000..fe385f45d1fd
--- /dev/null
+++ b/include/asm-frv/spinlock.h
@@ -0,0 +1,17 @@
1/* spinlock.h: spinlocks for FR-V
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_SPINLOCK_H
13#define _ASM_SPINLOCK_H
14
15#error no spinlocks for FR-V yet
16
17#endif /* _ASM_SPINLOCK_H */
diff --git a/include/asm-frv/spr-regs.h b/include/asm-frv/spr-regs.h
new file mode 100644
index 000000000000..ef472f058d9c
--- /dev/null
+++ b/include/asm-frv/spr-regs.h
@@ -0,0 +1,401 @@
1/* spr-regs.h: special-purpose registers on the FRV
2 *
3 * Copyright (C) 2003, 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_SPR_REGS_H
13#define _ASM_SPR_REGS_H
14
15/*
16 * PSR - Processor Status Register
17 */
18#define PSR_ET 0x00000001 /* enable interrupts/exceptions flag */
19#define PSR_PS 0x00000002 /* previous supervisor mode flag */
20#define PSR_S 0x00000004 /* supervisor mode flag */
21#define PSR_PIL 0x00000078 /* processor external interrupt level */
22#define PSR_PIL_0 0x00000000 /* - no interrupt in progress */
23#define PSR_PIL_13 0x00000068 /* - debugging only */
24#define PSR_PIL_14 0x00000070 /* - debugging in progress */
25#define PSR_PIL_15 0x00000078 /* - NMI in progress */
26#define PSR_EM 0x00000080 /* enable media operation */
27#define PSR_EF 0x00000100 /* enable FPU operation */
28#define PSR_BE 0x00001000 /* endianness mode */
29#define PSR_BE_LE 0x00000000 /* - little endian mode */
30#define PSR_BE_BE 0x00001000 /* - big endian mode */
31#define PSR_CM 0x00002000 /* conditional mode */
32#define PSR_NEM 0x00004000 /* non-excepting mode */
33#define PSR_ICE 0x00010000 /* in-circuit emulation mode */
34#define PSR_VERSION_SHIFT 24 /* CPU silicon ID */
35#define PSR_IMPLE_SHIFT 28 /* CPU core ID */
36
37#define PSR_VERSION(psr) (((psr) >> PSR_VERSION_SHIFT) & 0xf)
38#define PSR_IMPLE(psr) (((psr) >> PSR_IMPLE_SHIFT) & 0xf)
39
40#define PSR_IMPLE_FR401 0x2
41#define PSR_VERSION_FR401_MB93401 0x0
42#define PSR_VERSION_FR401_MB93401A 0x1
43#define PSR_VERSION_FR401_MB93403 0x2
44
45#define PSR_IMPLE_FR405 0x4
46#define PSR_VERSION_FR405_MB93405 0x0
47
48#define PSR_IMPLE_FR451 0x5
49#define PSR_VERSION_FR451_MB93451 0x0
50
51#define PSR_IMPLE_FR501 0x1
52#define PSR_VERSION_FR501_MB93501 0x1
53#define PSR_VERSION_FR501_MB93501A 0x2
54
55#define PSR_IMPLE_FR551 0x3
56#define PSR_VERSION_FR551_MB93555 0x1
57
58#define __get_PSR() ({ unsigned long x; asm volatile("movsg psr,%0" : "=r"(x)); x; })
59#define __set_PSR(V) do { asm volatile("movgs %0,psr" : : "r"(V)); } while(0)
60
61/*
62 * TBR - Trap Base Register
63 */
64#define TBR_TT 0x00000ff0
65#define TBR_TT_INSTR_MMU_MISS (0x01 << 4)
66#define TBR_TT_INSTR_ACC_ERROR (0x02 << 4)
67#define TBR_TT_INSTR_ACC_EXCEP (0x03 << 4)
68#define TBR_TT_PRIV_INSTR (0x06 << 4)
69#define TBR_TT_ILLEGAL_INSTR (0x07 << 4)
70#define TBR_TT_FP_EXCEPTION (0x0d << 4)
71#define TBR_TT_MP_EXCEPTION (0x0e << 4)
72#define TBR_TT_DATA_ACC_ERROR (0x11 << 4)
73#define TBR_TT_DATA_MMU_MISS (0x12 << 4)
74#define TBR_TT_DATA_ACC_EXCEP (0x13 << 4)
75#define TBR_TT_DATA_STR_ERROR (0x14 << 4)
76#define TBR_TT_DIVISION_EXCEP (0x17 << 4)
77#define TBR_TT_COMMIT_EXCEP (0x19 << 4)
78#define TBR_TT_INSTR_TLB_MISS (0x1a << 4)
79#define TBR_TT_DATA_TLB_MISS (0x1b << 4)
80#define TBR_TT_DATA_DAT_EXCEP (0x1d << 4)
81#define TBR_TT_DECREMENT_TIMER (0x1f << 4)
82#define TBR_TT_COMPOUND_EXCEP (0x20 << 4)
83#define TBR_TT_INTERRUPT_1 (0x21 << 4)
84#define TBR_TT_INTERRUPT_2 (0x22 << 4)
85#define TBR_TT_INTERRUPT_3 (0x23 << 4)
86#define TBR_TT_INTERRUPT_4 (0x24 << 4)
87#define TBR_TT_INTERRUPT_5 (0x25 << 4)
88#define TBR_TT_INTERRUPT_6 (0x26 << 4)
89#define TBR_TT_INTERRUPT_7 (0x27 << 4)
90#define TBR_TT_INTERRUPT_8 (0x28 << 4)
91#define TBR_TT_INTERRUPT_9 (0x29 << 4)
92#define TBR_TT_INTERRUPT_10 (0x2a << 4)
93#define TBR_TT_INTERRUPT_11 (0x2b << 4)
94#define TBR_TT_INTERRUPT_12 (0x2c << 4)
95#define TBR_TT_INTERRUPT_13 (0x2d << 4)
96#define TBR_TT_INTERRUPT_14 (0x2e << 4)
97#define TBR_TT_INTERRUPT_15 (0x2f << 4)
98#define TBR_TT_TRAP0 (0x80 << 4)
99#define TBR_TT_TRAP1 (0x81 << 4)
100#define TBR_TT_TRAP2 (0x82 << 4)
101#define TBR_TT_TRAP126 (0xfe << 4)
102#define TBR_TT_BREAK (0xff << 4)
103
104#define __get_TBR() ({ unsigned long x; asm volatile("movsg tbr,%0" : "=r"(x)); x; })
105
106/*
107 * HSR0 - Hardware Status Register 0
108 */
109#define HSR0_PDM 0x00000007 /* power down mode */
110#define HSR0_PDM_NORMAL 0x00000000 /* - normal mode */
111#define HSR0_PDM_CORE_SLEEP 0x00000001 /* - CPU core sleep mode */
112#define HSR0_PDM_BUS_SLEEP 0x00000003 /* - bus sleep mode */
113#define HSR0_PDM_PLL_RUN 0x00000005 /* - PLL run */
114#define HSR0_PDM_PLL_STOP 0x00000007 /* - PLL stop */
115#define HSR0_GRLE 0x00000040 /* GR lower register set enable */
116#define HSR0_GRHE 0x00000080 /* GR higher register set enable */
117#define HSR0_FRLE 0x00000100 /* FR lower register set enable */
118#define HSR0_FRHE 0x00000200 /* FR higher register set enable */
119#define HSR0_GRN 0x00000400 /* GR quantity */
120#define HSR0_GRN_64 0x00000000 /* - 64 GR registers */
121#define HSR0_GRN_32 0x00000400 /* - 32 GR registers */
122#define HSR0_FRN 0x00000800 /* FR quantity */
123#define HSR0_FRN_64 0x00000000 /* - 64 FR registers */
124#define HSR0_FRN_32 0x00000800 /* - 32 FR registers */
125#define HSR0_SA 0x00001000 /* start address (RAMBOOT#) */
126#define HSR0_ETMI 0x00008000 /* enable TIMERI (64-bit up timer) */
127#define HSR0_ETMD 0x00004000 /* enable TIMERD (32-bit down timer) */
128#define HSR0_PEDAT 0x00010000 /* previous DAT mode */
129#define HSR0_XEDAT 0x00020000 /* exception DAT mode */
130#define HSR0_EDAT 0x00080000 /* enable DAT mode */
131#define HSR0_RME 0x00400000 /* enable RAM mode */
132#define HSR0_EMEM 0x00800000 /* enable MMU_Miss mask */
133#define HSR0_EXMMU 0x01000000 /* enable extended MMU mode */
134#define HSR0_EDMMU 0x02000000 /* enable data MMU */
135#define HSR0_EIMMU 0x04000000 /* enable instruction MMU */
136#define HSR0_CBM 0x08000000 /* copy back mode */
137#define HSR0_CBM_WRITE_THRU 0x00000000 /* - write through */
138#define HSR0_CBM_COPY_BACK 0x08000000 /* - copy back */
139#define HSR0_NWA 0x10000000 /* no write allocate */
140#define HSR0_DCE 0x40000000 /* data cache enable */
141#define HSR0_ICE 0x80000000 /* instruction cache enable */
142
143#define __get_HSR(R) ({ unsigned long x; asm volatile("movsg hsr"#R",%0" : "=r"(x)); x; })
144#define __set_HSR(R,V) do { asm volatile("movgs %0,hsr"#R : : "r"(V)); } while(0)
145
146/*
147 * CCR - Condition Codes Register
148 */
149#define CCR_FCC0 0x0000000f /* FP/Media condition 0 (fcc0 reg) */
150#define CCR_FCC1 0x000000f0 /* FP/Media condition 1 (fcc1 reg) */
151#define CCR_FCC2 0x00000f00 /* FP/Media condition 2 (fcc2 reg) */
152#define CCR_FCC3 0x0000f000 /* FP/Media condition 3 (fcc3 reg) */
153#define CCR_ICC0 0x000f0000 /* Integer condition 0 (icc0 reg) */
154#define CCR_ICC0_C 0x00010000 /* - Carry flag */
155#define CCR_ICC0_V 0x00020000 /* - Overflow flag */
156#define CCR_ICC0_Z 0x00040000 /* - Zero flag */
157#define CCR_ICC0_N 0x00080000 /* - Negative flag */
158#define CCR_ICC1 0x00f00000 /* Integer condition 1 (icc1 reg) */
159#define CCR_ICC2 0x0f000000 /* Integer condition 2 (icc2 reg) */
160#define CCR_ICC3 0xf0000000 /* Integer condition 3 (icc3 reg) */
161
162/*
163 * CCCR - Condition Codes for Conditional Instructions Register
164 */
165#define CCCR_CC0 0x00000003 /* condition 0 (cc0 reg) */
166#define CCCR_CC0_FALSE 0x00000002 /* - condition is false */
167#define CCCR_CC0_TRUE 0x00000003 /* - condition is true */
168#define CCCR_CC1 0x0000000c /* condition 1 (cc1 reg) */
169#define CCCR_CC2 0x00000030 /* condition 2 (cc2 reg) */
170#define CCCR_CC3 0x000000c0 /* condition 3 (cc3 reg) */
171#define CCCR_CC4 0x00000300 /* condition 4 (cc4 reg) */
172#define CCCR_CC5 0x00000c00 /* condition 5 (cc5 reg) */
173#define CCCR_CC6 0x00003000 /* condition 6 (cc6 reg) */
174#define CCCR_CC7 0x0000c000 /* condition 7 (cc7 reg) */
175
176/*
177 * ISR - Integer Status Register
178 */
179#define ISR_EMAM 0x00000001 /* memory misaligned access handling */
180#define ISR_EMAM_EXCEPTION 0x00000000 /* - generate exception */
181#define ISR_EMAM_FUDGE 0x00000001 /* - mask out invalid address bits */
182#define ISR_AEXC 0x00000004 /* accrued [overflow] exception */
183#define ISR_DTT 0x00000018 /* division type trap */
184#define ISR_DTT_IGNORE 0x00000000 /* - ignore division error */
185#define ISR_DTT_DIVBYZERO 0x00000008 /* - generate exception */
186#define ISR_DTT_OVERFLOW 0x00000010 /* - record overflow */
187#define ISR_EDE 0x00000020 /* enable division exception */
188#define ISR_PLI 0x20000000 /* pre-load instruction information */
189#define ISR_QI 0x80000000 /* quad data implementation information */
190
191/*
192 * EPCR0 - Exception PC Register
193 */
194#define EPCR0_V 0x00000001 /* register content validity indicator */
195#define EPCR0_PC 0xfffffffc /* faulting instruction address */
196
197/*
198 * ESR0/14/15 - Exception Status Register
199 */
200#define ESRx_VALID 0x00000001 /* register content validity indicator */
201#define ESRx_EC 0x0000003e /* exception type */
202#define ESRx_EC_DATA_STORE 0x00000000 /* - data_store_error */
203#define ESRx_EC_INSN_ACCESS 0x00000006 /* - instruction_access_error */
204#define ESRx_EC_PRIV_INSN 0x00000008 /* - privileged_instruction */
205#define ESRx_EC_ILL_INSN 0x0000000a /* - illegal_instruction */
206#define ESRx_EC_MP_EXCEP 0x0000001c /* - mp_exception */
207#define ESRx_EC_DATA_ACCESS 0x00000020 /* - data_access_error */
208#define ESRx_EC_DIVISION 0x00000026 /* - division_exception */
209#define ESRx_EC_ITLB_MISS 0x00000034 /* - instruction_access_TLB_miss */
210#define ESRx_EC_DTLB_MISS 0x00000036 /* - data_access_TLB_miss */
211#define ESRx_EC_DATA_ACCESS_DAT 0x0000003a /* - data_access_DAT_exception */
212
213#define ESR0_IAEC 0x00000100 /* info for instruction-access-exception */
214#define ESR0_IAEC_RESV 0x00000000 /* - reserved */
215#define ESR0_IAEC_PROT_VIOL 0x00000100 /* - protection violation */
216
217#define ESR0_ATXC 0x00f00000 /* address translation exception code */
218#define ESR0_ATXC_MMU_MISS 0x00000000 /* - MMU miss exception and more (?) */
219#define ESR0_ATXC_MULTI_DAT 0x00800000 /* - multiple DAT entry hit */
220#define ESR0_ATXC_MULTI_SAT 0x00900000 /* - multiple SAT entry hit */
221#define ESR0_ATXC_AMRTLB_MISS 0x00a00000 /* - MMU/TLB miss exception */
222#define ESR0_ATXC_PRIV_EXCEP 0x00c00000 /* - privilege protection fault */
223#define ESR0_ATXC_WP_EXCEP 0x00d00000 /* - write protection fault */
224
225#define ESR0_EAV 0x00000800 /* true if EAR0 register valid */
226#define ESR15_EAV 0x00000800 /* true if EAR15 register valid */
227
228/*
229 * ESFR1 - Exception Status Valid Flag Register
230 */
231#define ESFR1_ESR0 0x00000001 /* true if ESR0 is valid */
232#define ESFR1_ESR14 0x00004000 /* true if ESR14 is valid */
233#define ESFR1_ESR15 0x00008000 /* true if ESR15 is valid */
234
235/*
236 * MSR - Media Status Register
237 */
238#define MSR0_AOVF 0x00000001 /* overflow exception accrued */
239#define MSRx_OVF 0x00000002 /* overflow exception detected */
240#define MSRx_SIE 0x0000003c /* last SIMD instruction exception detected */
241#define MSRx_SIE_NONE 0x00000000 /* - none detected */
242#define MSRx_SIE_FRkHI_ACCk 0x00000020 /* - exception at FRkHI or ACCk */
243#define MSRx_SIE_FRkLO_ACCk1 0x00000010 /* - exception at FRkLO or ACCk+1 */
244#define MSRx_SIE_FRk1HI_ACCk2 0x00000008 /* - exception at FRk+1HI or ACCk+2 */
245#define MSRx_SIE_FRk1LO_ACCk3 0x00000004 /* - exception at FRk+1LO or ACCk+3 */
246#define MSR0_MTT 0x00007000 /* type of last media trap detected */
247#define MSR0_MTT_NONE 0x00000000 /* - none detected */
248#define MSR0_MTT_OVERFLOW 0x00001000 /* - overflow detected */
249#define MSR0_HI 0x00c00000 /* hardware implementation */
250#define MSR0_HI_ROUNDING 0x00000000 /* - rounding mode */
251#define MSR0_HI_NONROUNDING 0x00c00000 /* - non-rounding mode */
252#define MSR0_EMCI 0x01000000 /* enable media custom instructions */
253#define MSR0_SRDAV 0x10000000 /* select rounding mode of MAVEH */
254#define MSR0_SRDAV_RDAV 0x00000000 /* - controlled by MSR.RDAV */
255#define MSR0_SRDAV_RD 0x10000000 /* - controlled by MSR.RD */
256#define MSR0_RDAV 0x20000000 /* rounding mode of MAVEH */
257#define MSR0_RDAV_NEAREST_MI 0x00000000 /* - round to nearest minus */
258#define MSR0_RDAV_NEAREST_PL 0x20000000 /* - round to nearest plus */
259#define MSR0_RD 0xc0000000 /* rounding mode */
260#define MSR0_RD_NEAREST 0x00000000 /* - nearest */
261#define MSR0_RD_ZERO 0x40000000 /* - zero */
262#define MSR0_RD_POS_INF 0x80000000 /* - postive infinity */
263#define MSR0_RD_NEG_INF 0xc0000000 /* - negative infinity */
264
265/*
266 * IAMPR0-7 - Instruction Address Mapping Register
267 * DAMPR0-7 - Data Address Mapping Register
268 */
269#define xAMPRx_V 0x00000001 /* register content validity indicator */
270#define DAMPRx_WP 0x00000002 /* write protect */
271#define DAMPRx_WP_RW 0x00000000 /* - read/write */
272#define DAMPRx_WP_RO 0x00000002 /* - read-only */
273#define xAMPRx_C 0x00000004 /* cached/uncached */
274#define xAMPRx_C_CACHED 0x00000000 /* - cached */
275#define xAMPRx_C_UNCACHED 0x00000004 /* - uncached */
276#define xAMPRx_S 0x00000008 /* supervisor only */
277#define xAMPRx_S_USER 0x00000000 /* - userspace can access */
278#define xAMPRx_S_KERNEL 0x00000008 /* - kernel only */
279#define xAMPRx_SS 0x000000f0 /* segment size */
280#define xAMPRx_SS_16Kb 0x00000000 /* - 16 kilobytes */
281#define xAMPRx_SS_64Kb 0x00000010 /* - 64 kilobytes */
282#define xAMPRx_SS_256Kb 0x00000020 /* - 256 kilobytes */
283#define xAMPRx_SS_1Mb 0x00000030 /* - 1 megabyte */
284#define xAMPRx_SS_2Mb 0x00000040 /* - 2 megabytes */
285#define xAMPRx_SS_4Mb 0x00000050 /* - 4 megabytes */
286#define xAMPRx_SS_8Mb 0x00000060 /* - 8 megabytes */
287#define xAMPRx_SS_16Mb 0x00000070 /* - 16 megabytes */
288#define xAMPRx_SS_32Mb 0x00000080 /* - 32 megabytes */
289#define xAMPRx_SS_64Mb 0x00000090 /* - 64 megabytes */
290#define xAMPRx_SS_128Mb 0x000000a0 /* - 128 megabytes */
291#define xAMPRx_SS_256Mb 0x000000b0 /* - 256 megabytes */
292#define xAMPRx_SS_512Mb 0x000000c0 /* - 512 megabytes */
293#define xAMPRx_RESERVED8 0x00000100 /* reserved bit */
294#define xAMPRx_NG 0x00000200 /* non-global */
295#define xAMPRx_L 0x00000400 /* locked */
296#define xAMPRx_M 0x00000800 /* modified */
297#define xAMPRx_D 0x00001000 /* DAT entry */
298#define xAMPRx_RESERVED13 0x00002000 /* reserved bit */
299#define xAMPRx_PPFN 0xfff00000 /* physical page frame number */
300
301#define xAMPRx_V_BIT 0
302#define DAMPRx_WP_BIT 1
303#define xAMPRx_C_BIT 2
304#define xAMPRx_S_BIT 3
305#define xAMPRx_RESERVED8_BIT 8
306#define xAMPRx_NG_BIT 9
307#define xAMPRx_L_BIT 10
308#define xAMPRx_M_BIT 11
309#define xAMPRx_D_BIT 12
310#define xAMPRx_RESERVED13_BIT 13
311
312#define __get_IAMPR(R) ({ unsigned long x; asm volatile("movsg iampr"#R",%0" : "=r"(x)); x; })
313#define __get_DAMPR(R) ({ unsigned long x; asm volatile("movsg dampr"#R",%0" : "=r"(x)); x; })
314
315#define __get_IAMLR(R) ({ unsigned long x; asm volatile("movsg iamlr"#R",%0" : "=r"(x)); x; })
316#define __get_DAMLR(R) ({ unsigned long x; asm volatile("movsg damlr"#R",%0" : "=r"(x)); x; })
317
318#define __set_IAMPR(R,V) do { asm volatile("movgs %0,iampr"#R : : "r"(V)); } while(0)
319#define __set_DAMPR(R,V) do { asm volatile("movgs %0,dampr"#R : : "r"(V)); } while(0)
320
321#define __set_IAMLR(R,V) do { asm volatile("movgs %0,iamlr"#R : : "r"(V)); } while(0)
322#define __set_DAMLR(R,V) do { asm volatile("movgs %0,damlr"#R : : "r"(V)); } while(0)
323
324#define save_dampr(R, _dampr) \
325do { \
326 asm volatile("movsg dampr"R",%0" : "=r"(_dampr)); \
327} while(0)
328
329#define restore_dampr(R, _dampr) \
330do { \
331 asm volatile("movgs %0,dampr"R :: "r"(_dampr)); \
332} while(0)
333
334/*
335 * AMCR - Address Mapping Control Register
336 */
337#define AMCR_IAMRN 0x000000ff /* quantity of IAMPR registers */
338#define AMCR_DAMRN 0x0000ff00 /* quantity of DAMPR registers */
339
340/*
341 * TTBR - Address Translation Table Base Register
342 */
343#define __get_TTBR() ({ unsigned long x; asm volatile("movsg ttbr,%0" : "=r"(x)); x; })
344
345/*
346 * TPXR - TLB Probe Extend Register
347 */
348#define TPXR_E 0x00000001
349#define TPXR_LMAX_SHIFT 20
350#define TPXR_LMAX_SMASK 0xf
351#define TPXR_WMAX_SHIFT 24
352#define TPXR_WMAX_SMASK 0xf
353#define TPXR_WAY_SHIFT 28
354#define TPXR_WAY_SMASK 0xf
355
356/*
357 * DCR - Debug Control Register
358 */
359#define DCR_IBCE3 0x00000001 /* break on conditional insn pointed to by IBAR3 */
360#define DCR_IBE3 0x00000002 /* break on insn pointed to by IBAR3 */
361#define DCR_IBCE1 0x00000004 /* break on conditional insn pointed to by IBAR2 */
362#define DCR_IBE1 0x00000008 /* break on insn pointed to by IBAR2 */
363#define DCR_IBCE2 0x00000010 /* break on conditional insn pointed to by IBAR1 */
364#define DCR_IBE2 0x00000020 /* break on insn pointed to by IBAR1 */
365#define DCR_IBCE0 0x00000040 /* break on conditional insn pointed to by IBAR0 */
366#define DCR_IBE0 0x00000080 /* break on insn pointed to by IBAR0 */
367
368#define DCR_DDBE1 0x00004000 /* use DBDR1x when checking DBAR1 */
369#define DCR_DWBE1 0x00008000 /* break on store to address in DBAR1/DBMR1x */
370#define DCR_DRBE1 0x00010000 /* break on load from address in DBAR1/DBMR1x */
371#define DCR_DDBE0 0x00020000 /* use DBDR0x when checking DBAR0 */
372#define DCR_DWBE0 0x00040000 /* break on store to address in DBAR0/DBMR0x */
373#define DCR_DRBE0 0x00080000 /* break on load from address in DBAR0/DBMR0x */
374
375#define DCR_EIM 0x0c000000 /* external interrupt disable */
376#define DCR_IBM 0x10000000 /* instruction break disable */
377#define DCR_SE 0x20000000 /* single step enable */
378#define DCR_EBE 0x40000000 /* exception break enable */
379
380/*
381 * BRR - Break Interrupt Request Register
382 */
383#define BRR_ST 0x00000001 /* single-step detected */
384#define BRR_SB 0x00000002 /* break instruction detected */
385#define BRR_BB 0x00000004 /* branch with hint detected */
386#define BRR_CBB 0x00000008 /* branch to LR detected */
387#define BRR_IBx 0x000000f0 /* hardware breakpoint detected */
388#define BRR_DBx 0x00000f00 /* hardware watchpoint detected */
389#define BRR_DBNEx 0x0000f000 /* ? */
390#define BRR_EBTT 0x00ff0000 /* trap type of exception break */
391#define BRR_TB 0x10000000 /* external break request detected */
392#define BRR_CB 0x20000000 /* ICE break command detected */
393#define BRR_EB 0x40000000 /* exception break detected */
394
395/*
396 * BPSR - Break PSR Save Register
397 */
398#define BPSR_BET 0x00000001 /* former PSR.ET */
399#define BPSR_BS 0x00001000 /* former PSR.S */
400
401#endif /* _ASM_SPR_REGS_H */
diff --git a/include/asm-frv/stat.h b/include/asm-frv/stat.h
new file mode 100644
index 000000000000..ce56de9b37ba
--- /dev/null
+++ b/include/asm-frv/stat.h
@@ -0,0 +1,100 @@
1#ifndef _ASM_STAT_H
2#define _ASM_STAT_H
3
4struct __old_kernel_stat {
5 unsigned short st_dev;
6 unsigned short st_ino;
7 unsigned short st_mode;
8 unsigned short st_nlink;
9 unsigned short st_uid;
10 unsigned short st_gid;
11 unsigned short st_rdev;
12 unsigned long st_size;
13 unsigned long st_atime;
14 unsigned long st_mtime;
15 unsigned long st_ctime;
16};
17
18/* This matches struct stat in uClibc/glibc. */
19struct stat {
20 unsigned char __pad1[6];
21 unsigned short st_dev;
22
23 unsigned long __pad2;
24 unsigned long st_ino;
25
26 unsigned short __pad3;
27 unsigned short st_mode;
28 unsigned short __pad4;
29 unsigned short st_nlink;
30
31 unsigned short __pad5;
32 unsigned short st_uid;
33 unsigned short __pad6;
34 unsigned short st_gid;
35
36 unsigned char __pad7[6];
37 unsigned short st_rdev;
38
39 unsigned long __pad8;
40 unsigned long st_size;
41
42 unsigned long __pad9; /* align 64-bit st_blocks to 2-word */
43 unsigned long st_blksize;
44
45 unsigned long __pad10; /* future possible st_blocks high bits */
46 unsigned long st_blocks; /* Number 512-byte blocks allocated. */
47
48 unsigned long __unused1;
49 unsigned long st_atime;
50
51 unsigned long __unused2;
52 unsigned long st_mtime;
53
54 unsigned long __unused3;
55 unsigned long st_ctime;
56
57 unsigned long long __unused4;
58};
59
60/* This matches struct stat64 in uClibc/glibc. The layout is exactly
61 the same as that of struct stat above, with 64-bit types taking up
62 space that was formerly used by padding. stat syscalls are still
63 different from stat64, though, in that the former tests for
64 overflow. */
65struct stat64 {
66 unsigned char __pad1[6];
67 unsigned short st_dev;
68
69 unsigned long long st_ino;
70
71 unsigned int st_mode;
72 unsigned int st_nlink;
73
74 unsigned long st_uid;
75 unsigned long st_gid;
76
77 unsigned char __pad2[6];
78 unsigned short st_rdev;
79
80 long long st_size;
81
82 unsigned long __pad3; /* align 64-bit st_blocks to 2-word */
83 unsigned long st_blksize;
84
85 unsigned long __pad4; /* future possible st_blocks high bits */
86 unsigned long st_blocks; /* Number 512-byte blocks allocated. */
87
88 unsigned long st_atime_nsec;
89 unsigned long st_atime;
90
91 unsigned int st_mtime_nsec;
92 unsigned long st_mtime;
93
94 unsigned long st_ctime_nsec;
95 unsigned long st_ctime;
96
97 unsigned long long __unused4;
98};
99
100#endif /* _ASM_STAT_H */
diff --git a/include/asm-frv/statfs.h b/include/asm-frv/statfs.h
new file mode 100644
index 000000000000..741f586045ba
--- /dev/null
+++ b/include/asm-frv/statfs.h
@@ -0,0 +1,7 @@
1#ifndef _ASM_STATFS_H
2#define _ASM_STATFS_H
3
4#include <asm-generic/statfs.h>
5
6#endif /* _ASM_STATFS_H */
7
diff --git a/include/asm-frv/string.h b/include/asm-frv/string.h
new file mode 100644
index 000000000000..5ed310f64b7e
--- /dev/null
+++ b/include/asm-frv/string.h
@@ -0,0 +1,51 @@
1/* string.h: FRV string handling
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_STRING_H_
13#define _ASM_STRING_H_
14
15#ifdef __KERNEL__ /* only set these up for kernel code */
16
17#define __HAVE_ARCH_MEMSET 1
18#define __HAVE_ARCH_MEMCPY 1
19
20extern void *memset(void *, int, __kernel_size_t);
21extern void *memcpy(void *, const void *, __kernel_size_t);
22
23#else /* KERNEL */
24
25/*
26 * let user libraries deal with these,
27 * IMHO the kernel has no place defining these functions for user apps
28 */
29
30#define __HAVE_ARCH_STRCPY 1
31#define __HAVE_ARCH_STRNCPY 1
32#define __HAVE_ARCH_STRCAT 1
33#define __HAVE_ARCH_STRNCAT 1
34#define __HAVE_ARCH_STRCMP 1
35#define __HAVE_ARCH_STRNCMP 1
36#define __HAVE_ARCH_STRNICMP 1
37#define __HAVE_ARCH_STRCHR 1
38#define __HAVE_ARCH_STRRCHR 1
39#define __HAVE_ARCH_STRSTR 1
40#define __HAVE_ARCH_STRLEN 1
41#define __HAVE_ARCH_STRNLEN 1
42#define __HAVE_ARCH_MEMSET 1
43#define __HAVE_ARCH_MEMCPY 1
44#define __HAVE_ARCH_MEMMOVE 1
45#define __HAVE_ARCH_MEMSCAN 1
46#define __HAVE_ARCH_MEMCMP 1
47#define __HAVE_ARCH_MEMCHR 1
48#define __HAVE_ARCH_STRTOK 1
49
50#endif /* KERNEL */
51#endif /* _ASM_STRING_H_ */
diff --git a/include/asm-frv/suspend.h b/include/asm-frv/suspend.h
new file mode 100644
index 000000000000..5fa7b5a6ee40
--- /dev/null
+++ b/include/asm-frv/suspend.h
@@ -0,0 +1,20 @@
1/* suspend.h: suspension stuff
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_SUSPEND_H
13#define _ASM_SUSPEND_H
14
15static inline int arch_prepare_suspend(void)
16{
17 return 0;
18}
19
20#endif /* _ASM_SUSPEND_H */
diff --git a/include/asm-frv/system.h b/include/asm-frv/system.h
new file mode 100644
index 000000000000..d2aea70a5f64
--- /dev/null
+++ b/include/asm-frv/system.h
@@ -0,0 +1,128 @@
1/* system.h: FR-V CPU control definitions
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_SYSTEM_H
13#define _ASM_SYSTEM_H
14
15#include <linux/config.h> /* get configuration macros */
16#include <linux/linkage.h>
17#include <asm/atomic.h>
18
19struct thread_struct;
20
21#define prepare_to_switch() do { } while(0)
22
23/*
24 * switch_to(prev, next) should switch from task `prev' to `next'
25 * `prev' will never be the same as `next'.
26 * The `mb' is to tell GCC not to cache `current' across this call.
27 */
28extern asmlinkage
29struct task_struct *__switch_to(struct thread_struct *prev_thread,
30 struct thread_struct *next_thread,
31 struct task_struct *prev);
32
33#define switch_to(prev, next, last) \
34do { \
35 (prev)->thread.sched_lr = \
36 (unsigned long) __builtin_return_address(0); \
37 (last) = __switch_to(&(prev)->thread, &(next)->thread, (prev)); \
38 mb(); \
39} while(0)
40
41/*
42 * interrupt flag manipulation
43 */
44#define local_irq_disable() \
45do { \
46 unsigned long psr; \
47 asm volatile(" movsg psr,%0 \n" \
48 " andi %0,%2,%0 \n" \
49 " ori %0,%1,%0 \n" \
50 " movgs %0,psr \n" \
51 : "=r"(psr) \
52 : "i" (PSR_PIL_14), "i" (~PSR_PIL) \
53 : "memory"); \
54} while(0)
55
56#define local_irq_enable() \
57do { \
58 unsigned long psr; \
59 asm volatile(" movsg psr,%0 \n" \
60 " andi %0,%1,%0 \n" \
61 " movgs %0,psr \n" \
62 : "=r"(psr) \
63 : "i" (~PSR_PIL) \
64 : "memory"); \
65} while(0)
66
67#define local_save_flags(flags) \
68do { \
69 typecheck(unsigned long, flags); \
70 asm("movsg psr,%0" \
71 : "=r"(flags) \
72 : \
73 : "memory"); \
74} while(0)
75
76#define local_irq_save(flags) \
77do { \
78 unsigned long npsr; \
79 typecheck(unsigned long, flags); \
80 asm volatile(" movsg psr,%0 \n" \
81 " andi %0,%3,%1 \n" \
82 " ori %1,%2,%1 \n" \
83 " movgs %1,psr \n" \
84 : "=r"(flags), "=r"(npsr) \
85 : "i" (PSR_PIL_14), "i" (~PSR_PIL) \
86 : "memory"); \
87} while(0)
88
89#define local_irq_restore(flags) \
90do { \
91 typecheck(unsigned long, flags); \
92 asm volatile(" movgs %0,psr \n" \
93 : \
94 : "r" (flags) \
95 : "memory"); \
96} while(0)
97
98#define irqs_disabled() \
99 ((__get_PSR() & PSR_PIL) >= PSR_PIL_14)
100
101/*
102 * Force strict CPU ordering.
103 */
104#define nop() asm volatile ("nop"::)
105#define mb() asm volatile ("membar" : : :"memory")
106#define rmb() asm volatile ("membar" : : :"memory")
107#define wmb() asm volatile ("membar" : : :"memory")
108#define set_mb(var, value) do { var = value; mb(); } while (0)
109#define set_wmb(var, value) do { var = value; wmb(); } while (0)
110
111#define smp_mb() mb()
112#define smp_rmb() rmb()
113#define smp_wmb() wmb()
114
115#define read_barrier_depends() do {} while(0)
116#define smp_read_barrier_depends() read_barrier_depends()
117
118#define HARD_RESET_NOW() \
119do { \
120 cli(); \
121} while(1)
122
123extern void die_if_kernel(const char *, ...) __attribute__((format(printf, 1, 2)));
124extern void free_initmem(void);
125
126#define arch_align_stack(x) (x)
127
128#endif /* _ASM_SYSTEM_H */
diff --git a/include/asm-frv/termbits.h b/include/asm-frv/termbits.h
new file mode 100644
index 000000000000..74f20d6e292f
--- /dev/null
+++ b/include/asm-frv/termbits.h
@@ -0,0 +1,177 @@
1#ifndef _ASM_TERMBITS_H__
2#define _ASM_TERMBITS_H__
3
4#include <linux/posix_types.h>
5
6typedef unsigned char cc_t;
7typedef unsigned int speed_t;
8typedef unsigned int tcflag_t;
9
10#define NCCS 19
11struct termios {
12 tcflag_t c_iflag; /* input mode flags */
13 tcflag_t c_oflag; /* output mode flags */
14 tcflag_t c_cflag; /* control mode flags */
15 tcflag_t c_lflag; /* local mode flags */
16 cc_t c_line; /* line discipline */
17 cc_t c_cc[NCCS]; /* control characters */
18};
19
20/* c_cc characters */
21#define VINTR 0
22#define VQUIT 1
23#define VERASE 2
24#define VKILL 3
25#define VEOF 4
26#define VTIME 5
27#define VMIN 6
28#define VSWTC 7
29#define VSTART 8
30#define VSTOP 9
31#define VSUSP 10
32#define VEOL 11
33#define VREPRINT 12
34#define VDISCARD 13
35#define VWERASE 14
36#define VLNEXT 15
37#define VEOL2 16
38
39
40/* c_iflag bits */
41#define IGNBRK 0000001
42#define BRKINT 0000002
43#define IGNPAR 0000004
44#define PARMRK 0000010
45#define INPCK 0000020
46#define ISTRIP 0000040
47#define INLCR 0000100
48#define IGNCR 0000200
49#define ICRNL 0000400
50#define IUCLC 0001000
51#define IXON 0002000
52#define IXANY 0004000
53#define IXOFF 0010000
54#define IMAXBEL 0020000
55#define IUTF8 0040000
56
57/* c_oflag bits */
58#define OPOST 0000001
59#define OLCUC 0000002
60#define ONLCR 0000004
61#define OCRNL 0000010
62#define ONOCR 0000020
63#define ONLRET 0000040
64#define OFILL 0000100
65#define OFDEL 0000200
66#define NLDLY 0000400
67#define NL0 0000000
68#define NL1 0000400
69#define CRDLY 0003000
70#define CR0 0000000
71#define CR1 0001000
72#define CR2 0002000
73#define CR3 0003000
74#define TABDLY 0014000
75#define TAB0 0000000
76#define TAB1 0004000
77#define TAB2 0010000
78#define TAB3 0014000
79#define XTABS 0014000
80#define BSDLY 0020000
81#define BS0 0000000
82#define BS1 0020000
83#define VTDLY 0040000
84#define VT0 0000000
85#define VT1 0040000
86#define FFDLY 0100000
87#define FF0 0000000
88#define FF1 0100000
89
90/* c_cflag bit meaning */
91#define CBAUD 0010017
92#define B0 0000000 /* hang up */
93#define B50 0000001
94#define B75 0000002
95#define B110 0000003
96#define B134 0000004
97#define B150 0000005
98#define B200 0000006
99#define B300 0000007
100#define B600 0000010
101#define B1200 0000011
102#define B1800 0000012
103#define B2400 0000013
104#define B4800 0000014
105#define B9600 0000015
106#define B19200 0000016
107#define B38400 0000017
108#define EXTA B19200
109#define EXTB B38400
110#define CSIZE 0000060
111#define CS5 0000000
112#define CS6 0000020
113#define CS7 0000040
114#define CS8 0000060
115#define CSTOPB 0000100
116#define CREAD 0000200
117#define PARENB 0000400
118#define PARODD 0001000
119#define HUPCL 0002000
120#define CLOCAL 0004000
121#define CBAUDEX 0010000
122#define B57600 0010001
123#define B115200 0010002
124#define B230400 0010003
125#define B460800 0010004
126#define B500000 0010005
127#define B576000 0010006
128#define B921600 0010007
129#define B1000000 0010010
130#define B1152000 0010011
131#define B1500000 0010012
132#define B2000000 0010013
133#define B2500000 0010014
134#define B3000000 0010015
135#define B3500000 0010016
136#define B4000000 0010017
137#define CIBAUD 002003600000 /* input baud rate (not used) */
138#define CTVB 004000000000 /* VisioBraille Terminal flow control */
139#define CMSPAR 010000000000 /* mark or space (stick) parity */
140#define CRTSCTS 020000000000 /* flow control */
141
142/* c_lflag bits */
143#define ISIG 0000001
144#define ICANON 0000002
145#define XCASE 0000004
146#define ECHO 0000010
147#define ECHOE 0000020
148#define ECHOK 0000040
149#define ECHONL 0000100
150#define NOFLSH 0000200
151#define TOSTOP 0000400
152#define ECHOCTL 0001000
153#define ECHOPRT 0002000
154#define ECHOKE 0004000
155#define FLUSHO 0010000
156#define PENDIN 0040000
157#define IEXTEN 0100000
158
159
160/* tcflow() and TCXONC use these */
161#define TCOOFF 0
162#define TCOON 1
163#define TCIOFF 2
164#define TCION 3
165
166/* tcflush() and TCFLSH use these */
167#define TCIFLUSH 0
168#define TCOFLUSH 1
169#define TCIOFLUSH 2
170
171/* tcsetattr uses these */
172#define TCSANOW 0
173#define TCSADRAIN 1
174#define TCSAFLUSH 2
175
176#endif /* _ASM_TERMBITS_H__ */
177
diff --git a/include/asm-frv/termios.h b/include/asm-frv/termios.h
new file mode 100644
index 000000000000..b4a664e7f55c
--- /dev/null
+++ b/include/asm-frv/termios.h
@@ -0,0 +1,74 @@
1#ifndef _ASM_TERMIOS_H
2#define _ASM_TERMIOS_H
3
4#include <asm/termbits.h>
5#include <asm/ioctls.h>
6
7struct winsize {
8 unsigned short ws_row;
9 unsigned short ws_col;
10 unsigned short ws_xpixel;
11 unsigned short ws_ypixel;
12};
13
14#define NCC 8
15struct termio {
16 unsigned short c_iflag; /* input mode flags */
17 unsigned short c_oflag; /* output mode flags */
18 unsigned short c_cflag; /* control mode flags */
19 unsigned short c_lflag; /* local mode flags */
20 unsigned char c_line; /* line discipline */
21 unsigned char c_cc[NCC]; /* control characters */
22};
23
24#ifdef __KERNEL__
25/* intr=^C quit=^| erase=del kill=^U
26 eof=^D vtime=\0 vmin=\1 sxtc=\0
27 start=^Q stop=^S susp=^Z eol=\0
28 reprint=^R discard=^U werase=^W lnext=^V
29 eol2=\0
30*/
31#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
32#endif
33
34/* modem lines */
35#define TIOCM_LE 0x001
36#define TIOCM_DTR 0x002
37#define TIOCM_RTS 0x004
38#define TIOCM_ST 0x008
39#define TIOCM_SR 0x010
40#define TIOCM_CTS 0x020
41#define TIOCM_CAR 0x040
42#define TIOCM_RNG 0x080
43#define TIOCM_DSR 0x100
44#define TIOCM_CD TIOCM_CAR
45#define TIOCM_RI TIOCM_RNG
46#define TIOCM_OUT1 0x2000
47#define TIOCM_OUT2 0x4000
48#define TIOCM_LOOP 0x8000
49
50#define TIOCM_MODEM_BITS TIOCM_OUT2 /* IRDA support */
51
52/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
53
54/* line disciplines */
55#define N_TTY 0
56#define N_SLIP 1
57#define N_MOUSE 2
58#define N_PPP 3
59#define N_STRIP 4
60#define N_AX25 5
61#define N_X25 6 /* X.25 async */
62#define N_6PACK 7
63#define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
64#define N_R3964 9 /* Reserved for Simatic R3964 module */
65#define N_PROFIBUS_FDL 10 /* Reserved for Profibus <Dave@mvhi.com> */
66#define N_IRDA 11 /* Linux IrDa - http://irda.sourceforge.net/ */
67#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */
68#define N_HDLC 13 /* synchronous HDLC */
69#define N_SYNC_PPP 14
70#define N_HCI 15 /* Bluetooth HCI UART */
71
72#include <asm-generic/termios.h>
73
74#endif /* _ASM_TERMIOS_H */
diff --git a/include/asm-frv/thread_info.h b/include/asm-frv/thread_info.h
new file mode 100644
index 000000000000..b80a97f50af6
--- /dev/null
+++ b/include/asm-frv/thread_info.h
@@ -0,0 +1,159 @@
1/* thread_info.h: description
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 * Derived from include/asm-i386/thread_info.h
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#ifndef _ASM_THREAD_INFO_H
14#define _ASM_THREAD_INFO_H
15
16#ifdef __KERNEL__
17
18#ifndef __ASSEMBLY__
19#include <asm/processor.h>
20#endif
21
22/*
23 * low level task data that entry.S needs immediate access to
24 * - this struct should fit entirely inside of one cache line
25 * - this struct shares the supervisor stack pages
26 * - if the contents of this structure are changed, the assembly constants must also be changed
27 */
28#ifndef __ASSEMBLY__
29
30struct thread_info {
31 struct task_struct *task; /* main task structure */
32 struct exec_domain *exec_domain; /* execution domain */
33 unsigned long flags; /* low level flags */
34 unsigned long status; /* thread-synchronous flags */
35 __u32 cpu; /* current CPU */
36 __s32 preempt_count; /* 0 => preemptable, <0 => BUG */
37
38 mm_segment_t addr_limit; /* thread address space:
39 0-0xBFFFFFFF for user-thead
40 0-0xFFFFFFFF for kernel-thread
41 */
42 struct restart_block restart_block;
43
44 __u8 supervisor_stack[0];
45};
46
47#else /* !__ASSEMBLY__ */
48
49/* offsets into the thread_info struct for assembly code access */
50#define TI_TASK 0x00000000
51#define TI_EXEC_DOMAIN 0x00000004
52#define TI_FLAGS 0x00000008
53#define TI_STATUS 0x0000000C
54#define TI_CPU 0x00000010
55#define TI_PRE_COUNT 0x00000014
56#define TI_ADDR_LIMIT 0x00000018
57#define TI_RESTART_BLOCK 0x0000001C
58
59#endif
60
61#define PREEMPT_ACTIVE 0x4000000
62
63/*
64 * macros/functions for gaining access to the thread information structure
65 *
66 * preempt_count needs to be 1 initially, until the scheduler is functional.
67 */
68#ifndef __ASSEMBLY__
69
70#define INIT_THREAD_INFO(tsk) \
71{ \
72 .task = &tsk, \
73 .exec_domain = &default_exec_domain, \
74 .flags = 0, \
75 .cpu = 0, \
76 .preempt_count = 1, \
77 .addr_limit = KERNEL_DS, \
78 .restart_block = { \
79 .fn = do_no_restart_syscall, \
80 }, \
81}
82
83#define init_thread_info (init_thread_union.thread_info)
84#define init_stack (init_thread_union.stack)
85
86#ifdef CONFIG_SMALL_TASKS
87#define THREAD_SIZE 4096
88#else
89#define THREAD_SIZE 8192
90#endif
91
92/* how to get the thread information struct from C */
93register struct thread_info *__current_thread_info asm("gr15");
94
95#define current_thread_info() ({ __current_thread_info; })
96
97/* thread information allocation */
98#ifdef CONFIG_DEBUG_STACK_USAGE
99#define alloc_thread_info(tsk) \
100 ({ \
101 struct thread_info *ret; \
102 \
103 ret = kmalloc(THREAD_SIZE, GFP_KERNEL); \
104 if (ret) \
105 memset(ret, 0, THREAD_SIZE); \
106 ret; \
107 })
108#else
109#define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
110#endif
111
112#define free_thread_info(info) kfree(info)
113#define get_thread_info(ti) get_task_struct((ti)->task)
114#define put_thread_info(ti) put_task_struct((ti)->task)
115
116#else /* !__ASSEMBLY__ */
117
118#define THREAD_SIZE 8192
119
120#endif
121
122/*
123 * thread information flags
124 * - these are process state flags that various assembly files may need to access
125 * - pending work-to-be-done flags are in LSW
126 * - other flags in MSW
127 */
128#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
129#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
130#define TIF_SIGPENDING 2 /* signal pending */
131#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
132#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
133#define TIF_IRET 5 /* return with iret */
134#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
135#define TIF_MEMDIE 17 /* OOM killer killed process */
136
137#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
138#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
139#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
140#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
141#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
142#define _TIF_IRET (1 << TIF_IRET)
143#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
144
145#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
146#define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
147
148/*
149 * Thread-synchronous status.
150 *
151 * This is different from the flags in that nobody else
152 * ever touches our thread-synchronous status, so we don't
153 * have to worry about atomic accesses.
154 */
155#define TS_USEDFPM 0x0001 /* FPU/Media was used by this task this quantum (SMP) */
156
157#endif /* __KERNEL__ */
158
159#endif /* _ASM_THREAD_INFO_H */
diff --git a/include/asm-frv/timer-regs.h b/include/asm-frv/timer-regs.h
new file mode 100644
index 000000000000..6c5a871ce5e9
--- /dev/null
+++ b/include/asm-frv/timer-regs.h
@@ -0,0 +1,106 @@
1/* timer-regs.h: hardware timer register definitions
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_TIMER_REGS_H
13#define _ASM_TIMER_REGS_H
14
15#include <asm/sections.h>
16
17extern unsigned long __nongprelbss __clkin_clock_speed_HZ;
18extern unsigned long __nongprelbss __ext_bus_clock_speed_HZ;
19extern unsigned long __nongprelbss __res_bus_clock_speed_HZ;
20extern unsigned long __nongprelbss __sdram_clock_speed_HZ;
21extern unsigned long __nongprelbss __core_bus_clock_speed_HZ;
22extern unsigned long __nongprelbss __core_clock_speed_HZ;
23extern unsigned long __nongprelbss __dsu_clock_speed_HZ;
24extern unsigned long __nongprelbss __serial_clock_speed_HZ;
25
26#define __get_CLKC() ({ *(volatile unsigned long *)(0xfeff9a00); })
27
28static inline void __set_CLKC(unsigned long v)
29{
30 int tmp;
31
32 asm volatile(" st%I0.p %2,%M0 \n"
33 " setlos %3,%1 \n"
34 " membar \n"
35 "0: \n"
36 " subicc %1,#1,%1,icc0 \n"
37 " bnc icc0,#1,0b \n"
38 : "=m"(*(volatile unsigned long *) 0xfeff9a00), "=r"(tmp)
39 : "r"(v), "i"(256)
40 : "icc0");
41}
42
43#define __get_TCTR() ({ *(volatile unsigned long *)(0xfeff9418); })
44#define __get_TPRV() ({ *(volatile unsigned long *)(0xfeff9420); })
45#define __get_TPRCKSL() ({ *(volatile unsigned long *)(0xfeff9428); })
46#define __get_TCSR(T) ({ *(volatile unsigned long *)(0xfeff9400 + 8 * (T)); })
47#define __get_TxCKSL(T) ({ *(volatile unsigned long *)(0xfeff9430 + 8 * (T)); })
48
49#define __get_TCSR_DATA(T) ({ __get_TCSR(T) >> 24; })
50
51#define __set_TCTR(V) do { *(volatile unsigned long *)(0xfeff9418) = (V); mb(); } while(0)
52#define __set_TPRV(V) do { *(volatile unsigned long *)(0xfeff9420) = (V) << 24; mb(); } while(0)
53#define __set_TPRCKSL(V) do { *(volatile unsigned long *)(0xfeff9428) = (V); mb(); } while(0)
54#define __set_TCSR(T,V) \
55do { *(volatile unsigned long *)(0xfeff9400 + 8 * (T)) = (V); mb(); } while(0)
56
57#define __set_TxCKSL(T,V) \
58do { *(volatile unsigned long *)(0xfeff9430 + 8 * (T)) = (V); mb(); } while(0)
59
60#define __set_TCSR_DATA(T,V) __set_TCSR(T, (V) << 24)
61#define __set_TxCKSL_DATA(T,V) __set_TxCKSL(T, TxCKSL_EIGHT | __TxCKSL_SELECT((V)))
62
63/* clock control register */
64#define CLKC_CMODE 0x0f000000
65#define CLKC_SLPL 0x000f0000
66#define CLKC_P0 0x00000100
67#define CLKC_CM 0x00000003
68
69#define CLKC_CMODE_s 24
70
71/* timer control register - non-readback mode */
72#define TCTR_MODE_0 0x00000000
73#define TCTR_MODE_2 0x04000000
74#define TCTR_MODE_4 0x08000000
75#define TCTR_MODE_5 0x0a000000
76#define TCTR_RL_LATCH 0x00000000
77#define TCTR_RL_RW_LOW8 0x10000000
78#define TCTR_RL_RW_HIGH8 0x20000000
79#define TCTR_RL_RW_LH8 0x30000000
80#define TCTR_SC_CTR0 0x00000000
81#define TCTR_SC_CTR1 0x40000000
82#define TCTR_SC_CTR2 0x80000000
83
84/* timer control register - readback mode */
85#define TCTR_CNT0 0x02000000
86#define TCTR_CNT1 0x04000000
87#define TCTR_CNT2 0x08000000
88#define TCTR_NSTATUS 0x10000000
89#define TCTR_NCOUNT 0x20000000
90#define TCTR_SC_READBACK 0xc0000000
91
92/* timer control status registers - non-readback mode */
93#define TCSRx_DATA 0xff000000
94
95/* timer control status registers - readback mode */
96#define TCSRx_OUTPUT 0x80000000
97#define TCSRx_NULLCOUNT 0x40000000
98#define TCSRx_RL 0x30000000
99#define TCSRx_MODE 0x07000000
100
101/* timer clock select registers */
102#define TxCKSL_SELECT 0x0f000000
103#define __TxCKSL_SELECT(X) ((X) << 24)
104#define TxCKSL_EIGHT 0xf0000000
105
106#endif /* _ASM_TIMER_REGS_H */
diff --git a/include/asm-frv/timex.h b/include/asm-frv/timex.h
new file mode 100644
index 000000000000..2aa562fa067b
--- /dev/null
+++ b/include/asm-frv/timex.h
@@ -0,0 +1,25 @@
1/* timex.h: FR-V architecture timex specifications
2 */
3#ifndef _ASM_TIMEX_H
4#define _ASM_TIMEX_H
5
6#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
7#define CLOCK_TICK_FACTOR 20 /* Factor of both 1000000 and CLOCK_TICK_RATE */
8
9#define FINETUNE \
10((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
11 (1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
12 << (SHIFT_SCALE-SHIFT_HZ)) / HZ)
13
14typedef unsigned long cycles_t;
15
16static inline cycles_t get_cycles(void)
17{
18 return 0;
19}
20
21#define vxtime_lock() do {} while (0)
22#define vxtime_unlock() do {} while (0)
23
24#endif
25
diff --git a/include/asm-frv/tlb.h b/include/asm-frv/tlb.h
new file mode 100644
index 000000000000..f94fe5cb9b3a
--- /dev/null
+++ b/include/asm-frv/tlb.h
@@ -0,0 +1,23 @@
1#ifndef _ASM_TLB_H
2#define _ASM_TLB_H
3
4#include <asm/tlbflush.h>
5
6#define check_pgt_cache() do {} while(0)
7
8/*
9 * we don't need any special per-pte or per-vma handling...
10 */
11#define tlb_start_vma(tlb, vma) do { } while (0)
12#define tlb_end_vma(tlb, vma) do { } while (0)
13#define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0)
14
15/*
16 * .. because we flush the whole mm when it fills up
17 */
18#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm)
19
20#include <asm-generic/tlb.h>
21
22#endif /* _ASM_TLB_H */
23
diff --git a/include/asm-frv/tlbflush.h b/include/asm-frv/tlbflush.h
new file mode 100644
index 000000000000..bc3462625084
--- /dev/null
+++ b/include/asm-frv/tlbflush.h
@@ -0,0 +1,77 @@
1/* tlbflush.h: TLB flushing functions
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_TLBFLUSH_H
13#define _ASM_TLBFLUSH_H
14
15#include <linux/config.h>
16#include <linux/mm.h>
17#include <asm/processor.h>
18
19#ifdef CONFIG_MMU
20
21#ifndef __ASSEMBLY__
22extern void asmlinkage __flush_tlb_all(void);
23extern void asmlinkage __flush_tlb_mm(unsigned long contextid);
24extern void asmlinkage __flush_tlb_page(unsigned long contextid, unsigned long start);
25extern void asmlinkage __flush_tlb_range(unsigned long contextid,
26 unsigned long start, unsigned long end);
27#endif /* !__ASSEMBLY__ */
28
29#define flush_tlb_all() \
30do { \
31 preempt_disable(); \
32 __flush_tlb_all(); \
33 preempt_enable(); \
34} while(0)
35
36#define flush_tlb_mm(mm) \
37do { \
38 preempt_disable(); \
39 __flush_tlb_mm((mm)->context.id); \
40 preempt_enable(); \
41} while(0)
42
43#define flush_tlb_range(vma,start,end) \
44do { \
45 preempt_disable(); \
46 __flush_tlb_range((vma)->vm_mm->context.id, start, end); \
47 preempt_enable(); \
48} while(0)
49
50#define flush_tlb_page(vma,addr) \
51do { \
52 preempt_disable(); \
53 __flush_tlb_page((vma)->vm_mm->context.id, addr); \
54 preempt_enable(); \
55} while(0)
56
57
58#define __flush_tlb_global() flush_tlb_all()
59#define flush_tlb() flush_tlb_all()
60#define flush_tlb_kernel_range(start, end) flush_tlb_all()
61#define flush_tlb_pgtables(mm,start,end) \
62 asm volatile("movgs %0,scr0 ! movgs %0,scr1" :: "r"(ULONG_MAX) : "memory");
63
64#else
65
66#define flush_tlb() BUG()
67#define flush_tlb_all() BUG()
68#define flush_tlb_mm(mm) BUG()
69#define flush_tlb_page(vma,addr) BUG()
70#define flush_tlb_range(mm,start,end) BUG()
71#define flush_tlb_pgtables(mm,start,end) BUG()
72#define flush_tlb_kernel_range(start, end) BUG()
73
74#endif
75
76
77#endif /* _ASM_TLBFLUSH_H */
diff --git a/include/asm-frv/topology.h b/include/asm-frv/topology.h
new file mode 100644
index 000000000000..abe7298742ac
--- /dev/null
+++ b/include/asm-frv/topology.h
@@ -0,0 +1,14 @@
1#ifndef _ASM_TOPOLOGY_H
2#define _ASM_TOPOLOGY_H
3
4#ifdef CONFIG_NUMA
5
6#error NUMA not supported yet
7
8#else /* !CONFIG_NUMA */
9
10#include <asm-generic/topology.h>
11
12#endif /* CONFIG_NUMA */
13
14#endif /* _ASM_TOPOLOGY_H */
diff --git a/include/asm-frv/types.h b/include/asm-frv/types.h
new file mode 100644
index 000000000000..1a5b6546bb41
--- /dev/null
+++ b/include/asm-frv/types.h
@@ -0,0 +1,74 @@
1/* types.h: FRV types
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_TYPES_H
13#define _ASM_TYPES_H
14
15#ifndef __ASSEMBLY__
16
17typedef unsigned short umode_t;
18
19/*
20 * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
21 * header files exported to user space
22 */
23
24typedef __signed__ char __s8;
25typedef unsigned char __u8;
26
27typedef __signed__ short __s16;
28typedef unsigned short __u16;
29
30typedef __signed__ int __s32;
31typedef unsigned int __u32;
32
33#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
34typedef __signed__ long long __s64;
35typedef unsigned long long __u64;
36#endif
37
38#endif /* __ASSEMBLY__ */
39
40/*
41 * These aren't exported outside the kernel to avoid name space clashes
42 */
43#ifdef __KERNEL__
44
45#define BITS_PER_LONG 32
46
47#ifndef __ASSEMBLY__
48
49#include <linux/config.h>
50
51typedef signed char s8;
52typedef unsigned char u8;
53
54typedef signed short s16;
55typedef unsigned short u16;
56
57typedef signed int s32;
58typedef unsigned int u32;
59
60typedef signed long long s64;
61typedef unsigned long long u64;
62typedef u64 u_quad_t;
63
64/* Dma addresses are 32-bits wide. */
65
66typedef u32 dma_addr_t;
67
68typedef unsigned short kmem_bufctl_t;
69
70#endif /* __ASSEMBLY__ */
71
72#endif /* __KERNEL__ */
73
74#endif /* _ASM_TYPES_H */
diff --git a/include/asm-frv/uaccess.h b/include/asm-frv/uaccess.h
new file mode 100644
index 000000000000..32dc52e883e5
--- /dev/null
+++ b/include/asm-frv/uaccess.h
@@ -0,0 +1,318 @@
1/* uaccess.h: userspace accessor functions
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_UACCESS_H
13#define _ASM_UACCESS_H
14
15/*
16 * User space memory access functions
17 */
18#include <linux/sched.h>
19#include <linux/mm.h>
20#include <asm/segment.h>
21#include <asm/sections.h>
22
23#define HAVE_ARCH_UNMAPPED_AREA /* we decide where to put mmaps */
24
25#define __ptr(x) ((unsigned long *)(x))
26
27#define VERIFY_READ 0
28#define VERIFY_WRITE 1
29
30#define __addr_ok(addr) ((unsigned long)(addr) < get_addr_limit())
31
32/*
33 * check that a range of addresses falls within the current address limit
34 */
35static inline int ___range_ok(unsigned long addr, unsigned long size)
36{
37#ifdef CONFIG_MMU
38 int flag = -EFAULT, tmp;
39
40 asm volatile (
41 " addcc %3,%2,%1,icc0 \n" /* set C-flag if addr+size>4GB */
42 " subcc.p %1,%4,gr0,icc1 \n" /* jump if addr+size>limit */
43 " bc icc0,#0,0f \n"
44 " bhi icc1,#0,0f \n"
45 " setlos #0,%0 \n" /* mark okay */
46 "0: \n"
47 : "=r"(flag), "=&r"(tmp)
48 : "r"(addr), "r"(size), "r"(get_addr_limit()), "0"(flag)
49 );
50
51 return flag;
52
53#else
54
55 if (addr < memory_start ||
56 addr > memory_end ||
57 size > memory_end - memory_start ||
58 addr + size > memory_end)
59 return -EFAULT;
60
61 return 0;
62#endif
63}
64
65#define __range_ok(addr,size) ___range_ok((unsigned long) (addr), (unsigned long) (size))
66
67#define access_ok(type,addr,size) (__range_ok((addr), (size)) == 0)
68#define __access_ok(addr,size) (__range_ok((addr), (size)) == 0)
69
70/* this function will go away soon - use access_ok() / __range_ok() instead */
71static inline int __deprecated verify_area(int type, const void * addr, unsigned long size)
72{
73 return __range_ok(addr, size);
74}
75
76/*
77 * The exception table consists of pairs of addresses: the first is the
78 * address of an instruction that is allowed to fault, and the second is
79 * the address at which the program should continue. No registers are
80 * modified, so it is entirely up to the continuation code to figure out
81 * what to do.
82 *
83 * All the routines below use bits of fixup code that are out of line
84 * with the main instruction path. This means when everything is well,
85 * we don't even have to jump over them. Further, they do not intrude
86 * on our cache or tlb entries.
87 */
88struct exception_table_entry
89{
90 unsigned long insn, fixup;
91};
92
93/* Returns 0 if exception not found and fixup otherwise. */
94extern unsigned long search_exception_table(unsigned long);
95
96
97/*
98 * These are the main single-value transfer routines. They automatically
99 * use the right size if we just have the right pointer type.
100 */
101#define __put_user(x, ptr) \
102({ \
103 int __pu_err = 0; \
104 \
105 typeof(*(ptr)) __pu_val = (x); \
106 \
107 switch (sizeof (*(ptr))) { \
108 case 1: \
109 __put_user_asm(__pu_err, __pu_val, ptr, "b", "r"); \
110 break; \
111 case 2: \
112 __put_user_asm(__pu_err, __pu_val, ptr, "h", "r"); \
113 break; \
114 case 4: \
115 __put_user_asm(__pu_err, __pu_val, ptr, "", "r"); \
116 break; \
117 case 8: \
118 __put_user_asm(__pu_err, __pu_val, ptr, "d", "e"); \
119 break; \
120 default: \
121 __pu_err = __put_user_bad(); \
122 break; \
123 } \
124 __pu_err; \
125})
126
127#define put_user(x, ptr) \
128({ \
129 typeof(&*ptr) _p = (ptr); \
130 int _e; \
131 \
132 _e = __range_ok(_p, sizeof(*_p)); \
133 if (_e == 0) \
134 _e = __put_user((x), _p); \
135 _e; \
136})
137
138extern int __put_user_bad(void);
139
140/*
141 * Tell gcc we read from memory instead of writing: this is because
142 * we do not write to any memory gcc knows about, so there are no
143 * aliasing issues.
144 */
145
146#ifdef CONFIG_MMU
147
148#define __put_user_asm(err,x,ptr,dsize,constraint) \
149do { \
150 asm volatile("1: st"dsize"%I1 %2,%M1 \n" \
151 "2: \n" \
152 ".subsection 2 \n" \
153 "3: setlos %3,%0 \n" \
154 " bra 2b \n" \
155 ".previous \n" \
156 ".section __ex_table,\"a\" \n" \
157 " .balign 8 \n" \
158 " .long 1b,3b \n" \
159 ".previous" \
160 : "=r" (err) \
161 : "m" (*__ptr(ptr)), constraint (x), "i"(-EFAULT), "0"(err) \
162 : "memory"); \
163} while (0)
164
165#else
166
167#define __put_user_asm(err,x,ptr,bwl,con) \
168do { \
169 asm(" st"bwl"%I0 %1,%M0 \n" \
170 " membar \n" \
171 : \
172 : "m" (*__ptr(ptr)), con (x) \
173 : "memory"); \
174} while (0)
175
176#endif
177
178/*****************************************************************************/
179/*
180 *
181 */
182#define __get_user(x, ptr) \
183({ \
184 typeof(*(ptr)) __gu_val = 0; \
185 int __gu_err = 0; \
186 \
187 switch (sizeof(*(ptr))) { \
188 case 1: \
189 __get_user_asm(__gu_err, __gu_val, ptr, "ub", "=r"); \
190 break; \
191 case 2: \
192 __get_user_asm(__gu_err, __gu_val, ptr, "uh", "=r"); \
193 break; \
194 case 4: \
195 __get_user_asm(__gu_err, __gu_val, ptr, "", "=r"); \
196 break; \
197 case 8: \
198 __get_user_asm(__gu_err, __gu_val, ptr, "d", "=e"); \
199 break; \
200 default: \
201 __gu_err = __get_user_bad(); \
202 break; \
203 } \
204 (x) = __gu_val; \
205 __gu_err; \
206})
207
208#define get_user(x, ptr) \
209({ \
210 typeof(&*ptr) _p = (ptr); \
211 int _e; \
212 \
213 _e = __range_ok(_p, sizeof(*_p)); \
214 if (likely(_e == 0)) \
215 _e = __get_user((x), _p); \
216 else \
217 (x) = (typeof(x)) 0; \
218 _e; \
219})
220
221extern int __get_user_bad(void);
222
223#ifdef CONFIG_MMU
224
225#define __get_user_asm(err,x,ptr,dtype,constraint) \
226do { \
227 asm("1: ld"dtype"%I2 %M2,%1 \n" \
228 "2: \n" \
229 ".subsection 2 \n" \
230 "3: setlos %3,%0 \n" \
231 " setlos #0,%1 \n" \
232 " bra 2b \n" \
233 ".previous \n" \
234 ".section __ex_table,\"a\" \n" \
235 " .balign 8 \n" \
236 " .long 1b,3b \n" \
237 ".previous" \
238 : "=r" (err), constraint (x) \
239 : "m" (*__ptr(ptr)), "i"(-EFAULT), "0"(err) \
240 ); \
241} while(0)
242
243#else
244
245#define __get_user_asm(err,x,ptr,bwl,con) \
246 asm(" ld"bwl"%I1 %M1,%0 \n" \
247 " membar \n" \
248 : con(x) \
249 : "m" (*__ptr(ptr)))
250
251#endif
252
253/*****************************************************************************/
254/*
255 *
256 */
257#ifdef CONFIG_MMU
258extern long __memset_user(void *dst, unsigned long count);
259extern long __memcpy_user(void *dst, const void *src, unsigned long count);
260
261#define clear_user(dst,count) __memset_user((dst), (count))
262#define __copy_from_user_inatomic(to, from, n) __memcpy_user((to), (from), (n))
263#define __copy_to_user_inatomic(to, from, n) __memcpy_user((to), (from), (n))
264
265#else
266
267#define clear_user(dst,count) (memset((dst), 0, (count)), 0)
268#define __copy_from_user_inatomic(to, from, n) (memcpy((to), (from), (n)), 0)
269#define __copy_to_user_inatomic(to, from, n) (memcpy((to), (from), (n)), 0)
270
271#endif
272
273static inline unsigned long __must_check
274__copy_to_user(void __user *to, const void *from, unsigned long n)
275{
276 might_sleep();
277 return __copy_to_user_inatomic(to, from, n);
278}
279
280static inline unsigned long
281__copy_from_user(void *to, const void __user *from, unsigned long n)
282{
283 might_sleep();
284 return __copy_from_user_inatomic(to, from, n);
285}
286
287static inline long copy_from_user(void *to, const void *from, unsigned long n)
288{
289 unsigned long ret = n;
290
291 if (likely(__access_ok(from, n)))
292 ret = __copy_from_user(to, from, n);
293
294 if (unlikely(ret != 0))
295 memset(to + (n - ret), 0, ret);
296
297 return ret;
298}
299
300static inline long copy_to_user(void *to, const void *from, unsigned long n)
301{
302 return likely(__access_ok(to, n)) ? __copy_to_user(to, from, n) : n;
303}
304
305#define copy_to_user_ret(to,from,n,retval) ({ if (copy_to_user(to,from,n)) return retval; })
306#define copy_from_user_ret(to,from,n,retval) ({ if (copy_from_user(to,from,n)) return retval; })
307
308extern long strncpy_from_user(char *dst, const char *src, long count);
309extern long strnlen_user(const char *src, long count);
310
311#define strlen_user(str) strnlen_user(str, 32767)
312
313extern unsigned long search_exception_table(unsigned long addr);
314
315#define copy_to_user_page(vma, page, vaddr, dst, src, len) memcpy(dst, src, len)
316#define copy_from_user_page(vma, page, vaddr, dst, src, len) memcpy(dst, src, len)
317
318#endif /* _ASM_UACCESS_H */
diff --git a/include/asm-frv/ucontext.h b/include/asm-frv/ucontext.h
new file mode 100644
index 000000000000..8d8c0c948007
--- /dev/null
+++ b/include/asm-frv/ucontext.h
@@ -0,0 +1,12 @@
1#ifndef _ASM_UCONTEXT_H
2#define _ASM_UCONTEXT_H
3
4struct ucontext {
5 unsigned long uc_flags;
6 struct ucontext *uc_link;
7 stack_t uc_stack;
8 struct sigcontext uc_mcontext;
9 sigset_t uc_sigmask; /* mask last for extensibility */
10};
11
12#endif
diff --git a/include/asm-frv/unaligned.h b/include/asm-frv/unaligned.h
new file mode 100644
index 000000000000..a0d199bf01d9
--- /dev/null
+++ b/include/asm-frv/unaligned.h
@@ -0,0 +1,203 @@
1/* unaligned.h: unaligned access handler
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_UNALIGNED_H
13#define _ASM_UNALIGNED_H
14
15#include <linux/config.h>
16
17/*
18 * Unaligned accesses on uClinux can't be performed in a fault handler - the
19 * CPU detects them as imprecise exceptions making this impossible.
20 *
21 * With the FR451, however, they are precise, and so we used to fix them up in
22 * the memory access fault handler. However, instruction bundling make this
23 * impractical. So, now we fall back to using memcpy.
24 */
25#ifdef CONFIG_MMU
26
27/*
28 * The asm statement in the macros below is a way to get GCC to copy a
29 * value from one variable to another without having any clue it's
30 * actually doing so, so that it won't have any idea that the values
31 * in the two variables are related.
32 */
33
34#define get_unaligned(ptr) ({ \
35 typeof((*(ptr))) __x; \
36 void *__ptrcopy; \
37 asm("" : "=r" (__ptrcopy) : "0" (ptr)); \
38 memcpy(&__x, __ptrcopy, sizeof(*(ptr))); \
39 __x; \
40})
41
42#define put_unaligned(val, ptr) ({ \
43 typeof((*(ptr))) __x = (val); \
44 void *__ptrcopy; \
45 asm("" : "=r" (__ptrcopy) : "0" (ptr)); \
46 memcpy(__ptrcopy, &__x, sizeof(*(ptr))); \
47})
48
49extern int handle_misalignment(unsigned long esr0, unsigned long ear0, unsigned long epcr0);
50
51#else
52
53#define get_unaligned(ptr) \
54({ \
55 typeof(*(ptr)) x; \
56 const char *__p = (const char *) (ptr); \
57 \
58 switch (sizeof(x)) { \
59 case 1: \
60 x = *(ptr); \
61 break; \
62 case 2: \
63 { \
64 uint8_t a; \
65 asm(" ldub%I2 %M2,%0 \n" \
66 " ldub%I3.p %M3,%1 \n" \
67 " slli %0,#8,%0 \n" \
68 " or %0,%1,%0 \n" \
69 : "=&r"(x), "=&r"(a) \
70 : "m"(__p[0]), "m"(__p[1]) \
71 ); \
72 break; \
73 } \
74 \
75 case 4: \
76 { \
77 uint8_t a; \
78 asm(" ldub%I2 %M2,%0 \n" \
79 " ldub%I3.p %M3,%1 \n" \
80 " slli %0,#8,%0 \n" \
81 " or %0,%1,%0 \n" \
82 " ldub%I4.p %M4,%1 \n" \
83 " slli %0,#8,%0 \n" \
84 " or %0,%1,%0 \n" \
85 " ldub%I5.p %M5,%1 \n" \
86 " slli %0,#8,%0 \n" \
87 " or %0,%1,%0 \n" \
88 : "=&r"(x), "=&r"(a) \
89 : "m"(__p[0]), "m"(__p[1]), "m"(__p[2]), "m"(__p[3]) \
90 ); \
91 break; \
92 } \
93 \
94 case 8: \
95 { \
96 union { uint64_t x; u32 y[2]; } z; \
97 uint8_t a; \
98 asm(" ldub%I3 %M3,%0 \n" \
99 " ldub%I4.p %M4,%2 \n" \
100 " slli %0,#8,%0 \n" \
101 " or %0,%2,%0 \n" \
102 " ldub%I5.p %M5,%2 \n" \
103 " slli %0,#8,%0 \n" \
104 " or %0,%2,%0 \n" \
105 " ldub%I6.p %M6,%2 \n" \
106 " slli %0,#8,%0 \n" \
107 " or %0,%2,%0 \n" \
108 " ldub%I7 %M7,%1 \n" \
109 " ldub%I8.p %M8,%2 \n" \
110 " slli %1,#8,%1 \n" \
111 " or %1,%2,%1 \n" \
112 " ldub%I9.p %M9,%2 \n" \
113 " slli %1,#8,%1 \n" \
114 " or %1,%2,%1 \n" \
115 " ldub%I10.p %M10,%2 \n" \
116 " slli %1,#8,%1 \n" \
117 " or %1,%2,%1 \n" \
118 : "=&r"(z.y[0]), "=&r"(z.y[1]), "=&r"(a) \
119 : "m"(__p[0]), "m"(__p[1]), "m"(__p[2]), "m"(__p[3]), \
120 "m"(__p[4]), "m"(__p[5]), "m"(__p[6]), "m"(__p[7]) \
121 ); \
122 x = z.x; \
123 break; \
124 } \
125 \
126 default: \
127 x = 0; \
128 BUG(); \
129 break; \
130 } \
131 \
132 x; \
133})
134
135#define put_unaligned(val, ptr) \
136do { \
137 char *__p = (char *) (ptr); \
138 int x; \
139 \
140 switch (sizeof(*ptr)) { \
141 case 2: \
142 { \
143 asm(" stb%I1.p %0,%M1 \n" \
144 " srli %0,#8,%0 \n" \
145 " stb%I2 %0,%M2 \n" \
146 : "=r"(x), "=m"(__p[1]), "=m"(__p[0]) \
147 : "0"(val) \
148 ); \
149 break; \
150 } \
151 \
152 case 4: \
153 { \
154 asm(" stb%I1.p %0,%M1 \n" \
155 " srli %0,#8,%0 \n" \
156 " stb%I2.p %0,%M2 \n" \
157 " srli %0,#8,%0 \n" \
158 " stb%I3.p %0,%M3 \n" \
159 " srli %0,#8,%0 \n" \
160 " stb%I4 %0,%M4 \n" \
161 : "=r"(x), "=m"(__p[3]), "=m"(__p[2]), "=m"(__p[1]), "=m"(__p[0]) \
162 : "0"(val) \
163 ); \
164 break; \
165 } \
166 \
167 case 8: \
168 { \
169 uint32_t __high, __low; \
170 __high = (uint64_t)val >> 32; \
171 __low = val & 0xffffffff; \
172 asm(" stb%I2.p %0,%M2 \n" \
173 " srli %0,#8,%0 \n" \
174 " stb%I3.p %0,%M3 \n" \
175 " srli %0,#8,%0 \n" \
176 " stb%I4.p %0,%M4 \n" \
177 " srli %0,#8,%0 \n" \
178 " stb%I5.p %0,%M5 \n" \
179 " srli %0,#8,%0 \n" \
180 " stb%I6.p %1,%M6 \n" \
181 " srli %1,#8,%1 \n" \
182 " stb%I7.p %1,%M7 \n" \
183 " srli %1,#8,%1 \n" \
184 " stb%I8.p %1,%M8 \n" \
185 " srli %1,#8,%1 \n" \
186 " stb%I9 %1,%M9 \n" \
187 : "=&r"(__low), "=&r"(__high), "=m"(__p[7]), "=m"(__p[6]), \
188 "=m"(__p[5]), "=m"(__p[4]), "=m"(__p[3]), "=m"(__p[2]), \
189 "=m"(__p[1]), "=m"(__p[0]) \
190 : "0"(__low), "1"(__high) \
191 ); \
192 break; \
193 } \
194 \
195 default: \
196 *(ptr) = (val); \
197 break; \
198 } \
199} while(0)
200
201#endif
202
203#endif
diff --git a/include/asm-frv/unistd.h b/include/asm-frv/unistd.h
new file mode 100644
index 000000000000..5cf989b448d5
--- /dev/null
+++ b/include/asm-frv/unistd.h
@@ -0,0 +1,501 @@
1#ifndef _ASM_UNISTD_H_
2#define _ASM_UNISTD_H_
3
4/*
5 * This file contains the system call numbers.
6 */
7
8#define __NR_restart_syscall 0
9#define __NR_exit 1
10#define __NR_fork 2
11#define __NR_read 3
12#define __NR_write 4
13#define __NR_open 5
14#define __NR_close 6
15#define __NR_waitpid 7
16#define __NR_creat 8
17#define __NR_link 9
18#define __NR_unlink 10
19#define __NR_execve 11
20#define __NR_chdir 12
21#define __NR_time 13
22#define __NR_mknod 14
23#define __NR_chmod 15
24#define __NR_lchown 16
25#define __NR_break 17
26#define __NR_oldstat 18
27#define __NR_lseek 19
28#define __NR_getpid 20
29#define __NR_mount 21
30#define __NR_umount 22
31#define __NR_setuid 23
32#define __NR_getuid 24
33#define __NR_stime 25
34#define __NR_ptrace 26
35#define __NR_alarm 27
36#define __NR_oldfstat 28
37#define __NR_pause 29
38#define __NR_utime 30
39#define __NR_stty 31
40#define __NR_gtty 32
41#define __NR_access 33
42#define __NR_nice 34
43#define __NR_ftime 35
44#define __NR_sync 36
45#define __NR_kill 37
46#define __NR_rename 38
47#define __NR_mkdir 39
48#define __NR_rmdir 40
49#define __NR_dup 41
50#define __NR_pipe 42
51#define __NR_times 43
52#define __NR_prof 44
53#define __NR_brk 45
54#define __NR_setgid 46
55#define __NR_getgid 47
56#define __NR_signal 48
57#define __NR_geteuid 49
58#define __NR_getegid 50
59#define __NR_acct 51
60#define __NR_umount2 52
61#define __NR_lock 53
62#define __NR_ioctl 54
63#define __NR_fcntl 55
64#define __NR_mpx 56
65#define __NR_setpgid 57
66#define __NR_ulimit 58
67// #define __NR_oldolduname /* 59 */ obsolete
68#define __NR_umask 60
69#define __NR_chroot 61
70#define __NR_ustat 62
71#define __NR_dup2 63
72#define __NR_getppid 64
73#define __NR_getpgrp 65
74#define __NR_setsid 66
75#define __NR_sigaction 67
76#define __NR_sgetmask 68
77#define __NR_ssetmask 69
78#define __NR_setreuid 70
79#define __NR_setregid 71
80#define __NR_sigsuspend 72
81#define __NR_sigpending 73
82#define __NR_sethostname 74
83#define __NR_setrlimit 75
84#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */
85#define __NR_getrusage 77
86#define __NR_gettimeofday 78
87#define __NR_settimeofday 79
88#define __NR_getgroups 80
89#define __NR_setgroups 81
90#define __NR_select 82
91#define __NR_symlink 83
92#define __NR_oldlstat 84
93#define __NR_readlink 85
94#define __NR_uselib 86
95#define __NR_swapon 87
96#define __NR_reboot 88
97#define __NR_readdir 89
98// #define __NR_mmap 90 /* obsolete - not implemented */
99#define __NR_munmap 91
100#define __NR_truncate 92
101#define __NR_ftruncate 93
102#define __NR_fchmod 94
103#define __NR_fchown 95
104#define __NR_getpriority 96
105#define __NR_setpriority 97
106// #define __NR_profil /* 98 */ obsolete
107#define __NR_statfs 99
108#define __NR_fstatfs 100
109// #define __NR_ioperm /* 101 */ not supported
110#define __NR_socketcall 102
111#define __NR_syslog 103
112#define __NR_setitimer 104
113#define __NR_getitimer 105
114#define __NR_stat 106
115#define __NR_lstat 107
116#define __NR_fstat 108
117// #define __NR_olduname /* 109 */ obsolete
118// #define __NR_iopl /* 110 */ not supported
119#define __NR_vhangup 111
120// #define __NR_idle /* 112 */ Obsolete
121// #define __NR_vm86old /* 113 */ not supported
122#define __NR_wait4 114
123#define __NR_swapoff 115
124#define __NR_sysinfo 116
125#define __NR_ipc 117
126#define __NR_fsync 118
127#define __NR_sigreturn 119
128#define __NR_clone 120
129#define __NR_setdomainname 121
130#define __NR_uname 122
131// #define __NR_modify_ldt /* 123 */ not supported
132#define __NR_cacheflush 123
133#define __NR_adjtimex 124
134#define __NR_mprotect 125
135#define __NR_sigprocmask 126
136#define __NR_create_module 127
137#define __NR_init_module 128
138#define __NR_delete_module 129
139#define __NR_get_kernel_syms 130
140#define __NR_quotactl 131
141#define __NR_getpgid 132
142#define __NR_fchdir 133
143#define __NR_bdflush 134
144#define __NR_sysfs 135
145#define __NR_personality 136
146#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
147#define __NR_setfsuid 138
148#define __NR_setfsgid 139
149#define __NR__llseek 140
150#define __NR_getdents 141
151#define __NR__newselect 142
152#define __NR_flock 143
153#define __NR_msync 144
154#define __NR_readv 145
155#define __NR_writev 146
156#define __NR_getsid 147
157#define __NR_fdatasync 148
158#define __NR__sysctl 149
159#define __NR_mlock 150
160#define __NR_munlock 151
161#define __NR_mlockall 152
162#define __NR_munlockall 153
163#define __NR_sched_setparam 154
164#define __NR_sched_getparam 155
165#define __NR_sched_setscheduler 156
166#define __NR_sched_getscheduler 157
167#define __NR_sched_yield 158
168#define __NR_sched_get_priority_max 159
169#define __NR_sched_get_priority_min 160
170#define __NR_sched_rr_get_interval 161
171#define __NR_nanosleep 162
172#define __NR_mremap 163
173#define __NR_setresuid 164
174#define __NR_getresuid 165
175// #define __NR_vm86 /* 166 */ not supported
176#define __NR_query_module 167
177#define __NR_poll 168
178#define __NR_nfsservctl 169
179#define __NR_setresgid 170
180#define __NR_getresgid 171
181#define __NR_prctl 172
182#define __NR_rt_sigreturn 173
183#define __NR_rt_sigaction 174
184#define __NR_rt_sigprocmask 175
185#define __NR_rt_sigpending 176
186#define __NR_rt_sigtimedwait 177
187#define __NR_rt_sigqueueinfo 178
188#define __NR_rt_sigsuspend 179
189#define __NR_pread 180
190#define __NR_pwrite 181
191#define __NR_chown 182
192#define __NR_getcwd 183
193#define __NR_capget 184
194#define __NR_capset 185
195#define __NR_sigaltstack 186
196#define __NR_sendfile 187
197#define __NR_getpmsg 188 /* some people actually want streams */
198#define __NR_putpmsg 189 /* some people actually want streams */
199#define __NR_vfork 190
200#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
201#define __NR_mmap2 192
202#define __NR_truncate64 193
203#define __NR_ftruncate64 194
204#define __NR_stat64 195
205#define __NR_lstat64 196
206#define __NR_fstat64 197
207#define __NR_lchown32 198
208#define __NR_getuid32 199
209#define __NR_getgid32 200
210#define __NR_geteuid32 201
211#define __NR_getegid32 202
212#define __NR_setreuid32 203
213#define __NR_setregid32 204
214#define __NR_getgroups32 205
215#define __NR_setgroups32 206
216#define __NR_fchown32 207
217#define __NR_setresuid32 208
218#define __NR_getresuid32 209
219#define __NR_setresgid32 210
220#define __NR_getresgid32 211
221#define __NR_chown32 212
222#define __NR_setuid32 213
223#define __NR_setgid32 214
224#define __NR_setfsuid32 215
225#define __NR_setfsgid32 216
226#define __NR_pivot_root 217
227#define __NR_mincore 218
228#define __NR_madvise 219
229
230#define __NR_getdents64 220
231#define __NR_fcntl64 221
232#define __NR_security 223 /* syscall for security modules */
233#define __NR_gettid 224
234#define __NR_readahead 225
235#define __NR_setxattr 226
236#define __NR_lsetxattr 227
237#define __NR_fsetxattr 228
238#define __NR_getxattr 229
239#define __NR_lgetxattr 230
240#define __NR_fgetxattr 231
241#define __NR_listxattr 232
242#define __NR_llistxattr 233
243#define __NR_flistxattr 234
244#define __NR_removexattr 235
245#define __NR_lremovexattr 236
246#define __NR_fremovexattr 237
247#define __NR_tkill 238
248#define __NR_sendfile64 239
249#define __NR_futex 240
250#define __NR_sched_setaffinity 241
251#define __NR_sched_getaffinity 242
252#define __NR_set_thread_area 243
253#define __NR_get_thread_area 244
254#define __NR_io_setup 245
255#define __NR_io_destroy 246
256#define __NR_io_getevents 247
257#define __NR_io_submit 248
258#define __NR_io_cancel 249
259#define __NR_fadvise64 250
260
261#define __NR_exit_group 252
262#define __NR_lookup_dcookie 253
263#define __NR_epoll_create 254
264#define __NR_epoll_ctl 255
265#define __NR_epoll_wait 256
266#define __NR_remap_file_pages 257
267#define __NR_set_tid_address 258
268#define __NR_timer_create 259
269#define __NR_timer_settime (__NR_timer_create+1)
270#define __NR_timer_gettime (__NR_timer_create+2)
271#define __NR_timer_getoverrun (__NR_timer_create+3)
272#define __NR_timer_delete (__NR_timer_create+4)
273#define __NR_clock_settime (__NR_timer_create+5)
274#define __NR_clock_gettime (__NR_timer_create+6)
275#define __NR_clock_getres (__NR_timer_create+7)
276#define __NR_clock_nanosleep (__NR_timer_create+8)
277#define __NR_statfs64 268
278#define __NR_fstatfs64 269
279#define __NR_tgkill 270
280#define __NR_utimes 271
281#define __NR_fadvise64_64 272
282#define __NR_vserver 273
283#define __NR_mbind 274
284#define __NR_get_mempolicy 275
285#define __NR_set_mempolicy 276
286#define __NR_mq_open 277
287#define __NR_mq_unlink (__NR_mq_open+1)
288#define __NR_mq_timedsend (__NR_mq_open+2)
289#define __NR_mq_timedreceive (__NR_mq_open+3)
290#define __NR_mq_notify (__NR_mq_open+4)
291#define __NR_mq_getsetattr (__NR_mq_open+5)
292#define __NR_sys_kexec_load 283
293#define __NR_waitid 284
294/* #define __NR_sys_setaltroot 285 */
295#define __NR_add_key 286
296#define __NR_request_key 287
297#define __NR_keyctl 288
298#define __NR_vperfctr_open 289
299#define __NR_vperfctr_control (__NR_perfctr_info+1)
300#define __NR_vperfctr_unlink (__NR_perfctr_info+2)
301#define __NR_vperfctr_iresume (__NR_perfctr_info+3)
302#define __NR_vperfctr_read (__NR_perfctr_info+4)
303
304#define NR_syscalls 294
305
306/*
307 * process the return value of a syscall, consigning it to one of two possible fates
308 * - user-visible error numbers are in the range -1 - -4095: see <asm-frv/errno.h>
309 */
310#undef __syscall_return
311#define __syscall_return(type, res) \
312do { \
313 unsigned long __sr2 = (res); \
314 if (__builtin_expect(__sr2 >= (unsigned long)(-4095), 0)) { \
315 errno = (-__sr2); \
316 __sr2 = ULONG_MAX; \
317 } \
318 return (type) __sr2; \
319} while (0)
320
321/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
322
323#undef _syscall0
324#define _syscall0(type,name) \
325type name(void) \
326{ \
327 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
328 register unsigned long __sc0 __asm__ ("gr8"); \
329 __asm__ __volatile__ ("tira gr0,#0" \
330 : "=r" (__sc0) \
331 : "r" (__scnum)); \
332 __syscall_return(type, __sc0); \
333}
334
335#undef _syscall1
336#define _syscall1(type,name,type1,arg1) \
337type name(type1 arg1) \
338{ \
339 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
340 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
341 __asm__ __volatile__ ("tira gr0,#0" \
342 : "+r" (__sc0) \
343 : "r" (__scnum)); \
344 __syscall_return(type, __sc0); \
345}
346
347#undef _syscall2
348#define _syscall2(type,name,type1,arg1,type2,arg2) \
349type name(type1 arg1,type2 arg2) \
350{ \
351 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
352 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
353 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
354 __asm__ __volatile__ ("tira gr0,#0" \
355 : "+r" (__sc0) \
356 : "r" (__scnum), "r" (__sc1)); \
357 __syscall_return(type, __sc0); \
358}
359
360#undef _syscall3
361#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
362type name(type1 arg1,type2 arg2,type3 arg3) \
363{ \
364 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
365 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
366 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
367 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
368 __asm__ __volatile__ ("tira gr0,#0" \
369 : "+r" (__sc0) \
370 : "r" (__scnum), "r" (__sc1), "r" (__sc2)); \
371 __syscall_return(type, __sc0); \
372}
373
374#undef _syscall4
375#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
376type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
377{ \
378 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
379 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
380 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
381 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
382 register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \
383 __asm__ __volatile__ ("tira gr0,#0" \
384 : "+r" (__sc0) \
385 : "r" (__scnum), "r" (__sc1), "r" (__sc2), "r" (__sc3)); \
386 __syscall_return(type, __sc0); \
387}
388
389#undef _syscall5
390#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
391type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
392{ \
393 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
394 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
395 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
396 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
397 register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \
398 register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5; \
399 __asm__ __volatile__ ("tira gr0,#0" \
400 : "+r" (__sc0) \
401 : "r" (__scnum), "r" (__sc1), "r" (__sc2), \
402 "r" (__sc3), "r" (__sc4)); \
403 __syscall_return(type, __sc0); \
404}
405
406#undef _syscall6
407#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6, arg6) \
408type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
409{ \
410 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
411 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
412 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
413 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
414 register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \
415 register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5; \
416 register unsigned long __sc5 __asm__ ("gr13") = (unsigned long) arg6; \
417 __asm__ __volatile__ ("tira gr0,#0" \
418 : "+r" (__sc0) \
419 : "r" (__scnum), "r" (__sc1), "r" (__sc2), \
420 "r" (__sc3), "r" (__sc4), "r" (__sc5)); \
421 __syscall_return(type, __sc0); \
422}
423
424
425#ifdef __KERNEL_SYSCALLS__
426
427#include <linux/compiler.h>
428#include <linux/types.h>
429#include <linux/linkage.h>
430#include <asm/ptrace.h>
431
432/*
433 * we need this inline - forking from kernel space will result
434 * in NO COPY ON WRITE (!!!), until an execve is executed. This
435 * is no problem, but for the stack. This is handled by not letting
436 * main() use the stack at all after fork(). Thus, no function
437 * calls - which means inline code for fork too, as otherwise we
438 * would use the stack upon exit from 'fork()'.
439 *
440 * Actually only pause and fork are needed inline, so that there
441 * won't be any messing with the stack from main(), but we define
442 * some others too.
443 */
444#define __NR__exit __NR_exit
445static inline _syscall0(int,pause)
446static inline _syscall0(int,sync)
447static inline _syscall0(pid_t,setsid)
448static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
449static inline _syscall3(int,read,int,fd,char *,buf,off_t,count)
450static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
451static inline _syscall1(int,dup,int,fd)
452static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
453static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
454static inline _syscall1(int,close,int,fd)
455static inline _syscall1(int,_exit,int,exitcode)
456static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
457static inline _syscall1(int,delete_module,const char *,name)
458
459static inline pid_t wait(int * wait_stat)
460{
461 return waitpid(-1,wait_stat,0);
462}
463
464#endif
465
466#ifdef __KERNEL__
467#define __ARCH_WANT_IPC_PARSE_VERSION
468/* #define __ARCH_WANT_OLD_READDIR */
469#define __ARCH_WANT_OLD_STAT
470#define __ARCH_WANT_STAT64
471#define __ARCH_WANT_SYS_ALARM
472/* #define __ARCH_WANT_SYS_GETHOSTNAME */
473#define __ARCH_WANT_SYS_PAUSE
474/* #define __ARCH_WANT_SYS_SGETMASK */
475/* #define __ARCH_WANT_SYS_SIGNAL */
476#define __ARCH_WANT_SYS_TIME
477#define __ARCH_WANT_SYS_UTIME
478#define __ARCH_WANT_SYS_WAITPID
479#define __ARCH_WANT_SYS_SOCKETCALL
480#define __ARCH_WANT_SYS_FADVISE64
481#define __ARCH_WANT_SYS_GETPGRP
482#define __ARCH_WANT_SYS_LLSEEK
483#define __ARCH_WANT_SYS_NICE
484/* #define __ARCH_WANT_SYS_OLD_GETRLIMIT */
485#define __ARCH_WANT_SYS_OLDUMOUNT
486/* #define __ARCH_WANT_SYS_SIGPENDING */
487#define __ARCH_WANT_SYS_SIGPROCMASK
488#define __ARCH_WANT_SYS_RT_SIGACTION
489#endif
490
491/*
492 * "Conditional" syscalls
493 *
494 * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
495 * but it doesn't work on all toolchains, so we just do it by hand
496 */
497#ifndef cond_syscall
498#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall")
499#endif
500
501#endif /* _ASM_UNISTD_H_ */
diff --git a/include/asm-frv/user.h b/include/asm-frv/user.h
new file mode 100644
index 000000000000..82fa8fab64ae
--- /dev/null
+++ b/include/asm-frv/user.h
@@ -0,0 +1,80 @@
1/* user.h: FR-V core file format stuff
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#ifndef _ASM_USER_H
12#define _ASM_USER_H
13
14#include <asm/page.h>
15#include <asm/registers.h>
16
17/* Core file format: The core file is written in such a way that gdb
18 * can understand it and provide useful information to the user (under
19 * linux we use the 'trad-core' bfd). There are quite a number of
20 * obstacles to being able to view the contents of the floating point
21 * registers, and until these are solved you will not be able to view
22 * the contents of them. Actually, you can read in the core file and
23 * look at the contents of the user struct to find out what the
24 * floating point registers contain.
25 *
26 * The actual file contents are as follows:
27 * UPAGE:
28 * 1 page consisting of a user struct that tells gdb what is present
29 * in the file. Directly after this is a copy of the task_struct,
30 * which is currently not used by gdb, but it may come in useful at
31 * some point. All of the registers are stored as part of the
32 * upage. The upage should always be only one page.
33 *
34 * DATA:
35 * The data area is stored. We use current->end_text to
36 * current->brk to pick up all of the user variables, plus any
37 * memory that may have been malloced. No attempt is made to
38 * determine if a page is demand-zero or if a page is totally
39 * unused, we just cover the entire range. All of the addresses are
40 * rounded in such a way that an integral number of pages is
41 * written.
42 *
43 * STACK:
44 * We need the stack information in order to get a meaningful
45 * backtrace. We need to write the data from (esp) to
46 * current->start_stack, so we round each of these off in order to
47 * be able to write an integer number of pages. The minimum core
48 * file size is 3 pages, or 12288 bytes.
49 */
50
51/* When the kernel dumps core, it starts by dumping the user struct -
52 * this will be used by gdb to figure out where the data and stack segments
53 * are within the file, and what virtual addresses to use.
54 */
55struct user {
56 /* We start with the registers, to mimic the way that "memory" is returned
57 * from the ptrace(3,...) function. */
58 struct user_context regs;
59
60 /* The rest of this junk is to help gdb figure out what goes where */
61 unsigned long u_tsize; /* Text segment size (pages). */
62 unsigned long u_dsize; /* Data segment size (pages). */
63 unsigned long u_ssize; /* Stack segment size (pages). */
64 unsigned long start_code; /* Starting virtual address of text. */
65 unsigned long start_stack; /* Starting virtual address of stack area.
66 * This is actually the bottom of the stack,
67 * the top of the stack is always found in the
68 * esp register. */
69 long int signal; /* Signal that caused the core dump. */
70
71 unsigned long magic; /* To uniquely identify a core file */
72 char u_comm[32]; /* User command that was responsible */
73};
74
75#define NBPG PAGE_SIZE
76#define UPAGES 1
77#define HOST_TEXT_START_ADDR (u.start_code)
78#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
79
80#endif
diff --git a/include/asm-frv/virtconvert.h b/include/asm-frv/virtconvert.h
new file mode 100644
index 000000000000..a29a0aec291f
--- /dev/null
+++ b/include/asm-frv/virtconvert.h
@@ -0,0 +1,42 @@
1/* virtconvert.h: virtual/physical/page address convertion
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#ifndef _ASM_VIRTCONVERT_H
12#define _ASM_VIRTCONVERT_H
13
14/*
15 * Macros used for converting between virtual and physical mappings.
16 */
17
18#ifdef __KERNEL__
19
20#include <linux/config.h>
21#include <asm/setup.h>
22
23#ifdef CONFIG_MMU
24
25#define phys_to_virt(vaddr) ((void *) ((unsigned long)(vaddr) + PAGE_OFFSET))
26#define virt_to_phys(vaddr) ((unsigned long) (vaddr) - PAGE_OFFSET)
27
28#else
29
30#define phys_to_virt(vaddr) ((void *) (vaddr))
31#define virt_to_phys(vaddr) ((unsigned long) (vaddr))
32
33#endif
34
35#define virt_to_bus virt_to_phys
36#define bus_to_virt phys_to_virt
37
38#define __page_address(page) (PAGE_OFFSET + (((page) - mem_map) << PAGE_SHIFT))
39#define page_to_phys(page) virt_to_phys((void *)__page_address(page))
40
41#endif
42#endif