aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-m32r
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-m32r
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-m32r')
-rw-r--r--include/asm-m32r/a.out.h28
-rw-r--r--include/asm-m32r/addrspace.h58
-rw-r--r--include/asm-m32r/assembler.h225
-rw-r--r--include/asm-m32r/atomic.h295
-rw-r--r--include/asm-m32r/bitops.h702
-rw-r--r--include/asm-m32r/bug.h4
-rw-r--r--include/asm-m32r/bugs.h21
-rw-r--r--include/asm-m32r/byteorder.h19
-rw-r--r--include/asm-m32r/cache.h12
-rw-r--r--include/asm-m32r/cachectl.h26
-rw-r--r--include/asm-m32r/cacheflush.h68
-rw-r--r--include/asm-m32r/checksum.h208
-rw-r--r--include/asm-m32r/cputime.h6
-rw-r--r--include/asm-m32r/current.h18
-rw-r--r--include/asm-m32r/delay.h28
-rw-r--r--include/asm-m32r/div64.h38
-rw-r--r--include/asm-m32r/dma-mapping.h23
-rw-r--r--include/asm-m32r/dma.h14
-rw-r--r--include/asm-m32r/elf.h136
-rw-r--r--include/asm-m32r/errno.h9
-rw-r--r--include/asm-m32r/fcntl.h92
-rw-r--r--include/asm-m32r/flat.h145
-rw-r--r--include/asm-m32r/hardirq.h37
-rw-r--r--include/asm-m32r/hdreg.h1
-rw-r--r--include/asm-m32r/hw_irq.h9
-rw-r--r--include/asm-m32r/ide.h82
-rw-r--r--include/asm-m32r/io.h232
-rw-r--r--include/asm-m32r/ioctl.h78
-rw-r--r--include/asm-m32r/ioctls.h88
-rw-r--r--include/asm-m32r/ipc.h1
-rw-r--r--include/asm-m32r/ipcbuf.h33
-rw-r--r--include/asm-m32r/irq.h75
-rw-r--r--include/asm-m32r/kmap_types.h34
-rw-r--r--include/asm-m32r/linkage.h7
-rw-r--r--include/asm-m32r/local.h6
-rw-r--r--include/asm-m32r/m32102.h294
-rw-r--r--include/asm-m32r/m32102peri.h468
-rw-r--r--include/asm-m32r/m32700ut/m32700ut_lan.h107
-rw-r--r--include/asm-m32r/m32700ut/m32700ut_lcd.h59
-rw-r--r--include/asm-m32r/m32700ut/m32700ut_pld.h265
-rw-r--r--include/asm-m32r/m32r.h134
-rw-r--r--include/asm-m32r/m32r_mp_fpga.h313
-rw-r--r--include/asm-m32r/mappi2/mappi2_pld.h151
-rw-r--r--include/asm-m32r/mc146818rtc.h32
-rw-r--r--include/asm-m32r/mman.h45
-rw-r--r--include/asm-m32r/mmu.h21
-rw-r--r--include/asm-m32r/mmu_context.h170
-rw-r--r--include/asm-m32r/mmzone.h80
-rw-r--r--include/asm-m32r/module.h13
-rw-r--r--include/asm-m32r/msgbuf.h35
-rw-r--r--include/asm-m32r/namei.h21
-rw-r--r--include/asm-m32r/numnodes.h15
-rw-r--r--include/asm-m32r/opsput/opsput_lan.h56
-rw-r--r--include/asm-m32r/opsput/opsput_lcd.h59
-rw-r--r--include/asm-m32r/opsput/opsput_pld.h259
-rw-r--r--include/asm-m32r/page.h115
-rw-r--r--include/asm-m32r/param.h27
-rw-r--r--include/asm-m32r/pci.h10
-rw-r--r--include/asm-m32r/percpu.h6
-rw-r--r--include/asm-m32r/pgalloc.h78
-rw-r--r--include/asm-m32r/pgtable-2level.h78
-rw-r--r--include/asm-m32r/pgtable.h400
-rw-r--r--include/asm-m32r/poll.h31
-rw-r--r--include/asm-m32r/posix_types.h126
-rw-r--r--include/asm-m32r/processor.h143
-rw-r--r--include/asm-m32r/ptrace.h165
-rw-r--r--include/asm-m32r/resource.h6
-rw-r--r--include/asm-m32r/rtc.h70
-rw-r--r--include/asm-m32r/scatterlist.h18
-rw-r--r--include/asm-m32r/sections.h8
-rw-r--r--include/asm-m32r/segment.h14
-rw-r--r--include/asm-m32r/semaphore.h205
-rw-r--r--include/asm-m32r/sembuf.h29
-rw-r--r--include/asm-m32r/serial.h10
-rw-r--r--include/asm-m32r/setup.h33
-rw-r--r--include/asm-m32r/shmbuf.h46
-rw-r--r--include/asm-m32r/shmparam.h8
-rw-r--r--include/asm-m32r/sigcontext.h50
-rw-r--r--include/asm-m32r/siginfo.h8
-rw-r--r--include/asm-m32r/signal.h200
-rw-r--r--include/asm-m32r/smp.h118
-rw-r--r--include/asm-m32r/socket.h50
-rw-r--r--include/asm-m32r/sockios.h14
-rw-r--r--include/asm-m32r/spinlock.h380
-rw-r--r--include/asm-m32r/stat.h91
-rw-r--r--include/asm-m32r/statfs.h6
-rw-r--r--include/asm-m32r/string.h15
-rw-r--r--include/asm-m32r/syscall.h11
-rw-r--r--include/asm-m32r/system.h299
-rw-r--r--include/asm-m32r/termbits.h176
-rw-r--r--include/asm-m32r/termios.h109
-rw-r--r--include/asm-m32r/thread_info.h182
-rw-r--r--include/asm-m32r/timex.h34
-rw-r--r--include/asm-m32r/tlb.h20
-rw-r--r--include/asm-m32r/tlbflush.h102
-rw-r--r--include/asm-m32r/topology.h48
-rw-r--r--include/asm-m32r/types.h64
-rw-r--r--include/asm-m32r/uaccess.h753
-rw-r--r--include/asm-m32r/ucontext.h14
-rw-r--r--include/asm-m32r/unaligned.h25
-rw-r--r--include/asm-m32r/unistd.h474
-rw-r--r--include/asm-m32r/user.h59
-rw-r--r--include/asm-m32r/vga.h22
-rw-r--r--include/asm-m32r/xor.h8
104 files changed, 10413 insertions, 0 deletions
diff --git a/include/asm-m32r/a.out.h b/include/asm-m32r/a.out.h
new file mode 100644
index 000000000000..4619ba5c372e
--- /dev/null
+++ b/include/asm-m32r/a.out.h
@@ -0,0 +1,28 @@
1#ifndef _ASM_M32R_A_OUT_H
2#define _ASM_M32R_A_OUT_H
3
4/* orig : i386 2.4.18 */
5
6struct exec
7{
8 unsigned long a_info; /* Use macros N_MAGIC, etc for access */
9 unsigned a_text; /* length of text, in bytes */
10 unsigned a_data; /* length of data, in bytes */
11 unsigned a_bss; /* length of uninitialized data area for file, in bytes */
12 unsigned a_syms; /* length of symbol table data in file, in bytes */
13 unsigned a_entry; /* start address */
14 unsigned a_trsize; /* length of relocation info for text, in bytes */
15 unsigned a_drsize; /* length of relocation info for data, in bytes */
16};
17
18#define N_TRSIZE(a) ((a).a_trsize)
19#define N_DRSIZE(a) ((a).a_drsize)
20#define N_SYMSIZE(a) ((a).a_syms)
21
22#ifdef __KERNEL__
23
24#define STACK_TOP TASK_SIZE
25
26#endif
27
28#endif /* _ASM_M32R_A_OUT_H */
diff --git a/include/asm-m32r/addrspace.h b/include/asm-m32r/addrspace.h
new file mode 100644
index 000000000000..06a83dc94648
--- /dev/null
+++ b/include/asm-m32r/addrspace.h
@@ -0,0 +1,58 @@
1/* $Id$ */
2/*
3 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive
5 * for more details.
6 *
7 * Copyright (C) 2001 by Hiroyuki Kondo
8 *
9 * Defitions for the address spaces of the M32R CPUs.
10 */
11#ifndef __ASM_M32R_ADDRSPACE_H
12#define __ASM_M32R_ADDRSPACE_H
13
14/*
15 * Memory segments (32bit kernel mode addresses)
16 */
17#define KUSEG 0x00000000
18#define KSEG0 0x80000000
19#define KSEG1 0xa0000000
20#define KSEG2 0xc0000000
21#define KSEG3 0xe0000000
22
23#define K0BASE KSEG0
24
25/*
26 * Returns the kernel segment base of a given address
27 */
28#ifndef __ASSEMBLY__
29#define KSEGX(a) (((unsigned long)(a)) & 0xe0000000)
30#else
31#define KSEGX(a) ((a) & 0xe0000000)
32#endif
33
34/*
35 * Returns the physical address of a KSEG0/KSEG1 address
36 */
37#ifndef __ASSEMBLY__
38#define PHYSADDR(a) (((unsigned long)(a)) & 0x1fffffff)
39#else
40#define PHYSADDR(a) ((a) & 0x1fffffff)
41#endif
42
43/*
44 * Map an address to a certain kernel segment
45 */
46#ifndef __ASSEMBLY__
47#define KSEG0ADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | KSEG0))
48#define KSEG1ADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | KSEG1))
49#define KSEG2ADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | KSEG2))
50#define KSEG3ADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | KSEG3))
51#else
52#define KSEG0ADDR(a) (((a) & 0x1fffffff) | KSEG0)
53#define KSEG1ADDR(a) (((a) & 0x1fffffff) | KSEG1)
54#define KSEG2ADDR(a) (((a) & 0x1fffffff) | KSEG2)
55#define KSEG3ADDR(a) (((a) & 0x1fffffff) | KSEG3)
56#endif
57
58#endif /* __ASM_M32R_ADDRSPACE_H */
diff --git a/include/asm-m32r/assembler.h b/include/asm-m32r/assembler.h
new file mode 100644
index 000000000000..e1dff9d6baad
--- /dev/null
+++ b/include/asm-m32r/assembler.h
@@ -0,0 +1,225 @@
1#ifndef _ASM_M32R_ASSEMBLER_H
2#define _ASM_M32R_ASSEMBLER_H
3
4/*
5 * linux/asm-m32r/assembler.h
6 *
7 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
8 *
9 * This file contains M32R architecture specific macro definitions.
10 */
11
12#include <linux/config.h>
13
14#ifndef __STR
15#ifdef __ASSEMBLY__
16#define __STR(x) x
17#else
18#define __STR(x) #x
19#endif
20#endif /* __STR */
21
22#ifdef CONFIG_SMP
23#define M32R_LOCK __STR(lock)
24#define M32R_UNLOCK __STR(unlock)
25#else
26#define M32R_LOCK __STR(ld)
27#define M32R_UNLOCK __STR(st)
28#endif
29
30#ifdef __ASSEMBLY__
31#undef ENTRY
32#define ENTRY(name) ENTRY_M name
33 .macro ENTRY_M name
34 .global \name
35 ALIGN
36\name:
37 .endm
38#endif
39
40
41/**
42 * LDIMM - load immediate value
43 * STI - enable interruption
44 * CLI - disable interruption
45 */
46
47#ifdef __ASSEMBLY__
48
49#define LDIMM(reg,x) LDIMM reg x
50 .macro LDIMM reg x
51 seth \reg, #high(\x)
52 or3 \reg, \reg, #low(\x)
53 .endm
54
55#if !defined(CONFIG_CHIP_M32102)
56#define STI(reg) STI_M reg
57 .macro STI_M reg
58 setpsw #0x40 -> nop
59 ; WORKAROUND: "-> nop" is a workaround for the M32700(TS1).
60 .endm
61
62#define CLI(reg) CLI_M reg
63 .macro CLI_M reg
64 clrpsw #0x40 -> nop
65 ; WORKAROUND: "-> nop" is a workaround for the M32700(TS1).
66 .endm
67#else /* CONFIG_CHIP_M32102 */
68#define STI(reg) STI_M reg
69 .macro STI_M reg
70 mvfc \reg, psw
71 or3 \reg, \reg, #0x0040
72 mvtc \reg, psw
73 .endm
74
75#define CLI(reg) CLI_M reg
76 .macro CLI_M reg
77 mvfc \reg, psw
78 and3 \reg, \reg, #0xffbf
79 mvtc \reg, psw
80 .endm
81#endif /* CONFIG_CHIP_M32102 */
82
83 .macro SAVE_ALL
84 push r0 ; orig_r0
85 push sp ; spi (r15)
86 push lr ; r14
87 push r13
88 mvfc r13, cr3 ; spu
89 push r13
90 mvfc r13, bbpc
91 push r13
92 mvfc r13, bbpsw
93 push r13
94 mvfc r13, bpc
95 push r13
96 mvfc r13, psw
97 push r13
98#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
99 mvfaclo r13, a1
100 push r13
101 mvfachi r13, a1
102 push r13
103 mvfaclo r13, a0
104 push r13
105 mvfachi r13, a0
106 push r13
107#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
108 mvfaclo r13
109 push r13
110 mvfachi r13
111 push r13
112#else
113#error unknown isa configuration
114#endif
115 ldi r13, #-1
116 push r13 ; syscall_nr (default: -1)
117 push r12
118 push r11
119 push r10
120 push r9
121 push r8
122 push r7
123 push r3
124 push r2
125 push r1
126 push r0
127 addi sp, #-4 ; room for implicit pt_regs parameter
128 push r6
129 push r5
130 push r4
131 .endm
132
133 .macro RESTORE_ALL
134 pop r4
135 pop r5
136 pop r6
137 addi sp, #4
138 pop r0
139 pop r1
140 pop r2
141 pop r3
142 pop r7
143 pop r8
144 pop r9
145 pop r10
146 pop r11
147 pop r12
148 addi r15, #4 ; Skip syscall number
149#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
150 pop r13
151 mvtachi r13, a0
152 pop r13
153 mvtaclo r13, a0
154 pop r13
155 mvtachi r13, a1
156 pop r13
157 mvtaclo r13, a1
158#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
159 pop r13
160 mvtachi r13
161 pop r13
162 mvtaclo r13
163#else
164#error unknown isa configuration
165#endif
166 pop r14
167 mvtc r14, psw
168 pop r14
169 mvtc r14, bpc
170 addi sp, #8 ; Skip bbpsw, bbpc
171 pop r14
172 mvtc r14, cr3 ; spu
173 pop r13
174 pop lr ; r14
175 pop sp ; spi (r15)
176 addi sp, #4 ; Skip orig_r0
177 .fillinsn
1781: rte
179 .section .fixup,"ax"
1802: bl do_exit
181 .previous
182 .section __ex_table,"a"
183 ALIGN
184 .long 1b, 2b
185 .previous
186 .endm
187
188#define GET_CURRENT(reg) get_current reg
189 .macro get_current reg
190 ldi \reg, #-8192
191 and \reg, sp
192 .endm
193
194#if !defined(CONFIG_CHIP_M32102)
195 .macro SWITCH_TO_KERNEL_STACK
196 ; switch to kernel stack (spi)
197 clrpsw #0x80 -> nop
198 .endm
199#else /* CONFIG_CHIP_M32102 */
200 .macro SWITCH_TO_KERNEL_STACK
201 push r0 ; save r0 for working
202 mvfc r0, psw
203 and3 r0, r0, #0x00ff7f
204 mvtc r0, psw
205 slli r0, #16
206 bltz r0, 1f ; check BSM-bit
207;
208 ;; called from kernel context: previous stack = spi
209 pop r0 ; retrieve r0
210 bra 2f
211 .fillinsn
2121:
213 ;; called from user context: previous stack = spu
214 mvfc r0, cr3 ; spu
215 addi r0, #4
216 mvtc r0, cr3 ; spu
217 ld r0, @(-4,r0) ; retrieve r0
218 .fillinsn
2192:
220 .endm
221#endif /* CONFIG_CHIP_M32102 */
222
223#endif /* __ASSEMBLY__ */
224
225#endif /* _ASM_M32R_ASSEMBLER_H */
diff --git a/include/asm-m32r/atomic.h b/include/asm-m32r/atomic.h
new file mode 100644
index 000000000000..bfff69a49936
--- /dev/null
+++ b/include/asm-m32r/atomic.h
@@ -0,0 +1,295 @@
1#ifndef _ASM_M32R_ATOMIC_H
2#define _ASM_M32R_ATOMIC_H
3
4/*
5 * linux/include/asm-m32r/atomic.h
6 *
7 * M32R version:
8 * Copyright (C) 2001, 2002 Hitoshi Yamamoto
9 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
10 */
11
12#include <linux/config.h>
13#include <asm/assembler.h>
14#include <asm/system.h>
15
16/*
17 * Atomic operations that C can't guarantee us. Useful for
18 * resource counting etc..
19 */
20
21/*
22 * Make sure gcc doesn't try to be clever and move things around
23 * on us. We need to use _exactly_ the address the user gave us,
24 * not some alias that contains the same information.
25 */
26typedef struct { volatile int counter; } atomic_t;
27
28#define ATOMIC_INIT(i) { (i) }
29
30/**
31 * atomic_read - read atomic variable
32 * @v: pointer of type atomic_t
33 *
34 * Atomically reads the value of @v.
35 */
36#define atomic_read(v) ((v)->counter)
37
38/**
39 * atomic_set - set atomic variable
40 * @v: pointer of type atomic_t
41 * @i: required value
42 *
43 * Atomically sets the value of @v to @i.
44 */
45#define atomic_set(v,i) (((v)->counter) = (i))
46
47/**
48 * atomic_add_return - add integer to atomic variable and return it
49 * @i: integer value to add
50 * @v: pointer of type atomic_t
51 *
52 * Atomically adds @i to @v and return (@i + @v).
53 */
54static __inline__ int atomic_add_return(int i, atomic_t *v)
55{
56 unsigned long flags;
57 int result;
58
59 local_irq_save(flags);
60 __asm__ __volatile__ (
61 "# atomic_add_return \n\t"
62 DCACHE_CLEAR("%0", "r4", "%1")
63 M32R_LOCK" %0, @%1; \n\t"
64 "add %0, %2; \n\t"
65 M32R_UNLOCK" %0, @%1; \n\t"
66 : "=&r" (result)
67 : "r" (&v->counter), "r" (i)
68 : "memory"
69#ifdef CONFIG_CHIP_M32700_TS1
70 , "r4"
71#endif /* CONFIG_CHIP_M32700_TS1 */
72 );
73 local_irq_restore(flags);
74
75 return result;
76}
77
78/**
79 * atomic_sub_return - subtract integer from atomic variable and return it
80 * @i: integer value to subtract
81 * @v: pointer of type atomic_t
82 *
83 * Atomically subtracts @i from @v and return (@v - @i).
84 */
85static __inline__ int atomic_sub_return(int i, atomic_t *v)
86{
87 unsigned long flags;
88 int result;
89
90 local_irq_save(flags);
91 __asm__ __volatile__ (
92 "# atomic_sub_return \n\t"
93 DCACHE_CLEAR("%0", "r4", "%1")
94 M32R_LOCK" %0, @%1; \n\t"
95 "sub %0, %2; \n\t"
96 M32R_UNLOCK" %0, @%1; \n\t"
97 : "=&r" (result)
98 : "r" (&v->counter), "r" (i)
99 : "memory"
100#ifdef CONFIG_CHIP_M32700_TS1
101 , "r4"
102#endif /* CONFIG_CHIP_M32700_TS1 */
103 );
104 local_irq_restore(flags);
105
106 return result;
107}
108
109/**
110 * atomic_add - add integer to atomic variable
111 * @i: integer value to add
112 * @v: pointer of type atomic_t
113 *
114 * Atomically adds @i to @v.
115 */
116#define atomic_add(i,v) ((void) atomic_add_return((i), (v)))
117
118/**
119 * atomic_sub - subtract the atomic variable
120 * @i: integer value to subtract
121 * @v: pointer of type atomic_t
122 *
123 * Atomically subtracts @i from @v.
124 */
125#define atomic_sub(i,v) ((void) atomic_sub_return((i), (v)))
126
127/**
128 * atomic_sub_and_test - subtract value from variable and test result
129 * @i: integer value to subtract
130 * @v: pointer of type atomic_t
131 *
132 * Atomically subtracts @i from @v and returns
133 * true if the result is zero, or false for all
134 * other cases.
135 */
136#define atomic_sub_and_test(i,v) (atomic_sub_return((i), (v)) == 0)
137
138/**
139 * atomic_inc_return - increment atomic variable and return it
140 * @v: pointer of type atomic_t
141 *
142 * Atomically increments @v by 1 and returns the result.
143 */
144static __inline__ int atomic_inc_return(atomic_t *v)
145{
146 unsigned long flags;
147 int result;
148
149 local_irq_save(flags);
150 __asm__ __volatile__ (
151 "# atomic_inc_return \n\t"
152 DCACHE_CLEAR("%0", "r4", "%1")
153 M32R_LOCK" %0, @%1; \n\t"
154 "addi %0, #1; \n\t"
155 M32R_UNLOCK" %0, @%1; \n\t"
156 : "=&r" (result)
157 : "r" (&v->counter)
158 : "memory"
159#ifdef CONFIG_CHIP_M32700_TS1
160 , "r4"
161#endif /* CONFIG_CHIP_M32700_TS1 */
162 );
163 local_irq_restore(flags);
164
165 return result;
166}
167
168/**
169 * atomic_dec_return - decrement atomic variable and return it
170 * @v: pointer of type atomic_t
171 *
172 * Atomically decrements @v by 1 and returns the result.
173 */
174static __inline__ int atomic_dec_return(atomic_t *v)
175{
176 unsigned long flags;
177 int result;
178
179 local_irq_save(flags);
180 __asm__ __volatile__ (
181 "# atomic_dec_return \n\t"
182 DCACHE_CLEAR("%0", "r4", "%1")
183 M32R_LOCK" %0, @%1; \n\t"
184 "addi %0, #-1; \n\t"
185 M32R_UNLOCK" %0, @%1; \n\t"
186 : "=&r" (result)
187 : "r" (&v->counter)
188 : "memory"
189#ifdef CONFIG_CHIP_M32700_TS1
190 , "r4"
191#endif /* CONFIG_CHIP_M32700_TS1 */
192 );
193 local_irq_restore(flags);
194
195 return result;
196}
197
198/**
199 * atomic_inc - increment atomic variable
200 * @v: pointer of type atomic_t
201 *
202 * Atomically increments @v by 1.
203 */
204#define atomic_inc(v) ((void)atomic_inc_return(v))
205
206/**
207 * atomic_dec - decrement atomic variable
208 * @v: pointer of type atomic_t
209 *
210 * Atomically decrements @v by 1.
211 */
212#define atomic_dec(v) ((void)atomic_dec_return(v))
213
214/**
215 * atomic_inc_and_test - increment and test
216 * @v: pointer of type atomic_t
217 *
218 * Atomically increments @v by 1
219 * and returns true if the result is zero, or false for all
220 * other cases.
221 */
222#define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
223
224/**
225 * atomic_dec_and_test - decrement and test
226 * @v: pointer of type atomic_t
227 *
228 * Atomically decrements @v by 1 and
229 * returns true if the result is 0, or false for all
230 * other cases.
231 */
232#define atomic_dec_and_test(v) (atomic_dec_return(v) == 0)
233
234/**
235 * atomic_add_negative - add and test if negative
236 * @v: pointer of type atomic_t
237 * @i: integer value to add
238 *
239 * Atomically adds @i to @v and returns true
240 * if the result is negative, or false when
241 * result is greater than or equal to zero.
242 */
243#define atomic_add_negative(i,v) (atomic_add_return((i), (v)) < 0)
244
245static __inline__ void atomic_clear_mask(unsigned long mask, atomic_t *addr)
246{
247 unsigned long flags;
248 unsigned long tmp;
249
250 local_irq_save(flags);
251 __asm__ __volatile__ (
252 "# atomic_clear_mask \n\t"
253 DCACHE_CLEAR("%0", "r5", "%1")
254 M32R_LOCK" %0, @%1; \n\t"
255 "and %0, %2; \n\t"
256 M32R_UNLOCK" %0, @%1; \n\t"
257 : "=&r" (tmp)
258 : "r" (addr), "r" (~mask)
259 : "memory"
260#ifdef CONFIG_CHIP_M32700_TS1
261 , "r5"
262#endif /* CONFIG_CHIP_M32700_TS1 */
263 );
264 local_irq_restore(flags);
265}
266
267static __inline__ void atomic_set_mask(unsigned long mask, atomic_t *addr)
268{
269 unsigned long flags;
270 unsigned long tmp;
271
272 local_irq_save(flags);
273 __asm__ __volatile__ (
274 "# atomic_set_mask \n\t"
275 DCACHE_CLEAR("%0", "r5", "%1")
276 M32R_LOCK" %0, @%1; \n\t"
277 "or %0, %2; \n\t"
278 M32R_UNLOCK" %0, @%1; \n\t"
279 : "=&r" (tmp)
280 : "r" (addr), "r" (mask)
281 : "memory"
282#ifdef CONFIG_CHIP_M32700_TS1
283 , "r5"
284#endif /* CONFIG_CHIP_M32700_TS1 */
285 );
286 local_irq_restore(flags);
287}
288
289/* Atomic operations are already serializing on m32r */
290#define smp_mb__before_atomic_dec() barrier()
291#define smp_mb__after_atomic_dec() barrier()
292#define smp_mb__before_atomic_inc() barrier()
293#define smp_mb__after_atomic_inc() barrier()
294
295#endif /* _ASM_M32R_ATOMIC_H */
diff --git a/include/asm-m32r/bitops.h b/include/asm-m32r/bitops.h
new file mode 100644
index 000000000000..e78443981349
--- /dev/null
+++ b/include/asm-m32r/bitops.h
@@ -0,0 +1,702 @@
1#ifndef _ASM_M32R_BITOPS_H
2#define _ASM_M32R_BITOPS_H
3
4/*
5 * linux/include/asm-m32r/bitops.h
6 *
7 * Copyright 1992, Linus Torvalds.
8 *
9 * M32R version:
10 * Copyright (C) 2001, 2002 Hitoshi Yamamoto
11 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
12 */
13
14#include <linux/config.h>
15#include <linux/compiler.h>
16#include <asm/assembler.h>
17#include <asm/system.h>
18#include <asm/byteorder.h>
19#include <asm/types.h>
20
21/*
22 * These have to be done with inline assembly: that way the bit-setting
23 * is guaranteed to be atomic. All bit operations return 0 if the bit
24 * was cleared before the operation and != 0 if it was not.
25 *
26 * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
27 */
28
29/**
30 * set_bit - Atomically set a bit in memory
31 * @nr: the bit to set
32 * @addr: the address to start counting from
33 *
34 * This function is atomic and may not be reordered. See __set_bit()
35 * if you do not require the atomic guarantees.
36 * Note that @nr may be almost arbitrarily large; this function is not
37 * restricted to acting on a single-word quantity.
38 */
39static __inline__ void set_bit(int nr, volatile void * addr)
40{
41 __u32 mask;
42 volatile __u32 *a = addr;
43 unsigned long flags;
44 unsigned long tmp;
45
46 a += (nr >> 5);
47 mask = (1 << (nr & 0x1F));
48
49 local_irq_save(flags);
50 __asm__ __volatile__ (
51 DCACHE_CLEAR("%0", "r6", "%1")
52 M32R_LOCK" %0, @%1; \n\t"
53 "or %0, %2; \n\t"
54 M32R_UNLOCK" %0, @%1; \n\t"
55 : "=&r" (tmp)
56 : "r" (a), "r" (mask)
57 : "memory"
58#ifdef CONFIG_CHIP_M32700_TS1
59 , "r6"
60#endif /* CONFIG_CHIP_M32700_TS1 */
61 );
62 local_irq_restore(flags);
63}
64
65/**
66 * __set_bit - Set a bit in memory
67 * @nr: the bit to set
68 * @addr: the address to start counting from
69 *
70 * Unlike set_bit(), this function is non-atomic and may be reordered.
71 * If it's called on the same region of memory simultaneously, the effect
72 * may be that only one operation succeeds.
73 */
74static __inline__ void __set_bit(int nr, volatile void * addr)
75{
76 __u32 mask;
77 volatile __u32 *a = addr;
78
79 a += (nr >> 5);
80 mask = (1 << (nr & 0x1F));
81 *a |= mask;
82}
83
84/**
85 * clear_bit - Clears a bit in memory
86 * @nr: Bit to clear
87 * @addr: Address to start counting from
88 *
89 * clear_bit() is atomic and may not be reordered. However, it does
90 * not contain a memory barrier, so if it is used for locking purposes,
91 * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
92 * in order to ensure changes are visible on other processors.
93 */
94static __inline__ void clear_bit(int nr, volatile void * addr)
95{
96 __u32 mask;
97 volatile __u32 *a = addr;
98 unsigned long flags;
99 unsigned long tmp;
100
101 a += (nr >> 5);
102 mask = (1 << (nr & 0x1F));
103
104 local_irq_save(flags);
105
106 __asm__ __volatile__ (
107 DCACHE_CLEAR("%0", "r6", "%1")
108 M32R_LOCK" %0, @%1; \n\t"
109 "and %0, %2; \n\t"
110 M32R_UNLOCK" %0, @%1; \n\t"
111 : "=&r" (tmp)
112 : "r" (a), "r" (~mask)
113 : "memory"
114#ifdef CONFIG_CHIP_M32700_TS1
115 , "r6"
116#endif /* CONFIG_CHIP_M32700_TS1 */
117 );
118 local_irq_restore(flags);
119}
120
121static __inline__ void __clear_bit(int nr, volatile unsigned long * addr)
122{
123 unsigned long mask;
124 volatile unsigned long *a = addr;
125
126 a += (nr >> 5);
127 mask = (1 << (nr & 0x1F));
128 *a &= ~mask;
129}
130
131#define smp_mb__before_clear_bit() barrier()
132#define smp_mb__after_clear_bit() barrier()
133
134/**
135 * __change_bit - Toggle a bit in memory
136 * @nr: the bit to set
137 * @addr: the address to start counting from
138 *
139 * Unlike change_bit(), this function is non-atomic and may be reordered.
140 * If it's called on the same region of memory simultaneously, the effect
141 * may be that only one operation succeeds.
142 */
143static __inline__ void __change_bit(int nr, volatile void * addr)
144{
145 __u32 mask;
146 volatile __u32 *a = addr;
147
148 a += (nr >> 5);
149 mask = (1 << (nr & 0x1F));
150 *a ^= mask;
151}
152
153/**
154 * change_bit - Toggle a bit in memory
155 * @nr: Bit to clear
156 * @addr: Address to start counting from
157 *
158 * change_bit() is atomic and may not be reordered.
159 * Note that @nr may be almost arbitrarily large; this function is not
160 * restricted to acting on a single-word quantity.
161 */
162static __inline__ void change_bit(int nr, volatile void * addr)
163{
164 __u32 mask;
165 volatile __u32 *a = addr;
166 unsigned long flags;
167 unsigned long tmp;
168
169 a += (nr >> 5);
170 mask = (1 << (nr & 0x1F));
171
172 local_irq_save(flags);
173 __asm__ __volatile__ (
174 DCACHE_CLEAR("%0", "r6", "%1")
175 M32R_LOCK" %0, @%1; \n\t"
176 "xor %0, %2; \n\t"
177 M32R_UNLOCK" %0, @%1; \n\t"
178 : "=&r" (tmp)
179 : "r" (a), "r" (mask)
180 : "memory"
181#ifdef CONFIG_CHIP_M32700_TS1
182 , "r6"
183#endif /* CONFIG_CHIP_M32700_TS1 */
184 );
185 local_irq_restore(flags);
186}
187
188/**
189 * test_and_set_bit - Set a bit and return its old value
190 * @nr: Bit to set
191 * @addr: Address to count from
192 *
193 * This operation is atomic and cannot be reordered.
194 * It also implies a memory barrier.
195 */
196static __inline__ int test_and_set_bit(int nr, volatile void * addr)
197{
198 __u32 mask, oldbit;
199 volatile __u32 *a = addr;
200 unsigned long flags;
201 unsigned long tmp;
202
203 a += (nr >> 5);
204 mask = (1 << (nr & 0x1F));
205
206 local_irq_save(flags);
207 __asm__ __volatile__ (
208 DCACHE_CLEAR("%0", "%1", "%2")
209 M32R_LOCK" %0, @%2; \n\t"
210 "mv %1, %0; \n\t"
211 "and %0, %3; \n\t"
212 "or %1, %3; \n\t"
213 M32R_UNLOCK" %1, @%2; \n\t"
214 : "=&r" (oldbit), "=&r" (tmp)
215 : "r" (a), "r" (mask)
216 : "memory"
217 );
218 local_irq_restore(flags);
219
220 return (oldbit != 0);
221}
222
223/**
224 * __test_and_set_bit - Set a bit and return its old value
225 * @nr: Bit to set
226 * @addr: Address to count from
227 *
228 * This operation is non-atomic and can be reordered.
229 * If two examples of this operation race, one can appear to succeed
230 * but actually fail. You must protect multiple accesses with a lock.
231 */
232static __inline__ int __test_and_set_bit(int nr, volatile void * addr)
233{
234 __u32 mask, oldbit;
235 volatile __u32 *a = addr;
236
237 a += (nr >> 5);
238 mask = (1 << (nr & 0x1F));
239 oldbit = (*a & mask);
240 *a |= mask;
241
242 return (oldbit != 0);
243}
244
245/**
246 * test_and_clear_bit - Clear a bit and return its old value
247 * @nr: Bit to set
248 * @addr: Address to count from
249 *
250 * This operation is atomic and cannot be reordered.
251 * It also implies a memory barrier.
252 */
253static __inline__ int test_and_clear_bit(int nr, volatile void * addr)
254{
255 __u32 mask, oldbit;
256 volatile __u32 *a = addr;
257 unsigned long flags;
258 unsigned long tmp;
259
260 a += (nr >> 5);
261 mask = (1 << (nr & 0x1F));
262
263 local_irq_save(flags);
264
265 __asm__ __volatile__ (
266 DCACHE_CLEAR("%0", "%1", "%3")
267 M32R_LOCK" %0, @%3; \n\t"
268 "mv %1, %0; \n\t"
269 "and %0, %2; \n\t"
270 "not %2, %2; \n\t"
271 "and %1, %2; \n\t"
272 M32R_UNLOCK" %1, @%3; \n\t"
273 : "=&r" (oldbit), "=&r" (tmp), "+r" (mask)
274 : "r" (a)
275 : "memory"
276 );
277 local_irq_restore(flags);
278
279 return (oldbit != 0);
280}
281
282/**
283 * __test_and_clear_bit - Clear a bit and return its old value
284 * @nr: Bit to set
285 * @addr: Address to count from
286 *
287 * This operation is non-atomic and can be reordered.
288 * If two examples of this operation race, one can appear to succeed
289 * but actually fail. You must protect multiple accesses with a lock.
290 */
291static __inline__ int __test_and_clear_bit(int nr, volatile void * addr)
292{
293 __u32 mask, oldbit;
294 volatile __u32 *a = addr;
295
296 a += (nr >> 5);
297 mask = (1 << (nr & 0x1F));
298 oldbit = (*a & mask);
299 *a &= ~mask;
300
301 return (oldbit != 0);
302}
303
304/* WARNING: non atomic and it can be reordered! */
305static __inline__ int __test_and_change_bit(int nr, volatile void * addr)
306{
307 __u32 mask, oldbit;
308 volatile __u32 *a = addr;
309
310 a += (nr >> 5);
311 mask = (1 << (nr & 0x1F));
312 oldbit = (*a & mask);
313 *a ^= mask;
314
315 return (oldbit != 0);
316}
317
318/**
319 * test_and_change_bit - Change a bit and return its old value
320 * @nr: Bit to set
321 * @addr: Address to count from
322 *
323 * This operation is atomic and cannot be reordered.
324 * It also implies a memory barrier.
325 */
326static __inline__ int test_and_change_bit(int nr, volatile void * addr)
327{
328 __u32 mask, oldbit;
329 volatile __u32 *a = addr;
330 unsigned long flags;
331 unsigned long tmp;
332
333 a += (nr >> 5);
334 mask = (1 << (nr & 0x1F));
335
336 local_irq_save(flags);
337 __asm__ __volatile__ (
338 DCACHE_CLEAR("%0", "%1", "%2")
339 M32R_LOCK" %0, @%2; \n\t"
340 "mv %1, %0; \n\t"
341 "and %0, %3; \n\t"
342 "xor %1, %3; \n\t"
343 M32R_UNLOCK" %1, @%2; \n\t"
344 : "=&r" (oldbit), "=&r" (tmp)
345 : "r" (a), "r" (mask)
346 : "memory"
347 );
348 local_irq_restore(flags);
349
350 return (oldbit != 0);
351}
352
353/**
354 * test_bit - Determine whether a bit is set
355 * @nr: bit number to test
356 * @addr: Address to start counting from
357 */
358static __inline__ int test_bit(int nr, const volatile void * addr)
359{
360 __u32 mask;
361 const volatile __u32 *a = addr;
362
363 a += (nr >> 5);
364 mask = (1 << (nr & 0x1F));
365
366 return ((*a & mask) != 0);
367}
368
369/**
370 * ffz - find first zero in word.
371 * @word: The word to search
372 *
373 * Undefined if no zero exists, so code should check against ~0UL first.
374 */
375static __inline__ unsigned long ffz(unsigned long word)
376{
377 int k;
378
379 word = ~word;
380 k = 0;
381 if (!(word & 0x0000ffff)) { k += 16; word >>= 16; }
382 if (!(word & 0x000000ff)) { k += 8; word >>= 8; }
383 if (!(word & 0x0000000f)) { k += 4; word >>= 4; }
384 if (!(word & 0x00000003)) { k += 2; word >>= 2; }
385 if (!(word & 0x00000001)) { k += 1; }
386
387 return k;
388}
389
390/**
391 * find_first_zero_bit - find the first zero bit in a memory region
392 * @addr: The address to start the search at
393 * @size: The maximum size to search
394 *
395 * Returns the bit-number of the first zero bit, not the number of the byte
396 * containing a bit.
397 */
398
399#define find_first_zero_bit(addr, size) \
400 find_next_zero_bit((addr), (size), 0)
401
402/**
403 * find_next_zero_bit - find the first zero bit in a memory region
404 * @addr: The address to base the search on
405 * @offset: The bitnumber to start searching at
406 * @size: The maximum size to search
407 */
408static __inline__ int find_next_zero_bit(const unsigned long *addr,
409 int size, int offset)
410{
411 const unsigned long *p = addr + (offset >> 5);
412 unsigned long result = offset & ~31UL;
413 unsigned long tmp;
414
415 if (offset >= size)
416 return size;
417 size -= result;
418 offset &= 31UL;
419 if (offset) {
420 tmp = *(p++);
421 tmp |= ~0UL >> (32-offset);
422 if (size < 32)
423 goto found_first;
424 if (~tmp)
425 goto found_middle;
426 size -= 32;
427 result += 32;
428 }
429 while (size & ~31UL) {
430 if (~(tmp = *(p++)))
431 goto found_middle;
432 result += 32;
433 size -= 32;
434 }
435 if (!size)
436 return result;
437 tmp = *p;
438
439found_first:
440 tmp |= ~0UL << size;
441found_middle:
442 return result + ffz(tmp);
443}
444
445/**
446 * __ffs - find first bit in word.
447 * @word: The word to search
448 *
449 * Undefined if no bit exists, so code should check against 0 first.
450 */
451static __inline__ unsigned long __ffs(unsigned long word)
452{
453 int k = 0;
454
455 if (!(word & 0x0000ffff)) { k += 16; word >>= 16; }
456 if (!(word & 0x000000ff)) { k += 8; word >>= 8; }
457 if (!(word & 0x0000000f)) { k += 4; word >>= 4; }
458 if (!(word & 0x00000003)) { k += 2; word >>= 2; }
459 if (!(word & 0x00000001)) { k += 1;}
460
461 return k;
462}
463
464/*
465 * fls: find last bit set.
466 */
467#define fls(x) generic_fls(x)
468
469#ifdef __KERNEL__
470
471/*
472 * Every architecture must define this function. It's the fastest
473 * way of searching a 140-bit bitmap where the first 100 bits are
474 * unlikely to be set. It's guaranteed that at least one of the 140
475 * bits is cleared.
476 */
477static inline int sched_find_first_bit(unsigned long *b)
478{
479 if (unlikely(b[0]))
480 return __ffs(b[0]);
481 if (unlikely(b[1]))
482 return __ffs(b[1]) + 32;
483 if (unlikely(b[2]))
484 return __ffs(b[2]) + 64;
485 if (b[3])
486 return __ffs(b[3]) + 96;
487 return __ffs(b[4]) + 128;
488}
489
490/**
491 * find_next_bit - find the first set bit in a memory region
492 * @addr: The address to base the search on
493 * @offset: The bitnumber to start searching at
494 * @size: The maximum size to search
495 */
496static inline unsigned long find_next_bit(const unsigned long *addr,
497 unsigned long size, unsigned long offset)
498{
499 unsigned int *p = ((unsigned int *) addr) + (offset >> 5);
500 unsigned int result = offset & ~31UL;
501 unsigned int tmp;
502
503 if (offset >= size)
504 return size;
505 size -= result;
506 offset &= 31UL;
507 if (offset) {
508 tmp = *p++;
509 tmp &= ~0UL << offset;
510 if (size < 32)
511 goto found_first;
512 if (tmp)
513 goto found_middle;
514 size -= 32;
515 result += 32;
516 }
517 while (size >= 32) {
518 if ((tmp = *p++) != 0)
519 goto found_middle;
520 result += 32;
521 size -= 32;
522 }
523 if (!size)
524 return result;
525 tmp = *p;
526
527found_first:
528 tmp &= ~0UL >> (32 - size);
529 if (tmp == 0UL) /* Are any bits set? */
530 return result + size; /* Nope. */
531found_middle:
532 return result + __ffs(tmp);
533}
534
535/**
536 * find_first_bit - find the first set bit in a memory region
537 * @addr: The address to start the search at
538 * @size: The maximum size to search
539 *
540 * Returns the bit-number of the first set bit, not the number of the byte
541 * containing a bit.
542 */
543#define find_first_bit(addr, size) \
544 find_next_bit((addr), (size), 0)
545
546/**
547 * ffs - find first bit set
548 * @x: the word to search
549 *
550 * This is defined the same way as
551 * the libc and compiler builtin ffs routines, therefore
552 * differs in spirit from the above ffz (man ffs).
553 */
554#define ffs(x) generic_ffs(x)
555
556/**
557 * hweightN - returns the hamming weight of a N-bit word
558 * @x: the word to weigh
559 *
560 * The Hamming Weight of a number is the total number of bits set in it.
561 */
562
563#define hweight32(x) generic_hweight32(x)
564#define hweight16(x) generic_hweight16(x)
565#define hweight8(x) generic_hweight8(x)
566
567#endif /* __KERNEL__ */
568
569#ifdef __KERNEL__
570
571/*
572 * ext2_XXXX function
573 * orig: include/asm-sh/bitops.h
574 */
575
576#ifdef __LITTLE_ENDIAN__
577#define ext2_set_bit test_and_set_bit
578#define ext2_clear_bit __test_and_clear_bit
579#define ext2_test_bit test_bit
580#define ext2_find_first_zero_bit find_first_zero_bit
581#define ext2_find_next_zero_bit find_next_zero_bit
582#else
583static inline int ext2_set_bit(int nr, volatile void * addr)
584{
585 __u8 mask, oldbit;
586 volatile __u8 *a = addr;
587
588 a += (nr >> 3);
589 mask = (1 << (nr & 0x07));
590 oldbit = (*a & mask);
591 *a |= mask;
592
593 return (oldbit != 0);
594}
595
596static inline int ext2_clear_bit(int nr, volatile void * addr)
597{
598 __u8 mask, oldbit;
599 volatile __u8 *a = addr;
600
601 a += (nr >> 3);
602 mask = (1 << (nr & 0x07));
603 oldbit = (*a & mask);
604 *a &= ~mask;
605
606 return (oldbit != 0);
607}
608
609static inline int ext2_test_bit(int nr, const volatile void * addr)
610{
611 __u32 mask;
612 const volatile __u8 *a = addr;
613
614 a += (nr >> 3);
615 mask = (1 << (nr & 0x07));
616
617 return ((mask & *a) != 0);
618}
619
620#define ext2_find_first_zero_bit(addr, size) \
621 ext2_find_next_zero_bit((addr), (size), 0)
622
623static inline unsigned long ext2_find_next_zero_bit(void *addr,
624 unsigned long size, unsigned long offset)
625{
626 unsigned long *p = ((unsigned long *) addr) + (offset >> 5);
627 unsigned long result = offset & ~31UL;
628 unsigned long tmp;
629
630 if (offset >= size)
631 return size;
632 size -= result;
633 offset &= 31UL;
634 if(offset) {
635 /* We hold the little endian value in tmp, but then the
636 * shift is illegal. So we could keep a big endian value
637 * in tmp, like this:
638 *
639 * tmp = __swab32(*(p++));
640 * tmp |= ~0UL >> (32-offset);
641 *
642 * but this would decrease preformance, so we change the
643 * shift:
644 */
645 tmp = *(p++);
646 tmp |= __swab32(~0UL >> (32-offset));
647 if(size < 32)
648 goto found_first;
649 if(~tmp)
650 goto found_middle;
651 size -= 32;
652 result += 32;
653 }
654 while(size & ~31UL) {
655 if(~(tmp = *(p++)))
656 goto found_middle;
657 result += 32;
658 size -= 32;
659 }
660 if(!size)
661 return result;
662 tmp = *p;
663
664found_first:
665 /* tmp is little endian, so we would have to swab the shift,
666 * see above. But then we have to swab tmp below for ffz, so
667 * we might as well do this here.
668 */
669 return result + ffz(__swab32(tmp) | (~0UL << size));
670found_middle:
671 return result + ffz(__swab32(tmp));
672}
673#endif
674
675#define ext2_set_bit_atomic(lock, nr, addr) \
676 ({ \
677 int ret; \
678 spin_lock(lock); \
679 ret = ext2_set_bit((nr), (addr)); \
680 spin_unlock(lock); \
681 ret; \
682 })
683
684#define ext2_clear_bit_atomic(lock, nr, addr) \
685 ({ \
686 int ret; \
687 spin_lock(lock); \
688 ret = ext2_clear_bit((nr), (addr)); \
689 spin_unlock(lock); \
690 ret; \
691 })
692
693/* Bitmap functions for the minix filesystem. */
694#define minix_test_and_set_bit(nr,addr) __test_and_set_bit(nr,addr)
695#define minix_set_bit(nr,addr) __set_bit(nr,addr)
696#define minix_test_and_clear_bit(nr,addr) __test_and_clear_bit(nr,addr)
697#define minix_test_bit(nr,addr) test_bit(nr,addr)
698#define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size)
699
700#endif /* __KERNEL__ */
701
702#endif /* _ASM_M32R_BITOPS_H */
diff --git a/include/asm-m32r/bug.h b/include/asm-m32r/bug.h
new file mode 100644
index 000000000000..4cc0462c15b8
--- /dev/null
+++ b/include/asm-m32r/bug.h
@@ -0,0 +1,4 @@
1#ifndef _M32R_BUG_H
2#define _M32R_BUG_H
3#include <asm-generic/bug.h>
4#endif
diff --git a/include/asm-m32r/bugs.h b/include/asm-m32r/bugs.h
new file mode 100644
index 000000000000..9a56f661bdb3
--- /dev/null
+++ b/include/asm-m32r/bugs.h
@@ -0,0 +1,21 @@
1#ifndef _ASM_M32R_BUGS_H
2#define _ASM_M32R_BUGS_H
3
4/* $Id$ */
5
6/*
7 * This is included by init/main.c to check for architecture-dependent bugs.
8 *
9 * Needs:
10 * void check_bugs(void);
11 */
12#include <asm/processor.h>
13
14static void __init check_bugs(void)
15{
16 extern unsigned long loops_per_jiffy;
17
18 current_cpu_data.loops_per_jiffy = loops_per_jiffy;
19}
20
21#endif /* _ASM_M32R_BUGS_H */
diff --git a/include/asm-m32r/byteorder.h b/include/asm-m32r/byteorder.h
new file mode 100644
index 000000000000..3c0b9a2e03bc
--- /dev/null
+++ b/include/asm-m32r/byteorder.h
@@ -0,0 +1,19 @@
1#ifndef _ASM_M32R_BYTEORDER_H
2#define _ASM_M32R_BYTEORDER_H
3
4/* $Id$ */
5
6#include <asm/types.h>
7
8#if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
9# define __BYTEORDER_HAS_U64__
10# define __SWAB_64_THRU_32__
11#endif
12
13#if defined(__LITTLE_ENDIAN__)
14# include <linux/byteorder/little_endian.h>
15#else
16# include <linux/byteorder/big_endian.h>
17#endif
18
19#endif /* _ASM_M32R_BYTEORDER_H */
diff --git a/include/asm-m32r/cache.h b/include/asm-m32r/cache.h
new file mode 100644
index 000000000000..724820596980
--- /dev/null
+++ b/include/asm-m32r/cache.h
@@ -0,0 +1,12 @@
1#ifndef _ASM_M32R_CACHE_H
2#define _ASM_M32R_CACHE_H
3
4/* $Id$ */
5
6/* L1 cache line size */
7#define L1_CACHE_SHIFT 4
8#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
9
10#define L1_CACHE_SHIFT_MAX 4
11
12#endif /* _ASM_M32R_CACHE_H */
diff --git a/include/asm-m32r/cachectl.h b/include/asm-m32r/cachectl.h
new file mode 100644
index 000000000000..2aab8f6fff41
--- /dev/null
+++ b/include/asm-m32r/cachectl.h
@@ -0,0 +1,26 @@
1/*
2 * cachectl.h -- defines for M32R cache control system calls
3 *
4 * Copyright (C) 2003 by Kazuhiro Inaoka
5 */
6#ifndef __ASM_M32R_CACHECTL
7#define __ASM_M32R_CACHECTL
8
9/*
10 * Options for cacheflush system call
11 *
12 * cacheflush() is currently fluch_cache_all().
13 */
14#define ICACHE (1<<0) /* flush instruction cache */
15#define DCACHE (1<<1) /* writeback and flush data cache */
16#define BCACHE (ICACHE|DCACHE) /* flush both caches */
17
18/*
19 * Caching modes for the cachectl(2) call
20 *
21 * cachectl(2) is currently not supported and returns ENOSYS.
22 */
23#define CACHEABLE 0 /* make pages cacheable */
24#define UNCACHEABLE 1 /* make pages uncacheable */
25
26#endif /* __ASM_M32R_CACHECTL */
diff --git a/include/asm-m32r/cacheflush.h b/include/asm-m32r/cacheflush.h
new file mode 100644
index 000000000000..46fc4c325108
--- /dev/null
+++ b/include/asm-m32r/cacheflush.h
@@ -0,0 +1,68 @@
1#ifndef _ASM_M32R_CACHEFLUSH_H
2#define _ASM_M32R_CACHEFLUSH_H
3
4#include <linux/config.h>
5#include <linux/mm.h>
6
7extern void _flush_cache_all(void);
8extern void _flush_cache_copyback_all(void);
9
10#if defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_OPSP)
11#define flush_cache_all() do { } while (0)
12#define flush_cache_mm(mm) do { } while (0)
13#define flush_cache_range(vma, start, end) do { } while (0)
14#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
15#define flush_dcache_page(page) do { } while (0)
16#define flush_dcache_mmap_lock(mapping) do { } while (0)
17#define flush_dcache_mmap_unlock(mapping) do { } while (0)
18#ifndef CONFIG_SMP
19#define flush_icache_range(start, end) _flush_cache_copyback_all()
20#define flush_icache_page(vma,pg) _flush_cache_copyback_all()
21#define flush_icache_user_range(vma,pg,adr,len) _flush_cache_copyback_all()
22#define flush_cache_sigtramp(addr) _flush_cache_copyback_all()
23#else /* CONFIG_SMP */
24extern void smp_flush_cache_all(void);
25#define flush_icache_range(start, end) smp_flush_cache_all()
26#define flush_icache_page(vma,pg) smp_flush_cache_all()
27#define flush_icache_user_range(vma,pg,adr,len) smp_flush_cache_all()
28#define flush_cache_sigtramp(addr) _flush_cache_copyback_all()
29#endif /* CONFIG_SMP */
30#elif defined(CONFIG_CHIP_M32102)
31#define flush_cache_all() do { } while (0)
32#define flush_cache_mm(mm) do { } while (0)
33#define flush_cache_range(vma, start, end) do { } while (0)
34#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
35#define flush_dcache_page(page) do { } while (0)
36#define flush_dcache_mmap_lock(mapping) do { } while (0)
37#define flush_dcache_mmap_unlock(mapping) do { } while (0)
38#define flush_icache_range(start, end) _flush_cache_all()
39#define flush_icache_page(vma,pg) _flush_cache_all()
40#define flush_icache_user_range(vma,pg,adr,len) _flush_cache_all()
41#define flush_cache_sigtramp(addr) _flush_cache_all()
42#else
43#define flush_cache_all() do { } while (0)
44#define flush_cache_mm(mm) do { } while (0)
45#define flush_cache_range(vma, start, end) do { } while (0)
46#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
47#define flush_dcache_page(page) do { } while (0)
48#define flush_dcache_mmap_lock(mapping) do { } while (0)
49#define flush_dcache_mmap_unlock(mapping) do { } while (0)
50#define flush_icache_range(start, end) do { } while (0)
51#define flush_icache_page(vma,pg) do { } while (0)
52#define flush_icache_user_range(vma,pg,adr,len) do { } while (0)
53#define flush_cache_sigtramp(addr) do { } while (0)
54#endif /* CONFIG_CHIP_* */
55
56#define flush_cache_vmap(start, end) do { } while (0)
57#define flush_cache_vunmap(start, end) do { } while (0)
58
59#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
60do { \
61 memcpy(dst, src, len); \
62 flush_icache_user_range(vma, page, vaddr, len); \
63} while (0)
64#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
65 memcpy(dst, src, len)
66
67#endif /* _ASM_M32R_CACHEFLUSH_H */
68
diff --git a/include/asm-m32r/checksum.h b/include/asm-m32r/checksum.h
new file mode 100644
index 000000000000..99f37dbf2558
--- /dev/null
+++ b/include/asm-m32r/checksum.h
@@ -0,0 +1,208 @@
1#ifdef __KERNEL__
2#ifndef _ASM_M32R_CHECKSUM_H
3#define _ASM_M32R_CHECKSUM_H
4
5/*
6 * include/asm-m32r/checksum.h
7 *
8 * IP/TCP/UDP checksum routines
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
13 *
14 * Some code taken from mips and parisc architecture.
15 *
16 * Copyright (C) 2001, 2002 Hiroyuki Kondo, Hirokazu Takata
17 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
18 */
19
20#include <linux/in6.h>
21
22/*
23 * computes the checksum of a memory block at buff, length len,
24 * and adds in "sum" (32-bit)
25 *
26 * returns a 32-bit number suitable for feeding into itself
27 * or csum_tcpudp_magic
28 *
29 * this function must be called with even lengths, except
30 * for the last fragment, which may be odd
31 *
32 * it's best to have buff aligned on a 32-bit boundary
33 */
34asmlinkage unsigned int csum_partial(const unsigned char *buff,
35 int len, unsigned int sum);
36
37/*
38 * The same as csum_partial, but copies from src while it checksums.
39 *
40 * Here even more important to align src and dst on a 32-bit (or even
41 * better 64-bit) boundary
42 */
43extern unsigned int csum_partial_copy_nocheck(const unsigned char *src,
44 unsigned char *dst,
45 int len, unsigned int sum);
46
47/*
48 * This is a new version of the above that records errors it finds in *errp,
49 * but continues and zeros thre rest of the buffer.
50 */
51extern unsigned int csum_partial_copy_from_user(const unsigned char __user *src,
52 unsigned char *dst,
53 int len, unsigned int sum,
54 int *err_ptr);
55
56/*
57 * Fold a partial checksum
58 */
59
60static inline unsigned int csum_fold(unsigned int sum)
61{
62 unsigned long tmpreg;
63 __asm__(
64 " sll3 %1, %0, #16 \n"
65 " cmp %0, %0 \n"
66 " addx %0, %1 \n"
67 " ldi %1, #0 \n"
68 " srli %0, #16 \n"
69 " addx %0, %1 \n"
70 " xor3 %0, %0, #0x0000ffff \n"
71 : "=r" (sum), "=&r" (tmpreg)
72 : "0" (sum)
73 : "cbit"
74 );
75 return sum;
76}
77
78/*
79 * This is a version of ip_compute_csum() optimized for IP headers,
80 * which always checksum on 4 octet boundaries.
81 */
82static inline unsigned short ip_fast_csum(unsigned char * iph,
83 unsigned int ihl) {
84 unsigned long sum, tmpreg0, tmpreg1;
85
86 __asm__ __volatile__(
87 " ld %0, @%1+ \n"
88 " addi %2, #-4 \n"
89 "# bgez %2, 2f \n"
90 " cmp %0, %0 \n"
91 " ld %3, @%1+ \n"
92 " ld %4, @%1+ \n"
93 " addx %0, %3 \n"
94 " ld %3, @%1+ \n"
95 " addx %0, %4 \n"
96 " addx %0, %3 \n"
97 " .fillinsn\n"
98 "1: \n"
99 " ld %4, @%1+ \n"
100 " addi %2, #-1 \n"
101 " addx %0, %4 \n"
102 " bgtz %2, 1b \n"
103 "\n"
104 " ldi %3, #0 \n"
105 " addx %0, %3 \n"
106 " .fillinsn\n"
107 "2: \n"
108 /* Since the input registers which are loaded with iph and ipl
109 are modified, we must also specify them as outputs, or gcc
110 will assume they contain their original values. */
111 : "=&r" (sum), "=r" (iph), "=r" (ihl), "=&r" (tmpreg0), "=&r" (tmpreg1)
112 : "1" (iph), "2" (ihl)
113 : "cbit", "memory");
114
115 return csum_fold(sum);
116}
117
118static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
119 unsigned long daddr,
120 unsigned short len,
121 unsigned short proto,
122 unsigned int sum)
123{
124#if defined(__LITTLE_ENDIAN)
125 unsigned long len_proto = (ntohs(len)<<16)+proto*256;
126#else
127 unsigned long len_proto = (proto<<16)+len;
128#endif
129 unsigned long tmpreg;
130
131 __asm__(
132 " cmp %0, %0 \n"
133 " addx %0, %2 \n"
134 " addx %0, %3 \n"
135 " addx %0, %4 \n"
136 " ldi %1, #0 \n"
137 " addx %0, %1 \n"
138 : "=r" (sum), "=&r" (tmpreg)
139 : "r" (daddr), "r" (saddr), "r" (len_proto), "0" (sum)
140 : "cbit"
141 );
142
143 return sum;
144}
145
146/*
147 * computes the checksum of the TCP/UDP pseudo-header
148 * returns a 16-bit checksum, already complemented
149 */
150static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
151 unsigned long daddr,
152 unsigned short len,
153 unsigned short proto,
154 unsigned int sum)
155{
156 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
157}
158
159/*
160 * this routine is used for miscellaneous IP-like checksums, mainly
161 * in icmp.c
162 */
163
164static inline unsigned short ip_compute_csum(unsigned char * buff, int len) {
165 return csum_fold (csum_partial(buff, len, 0));
166}
167
168#define _HAVE_ARCH_IPV6_CSUM
169static inline unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
170 struct in6_addr *daddr,
171 __u16 len,
172 unsigned short proto,
173 unsigned int sum)
174{
175 unsigned long tmpreg0, tmpreg1, tmpreg2, tmpreg3;
176 __asm__(
177 " ld %1, @(%5) \n"
178 " ld %2, @(4,%5) \n"
179 " ld %3, @(8,%5) \n"
180 " ld %4, @(12,%5) \n"
181 " add %0, %1 \n"
182 " addx %0, %2 \n"
183 " addx %0, %3 \n"
184 " addx %0, %4 \n"
185 " ld %1, @(%6) \n"
186 " ld %2, @(4,%6) \n"
187 " ld %3, @(8,%6) \n"
188 " ld %4, @(12,%6) \n"
189 " addx %0, %1 \n"
190 " addx %0, %2 \n"
191 " addx %0, %3 \n"
192 " addx %0, %4 \n"
193 " addx %0, %7 \n"
194 " addx %0, %8 \n"
195 " ldi %1, #0 \n"
196 " addx %0, %1 \n"
197 : "=&r" (sum), "=&r" (tmpreg0), "=&r" (tmpreg1),
198 "=&r" (tmpreg2), "=&r" (tmpreg3)
199 : "r" (saddr), "r" (daddr),
200 "r" (htonl((__u32) (len))), "r" (htonl(proto)), "0" (sum)
201 : "cbit"
202 );
203
204 return csum_fold(sum);
205}
206
207#endif /* _ASM_M32R_CHECKSUM_H */
208#endif /* __KERNEL__ */
diff --git a/include/asm-m32r/cputime.h b/include/asm-m32r/cputime.h
new file mode 100644
index 000000000000..0a47550df2b7
--- /dev/null
+++ b/include/asm-m32r/cputime.h
@@ -0,0 +1,6 @@
1#ifndef __M32R_CPUTIME_H
2#define __M32R_CPUTIME_H
3
4#include <asm-generic/cputime.h>
5
6#endif /* __M32R_CPUTIME_H */
diff --git a/include/asm-m32r/current.h b/include/asm-m32r/current.h
new file mode 100644
index 000000000000..c19d927ff22d
--- /dev/null
+++ b/include/asm-m32r/current.h
@@ -0,0 +1,18 @@
1#ifndef _ASM_M32R_CURRENT_H
2#define _ASM_M32R_CURRENT_H
3
4/* $Id$ */
5
6#include <linux/thread_info.h>
7
8struct task_struct;
9
10static __inline__ struct task_struct *get_current(void)
11{
12 return current_thread_info()->task;
13}
14
15#define current (get_current())
16
17#endif /* _ASM_M32R_CURRENT_H */
18
diff --git a/include/asm-m32r/delay.h b/include/asm-m32r/delay.h
new file mode 100644
index 000000000000..f285eaee7d27
--- /dev/null
+++ b/include/asm-m32r/delay.h
@@ -0,0 +1,28 @@
1#ifndef _ASM_M32R_DELAY_H
2#define _ASM_M32R_DELAY_H
3
4/* $Id$ */
5
6/*
7 * Copyright (C) 1993 Linus Torvalds
8 *
9 * Delay routines calling functions in arch/m32r/lib/delay.c
10 */
11
12extern void __bad_udelay(void);
13extern void __bad_ndelay(void);
14
15extern void __udelay(unsigned long usecs);
16extern void __ndelay(unsigned long nsecs);
17extern void __const_udelay(unsigned long usecs);
18extern void __delay(unsigned long loops);
19
20#define udelay(n) (__builtin_constant_p(n) ? \
21 ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c7ul)) : \
22 __udelay(n))
23
24#define ndelay(n) (__builtin_constant_p(n) ? \
25 ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \
26 __ndelay(n))
27
28#endif /* _ASM_M32R_DELAY_H */
diff --git a/include/asm-m32r/div64.h b/include/asm-m32r/div64.h
new file mode 100644
index 000000000000..417a51bd552d
--- /dev/null
+++ b/include/asm-m32r/div64.h
@@ -0,0 +1,38 @@
1#ifndef _ASM_M32R_DIV64
2#define _ASM_M32R_DIV64
3
4/* $Id$ */
5
6/* unsigned long long division.
7 * Input:
8 * unsigned long long n
9 * unsigned long base
10 * Output:
11 * n = n / base;
12 * return value = n % base;
13 */
14#define do_div(n, base) \
15({ \
16 unsigned long _res, _high, _mid, _low; \
17 \
18 _low = (n) & 0xffffffffUL; \
19 _high = (n) >> 32; \
20 if (_high) { \
21 _mid = (_high % (unsigned long)(base)) << 16; \
22 _high = _high / (unsigned long)(base); \
23 _mid += _low >> 16; \
24 _low &= 0x0000ffffUL; \
25 _low += (_mid % (unsigned long)(base)) << 16; \
26 _mid = _mid / (unsigned long)(base); \
27 _res = _low % (unsigned long)(base); \
28 _low = _low / (unsigned long)(base); \
29 n = _low + ((long long)_mid << 16) + \
30 ((long long)_high << 32); \
31 } else { \
32 _res = _low % (unsigned long)(base); \
33 n = (_low / (unsigned long)(base)); \
34 } \
35 _res; \
36})
37
38#endif /* _ASM_M32R_DIV64 */
diff --git a/include/asm-m32r/dma-mapping.h b/include/asm-m32r/dma-mapping.h
new file mode 100644
index 000000000000..3a2db28834b6
--- /dev/null
+++ b/include/asm-m32r/dma-mapping.h
@@ -0,0 +1,23 @@
1#ifndef _ASM_M32R_DMA_MAPPING_H
2#define _ASM_M32R_DMA_MAPPING_H
3
4/*
5 * NOTE: Do not include <asm-generic/dma-mapping.h>
6 * Because it requires PCI stuffs, but current M32R don't provide these.
7 */
8
9static inline void *
10dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
11 int flag)
12{
13 return (void *)NULL;
14}
15
16static inline void
17dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
18 dma_addr_t dma_handle)
19{
20 return;
21}
22
23#endif /* _ASM_M32R_DMA_MAPPING_H */
diff --git a/include/asm-m32r/dma.h b/include/asm-m32r/dma.h
new file mode 100644
index 000000000000..7263b013b67e
--- /dev/null
+++ b/include/asm-m32r/dma.h
@@ -0,0 +1,14 @@
1#ifndef _ASM_M32R_DMA_H
2#define _ASM_M32R_DMA_H
3
4/* $Id$ */
5
6#include <asm/io.h>
7
8/*
9 * The maximum address that we can perform a DMA transfer
10 * to on this platform
11 */
12#define MAX_DMA_ADDRESS (PAGE_OFFSET+0x20000000)
13
14#endif /* _ASM_M32R_DMA_H */
diff --git a/include/asm-m32r/elf.h b/include/asm-m32r/elf.h
new file mode 100644
index 000000000000..bbee8b25d175
--- /dev/null
+++ b/include/asm-m32r/elf.h
@@ -0,0 +1,136 @@
1#ifndef _ASM_M32R__ELF_H
2#define _ASM_M32R__ELF_H
3
4/*
5 * ELF-specific definitions.
6 *
7 * Copyright (C) 1999-2004, Renesas Technology Corp.
8 * Hirokazu Takata <takata at linux-m32r.org>
9 */
10
11#include <asm/ptrace.h>
12#include <asm/user.h>
13#include <asm/page.h>
14
15/* M32R relocation types */
16#define R_M32R_NONE 0
17#define R_M32R_16 1
18#define R_M32R_32 2
19#define R_M32R_24 3
20#define R_M32R_10_PCREL 4
21#define R_M32R_18_PCREL 5
22#define R_M32R_26_PCREL 6
23#define R_M32R_HI16_ULO 7
24#define R_M32R_HI16_SLO 8
25#define R_M32R_LO16 9
26#define R_M32R_SDA16 10
27#define R_M32R_GNU_VTINHERIT 11
28#define R_M32R_GNU_VTENTRY 12
29
30#define R_M32R_16_RELA 33
31#define R_M32R_32_RELA 34
32#define R_M32R_24_RELA 35
33#define R_M32R_10_PCREL_RELA 36
34#define R_M32R_18_PCREL_RELA 37
35#define R_M32R_26_PCREL_RELA 38
36#define R_M32R_HI16_ULO_RELA 39
37#define R_M32R_HI16_SLO_RELA 40
38#define R_M32R_LO16_RELA 41
39#define R_M32R_SDA16_RELA 42
40#define R_M32R_RELA_GNU_VTINHERIT 43
41#define R_M32R_RELA_GNU_VTENTRY 44
42
43#define R_M32R_GOT24 48
44#define R_M32R_26_PLTREL 49
45#define R_M32R_COPY 50
46#define R_M32R_GLOB_DAT 51
47#define R_M32R_JMP_SLOT 52
48#define R_M32R_RELATIVE 53
49#define R_M32R_GOTOFF 54
50#define R_M32R_GOTPC24 55
51#define R_M32R_GOT16_HI_ULO 56
52#define R_M32R_GOT16_HI_SLO 57
53#define R_M32R_GOT16_LO 58
54#define R_M32R_GOTPC_HI_ULO 59
55#define R_M32R_GOTPC_HI_SLO 60
56#define R_M32R_GOTPC_LO 61
57#define R_M32R_GOTOFF_HI_ULO 62
58#define R_M32R_GOTOFF_HI_SLO 63
59#define R_M32R_GOTOFF_LO 64
60
61#define R_M32R_NUM 256
62
63/*
64 * ELF register definitions..
65 */
66#define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t))
67
68typedef unsigned long elf_greg_t;
69typedef elf_greg_t elf_gregset_t[ELF_NGREG];
70
71/* We have no FP mumumu. */
72typedef double elf_fpreg_t;
73typedef elf_fpreg_t elf_fpregset_t;
74
75/*
76 * This is used to ensure we don't load something for the wrong architecture.
77 */
78#define elf_check_arch(x) \
79 (((x)->e_machine == EM_M32R) || ((x)->e_machine == EM_CYGNUS_M32R))
80
81/*
82 * These are used to set parameters in the core dumps.
83 */
84#define ELF_CLASS ELFCLASS32
85#if defined(__LITTLE_ENDIAN)
86#define ELF_DATA ELFDATA2LSB
87#elif defined(__BIG_ENDIAN)
88#define ELF_DATA ELFDATA2MSB
89#else
90#error no endian defined
91#endif
92#define ELF_ARCH EM_M32R
93
94/* r0 is set by ld.so to a pointer to a function which might be
95 * registered using 'atexit'. This provides a mean for the dynamic
96 * linker to call DT_FINI functions for shared libraries that have
97 * been loaded before the code runs.
98 *
99 * So that we can use the same startup file with static executables,
100 * we start programs with a value of 0 to indicate that there is no
101 * such function.
102 */
103#define ELF_PLAT_INIT(_r, load_addr) (_r)->r0 = 0
104
105#define USE_ELF_CORE_DUMP
106#define ELF_EXEC_PAGESIZE PAGE_SIZE
107
108/*
109 * This is the location that an ET_DYN program is loaded if exec'ed.
110 * Typical use of this is to invoke "./ld.so someprog" to test out a
111 * new version of the loader. We need to make sure that it is out of
112 * the way of the program that it will "exec", and that there is
113 * sufficient room for the brk.
114 */
115#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
116
117/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
118 now struct_user_regs, they are different) */
119
120#define ELF_CORE_COPY_REGS(pr_reg, regs) \
121 memcpy((char *)pr_reg, (char *)regs, sizeof (struct pt_regs));
122
123/* This yields a mask that user programs can use to figure out what
124 instruction set this CPU supports. */
125#define ELF_HWCAP (0)
126
127/* This yields a string that ld.so will use to load implementation
128 specific libraries for optimization. This is more specific in
129 intent than poking at uname or /proc/cpuinfo. */
130#define ELF_PLATFORM (NULL)
131
132#ifdef __KERNEL__
133#define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX)
134#endif
135
136#endif /* _ASM_M32R__ELF_H */
diff --git a/include/asm-m32r/errno.h b/include/asm-m32r/errno.h
new file mode 100644
index 000000000000..7a98520194a7
--- /dev/null
+++ b/include/asm-m32r/errno.h
@@ -0,0 +1,9 @@
1#ifndef _ASM_M32R_ERRNO_H
2#define _ASM_M32R_ERRNO_H
3
4/* $Id$ */
5
6#include <asm-generic/errno.h>
7
8#endif /* _ASM_M32R_ERRNO_H */
9
diff --git a/include/asm-m32r/fcntl.h b/include/asm-m32r/fcntl.h
new file mode 100644
index 000000000000..3e3089572028
--- /dev/null
+++ b/include/asm-m32r/fcntl.h
@@ -0,0 +1,92 @@
1#ifndef _ASM_M32R_FCNTL_H
2#define _ASM_M32R_FCNTL_H
3
4/* $Id$ */
5
6/* orig : i386 2.4.18 */
7
8/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
9 located on an ext2 file system */
10#define O_ACCMODE 0003
11#define O_RDONLY 00
12#define O_WRONLY 01
13#define O_RDWR 02
14#define O_CREAT 0100 /* not fcntl */
15#define O_EXCL 0200 /* not fcntl */
16#define O_NOCTTY 0400 /* not fcntl */
17#define O_TRUNC 01000 /* not fcntl */
18#define O_APPEND 02000
19#define O_NONBLOCK 04000
20#define O_NDELAY O_NONBLOCK
21#define O_SYNC 010000
22#define FASYNC 020000 /* fcntl, for BSD compatibility */
23#define O_DIRECT 040000 /* direct disk access hint */
24#define O_LARGEFILE 0100000
25#define O_DIRECTORY 0200000 /* must be a directory */
26#define O_NOFOLLOW 0400000 /* don't follow links */
27#define O_NOATIME 01000000
28
29#define F_DUPFD 0 /* dup */
30#define F_GETFD 1 /* get close_on_exec */
31#define F_SETFD 2 /* set/clear close_on_exec */
32#define F_GETFL 3 /* get file->f_flags */
33#define F_SETFL 4 /* set file->f_flags */
34#define F_GETLK 5
35#define F_SETLK 6
36#define F_SETLKW 7
37
38#define F_SETOWN 8 /* for sockets. */
39#define F_GETOWN 9 /* for sockets. */
40#define F_SETSIG 10 /* for sockets. */
41#define F_GETSIG 11 /* for sockets. */
42
43#define F_GETLK64 12 /* using 'struct flock64' */
44#define F_SETLK64 13
45#define F_SETLKW64 14
46
47/* for F_[GET|SET]FL */
48#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
49
50/* for posix fcntl() and lockf() */
51#define F_RDLCK 0
52#define F_WRLCK 1
53#define F_UNLCK 2
54
55/* for old implementation of bsd flock () */
56#define F_EXLCK 4 /* or 3 */
57#define F_SHLCK 8 /* or 4 */
58
59/* for leases */
60#define F_INPROGRESS 16
61
62/* operations for bsd flock(), also used by the kernel implementation */
63#define LOCK_SH 1 /* shared lock */
64#define LOCK_EX 2 /* exclusive lock */
65#define LOCK_NB 4 /* or'd with one of the above to prevent
66 blocking */
67#define LOCK_UN 8 /* remove lock */
68
69#define LOCK_MAND 32 /* This is a mandatory flock */
70#define LOCK_READ 64 /* ... Which allows concurrent read operations */
71#define LOCK_WRITE 128 /* ... Which allows concurrent write operations */
72#define LOCK_RW 192 /* ... Which allows concurrent read & write ops */
73
74struct flock {
75 short l_type;
76 short l_whence;
77 off_t l_start;
78 off_t l_len;
79 pid_t l_pid;
80};
81
82struct flock64 {
83 short l_type;
84 short l_whence;
85 loff_t l_start;
86 loff_t l_len;
87 pid_t l_pid;
88};
89
90#define F_LINUX_SPECIFIC_BASE 1024
91
92#endif /* _ASM_M32R_FCNTL_H */
diff --git a/include/asm-m32r/flat.h b/include/asm-m32r/flat.h
new file mode 100644
index 000000000000..1b285f65cab6
--- /dev/null
+++ b/include/asm-m32r/flat.h
@@ -0,0 +1,145 @@
1/*
2 * include/asm-m32r/flat.h
3 *
4 * uClinux flat-format executables
5 *
6 * Copyright (C) 2004 Kazuhiro Inaoka
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive for
10 * more details.
11 */
12#ifndef __ASM_M32R_FLAT_H
13#define __ASM_M32R_FLAT_H
14
15#define flat_stack_align(sp) (*sp += (*sp & 3 ? (4 - (*sp & 3)): 0))
16#define flat_argvp_envp_on_stack() 0
17#define flat_old_ram_flag(flags) (flags)
18#define flat_reloc_valid(reloc, size) \
19 (((reloc) - textlen_for_m32r_lo16_data) <= (size))
20#define flat_get_addr_from_rp(rp, relval, flags) \
21 m32r_flat_get_addr_from_rp(rp, relval, (text_len) )
22
23#define flat_put_addr_at_rp(rp, addr, relval) \
24 m32r_flat_put_addr_at_rp(rp, addr, relval)
25
26/* Convert a relocation entry into an address. */
27static inline unsigned long
28flat_get_relocate_addr (unsigned long relval)
29{
30 return relval & 0x00ffffff; /* Mask out top 8-bits */
31}
32
33#define flat_m32r_get_reloc_type(relval) ((relval) >> 24)
34
35#define M32R_SETH_OPCODE 0xd0c00000 /* SETH instruction code */
36
37#define FLAT_M32R_32 0x00 /* 32bits reloc */
38#define FLAT_M32R_24 0x01 /* unsigned 24bits reloc */
39#define FLAT_M32R_16 0x02 /* 16bits reloc */
40#define FLAT_M32R_LO16 0x03 /* signed low 16bits reloc (low()) */
41#define FLAT_M32R_LO16_DATA 0x04 /* signed low 16bits reloc (low())
42 for a symbol in .data section */
43 /* High 16bits of an address used
44 when the lower 16bbits are treated
45 as unsigned.
46 To create SETH instruction only.
47 0x1X: X means a number of register.
48 0x10 - 0x3F are reserved. */
49#define FLAT_M32R_HI16_ULO 0x10 /* reloc for SETH Rn,#high(imm16) */
50 /* High 16bits of an address used
51 when the lower 16bbits are treated
52 as signed.
53 To create SETH instruction only.
54 0x2X: X means a number of register.
55 0x20 - 0x4F are reserved. */
56#define FLAT_M32R_HI16_SLO 0x20 /* reloc for SETH Rn,#shigh(imm16) */
57
58static unsigned long textlen_for_m32r_lo16_data = 0;
59
60static inline unsigned long m32r_flat_get_addr_from_rp (unsigned long *rp,
61 unsigned long relval,
62 unsigned long textlen)
63{
64 unsigned int reloc = flat_m32r_get_reloc_type (relval);
65 textlen_for_m32r_lo16_data = 0;
66 if (reloc & 0xf0) {
67 unsigned long addr = htonl(*rp);
68 switch (reloc & 0xf0)
69 {
70 case FLAT_M32R_HI16_ULO:
71 case FLAT_M32R_HI16_SLO:
72 if (addr == 0) {
73 /* put "seth Rn,#0x0" instead of 0 (addr). */
74 *rp = (M32R_SETH_OPCODE | ((reloc & 0x0f)<<24));
75 }
76 return addr;
77 default:
78 break;
79 }
80 } else {
81 switch (reloc)
82 {
83 case FLAT_M32R_LO16:
84 return htonl(*rp) & 0xFFFF;
85 case FLAT_M32R_LO16_DATA:
86 /* FIXME: The return value will decrease by textlen
87 at m32r_flat_put_addr_at_rp () */
88 textlen_for_m32r_lo16_data = textlen;
89 return (htonl(*rp) & 0xFFFF) + textlen;
90 case FLAT_M32R_16:
91 return htons(*(unsigned short *)rp) & 0xFFFF;
92 case FLAT_M32R_24:
93 return htonl(*rp) & 0xFFFFFF;
94 case FLAT_M32R_32:
95 return htonl(*rp);
96 default:
97 break;
98 }
99 }
100 return ~0; /* bogus value */
101}
102
103static inline void m32r_flat_put_addr_at_rp (unsigned long *rp,
104 unsigned long addr,
105 unsigned long relval)
106{
107 unsigned int reloc = flat_m32r_get_reloc_type (relval);
108 if (reloc & 0xf0) {
109 unsigned long Rn = reloc & 0x0f; /* get a number of register */
110 Rn <<= 24; /* 0x0R000000 */
111 reloc &= 0xf0;
112 switch (reloc)
113 {
114 case FLAT_M32R_HI16_ULO: /* To create SETH Rn,#high(imm16) */
115 *rp = (M32R_SETH_OPCODE | Rn
116 | ((addr >> 16) & 0xFFFF));
117 break;
118 case FLAT_M32R_HI16_SLO: /* To create SETH Rn,#shigh(imm16) */
119 *rp = (M32R_SETH_OPCODE | Rn
120 | (((addr >> 16) + ((addr & 0x8000) ? 1 : 0))
121 & 0xFFFF));
122 break;
123 }
124 } else {
125 switch (reloc) {
126 case FLAT_M32R_LO16_DATA:
127 addr -= textlen_for_m32r_lo16_data;
128 textlen_for_m32r_lo16_data = 0;
129 case FLAT_M32R_LO16:
130 *rp = (htonl(*rp) & 0xFFFF0000) | (addr & 0xFFFF);
131 break;
132 case FLAT_M32R_16:
133 *(unsigned short *)rp = addr & 0xFFFF;
134 break;
135 case FLAT_M32R_24:
136 *rp = (htonl(*rp) & 0xFF000000) | (addr & 0xFFFFFF);
137 break;
138 case FLAT_M32R_32:
139 *rp = addr;
140 break;
141 }
142 }
143}
144
145#endif /* __ASM_M32R_FLAT_H */
diff --git a/include/asm-m32r/hardirq.h b/include/asm-m32r/hardirq.h
new file mode 100644
index 000000000000..5da830ec1587
--- /dev/null
+++ b/include/asm-m32r/hardirq.h
@@ -0,0 +1,37 @@
1#ifdef __KERNEL__
2#ifndef __ASM_HARDIRQ_H
3#define __ASM_HARDIRQ_H
4
5#include <linux/config.h>
6#include <linux/threads.h>
7#include <linux/irq.h>
8
9typedef struct {
10 unsigned int __softirq_pending;
11} ____cacheline_aligned irq_cpustat_t;
12
13#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
14
15#if NR_IRQS > 256
16#define HARDIRQ_BITS 9
17#else
18#define HARDIRQ_BITS 8
19#endif
20
21/*
22 * The hardirq mask has to be large enough to have
23 * space for potentially all IRQ sources in the system
24 * nesting on a single CPU:
25 */
26#if (1 << HARDIRQ_BITS) < NR_IRQS
27# error HARDIRQ_BITS is too low!
28#endif
29
30static inline void ack_bad_irq(int irq)
31{
32 printk(KERN_CRIT "unexpected IRQ trap at vector %02x\n", irq);
33 BUG();
34}
35
36#endif /* __ASM_HARDIRQ_H */
37#endif /* __KERNEL__ */
diff --git a/include/asm-m32r/hdreg.h b/include/asm-m32r/hdreg.h
new file mode 100644
index 000000000000..7f7fd1af0af3
--- /dev/null
+++ b/include/asm-m32r/hdreg.h
@@ -0,0 +1 @@
#include <asm-generic/hdreg.h>
diff --git a/include/asm-m32r/hw_irq.h b/include/asm-m32r/hw_irq.h
new file mode 100644
index 000000000000..8d7e9d0e09e8
--- /dev/null
+++ b/include/asm-m32r/hw_irq.h
@@ -0,0 +1,9 @@
1#ifndef _ASM_M32R_HW_IRQ_H
2#define _ASM_M32R_HW_IRQ_H
3
4static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i)
5{
6 /* Nothing to do */
7}
8
9#endif /* _ASM_M32R_HW_IRQ_H */
diff --git a/include/asm-m32r/ide.h b/include/asm-m32r/ide.h
new file mode 100644
index 000000000000..be64f24e37ee
--- /dev/null
+++ b/include/asm-m32r/ide.h
@@ -0,0 +1,82 @@
1#ifndef _ASM_M32R_IDE_H
2#define _ASM_M32R_IDE_H
3
4/* $Id$ */
5
6/*
7 * linux/include/asm-m32r/ide.h
8 *
9 * Copyright (C) 1994-1996 Linus Torvalds & authors
10 */
11
12/*
13 * This file contains the i386 architecture specific IDE code.
14 */
15
16#ifdef __KERNEL__
17
18#include <linux/config.h>
19
20#ifndef MAX_HWIFS
21# ifdef CONFIG_BLK_DEV_IDEPCI
22#define MAX_HWIFS 10
23# else
24#define MAX_HWIFS 2
25# endif
26#endif
27
28#if defined(CONFIG_PLAT_M32700UT)
29#include <asm/irq.h>
30#include <asm/m32700ut/m32700ut_pld.h>
31#endif
32
33#define IDE_ARCH_OBSOLETE_DEFAULTS
34
35static __inline__ int ide_default_irq(unsigned long base)
36{
37 switch (base) {
38#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2)
39 case 0x1f0: return PLD_IRQ_CFIREQ;
40 default:
41 return 0;
42#else
43 case 0x1f0: return 14;
44 case 0x170: return 15;
45 case 0x1e8: return 11;
46 case 0x168: return 10;
47 case 0x1e0: return 8;
48 case 0x160: return 12;
49 default:
50 return 0;
51#endif
52 }
53}
54
55static __inline__ unsigned long ide_default_io_base(int index)
56{
57 switch (index) {
58 case 0: return 0x1f0;
59 case 1: return 0x170;
60 case 2: return 0x1e8;
61 case 3: return 0x168;
62 case 4: return 0x1e0;
63 case 5: return 0x160;
64 default:
65 return 0;
66 }
67}
68
69#define IDE_ARCH_OBSOLETE_INIT
70#define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
71
72#ifdef CONFIG_BLK_DEV_IDEPCI
73#define ide_init_default_irq(base) (0)
74#else
75#define ide_init_default_irq(base) ide_default_irq(base)
76#endif
77
78#include <asm-generic/ide_iops.h>
79
80#endif /* __KERNEL__ */
81
82#endif /* _ASM_M32R_IDE_H */
diff --git a/include/asm-m32r/io.h b/include/asm-m32r/io.h
new file mode 100644
index 000000000000..8e9e481e6996
--- /dev/null
+++ b/include/asm-m32r/io.h
@@ -0,0 +1,232 @@
1#ifndef _ASM_M32R_IO_H
2#define _ASM_M32R_IO_H
3
4#include <linux/string.h>
5#include <linux/compiler.h>
6#include <asm/page.h> /* __va */
7
8#ifdef __KERNEL__
9
10#define IO_SPACE_LIMIT 0xFFFFFFFF
11
12/**
13 * virt_to_phys - map virtual addresses to physical
14 * @address: address to remap
15 *
16 * The returned physical address is the physical (CPU) mapping for
17 * the memory address given. It is only valid to use this function on
18 * addresses directly mapped or allocated via kmalloc.
19 *
20 * This function does not give bus mappings for DMA transfers. In
21 * almost all conceivable cases a device driver should not be using
22 * this function
23 */
24
25static inline unsigned long virt_to_phys(volatile void * address)
26{
27 return __pa(address);
28}
29
30/**
31 * phys_to_virt - map physical address to virtual
32 * @address: address to remap
33 *
34 * The returned virtual address is a current CPU mapping for
35 * the memory address given. It is only valid to use this function on
36 * addresses that have a kernel mapping
37 *
38 * This function does not handle bus mappings for DMA transfers. In
39 * almost all conceivable cases a device driver should not be using
40 * this function
41 */
42
43static inline void *phys_to_virt(unsigned long address)
44{
45 return __va(address);
46}
47
48extern void __iomem *
49__ioremap(unsigned long offset, unsigned long size, unsigned long flags);
50
51/**
52 * ioremap - map bus memory into CPU space
53 * @offset: bus address of the memory
54 * @size: size of the resource to map
55 *
56 * ioremap performs a platform specific sequence of operations to
57 * make bus memory CPU accessible via the readb/readw/readl/writeb/
58 * writew/writel functions and the other mmio helpers. The returned
59 * address is not guaranteed to be usable directly as a virtual
60 * address.
61 */
62
63static inline void * ioremap(unsigned long offset, unsigned long size)
64{
65 return __ioremap(offset, size, 0);
66}
67
68extern void iounmap(volatile void __iomem *addr);
69#define ioremap_nocache(off,size) ioremap(off,size)
70
71/*
72 * IO bus memory addresses are also 1:1 with the physical address
73 */
74#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
75#define page_to_bus page_to_phys
76#define virt_to_bus virt_to_phys
77
78extern unsigned char _inb(unsigned long);
79extern unsigned short _inw(unsigned long);
80extern unsigned long _inl(unsigned long);
81extern unsigned char _inb_p(unsigned long);
82extern unsigned short _inw_p(unsigned long);
83extern unsigned long _inl_p(unsigned long);
84extern void _outb(unsigned char, unsigned long);
85extern void _outw(unsigned short, unsigned long);
86extern void _outl(unsigned long, unsigned long);
87extern void _outb_p(unsigned char, unsigned long);
88extern void _outw_p(unsigned short, unsigned long);
89extern void _outl_p(unsigned long, unsigned long);
90extern void _insb(unsigned int, void *, unsigned long);
91extern void _insw(unsigned int, void *, unsigned long);
92extern void _insl(unsigned int, void *, unsigned long);
93extern void _outsb(unsigned int, const void *, unsigned long);
94extern void _outsw(unsigned int, const void *, unsigned long);
95extern void _outsl(unsigned int, const void *, unsigned long);
96
97static inline unsigned char _readb(unsigned long addr)
98{
99 return *(volatile unsigned char __force *)addr;
100}
101
102static inline unsigned short _readw(unsigned long addr)
103{
104 return *(volatile unsigned short __force *)addr;
105}
106
107static inline unsigned long _readl(unsigned long addr)
108{
109 return *(volatile unsigned long __force *)addr;
110}
111
112static inline void _writeb(unsigned char b, unsigned long addr)
113{
114 *(volatile unsigned char __force *)addr = b;
115}
116
117static inline void _writew(unsigned short w, unsigned long addr)
118{
119 *(volatile unsigned short __force *)addr = w;
120}
121
122static inline void _writel(unsigned long l, unsigned long addr)
123{
124 *(volatile unsigned long __force *)addr = l;
125}
126
127#define inb _inb
128#define inw _inw
129#define inl _inl
130#define outb _outb
131#define outw _outw
132#define outl _outl
133
134#define inb_p _inb_p
135#define inw_p _inw_p
136#define inl_p _inl_p
137#define outb_p _outb_p
138#define outw_p _outw_p
139#define outl_p _outl_p
140
141#define insb _insb
142#define insw _insw
143#define insl _insl
144#define outsb _outsb
145#define outsw _outsw
146#define outsl _outsl
147
148#define readb(addr) _readb((unsigned long)(addr))
149#define readw(addr) _readw((unsigned long)(addr))
150#define readl(addr) _readl((unsigned long)(addr))
151#define __raw_readb readb
152#define __raw_readw readw
153#define __raw_readl readl
154#define readb_relaxed readb
155#define readw_relaxed readw
156#define readl_relaxed readl
157
158#define writeb(val, addr) _writeb((val), (unsigned long)(addr))
159#define writew(val, addr) _writew((val), (unsigned long)(addr))
160#define writel(val, addr) _writel((val), (unsigned long)(addr))
161#define __raw_writeb writeb
162#define __raw_writew writew
163#define __raw_writel writel
164
165#define mmiowb()
166
167#define flush_write_buffers() do { } while (0) /* M32R_FIXME */
168
169/**
170 * check_signature - find BIOS signatures
171 * @io_addr: mmio address to check
172 * @signature: signature block
173 * @length: length of signature
174 *
175 * Perform a signature comparison with the ISA mmio address io_addr.
176 * Returns 1 on a match.
177 *
178 * This function is deprecated. New drivers should use ioremap and
179 * check_signature.
180 */
181
182static inline int check_signature(void __iomem *io_addr,
183 const unsigned char *signature, int length)
184{
185 int retval = 0;
186#if 0
187printk("check_signature\n");
188 do {
189 if (readb(io_addr) != *signature)
190 goto out;
191 io_addr++;
192 signature++;
193 length--;
194 } while (length);
195 retval = 1;
196out:
197#endif
198 return retval;
199}
200
201static inline void
202memset_io(volatile void __iomem *addr, unsigned char val, int count)
203{
204 memset((void __force *) addr, val, count);
205}
206
207static inline void
208memcpy_fromio(void *dst, volatile void __iomem *src, int count)
209{
210 memcpy(dst, (void __force *) src, count);
211}
212
213static inline void
214memcpy_toio(volatile void __iomem *dst, const void *src, int count)
215{
216 memcpy((void __force *) dst, src, count);
217}
218
219/*
220 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
221 * access
222 */
223#define xlate_dev_mem_ptr(p) __va(p)
224
225/*
226 * Convert a virtual cached pointer to an uncached pointer
227 */
228#define xlate_dev_kmem_ptr(p) p
229
230#endif /* __KERNEL__ */
231
232#endif /* _ASM_M32R_IO_H */
diff --git a/include/asm-m32r/ioctl.h b/include/asm-m32r/ioctl.h
new file mode 100644
index 000000000000..87d8f7db6af1
--- /dev/null
+++ b/include/asm-m32r/ioctl.h
@@ -0,0 +1,78 @@
1#ifndef _ASM_M32R_IOCTL_H
2#define _ASM_M32R_IOCTL_H
3
4/* $Id$ */
5
6/* orig : i386 2.4.18 */
7
8/*
9 * linux/ioctl.h for Linux by H.H. Bergman.
10 */
11
12/* ioctl command encoding: 32 bits total, command in lower 16 bits,
13 * size of the parameter structure in the lower 14 bits of the
14 * upper 16 bits.
15 * Encoding the size of the parameter structure in the ioctl request
16 * is useful for catching programs compiled with old versions
17 * and to avoid overwriting user space outside the user buffer area.
18 * The highest 2 bits are reserved for indicating the ``access mode''.
19 * NOTE: This limits the max parameter size to 16kB -1 !
20 */
21
22/*
23 * The following is for compatibility across the various Linux
24 * platforms. The i386 ioctl numbering scheme doesn't really enforce
25 * a type field. De facto, however, the top 8 bits of the lower 16
26 * bits are indeed used as a type field, so we might just as well make
27 * this explicit here. Please be sure to use the decoding macros
28 * below from now on.
29 */
30#define _IOC_NRBITS 8
31#define _IOC_TYPEBITS 8
32#define _IOC_SIZEBITS 14
33#define _IOC_DIRBITS 2
34
35#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
36#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
37#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
38#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
39
40#define _IOC_NRSHIFT 0
41#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
42#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
43#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
44
45/*
46 * Direction bits.
47 */
48#define _IOC_NONE 0U
49#define _IOC_WRITE 1U
50#define _IOC_READ 2U
51
52#define _IOC(dir,type,nr,size) \
53 (((dir) << _IOC_DIRSHIFT) | \
54 ((type) << _IOC_TYPESHIFT) | \
55 ((nr) << _IOC_NRSHIFT) | \
56 ((size) << _IOC_SIZESHIFT))
57
58/* used to create numbers */
59#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
60#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
61#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
62#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
63
64/* used to decode ioctl numbers.. */
65#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
66#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
67#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
68#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
69
70/* ...and for the drivers/sound files... */
71
72#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
73#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
74#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
75#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
76#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
77
78#endif /* _ASM_M32R_IOCTL_H */
diff --git a/include/asm-m32r/ioctls.h b/include/asm-m32r/ioctls.h
new file mode 100644
index 000000000000..b3508292246a
--- /dev/null
+++ b/include/asm-m32r/ioctls.h
@@ -0,0 +1,88 @@
1#ifndef __ARCH_M32R_IOCTLS_H__
2#define __ARCH_M32R_IOCTLS_H__
3
4/* $Id$ */
5
6/* orig : i386 2.5.67 */
7
8#include <asm/ioctl.h>
9
10/* 0x54 is just a magic number to make these relatively unique ('T') */
11
12#define TCGETS 0x5401
13#define TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */
14#define TCSETSW 0x5403
15#define TCSETSF 0x5404
16#define TCGETA 0x5405
17#define TCSETA 0x5406
18#define TCSETAW 0x5407
19#define TCSETAF 0x5408
20#define TCSBRK 0x5409
21#define TCXONC 0x540A
22#define TCFLSH 0x540B
23#define TIOCEXCL 0x540C
24#define TIOCNXCL 0x540D
25#define TIOCSCTTY 0x540E
26#define TIOCGPGRP 0x540F
27#define TIOCSPGRP 0x5410
28#define TIOCOUTQ 0x5411
29#define TIOCSTI 0x5412
30#define TIOCGWINSZ 0x5413
31#define TIOCSWINSZ 0x5414
32#define TIOCMGET 0x5415
33#define TIOCMBIS 0x5416
34#define TIOCMBIC 0x5417
35#define TIOCMSET 0x5418
36#define TIOCGSOFTCAR 0x5419
37#define TIOCSSOFTCAR 0x541A
38#define FIONREAD 0x541B
39#define TIOCINQ FIONREAD
40#define TIOCLINUX 0x541C
41#define TIOCCONS 0x541D
42#define TIOCGSERIAL 0x541E
43#define TIOCSSERIAL 0x541F
44#define TIOCPKT 0x5420
45#define FIONBIO 0x5421
46#define TIOCNOTTY 0x5422
47#define TIOCSETD 0x5423
48#define TIOCGETD 0x5424
49#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
50/* #define TIOCTTYGSTRUCT 0x5426 - Former debugging-only ioctl */
51#define TIOCSBRK 0x5427 /* BSD compatibility */
52#define TIOCCBRK 0x5428 /* BSD compatibility */
53#define TIOCGSID 0x5429 /* Return the session ID of FD */
54#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
55#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
56
57#define FIONCLEX 0x5450
58#define FIOCLEX 0x5451
59#define FIOASYNC 0x5452
60#define TIOCSERCONFIG 0x5453
61#define TIOCSERGWILD 0x5454
62#define TIOCSERSWILD 0x5455
63#define TIOCGLCKTRMIOS 0x5456
64#define TIOCSLCKTRMIOS 0x5457
65#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
66#define TIOCSERGETLSR 0x5459 /* Get line status register */
67#define TIOCSERGETMULTI 0x545A /* Get multiport config */
68#define TIOCSERSETMULTI 0x545B /* Set multiport config */
69
70#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
71#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
72#define TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */
73#define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */
74#define FIOQSIZE 0x5460
75
76/* Used for packet mode */
77#define TIOCPKT_DATA 0
78#define TIOCPKT_FLUSHREAD 1
79#define TIOCPKT_FLUSHWRITE 2
80#define TIOCPKT_STOP 4
81#define TIOCPKT_START 8
82#define TIOCPKT_NOSTOP 16
83#define TIOCPKT_DOSTOP 32
84
85#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
86
87#endif /* __ARCH_M32R_IOCTLS_H__ */
88
diff --git a/include/asm-m32r/ipc.h b/include/asm-m32r/ipc.h
new file mode 100644
index 000000000000..a46e3d9c2a3f
--- /dev/null
+++ b/include/asm-m32r/ipc.h
@@ -0,0 +1 @@
#include <asm-generic/ipc.h>
diff --git a/include/asm-m32r/ipcbuf.h b/include/asm-m32r/ipcbuf.h
new file mode 100644
index 000000000000..7c77fb0b1467
--- /dev/null
+++ b/include/asm-m32r/ipcbuf.h
@@ -0,0 +1,33 @@
1#ifndef _ASM_M32R_IPCBUF_H
2#define _ASM_M32R_IPCBUF_H
3
4/* $Id$ */
5
6/* orig : i386 2.4.18 */
7
8/*
9 * The ipc64_perm structure for m32r architecture.
10 * Note extra padding because this structure is passed back and forth
11 * between kernel and user space.
12 *
13 * Pad space is left for:
14 * - 32-bit mode_t and seq
15 * - 2 miscellaneous 32-bit values
16 */
17
18struct ipc64_perm
19{
20 __kernel_key_t key;
21 __kernel_uid32_t uid;
22 __kernel_gid32_t gid;
23 __kernel_uid32_t cuid;
24 __kernel_gid32_t cgid;
25 __kernel_mode_t mode;
26 unsigned short __pad1;
27 unsigned short seq;
28 unsigned short __pad2;
29 unsigned long __unused1;
30 unsigned long __unused2;
31};
32
33#endif /* _ASM_M32R_IPCBUF_H */
diff --git a/include/asm-m32r/irq.h b/include/asm-m32r/irq.h
new file mode 100644
index 000000000000..8ed77968ecb4
--- /dev/null
+++ b/include/asm-m32r/irq.h
@@ -0,0 +1,75 @@
1#ifdef __KERNEL__
2#ifndef _ASM_M32R_IRQ_H
3#define _ASM_M32R_IRQ_H
4
5#include <linux/config.h>
6
7#if defined(CONFIG_PLAT_M32700UT_Alpha) || defined(CONFIG_PLAT_USRV)
8/*
9 * IRQ definitions for M32700UT
10 * M32700 Chip: 64 interrupts
11 * ICU of M32700UT-on-board PLD: 32 interrupts cascaded to INT1# chip pin
12 */
13#define M32700UT_NUM_CPU_IRQ (64)
14#define M32700UT_NUM_PLD_IRQ (32)
15#define M32700UT_IRQ_BASE 0
16#define M32700UT_CPU_IRQ_BASE M32700UT_IRQ_BASE
17#define M32700UT_PLD_IRQ_BASE (M32700UT_CPU_IRQ_BASE + M32700UT_NUM_CPU_IRQ)
18
19#define NR_IRQS (M32700UT_NUM_CPU_IRQ + M32700UT_NUM_PLD_IRQ)
20#elif defined(CONFIG_PLAT_M32700UT)
21/*
22 * IRQ definitions for M32700UT(Rev.C) + M32R-LAN
23 * M32700 Chip: 64 interrupts
24 * ICU of M32700UT-on-board PLD: 32 interrupts cascaded to INT1# chip pin
25 * ICU of M32R-LCD-on-board PLD: 32 interrupts cascaded to INT2# chip pin
26 * ICU of M32R-LAN-on-board PLD: 32 interrupts cascaded to INT0# chip pin
27 */
28#define M32700UT_NUM_CPU_IRQ (64)
29#define M32700UT_NUM_PLD_IRQ (32)
30#define M32700UT_NUM_LCD_PLD_IRQ (32)
31#define M32700UT_NUM_LAN_PLD_IRQ (32)
32#define M32700UT_IRQ_BASE 0
33#define M32700UT_CPU_IRQ_BASE (M32700UT_IRQ_BASE)
34#define M32700UT_PLD_IRQ_BASE \
35 (M32700UT_CPU_IRQ_BASE + M32700UT_NUM_CPU_IRQ)
36#define M32700UT_LCD_PLD_IRQ_BASE \
37 (M32700UT_PLD_IRQ_BASE + M32700UT_NUM_PLD_IRQ)
38#define M32700UT_LAN_PLD_IRQ_BASE \
39 (M32700UT_LCD_PLD_IRQ_BASE + M32700UT_NUM_LCD_PLD_IRQ)
40
41#define NR_IRQS \
42 (M32700UT_NUM_CPU_IRQ + M32700UT_NUM_PLD_IRQ \
43 + M32700UT_NUM_LCD_PLD_IRQ + M32700UT_NUM_LAN_PLD_IRQ)
44#elif defined(CONFIG_PLAT_OPSPUT)
45/*
46 * IRQ definitions for OPSPUT + M32R-LAN
47 * OPSP Chip: 64 interrupts
48 * ICU of OPSPUT-on-board PLD: 32 interrupts cascaded to INT1# chip pin
49 * ICU of M32R-LCD-on-board PLD: 32 interrupts cascaded to INT2# chip pin
50 * ICU of M32R-LAN-on-board PLD: 32 interrupts cascaded to INT0# chip pin
51 */
52#define OPSPUT_NUM_CPU_IRQ (64)
53#define OPSPUT_NUM_PLD_IRQ (32)
54#define OPSPUT_NUM_LCD_PLD_IRQ (32)
55#define OPSPUT_NUM_LAN_PLD_IRQ (32)
56#define OPSPUT_IRQ_BASE 0
57#define OPSPUT_CPU_IRQ_BASE (OPSPUT_IRQ_BASE)
58#define OPSPUT_PLD_IRQ_BASE \
59 (OPSPUT_CPU_IRQ_BASE + OPSPUT_NUM_CPU_IRQ)
60#define OPSPUT_LCD_PLD_IRQ_BASE \
61 (OPSPUT_PLD_IRQ_BASE + OPSPUT_NUM_PLD_IRQ)
62#define OPSPUT_LAN_PLD_IRQ_BASE \
63 (OPSPUT_LCD_PLD_IRQ_BASE + OPSPUT_NUM_LCD_PLD_IRQ)
64
65#define NR_IRQS \
66 (OPSPUT_NUM_CPU_IRQ + OPSPUT_NUM_PLD_IRQ \
67 + OPSPUT_NUM_LCD_PLD_IRQ + OPSPUT_NUM_LAN_PLD_IRQ)
68#else
69#define NR_IRQS 64
70#endif
71
72#define irq_canonicalize(irq) (irq)
73
74#endif /* _ASM_M32R_IRQ_H */
75#endif /* __KERNEL__ */
diff --git a/include/asm-m32r/kmap_types.h b/include/asm-m32r/kmap_types.h
new file mode 100644
index 000000000000..7429591010b6
--- /dev/null
+++ b/include/asm-m32r/kmap_types.h
@@ -0,0 +1,34 @@
1#ifndef __M32R_KMAP_TYPES_H
2#define __M32R_KMAP_TYPES_H
3
4/* Dummy header just to define km_type. */
5
6#include <linux/config.h>
7
8#ifdef CONFIG_DEBUG_HIGHMEM
9# define D(n) __KM_FENCE_##n ,
10#else
11# define D(n)
12#endif
13
14enum km_type {
15D(0) KM_BOUNCE_READ,
16D(1) KM_SKB_SUNRPC_DATA,
17D(2) KM_SKB_DATA_SOFTIRQ,
18D(3) KM_USER0,
19D(4) KM_USER1,
20D(5) KM_BIO_SRC_IRQ,
21D(6) KM_BIO_DST_IRQ,
22D(7) KM_PTE0,
23D(8) KM_PTE1,
24D(9) KM_IRQ0,
25D(10) KM_IRQ1,
26D(11) KM_SOFTIRQ0,
27D(12) KM_SOFTIRQ1,
28D(13) KM_TYPE_NR
29};
30
31#undef D
32
33#endif /* __M32R_KMAP_TYPES_H */
34
diff --git a/include/asm-m32r/linkage.h b/include/asm-m32r/linkage.h
new file mode 100644
index 000000000000..a9fb151cf648
--- /dev/null
+++ b/include/asm-m32r/linkage.h
@@ -0,0 +1,7 @@
1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H
3
4#define __ALIGN .balign 4
5#define __ALIGN_STR ".balign 4"
6
7#endif /* __ASM_LINKAGE_H */
diff --git a/include/asm-m32r/local.h b/include/asm-m32r/local.h
new file mode 100644
index 000000000000..def29d095740
--- /dev/null
+++ b/include/asm-m32r/local.h
@@ -0,0 +1,6 @@
1#ifndef __M32R_LOCAL_H
2#define __M32R_LOCAL_H
3
4#include <asm-generic/local.h>
5
6#endif /* __M32R_LOCAL_H */
diff --git a/include/asm-m32r/m32102.h b/include/asm-m32r/m32102.h
new file mode 100644
index 000000000000..b56034026bf8
--- /dev/null
+++ b/include/asm-m32r/m32102.h
@@ -0,0 +1,294 @@
1#ifndef _M32102_H_
2#define _M32102_H_
3
4/*
5 * Renesas M32R 32102 group
6 *
7 * Copyright (c) 2001 Hitoshi Yamamoto
8 * Copyright (c) 2003, 2004 Renesas Technology Corp.
9 */
10
11/*======================================================================*
12 * Special Function Register
13 *======================================================================*/
14#define M32R_SFR_OFFSET (0x00E00000) /* 0x00E00000-0x00EFFFFF 1[MB] */
15
16/*
17 * Clock and Power Management registers.
18 */
19#define M32R_CPM_OFFSET (0x000F4000+M32R_SFR_OFFSET)
20
21#define M32R_CPM_CPUCLKCR_PORTL (0x00+M32R_CPM_OFFSET)
22#define M32R_CPM_CLKMOD_PORTL (0x04+M32R_CPM_OFFSET)
23#define M32R_CPM_PLLCR_PORTL (0x08+M32R_CPM_OFFSET)
24
25/*
26 * DMA Controller registers.
27 */
28#define M32R_DMA_OFFSET (0x000F8000+M32R_SFR_OFFSET)
29
30#define M32R_DMAEN_PORTL (0x000+M32R_DMA_OFFSET)
31#define M32R_DMAISTS_PORTL (0x004+M32R_DMA_OFFSET)
32#define M32R_DMAEDET_PORTL (0x008+M32R_DMA_OFFSET)
33#define M32R_DMAASTS_PORTL (0x00c+M32R_DMA_OFFSET)
34
35#define M32R_DMA0CR0_PORTL (0x100+M32R_DMA_OFFSET)
36#define M32R_DMA0CR1_PORTL (0x104+M32R_DMA_OFFSET)
37#define M32R_DMA0CSA_PORTL (0x108+M32R_DMA_OFFSET)
38#define M32R_DMA0RSA_PORTL (0x10c+M32R_DMA_OFFSET)
39#define M32R_DMA0CDA_PORTL (0x110+M32R_DMA_OFFSET)
40#define M32R_DMA0RDA_PORTL (0x114+M32R_DMA_OFFSET)
41#define M32R_DMA0CBCUT_PORTL (0x118+M32R_DMA_OFFSET)
42#define M32R_DMA0RBCUT_PORTL (0x11c+M32R_DMA_OFFSET)
43
44#define M32R_DMA1CR0_PORTL (0x200+M32R_DMA_OFFSET)
45#define M32R_DMA1CR1_PORTL (0x204+M32R_DMA_OFFSET)
46#define M32R_DMA1CSA_PORTL (0x208+M32R_DMA_OFFSET)
47#define M32R_DMA1RSA_PORTL (0x20c+M32R_DMA_OFFSET)
48#define M32R_DMA1CDA_PORTL (0x210+M32R_DMA_OFFSET)
49#define M32R_DMA1RDA_PORTL (0x214+M32R_DMA_OFFSET)
50#define M32R_DMA1CBCUT_PORTL (0x218+M32R_DMA_OFFSET)
51#define M32R_DMA1RBCUT_PORTL (0x21c+M32R_DMA_OFFSET)
52
53/*
54 * Multi Function Timer registers.
55 */
56#define M32R_MFT_OFFSET (0x000FC000+M32R_SFR_OFFSET)
57
58#define M32R_MFTCR_PORTL (0x000+M32R_MFT_OFFSET) /* MFT control */
59#define M32R_MFTRPR_PORTL (0x004+M32R_MFT_OFFSET) /* MFT real port */
60
61#define M32R_MFT0_OFFSET (0x100+M32R_MFT_OFFSET)
62#define M32R_MFT0MOD_PORTL (0x00+M32R_MFT0_OFFSET) /* MFT0 mode */
63#define M32R_MFT0BOS_PORTL (0x04+M32R_MFT0_OFFSET) /* MFT0 b-port output status */
64#define M32R_MFT0CUT_PORTL (0x08+M32R_MFT0_OFFSET) /* MFT0 count */
65#define M32R_MFT0RLD_PORTL (0x0C+M32R_MFT0_OFFSET) /* MFT0 reload */
66#define M32R_MFT0CMPRLD_PORTL (0x10+M32R_MFT0_OFFSET) /* MFT0 compare reload */
67
68#define M32R_MFT1_OFFSET (0x200+M32R_MFT_OFFSET)
69#define M32R_MFT1MOD_PORTL (0x00+M32R_MFT1_OFFSET) /* MFT1 mode */
70#define M32R_MFT1BOS_PORTL (0x04+M32R_MFT1_OFFSET) /* MFT1 b-port output status */
71#define M32R_MFT1CUT_PORTL (0x08+M32R_MFT1_OFFSET) /* MFT1 count */
72#define M32R_MFT1RLD_PORTL (0x0C+M32R_MFT1_OFFSET) /* MFT1 reload */
73#define M32R_MFT1CMPRLD_PORTL (0x10+M32R_MFT1_OFFSET) /* MFT1 compare reload */
74
75#define M32R_MFT2_OFFSET (0x300+M32R_MFT_OFFSET)
76#define M32R_MFT2MOD_PORTL (0x00+M32R_MFT2_OFFSET) /* MFT2 mode */
77#define M32R_MFT2BOS_PORTL (0x04+M32R_MFT2_OFFSET) /* MFT2 b-port output status */
78#define M32R_MFT2CUT_PORTL (0x08+M32R_MFT2_OFFSET) /* MFT2 count */
79#define M32R_MFT2RLD_PORTL (0x0C+M32R_MFT2_OFFSET) /* MFT2 reload */
80#define M32R_MFT2CMPRLD_PORTL (0x10+M32R_MFT2_OFFSET) /* MFT2 compare reload */
81
82#define M32R_MFT3_OFFSET (0x400+M32R_MFT_OFFSET)
83#define M32R_MFT3MOD_PORTL (0x00+M32R_MFT3_OFFSET) /* MFT3 mode */
84#define M32R_MFT3BOS_PORTL (0x04+M32R_MFT3_OFFSET) /* MFT3 b-port output status */
85#define M32R_MFT3CUT_PORTL (0x08+M32R_MFT3_OFFSET) /* MFT3 count */
86#define M32R_MFT3RLD_PORTL (0x0C+M32R_MFT3_OFFSET) /* MFT3 reload */
87#define M32R_MFT3CMPRLD_PORTL (0x10+M32R_MFT3_OFFSET) /* MFT3 compare reload */
88
89#define M32R_MFT4_OFFSET (0x500+M32R_MFT_OFFSET)
90#define M32R_MFT4MOD_PORTL (0x00+M32R_MFT4_OFFSET) /* MFT4 mode */
91#define M32R_MFT4BOS_PORTL (0x04+M32R_MFT4_OFFSET) /* MFT4 b-port output status */
92#define M32R_MFT4CUT_PORTL (0x08+M32R_MFT4_OFFSET) /* MFT4 count */
93#define M32R_MFT4RLD_PORTL (0x0C+M32R_MFT4_OFFSET) /* MFT4 reload */
94#define M32R_MFT4CMPRLD_PORTL (0x10+M32R_MFT4_OFFSET) /* MFT4 compare reload */
95
96#define M32R_MFT5_OFFSET (0x600+M32R_MFT_OFFSET)
97#define M32R_MFT5MOD_PORTL (0x00+M32R_MFT5_OFFSET) /* MFT4 mode */
98#define M32R_MFT5BOS_PORTL (0x04+M32R_MFT5_OFFSET) /* MFT4 b-port output status */
99#define M32R_MFT5CUT_PORTL (0x08+M32R_MFT5_OFFSET) /* MFT4 count */
100#define M32R_MFT5RLD_PORTL (0x0C+M32R_MFT5_OFFSET) /* MFT4 reload */
101#define M32R_MFT5CMPRLD_PORTL (0x10+M32R_MFT5_OFFSET) /* MFT4 compare reload */
102
103#ifdef CONFIG_CHIP_M32700
104#define M32R_MFTCR_MFT0MSK (1UL<<31) /* b0 */
105#define M32R_MFTCR_MFT1MSK (1UL<<30) /* b1 */
106#define M32R_MFTCR_MFT2MSK (1UL<<29) /* b2 */
107#define M32R_MFTCR_MFT3MSK (1UL<<28) /* b3 */
108#define M32R_MFTCR_MFT4MSK (1UL<<27) /* b4 */
109#define M32R_MFTCR_MFT5MSK (1UL<<26) /* b5 */
110#define M32R_MFTCR_MFT0EN (1UL<<23) /* b8 */
111#define M32R_MFTCR_MFT1EN (1UL<<22) /* b9 */
112#define M32R_MFTCR_MFT2EN (1UL<<21) /* b10 */
113#define M32R_MFTCR_MFT3EN (1UL<<20) /* b11 */
114#define M32R_MFTCR_MFT4EN (1UL<<19) /* b12 */
115#define M32R_MFTCR_MFT5EN (1UL<<18) /* b13 */
116#else /* not CONFIG_CHIP_M32700 */
117#define M32R_MFTCR_MFT0MSK (1UL<<15) /* b16 */
118#define M32R_MFTCR_MFT1MSK (1UL<<14) /* b17 */
119#define M32R_MFTCR_MFT2MSK (1UL<<13) /* b18 */
120#define M32R_MFTCR_MFT3MSK (1UL<<12) /* b19 */
121#define M32R_MFTCR_MFT4MSK (1UL<<11) /* b20 */
122#define M32R_MFTCR_MFT5MSK (1UL<<10) /* b21 */
123#define M32R_MFTCR_MFT0EN (1UL<<7) /* b24 */
124#define M32R_MFTCR_MFT1EN (1UL<<6) /* b25 */
125#define M32R_MFTCR_MFT2EN (1UL<<5) /* b26 */
126#define M32R_MFTCR_MFT3EN (1UL<<4) /* b27 */
127#define M32R_MFTCR_MFT4EN (1UL<<3) /* b28 */
128#define M32R_MFTCR_MFT5EN (1UL<<2) /* b29 */
129#endif /* not CONFIG_CHIP_M32700 */
130
131#define M32R_MFTMOD_CC_MASK (1UL<<15) /* b16 */
132#define M32R_MFTMOD_TCCR (1UL<<13) /* b18 */
133#define M32R_MFTMOD_GTSEL000 (0UL<<8) /* b21-23 : 000 */
134#define M32R_MFTMOD_GTSEL001 (1UL<<8) /* b21-23 : 001 */
135#define M32R_MFTMOD_GTSEL010 (2UL<<8) /* b21-23 : 010 */
136#define M32R_MFTMOD_GTSEL011 (3UL<<8) /* b21-23 : 011 */
137#define M32R_MFTMOD_GTSEL110 (6UL<<8) /* b21-23 : 110 */
138#define M32R_MFTMOD_GTSEL111 (7UL<<8) /* b21-23 : 111 */
139#define M32R_MFTMOD_CMSEL (1UL<<3) /* b28 */
140#define M32R_MFTMOD_CSSEL000 (0UL<<0) /* b29-b31 : 000 */
141#define M32R_MFTMOD_CSSEL001 (1UL<<0) /* b29-b31 : 001 */
142#define M32R_MFTMOD_CSSEL010 (2UL<<0) /* b29-b31 : 010 */
143#define M32R_MFTMOD_CSSEL011 (3UL<<0) /* b29-b31 : 011 */
144#define M32R_MFTMOD_CSSEL100 (4UL<<0) /* b29-b31 : 100 */
145#define M32R_MFTMOD_CSSEL110 (6UL<<0) /* b29-b31 : 110 */
146
147/*
148 * Serial I/O registers.
149 */
150#define M32R_SIO_OFFSET (0x000FD000+M32R_SFR_OFFSET)
151
152#define M32R_SIO0_CR_PORTL (0x000+M32R_SIO_OFFSET)
153#define M32R_SIO0_MOD0_PORTL (0x004+M32R_SIO_OFFSET)
154#define M32R_SIO0_MOD1_PORTL (0x008+M32R_SIO_OFFSET)
155#define M32R_SIO0_STS_PORTL (0x00C+M32R_SIO_OFFSET)
156#define M32R_SIO0_TRCR_PORTL (0x010+M32R_SIO_OFFSET)
157#define M32R_SIO0_BAUR_PORTL (0x014+M32R_SIO_OFFSET)
158#define M32R_SIO0_RBAUR_PORTL (0x018+M32R_SIO_OFFSET)
159#define M32R_SIO0_TXB_PORTL (0x01C+M32R_SIO_OFFSET)
160#define M32R_SIO0_RXB_PORTL (0x020+M32R_SIO_OFFSET)
161
162/*
163 * Interrupt Control Unit registers.
164 */
165#define M32R_ICU_OFFSET (0x000FF000+M32R_SFR_OFFSET)
166#define M32R_ICU_ISTS_PORTL (0x004+M32R_ICU_OFFSET)
167#define M32R_ICU_IREQ0_PORTL (0x008+M32R_ICU_OFFSET)
168#define M32R_ICU_IREQ1_PORTL (0x00C+M32R_ICU_OFFSET)
169#define M32R_ICU_SBICR_PORTL (0x018+M32R_ICU_OFFSET)
170#define M32R_ICU_IMASK_PORTL (0x01C+M32R_ICU_OFFSET)
171#define M32R_ICU_CR1_PORTL (0x200+M32R_ICU_OFFSET) /* INT0 */
172#define M32R_ICU_CR2_PORTL (0x204+M32R_ICU_OFFSET) /* INT1 */
173#define M32R_ICU_CR3_PORTL (0x208+M32R_ICU_OFFSET) /* INT2 */
174#define M32R_ICU_CR4_PORTL (0x20C+M32R_ICU_OFFSET) /* INT3 */
175#define M32R_ICU_CR5_PORTL (0x210+M32R_ICU_OFFSET) /* INT4 */
176#define M32R_ICU_CR6_PORTL (0x214+M32R_ICU_OFFSET) /* INT5 */
177#define M32R_ICU_CR7_PORTL (0x218+M32R_ICU_OFFSET) /* INT6 */
178#define M32R_ICU_CR16_PORTL (0x23C+M32R_ICU_OFFSET) /* MFT0 */
179#define M32R_ICU_CR17_PORTL (0x240+M32R_ICU_OFFSET) /* MFT1 */
180#define M32R_ICU_CR18_PORTL (0x244+M32R_ICU_OFFSET) /* MFT2 */
181#define M32R_ICU_CR19_PORTL (0x248+M32R_ICU_OFFSET) /* MFT3 */
182#define M32R_ICU_CR20_PORTL (0x24C+M32R_ICU_OFFSET) /* MFT4 */
183#define M32R_ICU_CR21_PORTL (0x250+M32R_ICU_OFFSET) /* MFT5 */
184#define M32R_ICU_CR32_PORTL (0x27C+M32R_ICU_OFFSET) /* DMA0 */
185#define M32R_ICU_CR33_PORTL (0x280+M32R_ICU_OFFSET) /* DMA1 */
186#define M32R_ICU_CR48_PORTL (0x2BC+M32R_ICU_OFFSET) /* SIO0 */
187#define M32R_ICU_CR49_PORTL (0x2C0+M32R_ICU_OFFSET) /* SIO0 */
188#define M32R_ICU_CR50_PORTL (0x2C4+M32R_ICU_OFFSET) /* SIO1 */
189#define M32R_ICU_CR51_PORTL (0x2C8+M32R_ICU_OFFSET) /* SIO1 */
190#define M32R_ICU_CR52_PORTL (0x2CC+M32R_ICU_OFFSET) /* SIO2 */
191#define M32R_ICU_CR53_PORTL (0x2D0+M32R_ICU_OFFSET) /* SIO2 */
192#define M32R_ICU_CR54_PORTL (0x2D4+M32R_ICU_OFFSET) /* SIO3 */
193#define M32R_ICU_CR55_PORTL (0x2D8+M32R_ICU_OFFSET) /* SIO3 */
194#define M32R_ICU_CR56_PORTL (0x2DC+M32R_ICU_OFFSET) /* SIO4 */
195#define M32R_ICU_CR57_PORTL (0x2E0+M32R_ICU_OFFSET) /* SIO4 */
196
197#ifdef CONFIG_SMP
198#define M32R_ICU_IPICR0_PORTL (0x2dc+M32R_ICU_OFFSET) /* IPI0 */
199#define M32R_ICU_IPICR1_PORTL (0x2e0+M32R_ICU_OFFSET) /* IPI1 */
200#define M32R_ICU_IPICR2_PORTL (0x2e4+M32R_ICU_OFFSET) /* IPI2 */
201#define M32R_ICU_IPICR3_PORTL (0x2e8+M32R_ICU_OFFSET) /* IPI3 */
202#define M32R_ICU_IPICR4_PORTL (0x2ec+M32R_ICU_OFFSET) /* IPI4 */
203#define M32R_ICU_IPICR5_PORTL (0x2f0+M32R_ICU_OFFSET) /* IPI5 */
204#define M32R_ICU_IPICR6_PORTL (0x2f4+M32R_ICU_OFFSET) /* IPI6 */
205#define M32R_ICU_IPICR7_PORTL (0x2f8+M32R_ICU_OFFSET) /* IPI7 */
206#endif /* CONFIG_SMP */
207
208#define M32R_ICUIMASK_IMSK0 (0UL<<16) /* b13-b15: Disable interrupt */
209#define M32R_ICUIMASK_IMSK1 (1UL<<16) /* b13-b15: Enable level 0 interrupt */
210#define M32R_ICUIMASK_IMSK2 (2UL<<16) /* b13-b15: Enable level 0,1 interrupt */
211#define M32R_ICUIMASK_IMSK3 (3UL<<16) /* b13-b15: Enable level 0-2 interrupt */
212#define M32R_ICUIMASK_IMSK4 (4UL<<16) /* b13-b15: Enable level 0-3 interrupt */
213#define M32R_ICUIMASK_IMSK5 (5UL<<16) /* b13-b15: Enable level 0-4 interrupt */
214#define M32R_ICUIMASK_IMSK6 (6UL<<16) /* b13-b15: Enable level 0-5 interrupt */
215#define M32R_ICUIMASK_IMSK7 (7UL<<16) /* b13-b15: Enable level 0-6 interrupt */
216
217#define M32R_ICUCR_IEN (1UL<<12) /* b19: Interrupt enable */
218#define M32R_ICUCR_IRQ (1UL<<8) /* b23: Interrupt request */
219#define M32R_ICUCR_ISMOD00 (0UL<<4) /* b26-b27: Interrupt sense mode Edge HtoL */
220#define M32R_ICUCR_ISMOD01 (1UL<<4) /* b26-b27: Interrupt sense mode Level L */
221#define M32R_ICUCR_ISMOD10 (2UL<<4) /* b26-b27: Interrupt sense mode Edge LtoH*/
222#define M32R_ICUCR_ISMOD11 (3UL<<4) /* b26-b27: Interrupt sense mode Level H */
223#define M32R_ICUCR_ILEVEL0 (0UL<<0) /* b29-b31: Interrupt priority level 0 */
224#define M32R_ICUCR_ILEVEL1 (1UL<<0) /* b29-b31: Interrupt priority level 1 */
225#define M32R_ICUCR_ILEVEL2 (2UL<<0) /* b29-b31: Interrupt priority level 2 */
226#define M32R_ICUCR_ILEVEL3 (3UL<<0) /* b29-b31: Interrupt priority level 3 */
227#define M32R_ICUCR_ILEVEL4 (4UL<<0) /* b29-b31: Interrupt priority level 4 */
228#define M32R_ICUCR_ILEVEL5 (5UL<<0) /* b29-b31: Interrupt priority level 5 */
229#define M32R_ICUCR_ILEVEL6 (6UL<<0) /* b29-b31: Interrupt priority level 6 */
230#define M32R_ICUCR_ILEVEL7 (7UL<<0) /* b29-b31: Disable interrupt */
231
232#define M32R_IRQ_INT0 (1) /* INT0 */
233#define M32R_IRQ_INT1 (2) /* INT1 */
234#define M32R_IRQ_INT2 (3) /* INT2 */
235#define M32R_IRQ_INT3 (4) /* INT3 */
236#define M32R_IRQ_INT4 (5) /* INT4 */
237#define M32R_IRQ_INT5 (6) /* INT5 */
238#define M32R_IRQ_INT6 (7) /* INT6 */
239#define M32R_IRQ_MFT0 (16) /* MFT0 */
240#define M32R_IRQ_MFT1 (17) /* MFT1 */
241#define M32R_IRQ_MFT2 (18) /* MFT2 */
242#define M32R_IRQ_MFT3 (19) /* MFT3 */
243#define M32R_IRQ_MFT4 (20) /* MFT4 */
244#define M32R_IRQ_MFT5 (21) /* MFT5 */
245#define M32R_IRQ_DMA0 (32) /* DMA0 */
246#define M32R_IRQ_DMA1 (33) /* DMA1 */
247#define M32R_IRQ_SIO0_R (48) /* SIO0 send */
248#define M32R_IRQ_SIO0_S (49) /* SIO0 receive */
249#define M32R_IRQ_SIO1_R (50) /* SIO1 send */
250#define M32R_IRQ_SIO1_S (51) /* SIO1 receive */
251#define M32R_IRQ_SIO2_R (52) /* SIO2 send */
252#define M32R_IRQ_SIO2_S (53) /* SIO2 receive */
253#define M32R_IRQ_SIO3_R (54) /* SIO3 send */
254#define M32R_IRQ_SIO3_S (55) /* SIO3 receive */
255#define M32R_IRQ_SIO4_R (56) /* SIO4 send */
256#define M32R_IRQ_SIO4_S (57) /* SIO4 receive */
257
258#ifdef CONFIG_SMP
259#define M32R_IRQ_IPI0 (56)
260#define M32R_IRQ_IPI1 (57)
261#define M32R_IRQ_IPI2 (58)
262#define M32R_IRQ_IPI3 (59)
263#define M32R_IRQ_IPI4 (60)
264#define M32R_IRQ_IPI5 (61)
265#define M32R_IRQ_IPI6 (62)
266#define M32R_IRQ_IPI7 (63)
267#define M32R_CPUID_PORTL (0xffffffe0)
268
269#define M32R_FPGA_TOP (0x000F0000+M32R_SFR_OFFSET)
270
271#define M32R_FPGA_NUM_OF_CPUS_PORTL (0x00+M32R_FPGA_TOP)
272#define M32R_FPGA_CPU_NAME0_PORTL (0x10+M32R_FPGA_TOP)
273#define M32R_FPGA_CPU_NAME1_PORTL (0x14+M32R_FPGA_TOP)
274#define M32R_FPGA_CPU_NAME2_PORTL (0x18+M32R_FPGA_TOP)
275#define M32R_FPGA_CPU_NAME3_PORTL (0x1c+M32R_FPGA_TOP)
276#define M32R_FPGA_MODEL_ID0_PORTL (0x20+M32R_FPGA_TOP)
277#define M32R_FPGA_MODEL_ID1_PORTL (0x24+M32R_FPGA_TOP)
278#define M32R_FPGA_MODEL_ID2_PORTL (0x28+M32R_FPGA_TOP)
279#define M32R_FPGA_MODEL_ID3_PORTL (0x2c+M32R_FPGA_TOP)
280#define M32R_FPGA_VERSION0_PORTL (0x30+M32R_FPGA_TOP)
281#define M32R_FPGA_VERSION1_PORTL (0x34+M32R_FPGA_TOP)
282
283#ifndef __ASSEMBLY__
284/* For NETDEV WATCHDOG */
285typedef struct {
286 unsigned long icucr; /* ICU Control Register */
287} icu_data_t;
288
289extern icu_data_t icu_data[];
290#endif
291
292#endif /* CONFIG_SMP */
293
294#endif /* _M32102_H_ */
diff --git a/include/asm-m32r/m32102peri.h b/include/asm-m32r/m32102peri.h
new file mode 100644
index 000000000000..3c12955ad0f0
--- /dev/null
+++ b/include/asm-m32r/m32102peri.h
@@ -0,0 +1,468 @@
1/* $Id$
2 *
3 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive
5 * for more details.
6 *
7 * Copyright (C) 2000,2001 by Hiroyuki Kondo
8 */
9
10#ifndef __ASSEMBLY__
11
12typedef void V;
13typedef char B;
14typedef short S;
15typedef int W;
16typedef long L;
17typedef float F;
18typedef double D;
19typedef unsigned char UB;
20typedef unsigned short US;
21typedef unsigned int UW;
22typedef unsigned long UL;
23typedef const unsigned int CUW;
24
25/*********************************
26
27M32102 ICU
28
29*********************************/
30#define ICUISTS (UW *)0xa0EFF004
31#define ICUIREQ0 (UW *)0xa0EFF008
32#define ICUIREQ1 (UW *)0xa0EFF00C
33
34#define ICUSBICR (UW *)0xa0EFF018
35#define ICUIMASK (UW *)0xa0EFF01C
36
37#define ICUCR1 (UW *)0xa0EFF200 /* INT0 */
38#define ICUCR2 (UW *)0xa0EFF204 /* INT1 */
39#define ICUCR3 (UW *)0xa0EFF208 /* INT2 */
40#define ICUCR4 (UW *)0xa0EFF20C /* INT3 */
41#define ICUCR5 (UW *)0xa0EFF210 /* INT4 */
42#define ICUCR6 (UW *)0xa0EFF214 /* INT5 */
43#define ICUCR7 (UW *)0xa0EFF218 /* INT6 */
44
45#define ICUCR16 (UW *)0xa0EFF23C /* MFT0 */
46#define ICUCR17 (UW *)0xa0EFF240 /* MFT1 */
47#define ICUCR18 (UW *)0xa0EFF244 /* MFT2 */
48#define ICUCR19 (UW *)0xa0EFF248 /* MFT3 */
49#define ICUCR20 (UW *)0xa0EFF24C /* MFT4 */
50#define ICUCR21 (UW *)0xa0EFF250 /* MFT5 */
51
52#define ICUCR32 (UW *)0xa0EFF27C /* DMA0 */
53#define ICUCR33 (UW *)0xa0EFF280 /* DMA1 */
54
55#define ICUCR48 (UW *)0xa0EFF2BC /* SIO0R */
56#define ICUCR49 (UW *)0xa0EFF2C0 /* SIO0S */
57#define ICUCR50 (UW *)0xa0EFF2C4 /* SIO1R */
58#define ICUCR51 (UW *)0xa0EFF2C8 /* SIO1S */
59#define ICUCR52 (UW *)0xa0EFF2CC /* SIO2R */
60#define ICUCR53 (UW *)0xa0EFF2D0 /* SIO2S */
61#define ICUCR54 (UW *)0xa0EFF2D4 /* SIO3R */
62#define ICUCR55 (UW *)0xa0EFF2D8 /* SIO3S */
63#define ICUCR56 (UW *)0xa0EFF2DC /* SIO4R */
64#define ICUCR57 (UW *)0xa0EFF2E0 /* SIO4S */
65
66/*********************************
67
68M32102 MFT
69
70*********************************/
71#define MFTCR (US *)0xa0EFC002
72#define MFTRPR (UB *)0xa0EFC006
73
74#define MFT0MOD (US *)0xa0EFC102
75#define MFT0BOS (US *)0xa0EFC106
76#define MFT0CUT (US *)0xa0EFC10A
77#define MFT0RLD (US *)0xa0EFC10E
78#define MFT0CRLD (US *)0xa0EFC112
79
80#define MFT1MOD (US *)0xa0EFC202
81#define MFT1BOS (US *)0xa0EFC206
82#define MFT1CUT (US *)0xa0EFC20A
83#define MFT1RLD (US *)0xa0EFC20E
84#define MFT1CRLD (US *)0xa0EFC212
85
86#define MFT2MOD (US *)0xa0EFC302
87#define MFT2BOS (US *)0xa0EFC306
88#define MFT2CUT (US *)0xa0EFC30A
89#define MFT2RLD (US *)0xa0EFC30E
90#define MFT2CRLD (US *)0xa0EFC312
91
92#define MFT3MOD (US *)0xa0EFC402
93#define MFT3CUT (US *)0xa0EFC40A
94#define MFT3RLD (US *)0xa0EFC40E
95#define MFT3CRLD (US *)0xa0EFC412
96
97#define MFT4MOD (US *)0xa0EFC502
98#define MFT4CUT (US *)0xa0EFC50A
99#define MFT4RLD (US *)0xa0EFC50E
100#define MFT4CRLD (US *)0xa0EFC512
101
102#define MFT5MOD (US *)0xa0EFC602
103#define MFT5CUT (US *)0xa0EFC60A
104#define MFT5RLD (US *)0xa0EFC60E
105#define MFT5CRLD (US *)0xa0EFC612
106
107/*********************************
108
109M32102 SIO
110
111*********************************/
112
113#define SIO0CR (volatile int *)0xa0efd000
114#define SIO0MOD0 (volatile int *)0xa0efd004
115#define SIO0MOD1 (volatile int *)0xa0efd008
116#define SIO0STS (volatile int *)0xa0efd00c
117#define SIO0IMASK (volatile int *)0xa0efd010
118#define SIO0BAUR (volatile int *)0xa0efd014
119#define SIO0RBAUR (volatile int *)0xa0efd018
120#define SIO0TXB (volatile int *)0xa0efd01c
121#define SIO0RXB (volatile int *)0xa0efd020
122
123#define SIO1CR (volatile int *)0xa0efd100
124#define SIO1MOD0 (volatile int *)0xa0efd104
125#define SIO1MOD1 (volatile int *)0xa0efd108
126#define SIO1STS (volatile int *)0xa0efd10c
127#define SIO1IMASK (volatile int *)0xa0efd110
128#define SIO1BAUR (volatile int *)0xa0efd114
129#define SIO1RBAUR (volatile int *)0xa0efd118
130#define SIO1TXB (volatile int *)0xa0efd11c
131#define SIO1RXB (volatile int *)0xa0efd120
132/*********************************
133
134M32102 PORT
135
136*********************************/
137#define PIEN (UB *)0xa0EF1003 /* input enable */
138
139#define P0DATA (UB *)0xa0EF1020 /* data */
140#define P1DATA (UB *)0xa0EF1021
141#define P2DATA (UB *)0xa0EF1022
142#define P3DATA (UB *)0xa0EF1023
143#define P4DATA (UB *)0xa0EF1024
144#define P5DATA (UB *)0xa0EF1025
145#define P6DATA (UB *)0xa0EF1026
146#define P7DATA (UB *)0xa0EF1027
147
148#define P0DIR (UB *)0xa0EF1040 /* direction */
149#define P1DIR (UB *)0xa0EF1041
150#define P2DIR (UB *)0xa0EF1042
151#define P3DIR (UB *)0xa0EF1043
152#define P4DIR (UB *)0xa0EF1044
153#define P5DIR (UB *)0xa0EF1045
154#define P6DIR (UB *)0xa0EF1046
155#define P7DIR (UB *)0xa0EF1047
156
157#define P0MOD (US *)0xa0EF1060 /* mode control */
158#define P1MOD (US *)0xa0EF1062
159#define P2MOD (US *)0xa0EF1064
160#define P3MOD (US *)0xa0EF1066
161#define P4MOD (US *)0xa0EF1068
162#define P5MOD (US *)0xa0EF106A
163#define P6MOD (US *)0xa0EF106C
164#define P7MOD (US *)0xa0EF106E
165
166#define P0ODCR (UB *)0xa0EF1080 /* open-drain control */
167#define P1ODCR (UB *)0xa0EF1081
168#define P2ODCR (UB *)0xa0EF1082
169#define P3ODCR (UB *)0xa0EF1083
170#define P4ODCR (UB *)0xa0EF1084
171#define P5ODCR (UB *)0xa0EF1085
172#define P6ODCR (UB *)0xa0EF1086
173#define P7ODCR (UB *)0xa0EF1087
174
175/*********************************
176
177M32102 Cache
178
179********************************/
180
181#define MCCR (US *)0xFFFFFFFE
182
183
184#else /* __ASSEMBLY__ */
185
186;;
187;; PIO 0x80ef1000
188;;
189
190#define PIEN 0xa0ef1000
191
192#define P0DATA 0xa0ef1020
193#define P1DATA 0xa0ef1021
194#define P2DATA 0xa0ef1022
195#define P3DATA 0xa0ef1023
196#define P4DATA 0xa0ef1024
197#define P5DATA 0xa0ef1025
198#define P6DATA 0xa0ef1026
199#define P7DATA 0xa0ef1027
200
201#define P0DIR 0xa0ef1040
202#define P1DIR 0xa0ef1041
203#define P2DIR 0xa0ef1042
204#define P3DIR 0xa0ef1043
205#define P4DIR 0xa0ef1044
206#define P5DIR 0xa0ef1045
207#define P6DIR 0xa0ef1046
208#define P7DIR 0xa0ef1047
209
210#define P0MOD 0xa0ef1060
211#define P1MOD 0xa0ef1062
212#define P2MOD 0xa0ef1064
213#define P3MOD 0xa0ef1066
214#define P4MOD 0xa0ef1068
215#define P5MOD 0xa0ef106a
216#define P6MOD 0xa0ef106c
217#define P7MOD 0xa0ef106e
218;
219#define P0ODCR 0xa0ef1080
220#define P1ODCR 0xa0ef1081
221#define P2ODCR 0xa0ef1082
222#define P3ODCR 0xa0ef1083
223#define P4ODCR 0xa0ef1084
224#define P5ODCR 0xa0ef1085
225#define P6ODCR 0xa0ef1086
226#define P7ODCR 0xa0ef1087
227
228;;
229;; WDT 0xa0ef2000
230;;
231
232#define WDTCR 0xa0ef2000
233
234
235;;
236;; CLK 0xa0ef4000
237;;
238
239#define CPUCLKCR 0xa0ef4000
240#define CLKMOD 0xa0ef4004
241#define PLLCR 0xa0ef4008
242
243
244;;
245;; BSEL 0xa0ef5000
246;;
247
248#define BSEL0CR 0xa0ef5000
249#define BSEL1CR 0xa0ef5004
250#define BSEL2CR 0xa0ef5008
251#define BSEL3CR 0xa0ef500c
252#define BSEL4CR 0xa0ef5010
253#define BSEL5CR 0xa0ef5014
254
255
256;;
257;; SDRAMC 0xa0ef6000
258;;
259
260#define SDRF0 0xa0ef6000
261#define SDRF1 0xa0ef6004
262#define SDIR0 0xa0ef6008
263#define SDIR1 0xa0ef600c
264#define SDBR 0xa0ef6010
265
266;; CH0
267#define SD0ADR 0xa0ef6020
268#define SD0SZ 0xa0ef6022
269#define SD0ER 0xa0ef6024
270#define SD0TR 0xa0ef6028
271#define SD0MOD 0xa0ef602c
272
273;; CH1
274#define SD1ADR 0xa0ef6040
275#define SD1SZ 0xa0ef6042
276#define SD1ER 0xa0ef6044
277#define SD1TR 0xa0ef6048
278#define SD1MOD 0xa0ef604c
279
280
281;;
282;; DMAC 0xa0ef8000
283;;
284
285#define DMAEN 0xa0ef8000
286#define DMAISTS 0xa0ef8004
287#define DMAEDET 0xa0ef8008
288#define DMAASTS 0xa0ef800c
289
290;; CH0
291#define DMA0CR0 0xa0ef8100
292#define DMA0CR1 0xa0ef8104
293#define DMA0CSA 0xa0ef8108
294#define DMA0RSA 0xa0ef810c
295#define DMA0CDA 0xa0ef8110
296#define DMA0RDA 0xa0ef8114
297#define DMA0CBCUT 0xa0ef8118
298#define DMA0RBCUT 0xa0ef811c
299
300;; CH1
301#define DMA1CR0 0xa0ef8200
302#define DMA1CR1 0xa0ef8204
303#define DMA1CSA 0xa0ef8208
304#define DMA1RSA 0xa0ef820c
305#define DMA1CDA 0xa0ef8210
306#define DMA1RDA 0xa0ef8214
307#define DMA1CBCUT 0xa0ef8218
308#define DMA1RBCUT 0xa0ef821c
309
310
311;;
312;; MFT 0xa0efc000
313;;
314
315#define MFTCR 0xa0efc000
316#define MFTRPR 0xa0efc004
317
318;; CH0
319#define MFT0MOD 0xa0efc100
320#define MFT0BOS 0xa0efc104
321#define MFT0CUT 0xa0efc108
322#define MFT0RLD 0xa0efc10c
323#define MFT0CMPRLD 0xa0efc110
324
325;; CH1
326#define MFT1MOD 0xa0efc200
327#define MFT1BOS 0xa0efc204
328#define MFT1CUT 0xa0efc208
329#define MFT1RLD 0xa0efc20c
330#define MFT1CMPRLD 0xa0efc210
331
332;; CH2
333#define MFT2MOD 0xa0efc300
334#define MFT2BOS 0xa0efc304
335#define MFT2CUT 0xa0efc308
336#define MFT2RLD 0xa0efc30c
337#define MFT2CMPRLD 0xa0efc310
338
339;; CH3
340#define MFT3MOD 0xa0efc400
341#define MFT3BOS 0xa0efc404
342#define MFT3CUT 0xa0efc408
343#define MFT3RLD 0xa0efc40c
344#define MFT3CMPRLD 0xa0efc410
345
346;; CH4
347#define MFT4MOD 0xa0efc500
348#define MFT4BOS 0xa0efc504
349#define MFT4CUT 0xa0efc508
350#define MFT4RLD 0xa0efc50c
351#define MFT4CMPRLD 0xa0efc510
352
353;; CH5
354#define MFT5MOD 0xa0efc600
355#define MFT5BOS 0xa0efc604
356#define MFT5CUT 0xa0efc608
357#define MFT5RLD 0xa0efc60c
358#define MFT5CMPRLD 0xa0efc610
359
360
361;;
362;; SIO 0xa0efd000
363;;
364
365;; CH0
366#define SIO0CR 0xa0efd000
367#define SIO0MOD0 0xa0efd004
368#define SIO0MOD1 0xa0efd008
369#define SIO0STS 0xa0efd00c
370#define SIO0IMASK 0xa0efd010
371#define SIO0BAUR 0xa0efd014
372#define SIO0RBAUR 0xa0efd018
373#define SIO0TXB 0xa0efd01c
374#define SIO0RXB 0xa0efd020
375
376;; CH1
377#define SIO1CR 0xa0efd100
378#define SIO1MOD0 0xa0efd104
379#define SIO1MOD1 0xa0efd108
380#define SIO1STS 0xa0efd10c
381#define SIO1IMASK 0xa0efd110
382#define SIO1BAUR 0xa0efd114
383#define SIO1RBAUR 0xa0efd118
384#define SIO1TXB 0xa0efd11c
385#define SIO1RXB 0xa0efd120
386
387;; CH2
388#define SIO2CR 0xa0efd200
389#define SIO2MOD0 0xa0efd204
390#define SIO2MOD1 0xa0efd208
391#define SIO2STS 0xa0efd20c
392#define SIO2IMASK 0xa0efd210
393#define SIO2BAUR 0xa0efd214
394#define SIO2RBAUR 0xa0efd218
395#define SIO2TXB 0xa0efd21c
396#define SIO2RXB 0xa0efd220
397
398;; CH3
399#define SIO3CR 0xa0efd300
400#define SIO3MOD0 0xa0efd304
401#define SIO3MOD1 0xa0efd308
402#define SIO3STS 0xa0efd30c
403#define SIO3IMASK 0xa0efd310
404#define SIO3BAUR 0xa0efd314
405#define SIO3RBAUR 0xa0efd318
406#define SIO3TXB 0xa0efd31c
407#define SIO3RXB 0xa0efd320
408
409;; CH4
410#define SIO4CR 0xa0efd400
411#define SIO4MOD0 0xa0efd404
412#define SIO4MOD1 0xa0efd408
413#define SIO4STS 0xa0efd40c
414#define SIO4IMASK 0xa0efd410
415#define SIO4BAUR 0xa0efd414
416#define SIO4RBAUR 0xa0efd418
417#define SIO4TXB 0xa0efd41c
418#define SIO4RXB 0xa0efd420
419
420
421;;
422;; ICU 0xa0eff000
423;;
424
425#define ICUISTS 0xa0eff004
426#define ICUIREQ0 0xa0eff008
427#define ICUIREQ1 0xa0eff00c
428
429#define ICUSBICR 0xa0eff018
430#define ICUIMASK 0xa0eff01c
431
432#define ICUCR1 0xa0eff200
433#define ICUCR2 0xa0eff204
434#define ICUCR3 0xa0eff208
435#define ICUCR4 0xa0eff20c
436#define ICUCR5 0xa0eff210
437#define ICUCR6 0xa0eff214
438#define ICUCR7 0xa0eff218
439
440#define ICUCR16 0xa0eff23c
441#define ICUCR17 0xa0eff240
442#define ICUCR18 0xa0eff244
443#define ICUCR19 0xa0eff248
444#define ICUCR20 0xa0eff24c
445#define ICUCR21 0xa0eff250
446
447#define ICUCR32 0xa0eff27c
448#define ICUCR33 0xa0eff280
449
450#define ICUCR48 0xa0eff2bc
451#define ICUCR49 0xa0eff2c0
452#define ICUCR50 0xa0eff2c4
453#define ICUCR51 0xa0eff2c8
454#define ICUCR52 0xa0eff2cc
455#define ICUCR53 0xa0eff2d0
456#define ICUCR54 0xa0eff2d4
457#define ICUCR55 0xa0eff2d8
458#define ICUCR56 0xa0eff2dc
459#define ICUCR57 0xa0eff2e0
460
461;;
462;; CACHE
463;;
464
465#define MCCR 0xfffffffc
466
467
468#endif /* __ASSEMBLY__ */
diff --git a/include/asm-m32r/m32700ut/m32700ut_lan.h b/include/asm-m32r/m32700ut/m32700ut_lan.h
new file mode 100644
index 000000000000..50545ec9c42c
--- /dev/null
+++ b/include/asm-m32r/m32700ut/m32700ut_lan.h
@@ -0,0 +1,107 @@
1/*
2 * include/asm/m32700ut_lan.h
3 *
4 * M32700UT-LAN board
5 *
6 * Copyright (c) 2002 Takeo Takahashi
7 *
8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file "COPYING" in the main directory of
10 * this archive for more details.
11 *
12 * $Id$
13 */
14
15#ifndef _M32700UT_M32700UT_LAN_H
16#define _M32700UT_M32700UT_LAN_H
17
18#include <linux/config.h>
19
20#ifndef __ASSEMBLY__
21/*
22 * C functions use non-cache address.
23 */
24#define M32700UT_LAN_BASE (0x10000000 /* + NONCACHE_OFFSET */)
25#else
26#define M32700UT_LAN_BASE (0x10000000 + NONCACHE_OFFSET)
27#endif /* __ASSEMBLY__ */
28
29/* ICU
30 * ICUISTS: status register
31 * ICUIREQ0: request register
32 * ICUIREQ1: request register
33 * ICUCR3: control register for CFIREQ# interrupt
34 * ICUCR4: control register for CFC Card insert interrupt
35 * ICUCR5: control register for CFC Card eject interrupt
36 * ICUCR6: control register for external interrupt
37 * ICUCR11: control register for MMC Card insert/eject interrupt
38 * ICUCR13: control register for SC error interrupt
39 * ICUCR14: control register for SC receive interrupt
40 * ICUCR15: control register for SC send interrupt
41 * ICUCR16: control register for SIO0 receive interrupt
42 * ICUCR17: control register for SIO0 send interrupt
43 */
44#define M32700UT_LAN_IRQ_LAN (M32700UT_LAN_PLD_IRQ_BASE + 1) /* LAN */
45#define M32700UT_LAN_IRQ_I2C (M32700UT_LAN_PLD_IRQ_BASE + 3) /* I2C */
46
47#define M32700UT_LAN_ICUISTS __reg16(M32700UT_LAN_BASE + 0xc0002)
48#define M32700UT_LAN_ICUISTS_VECB_MASK (0xf000)
49#define M32700UT_LAN_VECB(x) ((x) & M32700UT_LAN_ICUISTS_VECB_MASK)
50#define M32700UT_LAN_ICUISTS_ISN_MASK (0x07c0)
51#define M32700UT_LAN_ICUISTS_ISN(x) ((x) & M32700UT_LAN_ICUISTS_ISN_MASK)
52#define M32700UT_LAN_ICUIREQ0 __reg16(M32700UT_LAN_BASE + 0xc0004)
53#define M32700UT_LAN_ICUCR1 __reg16(M32700UT_LAN_BASE + 0xc0010)
54#define M32700UT_LAN_ICUCR3 __reg16(M32700UT_LAN_BASE + 0xc0014)
55
56/*
57 * AR register on PLD
58 */
59#define ARVCR0 __reg32(M32700UT_LAN_BASE + 0x40000)
60#define ARVCR0_VDS 0x00080000
61#define ARVCR0_RST 0x00010000
62#define ARVCR1 __reg32(M32700UT_LAN_BASE + 0x40004)
63#define ARVCR1_QVGA 0x02000000
64#define ARVCR1_NORMAL 0x01000000
65#define ARVCR1_HIEN 0x00010000
66#define ARVHCOUNT __reg32(M32700UT_LAN_BASE + 0x40008)
67#define ARDATA __reg32(M32700UT_LAN_BASE + 0x40010)
68#define ARINTSEL __reg32(M32700UT_LAN_BASE + 0x40014)
69#define ARINTSEL_INT3 0x10000000 /* CPU INT3 */
70#define ARDATA32 __reg32(M32700UT_LAN_BASE + 0x04040010) // Block 5
71/*
72#define ARINTSEL_SEL2 0x00002000
73#define ARINTSEL_SEL3 0x00001000
74#define ARINTSEL_SEL6 0x00000200
75#define ARINTSEL_SEL7 0x00000100
76#define ARINTSEL_SEL9 0x00000040
77#define ARINTSEL_SEL10 0x00000020
78#define ARINTSEL_SEL11 0x00000010
79#define ARINTSEL_SEL12 0x00000008
80*/
81
82/*
83 * I2C register on PLD
84 */
85#define PLDI2CCR __reg32(M32700UT_LAN_BASE + 0x40040)
86#define PLDI2CCR_ES0 0x00000001 /* enable I2C interface */
87#define PLDI2CMOD __reg32(M32700UT_LAN_BASE + 0x40044)
88#define PLDI2CMOD_ACKCLK 0x00000200
89#define PLDI2CMOD_DTWD 0x00000100
90#define PLDI2CMOD_10BT 0x00000004
91#define PLDI2CMOD_ATM_NORMAL 0x00000000
92#define PLDI2CMOD_ATM_AUTO 0x00000003
93#define PLDI2CACK __reg32(M32700UT_LAN_BASE + 0x40048)
94#define PLDI2CACK_ACK 0x00000001
95#define PLDI2CFREQ __reg32(M32700UT_LAN_BASE + 0x4004c)
96#define PLDI2CCND __reg32(M32700UT_LAN_BASE + 0x40050)
97#define PLDI2CCND_START 0x00000001
98#define PLDI2CCND_STOP 0x00000002
99#define PLDI2CSTEN __reg32(M32700UT_LAN_BASE + 0x40054)
100#define PLDI2CSTEN_STEN 0x00000001
101#define PLDI2CDATA __reg32(M32700UT_LAN_BASE + 0x40060)
102#define PLDI2CSTS __reg32(M32700UT_LAN_BASE + 0x40064)
103#define PLDI2CSTS_TRX 0x00000020
104#define PLDI2CSTS_BB 0x00000010
105#define PLDI2CSTS_NOACK 0x00000001 /* 0:ack, 1:noack */
106
107#endif /* _M32700UT_M32700UT_LAN_H */
diff --git a/include/asm-m32r/m32700ut/m32700ut_lcd.h b/include/asm-m32r/m32700ut/m32700ut_lcd.h
new file mode 100644
index 000000000000..ede6c77bd5e6
--- /dev/null
+++ b/include/asm-m32r/m32700ut/m32700ut_lcd.h
@@ -0,0 +1,59 @@
1/*
2 * include/asm/m32700ut_lcd.h
3 *
4 * M32700UT-LCD board
5 *
6 * Copyright (c) 2002 Takeo Takahashi
7 *
8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file "COPYING" in the main directory of
10 * this archive for more details.
11 *
12 * $Id$
13 */
14
15#ifndef _M32700UT_M32700UT_LCD_H
16#define _M32700UT_M32700UT_LCD_H
17
18#include <linux/config.h>
19
20#ifndef __ASSEMBLY__
21/*
22 * C functions use non-cache address.
23 */
24#define M32700UT_LCD_BASE (0x10000000 /* + NONCACHE_OFFSET */)
25#else
26#define M32700UT_LCD_BASE (0x10000000 + NONCACHE_OFFSET)
27#endif /* __ASSEMBLY__ */
28
29/*
30 * ICU
31 */
32#define M32700UT_LCD_IRQ_BAT_INT (M32700UT_LCD_PLD_IRQ_BASE + 1)
33#define M32700UT_LCD_IRQ_USB_INT1 (M32700UT_LCD_PLD_IRQ_BASE + 2)
34#define M32700UT_LCD_IRQ_AUDT0 (M32700UT_LCD_PLD_IRQ_BASE + 3)
35#define M32700UT_LCD_IRQ_AUDT2 (M32700UT_LCD_PLD_IRQ_BASE + 4)
36#define M32700UT_LCD_IRQ_BATSIO_RCV (M32700UT_LCD_PLD_IRQ_BASE + 16)
37#define M32700UT_LCD_IRQ_BATSIO_SND (M32700UT_LCD_PLD_IRQ_BASE + 17)
38#define M32700UT_LCD_IRQ_ASNDSIO_RCV (M32700UT_LCD_PLD_IRQ_BASE + 18)
39#define M32700UT_LCD_IRQ_ASNDSIO_SND (M32700UT_LCD_PLD_IRQ_BASE + 19)
40#define M32700UT_LCD_IRQ_ACNLSIO_SND (M32700UT_LCD_PLD_IRQ_BASE + 21)
41
42#define M32700UT_LCD_ICUISTS __reg16(M32700UT_LCD_BASE + 0x300002)
43#define M32700UT_LCD_ICUISTS_VECB_MASK (0xf000)
44#define M32700UT_LCD_VECB(x) ((x) & M32700UT_LCD_ICUISTS_VECB_MASK)
45#define M32700UT_LCD_ICUISTS_ISN_MASK (0x07c0)
46#define M32700UT_LCD_ICUISTS_ISN(x) ((x) & M32700UT_LCD_ICUISTS_ISN_MASK)
47#define M32700UT_LCD_ICUIREQ0 __reg16(M32700UT_LCD_BASE + 0x300004)
48#define M32700UT_LCD_ICUIREQ1 __reg16(M32700UT_LCD_BASE + 0x300006)
49#define M32700UT_LCD_ICUCR1 __reg16(M32700UT_LCD_BASE + 0x300020)
50#define M32700UT_LCD_ICUCR2 __reg16(M32700UT_LCD_BASE + 0x300022)
51#define M32700UT_LCD_ICUCR3 __reg16(M32700UT_LCD_BASE + 0x300024)
52#define M32700UT_LCD_ICUCR4 __reg16(M32700UT_LCD_BASE + 0x300026)
53#define M32700UT_LCD_ICUCR16 __reg16(M32700UT_LCD_BASE + 0x300030)
54#define M32700UT_LCD_ICUCR17 __reg16(M32700UT_LCD_BASE + 0x300032)
55#define M32700UT_LCD_ICUCR18 __reg16(M32700UT_LCD_BASE + 0x300034)
56#define M32700UT_LCD_ICUCR19 __reg16(M32700UT_LCD_BASE + 0x300036)
57#define M32700UT_LCD_ICUCR21 __reg16(M32700UT_LCD_BASE + 0x30003a)
58
59#endif /* _M32700UT_M32700UT_LCD_H */
diff --git a/include/asm-m32r/m32700ut/m32700ut_pld.h b/include/asm-m32r/m32700ut/m32700ut_pld.h
new file mode 100644
index 000000000000..f5e479486696
--- /dev/null
+++ b/include/asm-m32r/m32700ut/m32700ut_pld.h
@@ -0,0 +1,265 @@
1/*
2 * include/asm/m32700ut/m32700ut_pld.h
3 *
4 * Definitions for Programable Logic Device(PLD) on M32700UT board.
5 *
6 * Copyright (c) 2002 Takeo Takahashi
7 *
8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file "COPYING" in the main directory of
10 * this archive for more details.
11 *
12 * $Id$
13 */
14
15#ifndef _M32700UT_M32700UT_PLD_H
16#define _M32700UT_M32700UT_PLD_H
17
18#include <linux/config.h>
19
20#if defined(CONFIG_PLAT_M32700UT_Alpha)
21#define PLD_PLAT_BASE 0x08c00000
22#elif defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_USRV)
23#define PLD_PLAT_BASE 0x04c00000
24#else
25#error "no platform configuration"
26#endif
27
28#ifndef __ASSEMBLY__
29/*
30 * C functions use non-cache address.
31 */
32#define PLD_BASE (PLD_PLAT_BASE /* + NONCACHE_OFFSET */)
33#define __reg8 (volatile unsigned char *)
34#define __reg16 (volatile unsigned short *)
35#define __reg32 (volatile unsigned int *)
36#else
37#define PLD_BASE (PLD_PLAT_BASE + NONCACHE_OFFSET)
38#define __reg8
39#define __reg16
40#define __reg32
41#endif /* __ASSEMBLY__ */
42
43/* CFC */
44#define PLD_CFRSTCR __reg16(PLD_BASE + 0x0000)
45#define PLD_CFSTS __reg16(PLD_BASE + 0x0002)
46#define PLD_CFIMASK __reg16(PLD_BASE + 0x0004)
47#define PLD_CFBUFCR __reg16(PLD_BASE + 0x0006)
48#define PLD_CFVENCR __reg16(PLD_BASE + 0x0008)
49#define PLD_CFCR0 __reg16(PLD_BASE + 0x000a)
50#define PLD_CFCR1 __reg16(PLD_BASE + 0x000c)
51#define PLD_IDERSTCR __reg16(PLD_BASE + 0x0010)
52
53/* MMC */
54#define PLD_MMCCR __reg16(PLD_BASE + 0x4000)
55#define PLD_MMCMOD __reg16(PLD_BASE + 0x4002)
56#define PLD_MMCSTS __reg16(PLD_BASE + 0x4006)
57#define PLD_MMCBAUR __reg16(PLD_BASE + 0x400a)
58#define PLD_MMCCMDBCUT __reg16(PLD_BASE + 0x400c)
59#define PLD_MMCCDTBCUT __reg16(PLD_BASE + 0x400e)
60#define PLD_MMCDET __reg16(PLD_BASE + 0x4010)
61#define PLD_MMCWP __reg16(PLD_BASE + 0x4012)
62#define PLD_MMCWDATA __reg16(PLD_BASE + 0x5000)
63#define PLD_MMCRDATA __reg16(PLD_BASE + 0x6000)
64#define PLD_MMCCMDDATA __reg16(PLD_BASE + 0x7000)
65#define PLD_MMCRSPDATA __reg16(PLD_BASE + 0x7006)
66
67/* ICU
68 * ICUISTS: status register
69 * ICUIREQ0: request register
70 * ICUIREQ1: request register
71 * ICUCR3: control register for CFIREQ# interrupt
72 * ICUCR4: control register for CFC Card insert interrupt
73 * ICUCR5: control register for CFC Card eject interrupt
74 * ICUCR6: control register for external interrupt
75 * ICUCR11: control register for MMC Card insert/eject interrupt
76 * ICUCR13: control register for SC error interrupt
77 * ICUCR14: control register for SC receive interrupt
78 * ICUCR15: control register for SC send interrupt
79 * ICUCR16: control register for SIO0 receive interrupt
80 * ICUCR17: control register for SIO0 send interrupt
81 */
82#if !defined(CONFIG_PLAT_USRV)
83#define PLD_IRQ_INT0 (M32700UT_PLD_IRQ_BASE + 0) /* None */
84#define PLD_IRQ_INT1 (M32700UT_PLD_IRQ_BASE + 1) /* reserved */
85#define PLD_IRQ_INT2 (M32700UT_PLD_IRQ_BASE + 2) /* reserved */
86#define PLD_IRQ_CFIREQ (M32700UT_PLD_IRQ_BASE + 3) /* CF IREQ */
87#define PLD_IRQ_CFC_INSERT (M32700UT_PLD_IRQ_BASE + 4) /* CF Insert */
88#define PLD_IRQ_CFC_EJECT (M32700UT_PLD_IRQ_BASE + 5) /* CF Eject */
89#define PLD_IRQ_EXINT (M32700UT_PLD_IRQ_BASE + 6) /* EXINT */
90#define PLD_IRQ_INT7 (M32700UT_PLD_IRQ_BASE + 7) /* reserved */
91#define PLD_IRQ_INT8 (M32700UT_PLD_IRQ_BASE + 8) /* reserved */
92#define PLD_IRQ_INT9 (M32700UT_PLD_IRQ_BASE + 9) /* reserved */
93#define PLD_IRQ_INT10 (M32700UT_PLD_IRQ_BASE + 10) /* reserved */
94#define PLD_IRQ_MMCCARD (M32700UT_PLD_IRQ_BASE + 11) /* MMC Insert/Eject */
95#define PLD_IRQ_INT12 (M32700UT_PLD_IRQ_BASE + 12) /* reserved */
96#define PLD_IRQ_SC_ERROR (M32700UT_PLD_IRQ_BASE + 13) /* SC error */
97#define PLD_IRQ_SC_RCV (M32700UT_PLD_IRQ_BASE + 14) /* SC receive */
98#define PLD_IRQ_SC_SND (M32700UT_PLD_IRQ_BASE + 15) /* SC send */
99#define PLD_IRQ_SIO0_RCV (M32700UT_PLD_IRQ_BASE + 16) /* SIO receive */
100#define PLD_IRQ_SIO0_SND (M32700UT_PLD_IRQ_BASE + 17) /* SIO send */
101#define PLD_IRQ_INT18 (M32700UT_PLD_IRQ_BASE + 18) /* reserved */
102#define PLD_IRQ_INT19 (M32700UT_PLD_IRQ_BASE + 19) /* reserved */
103#define PLD_IRQ_INT20 (M32700UT_PLD_IRQ_BASE + 20) /* reserved */
104#define PLD_IRQ_INT21 (M32700UT_PLD_IRQ_BASE + 21) /* reserved */
105#define PLD_IRQ_INT22 (M32700UT_PLD_IRQ_BASE + 22) /* reserved */
106#define PLD_IRQ_INT23 (M32700UT_PLD_IRQ_BASE + 23) /* reserved */
107#define PLD_IRQ_INT24 (M32700UT_PLD_IRQ_BASE + 24) /* reserved */
108#define PLD_IRQ_INT25 (M32700UT_PLD_IRQ_BASE + 25) /* reserved */
109#define PLD_IRQ_INT26 (M32700UT_PLD_IRQ_BASE + 26) /* reserved */
110#define PLD_IRQ_INT27 (M32700UT_PLD_IRQ_BASE + 27) /* reserved */
111#define PLD_IRQ_INT28 (M32700UT_PLD_IRQ_BASE + 28) /* reserved */
112#define PLD_IRQ_INT29 (M32700UT_PLD_IRQ_BASE + 29) /* reserved */
113#define PLD_IRQ_INT30 (M32700UT_PLD_IRQ_BASE + 30) /* reserved */
114#define PLD_IRQ_INT31 (M32700UT_PLD_IRQ_BASE + 31) /* reserved */
115
116#else /* CONFIG_PLAT_USRV */
117
118#define PLD_IRQ_INT0 (M32700UT_PLD_IRQ_BASE + 0) /* None */
119#define PLD_IRQ_INT1 (M32700UT_PLD_IRQ_BASE + 1) /* reserved */
120#define PLD_IRQ_INT2 (M32700UT_PLD_IRQ_BASE + 2) /* reserved */
121#define PLD_IRQ_CF0 (M32700UT_PLD_IRQ_BASE + 3) /* CF0# */
122#define PLD_IRQ_CF1 (M32700UT_PLD_IRQ_BASE + 4) /* CF1# */
123#define PLD_IRQ_CF2 (M32700UT_PLD_IRQ_BASE + 5) /* CF2# */
124#define PLD_IRQ_CF3 (M32700UT_PLD_IRQ_BASE + 6) /* CF3# */
125#define PLD_IRQ_CF4 (M32700UT_PLD_IRQ_BASE + 7) /* CF4# */
126#define PLD_IRQ_INT8 (M32700UT_PLD_IRQ_BASE + 8) /* reserved */
127#define PLD_IRQ_INT9 (M32700UT_PLD_IRQ_BASE + 9) /* reserved */
128#define PLD_IRQ_INT10 (M32700UT_PLD_IRQ_BASE + 10) /* reserved */
129#define PLD_IRQ_INT11 (M32700UT_PLD_IRQ_BASE + 11) /* reserved */
130#define PLD_IRQ_UART0 (M32700UT_PLD_IRQ_BASE + 12) /* UARTIRQ0 */
131#define PLD_IRQ_UART1 (M32700UT_PLD_IRQ_BASE + 13) /* UARTIRQ1 */
132#define PLD_IRQ_INT14 (M32700UT_PLD_IRQ_BASE + 14) /* reserved */
133#define PLD_IRQ_INT15 (M32700UT_PLD_IRQ_BASE + 15) /* reserved */
134#define PLD_IRQ_SNDINT (M32700UT_PLD_IRQ_BASE + 16) /* SNDINT# */
135#define PLD_IRQ_INT17 (M32700UT_PLD_IRQ_BASE + 17) /* reserved */
136#define PLD_IRQ_INT18 (M32700UT_PLD_IRQ_BASE + 18) /* reserved */
137#define PLD_IRQ_INT19 (M32700UT_PLD_IRQ_BASE + 19) /* reserved */
138#define PLD_IRQ_INT20 (M32700UT_PLD_IRQ_BASE + 20) /* reserved */
139#define PLD_IRQ_INT21 (M32700UT_PLD_IRQ_BASE + 21) /* reserved */
140#define PLD_IRQ_INT22 (M32700UT_PLD_IRQ_BASE + 22) /* reserved */
141#define PLD_IRQ_INT23 (M32700UT_PLD_IRQ_BASE + 23) /* reserved */
142#define PLD_IRQ_INT24 (M32700UT_PLD_IRQ_BASE + 24) /* reserved */
143#define PLD_IRQ_INT25 (M32700UT_PLD_IRQ_BASE + 25) /* reserved */
144#define PLD_IRQ_INT26 (M32700UT_PLD_IRQ_BASE + 26) /* reserved */
145#define PLD_IRQ_INT27 (M32700UT_PLD_IRQ_BASE + 27) /* reserved */
146#define PLD_IRQ_INT28 (M32700UT_PLD_IRQ_BASE + 28) /* reserved */
147#define PLD_IRQ_INT29 (M32700UT_PLD_IRQ_BASE + 29) /* reserved */
148#define PLD_IRQ_INT30 (M32700UT_PLD_IRQ_BASE + 30) /* reserved */
149
150#endif /* CONFIG_PLAT_USRV */
151
152#define PLD_ICUISTS __reg16(PLD_BASE + 0x8002)
153#define PLD_ICUISTS_VECB_MASK (0xf000)
154#define PLD_ICUISTS_VECB(x) ((x) & PLD_ICUISTS_VECB_MASK)
155#define PLD_ICUISTS_ISN_MASK (0x07c0)
156#define PLD_ICUISTS_ISN(x) ((x) & PLD_ICUISTS_ISN_MASK)
157#define PLD_ICUIREQ0 __reg16(PLD_BASE + 0x8004)
158#define PLD_ICUIREQ1 __reg16(PLD_BASE + 0x8006)
159#define PLD_ICUCR1 __reg16(PLD_BASE + 0x8100)
160#define PLD_ICUCR2 __reg16(PLD_BASE + 0x8102)
161#define PLD_ICUCR3 __reg16(PLD_BASE + 0x8104)
162#define PLD_ICUCR4 __reg16(PLD_BASE + 0x8106)
163#define PLD_ICUCR5 __reg16(PLD_BASE + 0x8108)
164#define PLD_ICUCR6 __reg16(PLD_BASE + 0x810a)
165#define PLD_ICUCR7 __reg16(PLD_BASE + 0x810c)
166#define PLD_ICUCR8 __reg16(PLD_BASE + 0x810e)
167#define PLD_ICUCR9 __reg16(PLD_BASE + 0x8110)
168#define PLD_ICUCR10 __reg16(PLD_BASE + 0x8112)
169#define PLD_ICUCR11 __reg16(PLD_BASE + 0x8114)
170#define PLD_ICUCR12 __reg16(PLD_BASE + 0x8116)
171#define PLD_ICUCR13 __reg16(PLD_BASE + 0x8118)
172#define PLD_ICUCR14 __reg16(PLD_BASE + 0x811a)
173#define PLD_ICUCR15 __reg16(PLD_BASE + 0x811c)
174#define PLD_ICUCR16 __reg16(PLD_BASE + 0x811e)
175#define PLD_ICUCR17 __reg16(PLD_BASE + 0x8120)
176#define PLD_ICUCR_IEN (0x1000)
177#define PLD_ICUCR_IREQ (0x0100)
178#define PLD_ICUCR_ISMOD00 (0x0000) /* Low edge */
179#define PLD_ICUCR_ISMOD01 (0x0010) /* Low level */
180#define PLD_ICUCR_ISMOD02 (0x0020) /* High edge */
181#define PLD_ICUCR_ISMOD03 (0x0030) /* High level */
182#define PLD_ICUCR_ILEVEL0 (0x0000)
183#define PLD_ICUCR_ILEVEL1 (0x0001)
184#define PLD_ICUCR_ILEVEL2 (0x0002)
185#define PLD_ICUCR_ILEVEL3 (0x0003)
186#define PLD_ICUCR_ILEVEL4 (0x0004)
187#define PLD_ICUCR_ILEVEL5 (0x0005)
188#define PLD_ICUCR_ILEVEL6 (0x0006)
189#define PLD_ICUCR_ILEVEL7 (0x0007)
190
191/* Power Control of MMC and CF */
192#define PLD_CPCR __reg16(PLD_BASE + 0x14000)
193#define PLD_CPCR_CF 0x0001
194#define PLD_CPCR_MMC 0x0002
195
196/* LED Control
197 *
198 * 1: DIP swich side
199 * 2: Reset switch side
200 */
201#define PLD_IOLEDCR __reg16(PLD_BASE + 0x14002)
202#define PLD_IOLED_1_ON 0x001
203#define PLD_IOLED_1_OFF 0x000
204#define PLD_IOLED_2_ON 0x002
205#define PLD_IOLED_2_OFF 0x000
206
207/* DIP Switch
208 * 0: Write-protect of Flash Memory (0:protected, 1:non-protected)
209 * 1: -
210 * 2: -
211 * 3: -
212 */
213#define PLD_IOSWSTS __reg16(PLD_BASE + 0x14004)
214#define PLD_IOSWSTS_IOSW2 0x0200
215#define PLD_IOSWSTS_IOSW1 0x0100
216#define PLD_IOSWSTS_IOWP0 0x0001
217
218/* CRC */
219#define PLD_CRC7DATA __reg16(PLD_BASE + 0x18000)
220#define PLD_CRC7INDATA __reg16(PLD_BASE + 0x18002)
221#define PLD_CRC16DATA __reg16(PLD_BASE + 0x18004)
222#define PLD_CRC16INDATA __reg16(PLD_BASE + 0x18006)
223#define PLD_CRC16ADATA __reg16(PLD_BASE + 0x18008)
224#define PLD_CRC16AINDATA __reg16(PLD_BASE + 0x1800a)
225
226/* RTC */
227#define PLD_RTCCR __reg16(PLD_BASE + 0x1c000)
228#define PLD_RTCBAUR __reg16(PLD_BASE + 0x1c002)
229#define PLD_RTCWRDATA __reg16(PLD_BASE + 0x1c004)
230#define PLD_RTCRDDATA __reg16(PLD_BASE + 0x1c006)
231#define PLD_RTCRSTODT __reg16(PLD_BASE + 0x1c008)
232
233/* SIO0 */
234#define PLD_ESIO0CR __reg16(PLD_BASE + 0x20000)
235#define PLD_ESIO0CR_TXEN 0x0001
236#define PLD_ESIO0CR_RXEN 0x0002
237#define PLD_ESIO0MOD0 __reg16(PLD_BASE + 0x20002)
238#define PLD_ESIO0MOD0_CTSS 0x0040
239#define PLD_ESIO0MOD0_RTSS 0x0080
240#define PLD_ESIO0MOD1 __reg16(PLD_BASE + 0x20004)
241#define PLD_ESIO0MOD1_LMFS 0x0010
242#define PLD_ESIO0STS __reg16(PLD_BASE + 0x20006)
243#define PLD_ESIO0STS_TEMP 0x0001
244#define PLD_ESIO0STS_TXCP 0x0002
245#define PLD_ESIO0STS_RXCP 0x0004
246#define PLD_ESIO0STS_TXSC 0x0100
247#define PLD_ESIO0STS_RXSC 0x0200
248#define PLD_ESIO0STS_TXREADY (PLD_ESIO0STS_TXCP | PLD_ESIO0STS_TEMP)
249#define PLD_ESIO0INTCR __reg16(PLD_BASE + 0x20008)
250#define PLD_ESIO0INTCR_TXIEN 0x0002
251#define PLD_ESIO0INTCR_RXCEN 0x0004
252#define PLD_ESIO0BAUR __reg16(PLD_BASE + 0x2000a)
253#define PLD_ESIO0TXB __reg16(PLD_BASE + 0x2000c)
254#define PLD_ESIO0RXB __reg16(PLD_BASE + 0x2000e)
255
256/* SIM Card */
257#define PLD_SCCR __reg16(PLD_BASE + 0x38000)
258#define PLD_SCMOD __reg16(PLD_BASE + 0x38004)
259#define PLD_SCSTS __reg16(PLD_BASE + 0x38006)
260#define PLD_SCINTCR __reg16(PLD_BASE + 0x38008)
261#define PLD_SCBAUR __reg16(PLD_BASE + 0x3800a)
262#define PLD_SCTXB __reg16(PLD_BASE + 0x3800c)
263#define PLD_SCRXB __reg16(PLD_BASE + 0x3800e)
264
265#endif /* _M32700UT_M32700UT_PLD.H */
diff --git a/include/asm-m32r/m32r.h b/include/asm-m32r/m32r.h
new file mode 100644
index 000000000000..f116649bbef3
--- /dev/null
+++ b/include/asm-m32r/m32r.h
@@ -0,0 +1,134 @@
1#ifndef _ASM_M32R_M32R_H_
2#define _ASM_M32R_M32R_H_
3
4/*
5 * Renesas M32R processor
6 *
7 * Copyright (C) 2003, 2004 Renesas Technology Corp.
8 */
9
10#include <linux/config.h>
11
12/* Chip type */
13#if defined(CONFIG_CHIP_XNUX_MP) || defined(CONFIG_CHIP_XNUX2_MP)
14#include <asm/m32r_mp_fpga.h>
15#elif defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_XNUX2) \
16 || defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_M32102) \
17 || defined(CONFIG_CHIP_OPSP)
18#include <asm/m32102.h>
19#include <asm/m32102peri.h>
20#endif
21
22/* Platform type */
23#if defined(CONFIG_PLAT_M32700UT)
24#include <asm/m32700ut/m32700ut_pld.h>
25#include <asm/m32700ut/m32700ut_lan.h>
26#include <asm/m32700ut/m32700ut_lcd.h>
27#endif /* CONFIG_PLAT_M32700UT */
28
29#if defined(CONFIG_PLAT_OPSPUT)
30#include <asm/opsput/opsput_pld.h>
31#include <asm/opsput/opsput_lan.h>
32#include <asm/opsput/opsput_lcd.h>
33#endif /* CONFIG_PLAT_OPSPUT */
34
35#if defined(CONFIG_PLAT_MAPPI2)
36#include <asm/mappi2/mappi2_pld.h>
37#endif /* CONFIG_PLAT_MAPPI2 */
38
39#if defined(CONFIG_PLAT_USRV)
40#include <asm/m32700ut/m32700ut_pld.h>
41#endif
42
43/*
44 * M32R Register
45 */
46
47/*
48 * MMU Register
49 */
50
51#define MMU_REG_BASE (0xffff0000)
52#define ITLB_BASE (0xfe000000)
53#define DTLB_BASE (0xfe000800)
54
55#define NR_TLB_ENTRIES CONFIG_TLB_ENTRIES
56
57#define MATM MMU_REG_BASE /* MMU Address Translation Mode
58 Register */
59#define MPSZ (0x04 + MMU_REG_BASE) /* MMU Page Size Designation Register */
60#define MASID (0x08 + MMU_REG_BASE) /* MMU Address Space ID Register */
61#define MESTS (0x0c + MMU_REG_BASE) /* MMU Exception Status Register */
62#define MDEVA (0x10 + MMU_REG_BASE) /* MMU Operand Exception Virtual
63 Address Register */
64#define MDEVP (0x14 + MMU_REG_BASE) /* MMU Operand Exception Virtual Page
65 Number Register */
66#define MPTB (0x18 + MMU_REG_BASE) /* MMU Page Table Base Register */
67#define MSVA (0x20 + MMU_REG_BASE) /* MMU Search Virtual Address
68 Register */
69#define MTOP (0x24 + MMU_REG_BASE) /* MMU TLB Operation Register */
70#define MIDXI (0x28 + MMU_REG_BASE) /* MMU Index Register for
71 Instruciton */
72#define MIDXD (0x2c + MMU_REG_BASE) /* MMU Index Register for Operand */
73
74#define MATM_offset (MATM - MMU_REG_BASE)
75#define MPSZ_offset (MPSZ - MMU_REG_BASE)
76#define MASID_offset (MASID - MMU_REG_BASE)
77#define MESTS_offset (MESTS - MMU_REG_BASE)
78#define MDEVA_offset (MDEVA - MMU_REG_BASE)
79#define MDEVP_offset (MDEVP - MMU_REG_BASE)
80#define MPTB_offset (MPTB - MMU_REG_BASE)
81#define MSVA_offset (MSVA - MMU_REG_BASE)
82#define MTOP_offset (MTOP - MMU_REG_BASE)
83#define MIDXI_offset (MIDXI - MMU_REG_BASE)
84#define MIDXD_offset (MIDXD - MMU_REG_BASE)
85
86#define MESTS_IT (1 << 0) /* Instruction TLB miss */
87#define MESTS_IA (1 << 1) /* Instruction Access Exception */
88#define MESTS_DT (1 << 4) /* Operand TLB miss */
89#define MESTS_DA (1 << 5) /* Operand Access Exception */
90#define MESTS_DRW (1 << 6) /* Operand Write Exception Flag */
91
92/*
93 * PSW (Processor Status Word)
94 */
95
96/* PSW bit */
97#define M32R_PSW_BIT_SM (7) /* Stack Mode */
98#define M32R_PSW_BIT_IE (6) /* Interrupt Enable */
99#define M32R_PSW_BIT_PM (3) /* Processor Mode [0:Supervisor,1:User] */
100#define M32R_PSW_BIT_C (0) /* Condition */
101#define M32R_PSW_BIT_BSM (7+8) /* Backup Stack Mode */
102#define M32R_PSW_BIT_BIE (6+8) /* Backup Interrupt Enable */
103#define M32R_PSW_BIT_BPM (3+8) /* Backup Processor Mode */
104#define M32R_PSW_BIT_BC (0+8) /* Backup Condition */
105
106/* PSW bit map */
107#define M32R_PSW_SM (1UL<< M32R_PSW_BIT_SM) /* Stack Mode */
108#define M32R_PSW_IE (1UL<< M32R_PSW_BIT_IE) /* Interrupt Enable */
109#define M32R_PSW_PM (1UL<< M32R_PSW_BIT_PM) /* Processor Mode */
110#define M32R_PSW_C (1UL<< M32R_PSW_BIT_C) /* Condition */
111#define M32R_PSW_BSM (1UL<< M32R_PSW_BIT_BSM) /* Backup Stack Mode */
112#define M32R_PSW_BIE (1UL<< M32R_PSW_BIT_BIE) /* Backup Interrupt Enable */
113#define M32R_PSW_BPM (1UL<< M32R_PSW_BIT_BPM) /* Backup Processor Mode */
114#define M32R_PSW_BC (1UL<< M32R_PSW_BIT_BC) /* Backup Condition */
115
116/*
117 * Direct address to SFR
118 */
119
120#include <asm/page.h>
121#ifdef CONFIG_MMU
122#define NONCACHE_OFFSET __PAGE_OFFSET+0x20000000
123#else
124#define NONCACHE_OFFSET __PAGE_OFFSET
125#endif /* CONFIG_MMU */
126
127#define M32R_ICU_ISTS_ADDR M32R_ICU_ISTS_PORTL+NONCACHE_OFFSET
128#define M32R_ICU_IPICR_ADDR M32R_ICU_IPICR0_PORTL+NONCACHE_OFFSET
129#define M32R_ICU_IMASK_ADDR M32R_ICU_IMASK_PORTL+NONCACHE_OFFSET
130#define M32R_FPGA_CPU_NAME_ADDR M32R_FPGA_CPU_NAME0_PORTL+NONCACHE_OFFSET
131#define M32R_FPGA_MODEL_ID_ADDR M32R_FPGA_MODEL_ID0_PORTL+NONCACHE_OFFSET
132#define M32R_FPGA_VERSION_ADDR M32R_FPGA_VERSION0_PORTL+NONCACHE_OFFSET
133
134#endif /* _ASM_M32R_M32R_H_ */
diff --git a/include/asm-m32r/m32r_mp_fpga.h b/include/asm-m32r/m32r_mp_fpga.h
new file mode 100644
index 000000000000..976d2b995919
--- /dev/null
+++ b/include/asm-m32r/m32r_mp_fpga.h
@@ -0,0 +1,313 @@
1#ifndef _ASM_M32R_M32R_MP_FPGA_
2#define _ASM_M32R_M32R_MP_FPGA_
3
4/*
5 * Renesas M32R-MP-FPGA
6 *
7 * Copyright (c) 2002 Hitoshi Yamamoto
8 * Copyright (c) 2003, 2004 Renesas Technology Corp.
9 */
10
11/*
12 * ========================================================
13 * M32R-MP-FPGA Memory Map
14 * ========================================================
15 * 0x00000000 : Block#0 : 64[MB]
16 * 0x03E00000 : SFR
17 * 0x03E00000 : reserved
18 * 0x03EF0000 : FPGA
19 * 0x03EF1000 : reserved
20 * 0x03EF4000 : CKM
21 * 0x03EF4000 : BSELC
22 * 0x03EF5000 : reserved
23 * 0x03EFC000 : MFT
24 * 0x03EFD000 : SIO
25 * 0x03EFE000 : reserved
26 * 0x03EFF000 : ICU
27 * 0x03F00000 : Internal SRAM 64[KB]
28 * 0x03F10000 : reserved
29 * --------------------------------------------------------
30 * 0x04000000 : Block#1 : 64[MB]
31 * 0x04000000 : Debug board SRAM 4[MB]
32 * 0x04400000 : reserved
33 * --------------------------------------------------------
34 * 0x08000000 : Block#2 : 64[MB]
35 * --------------------------------------------------------
36 * 0x0C000000 : Block#3 : 64[MB]
37 * --------------------------------------------------------
38 * 0x10000000 : Block#4 : 64[MB]
39 * --------------------------------------------------------
40 * 0x14000000 : Block#5 : 64[MB]
41 * --------------------------------------------------------
42 * 0x18000000 : Block#6 : 64[MB]
43 * --------------------------------------------------------
44 * 0x1C000000 : Block#7 : 64[MB]
45 * --------------------------------------------------------
46 * 0xFE000000 : TLB
47 * 0xFE000000 : ITLB
48 * 0xFE000080 : reserved
49 * 0xFE000800 : DTLB
50 * 0xFE000880 : reserved
51 * --------------------------------------------------------
52 * 0xFF000000 : System area
53 * 0xFFFF0000 : MMU
54 * 0xFFFF0030 : reserved
55 * 0xFFFF8000 : Debug function
56 * 0xFFFFA000 : reserved
57 * 0xFFFFC000 : CPU control
58 * 0xFFFFFFFF
59 * ========================================================
60 */
61
62/*======================================================================*
63 * Special Function Register
64 *======================================================================*/
65#define M32R_SFR_OFFSET (0x00E00000) /* 0x03E00000-0x03EFFFFF 1[MB] */
66
67/*
68 * FPGA registers.
69 */
70#define M32R_FPGA_TOP (0x000F0000+M32R_SFR_OFFSET)
71
72#define M32R_FPGA_NUM_OF_CPUS_PORTL (0x00+M32R_FPGA_TOP)
73#define M32R_FPGA_CPU_NAME0_PORTL (0x10+M32R_FPGA_TOP)
74#define M32R_FPGA_CPU_NAME1_PORTL (0x14+M32R_FPGA_TOP)
75#define M32R_FPGA_CPU_NAME2_PORTL (0x18+M32R_FPGA_TOP)
76#define M32R_FPGA_CPU_NAME3_PORTL (0x1C+M32R_FPGA_TOP)
77#define M32R_FPGA_MODEL_ID0_PORTL (0x20+M32R_FPGA_TOP)
78#define M32R_FPGA_MODEL_ID1_PORTL (0x24+M32R_FPGA_TOP)
79#define M32R_FPGA_MODEL_ID2_PORTL (0x28+M32R_FPGA_TOP)
80#define M32R_FPGA_MODEL_ID3_PORTL (0x2C+M32R_FPGA_TOP)
81#define M32R_FPGA_VERSION0_PORTL (0x30+M32R_FPGA_TOP)
82#define M32R_FPGA_VERSION1_PORTL (0x34+M32R_FPGA_TOP)
83
84/*
85 * Clock and Power Manager registers.
86 */
87#define M32R_CPM_OFFSET (0x000F4000+M32R_SFR_OFFSET)
88
89#define M32R_CPM_CPUCLKCR_PORTL (0x00+M32R_CPM_OFFSET)
90#define M32R_CPM_CLKMOD_PORTL (0x04+M32R_CPM_OFFSET)
91#define M32R_CPM_PLLCR_PORTL (0x08+M32R_CPM_OFFSET)
92
93/*
94 * Block SELect Controller registers.
95 */
96#define M32R_BSELC_OFFSET (0x000F5000+M32R_SFR_OFFSET)
97
98#define M32R_BSEL0_CR0_PORTL (0x000+M32R_BSELC_OFFSET)
99#define M32R_BSEL0_CR1_PORTL (0x004+M32R_BSELC_OFFSET)
100#define M32R_BSEL1_CR0_PORTL (0x100+M32R_BSELC_OFFSET)
101#define M32R_BSEL1_CR1_PORTL (0x104+M32R_BSELC_OFFSET)
102#define M32R_BSEL2_CR0_PORTL (0x200+M32R_BSELC_OFFSET)
103#define M32R_BSEL2_CR1_PORTL (0x204+M32R_BSELC_OFFSET)
104#define M32R_BSEL3_CR0_PORTL (0x300+M32R_BSELC_OFFSET)
105#define M32R_BSEL3_CR1_PORTL (0x304+M32R_BSELC_OFFSET)
106#define M32R_BSEL4_CR0_PORTL (0x400+M32R_BSELC_OFFSET)
107#define M32R_BSEL4_CR1_PORTL (0x404+M32R_BSELC_OFFSET)
108#define M32R_BSEL5_CR0_PORTL (0x500+M32R_BSELC_OFFSET)
109#define M32R_BSEL5_CR1_PORTL (0x504+M32R_BSELC_OFFSET)
110#define M32R_BSEL6_CR0_PORTL (0x600+M32R_BSELC_OFFSET)
111#define M32R_BSEL6_CR1_PORTL (0x604+M32R_BSELC_OFFSET)
112#define M32R_BSEL7_CR0_PORTL (0x700+M32R_BSELC_OFFSET)
113#define M32R_BSEL7_CR1_PORTL (0x704+M32R_BSELC_OFFSET)
114
115/*
116 * Multi Function Timer registers.
117 */
118#define M32R_MFT_OFFSET (0x000FC000+M32R_SFR_OFFSET)
119
120#define M32R_MFTCR_PORTL (0x000+M32R_MFT_OFFSET) /* MFT control */
121#define M32R_MFTRPR_PORTL (0x004+M32R_MFT_OFFSET) /* MFT real port */
122
123#define M32R_MFT0_OFFSET (0x100+M32R_MFT_OFFSET)
124#define M32R_MFT0MOD_PORTL (0x00+M32R_MFT0_OFFSET) /* MFT0 mode */
125#define M32R_MFT0BOS_PORTL (0x04+M32R_MFT0_OFFSET) /* MFT0 b-port output status */
126#define M32R_MFT0CUT_PORTL (0x08+M32R_MFT0_OFFSET) /* MFT0 count */
127#define M32R_MFT0RLD_PORTL (0x0C+M32R_MFT0_OFFSET) /* MFT0 reload */
128#define M32R_MFT0CMPRLD_PORTL (0x10+M32R_MFT0_OFFSET) /* MFT0 compare reload */
129
130#define M32R_MFT1_OFFSET (0x200+M32R_MFT_OFFSET)
131#define M32R_MFT1MOD_PORTL (0x00+M32R_MFT1_OFFSET) /* MFT1 mode */
132#define M32R_MFT1BOS_PORTL (0x04+M32R_MFT1_OFFSET) /* MFT1 b-port output status */
133#define M32R_MFT1CUT_PORTL (0x08+M32R_MFT1_OFFSET) /* MFT1 count */
134#define M32R_MFT1RLD_PORTL (0x0C+M32R_MFT1_OFFSET) /* MFT1 reload */
135#define M32R_MFT1CMPRLD_PORTL (0x10+M32R_MFT1_OFFSET) /* MFT1 compare reload */
136
137#define M32R_MFT2_OFFSET (0x300+M32R_MFT_OFFSET)
138#define M32R_MFT2MOD_PORTL (0x00+M32R_MFT2_OFFSET) /* MFT2 mode */
139#define M32R_MFT2BOS_PORTL (0x04+M32R_MFT2_OFFSET) /* MFT2 b-port output status */
140#define M32R_MFT2CUT_PORTL (0x08+M32R_MFT2_OFFSET) /* MFT2 count */
141#define M32R_MFT2RLD_PORTL (0x0C+M32R_MFT2_OFFSET) /* MFT2 reload */
142#define M32R_MFT2CMPRLD_PORTL (0x10+M32R_MFT2_OFFSET) /* MFT2 compare reload */
143
144#define M32R_MFT3_OFFSET (0x400+M32R_MFT_OFFSET)
145#define M32R_MFT3MOD_PORTL (0x00+M32R_MFT3_OFFSET) /* MFT3 mode */
146#define M32R_MFT3BOS_PORTL (0x04+M32R_MFT3_OFFSET) /* MFT3 b-port output status */
147#define M32R_MFT3CUT_PORTL (0x08+M32R_MFT3_OFFSET) /* MFT3 count */
148#define M32R_MFT3RLD_PORTL (0x0C+M32R_MFT3_OFFSET) /* MFT3 reload */
149#define M32R_MFT3CMPRLD_PORTL (0x10+M32R_MFT3_OFFSET) /* MFT3 compare reload */
150
151#define M32R_MFT4_OFFSET (0x500+M32R_MFT_OFFSET)
152#define M32R_MFT4MOD_PORTL (0x00+M32R_MFT4_OFFSET) /* MFT4 mode */
153#define M32R_MFT4BOS_PORTL (0x04+M32R_MFT4_OFFSET) /* MFT4 b-port output status */
154#define M32R_MFT4CUT_PORTL (0x08+M32R_MFT4_OFFSET) /* MFT4 count */
155#define M32R_MFT4RLD_PORTL (0x0C+M32R_MFT4_OFFSET) /* MFT4 reload */
156#define M32R_MFT4CMPRLD_PORTL (0x10+M32R_MFT4_OFFSET) /* MFT4 compare reload */
157
158#define M32R_MFT5_OFFSET (0x600+M32R_MFT_OFFSET)
159#define M32R_MFT5MOD_PORTL (0x00+M32R_MFT5_OFFSET) /* MFT4 mode */
160#define M32R_MFT5BOS_PORTL (0x04+M32R_MFT5_OFFSET) /* MFT4 b-port output status */
161#define M32R_MFT5CUT_PORTL (0x08+M32R_MFT5_OFFSET) /* MFT4 count */
162#define M32R_MFT5RLD_PORTL (0x0C+M32R_MFT5_OFFSET) /* MFT4 reload */
163#define M32R_MFT5CMPRLD_PORTL (0x10+M32R_MFT5_OFFSET) /* MFT4 compare reload */
164
165#define M32R_MFTCR_MFT0MSK (1UL<<15) /* b16 */
166#define M32R_MFTCR_MFT1MSK (1UL<<14) /* b17 */
167#define M32R_MFTCR_MFT2MSK (1UL<<13) /* b18 */
168#define M32R_MFTCR_MFT3MSK (1UL<<12) /* b19 */
169#define M32R_MFTCR_MFT4MSK (1UL<<11) /* b20 */
170#define M32R_MFTCR_MFT5MSK (1UL<<10) /* b21 */
171#define M32R_MFTCR_MFT0EN (1UL<<7) /* b24 */
172#define M32R_MFTCR_MFT1EN (1UL<<6) /* b25 */
173#define M32R_MFTCR_MFT2EN (1UL<<5) /* b26 */
174#define M32R_MFTCR_MFT3EN (1UL<<4) /* b27 */
175#define M32R_MFTCR_MFT4EN (1UL<<3) /* b28 */
176#define M32R_MFTCR_MFT5EN (1UL<<2) /* b29 */
177
178#define M32R_MFTMOD_CC_MASK (1UL<<15) /* b16 */
179#define M32R_MFTMOD_TCCR (1UL<<13) /* b18 */
180#define M32R_MFTMOD_GTSEL000 (0UL<<8) /* b21-23 : 000 */
181#define M32R_MFTMOD_GTSEL001 (1UL<<8) /* b21-23 : 001 */
182#define M32R_MFTMOD_GTSEL010 (2UL<<8) /* b21-23 : 010 */
183#define M32R_MFTMOD_GTSEL011 (3UL<<8) /* b21-23 : 011 */
184#define M32R_MFTMOD_GTSEL110 (6UL<<8) /* b21-23 : 110 */
185#define M32R_MFTMOD_GTSEL111 (7UL<<8) /* b21-23 : 111 */
186#define M32R_MFTMOD_CMSEL (1UL<<3) /* b28 */
187#define M32R_MFTMOD_CSSEL000 (0UL<<0) /* b29-b31 : 000 */
188#define M32R_MFTMOD_CSSEL001 (1UL<<0) /* b29-b31 : 001 */
189#define M32R_MFTMOD_CSSEL010 (2UL<<0) /* b29-b31 : 010 */
190#define M32R_MFTMOD_CSSEL011 (3UL<<0) /* b29-b31 : 011 */
191#define M32R_MFTMOD_CSSEL100 (4UL<<0) /* b29-b31 : 100 */
192#define M32R_MFTMOD_CSSEL110 (6UL<<0) /* b29-b31 : 110 */
193
194/*
195 * Serial I/O registers.
196 */
197#define M32R_SIO_OFFSET (0x000FD000+M32R_SFR_OFFSET)
198
199#define M32R_SIO0_CR_PORTL (0x000+M32R_SIO_OFFSET)
200#define M32R_SIO0_MOD0_PORTL (0x004+M32R_SIO_OFFSET)
201#define M32R_SIO0_MOD1_PORTL (0x008+M32R_SIO_OFFSET)
202#define M32R_SIO0_STS_PORTL (0x00C+M32R_SIO_OFFSET)
203#define M32R_SIO0_TRCR_PORTL (0x010+M32R_SIO_OFFSET)
204#define M32R_SIO0_BAUR_PORTL (0x014+M32R_SIO_OFFSET)
205#define M32R_SIO0_RBAUR_PORTL (0x018+M32R_SIO_OFFSET)
206#define M32R_SIO0_TXB_PORTL (0x01C+M32R_SIO_OFFSET)
207#define M32R_SIO0_RXB_PORTL (0x020+M32R_SIO_OFFSET)
208
209/*
210 * Interrupt Control Unit registers.
211 */
212#define M32R_ICU_OFFSET (0x000FF000+M32R_SFR_OFFSET)
213
214#define M32R_ICU_ISTS_PORTL (0x004+M32R_ICU_OFFSET)
215#define M32R_ICU_IREQ0_PORTL (0x008+M32R_ICU_OFFSET)
216#define M32R_ICU_IREQ1_PORTL (0x00C+M32R_ICU_OFFSET)
217#define M32R_ICU_SBICR_PORTL (0x018+M32R_ICU_OFFSET)
218#define M32R_ICU_IMASK_PORTL (0x01C+M32R_ICU_OFFSET)
219#define M32R_ICU_CR1_PORTL (0x200+M32R_ICU_OFFSET) /* INT0 */
220#define M32R_ICU_CR2_PORTL (0x204+M32R_ICU_OFFSET) /* INT1 */
221#define M32R_ICU_CR3_PORTL (0x208+M32R_ICU_OFFSET) /* INT2 */
222#define M32R_ICU_CR4_PORTL (0x20C+M32R_ICU_OFFSET) /* INT3 */
223#define M32R_ICU_CR5_PORTL (0x210+M32R_ICU_OFFSET) /* INT4 */
224#define M32R_ICU_CR6_PORTL (0x214+M32R_ICU_OFFSET) /* INT5 */
225#define M32R_ICU_CR7_PORTL (0x218+M32R_ICU_OFFSET) /* INT6 */
226#define M32R_ICU_CR8_PORTL (0x218+M32R_ICU_OFFSET) /* INT7 */
227#define M32R_ICU_CR32_PORTL (0x27C+M32R_ICU_OFFSET) /* SIO0 RX */
228#define M32R_ICU_CR33_PORTL (0x280+M32R_ICU_OFFSET) /* SIO0 TX */
229#define M32R_ICU_CR40_PORTL (0x29C+M32R_ICU_OFFSET) /* DMAC0 */
230#define M32R_ICU_CR41_PORTL (0x2A0+M32R_ICU_OFFSET) /* DMAC1 */
231#define M32R_ICU_CR48_PORTL (0x2BC+M32R_ICU_OFFSET) /* MFT0 */
232#define M32R_ICU_CR49_PORTL (0x2C0+M32R_ICU_OFFSET) /* MFT1 */
233#define M32R_ICU_CR50_PORTL (0x2C4+M32R_ICU_OFFSET) /* MFT2 */
234#define M32R_ICU_CR51_PORTL (0x2C8+M32R_ICU_OFFSET) /* MFT3 */
235#define M32R_ICU_CR52_PORTL (0x2CC+M32R_ICU_OFFSET) /* MFT4 */
236#define M32R_ICU_CR53_PORTL (0x2D0+M32R_ICU_OFFSET) /* MFT5 */
237#define M32R_ICU_IPICR0_PORTL (0x2DC+M32R_ICU_OFFSET) /* IPI0 */
238#define M32R_ICU_IPICR1_PORTL (0x2E0+M32R_ICU_OFFSET) /* IPI1 */
239#define M32R_ICU_IPICR2_PORTL (0x2E4+M32R_ICU_OFFSET) /* IPI2 */
240#define M32R_ICU_IPICR3_PORTL (0x2E8+M32R_ICU_OFFSET) /* IPI3 */
241#define M32R_ICU_IPICR4_PORTL (0x2EC+M32R_ICU_OFFSET) /* IPI4 */
242#define M32R_ICU_IPICR5_PORTL (0x2F0+M32R_ICU_OFFSET) /* IPI5 */
243#define M32R_ICU_IPICR6_PORTL (0x2F4+M32R_ICU_OFFSET) /* IPI6 */
244#define M32R_ICU_IPICR7_PORTL (0x2FC+M32R_ICU_OFFSET) /* IPI7 */
245
246#define M32R_ICUISTS_VECB(val) ((val>>28) & 0xF)
247#define M32R_ICUISTS_ISN(val) ((val>>22) & 0x3F)
248#define M32R_ICUISTS_PIML(val) ((val>>16) & 0x7)
249
250#define M32R_ICUIMASK_IMSK0 (0UL<<16) /* b13-b15: Disable interrupt */
251#define M32R_ICUIMASK_IMSK1 (1UL<<16) /* b13-b15: Enable level 0 interrupt */
252#define M32R_ICUIMASK_IMSK2 (2UL<<16) /* b13-b15: Enable level 0,1 interrupt */
253#define M32R_ICUIMASK_IMSK3 (3UL<<16) /* b13-b15: Enable level 0-2 interrupt */
254#define M32R_ICUIMASK_IMSK4 (4UL<<16) /* b13-b15: Enable level 0-3 interrupt */
255#define M32R_ICUIMASK_IMSK5 (5UL<<16) /* b13-b15: Enable level 0-4 interrupt */
256#define M32R_ICUIMASK_IMSK6 (6UL<<16) /* b13-b15: Enable level 0-5 interrupt */
257#define M32R_ICUIMASK_IMSK7 (7UL<<16) /* b13-b15: Enable level 0-6 interrupt */
258
259#define M32R_ICUCR_IEN (1UL<<12) /* b19: Interrupt enable */
260#define M32R_ICUCR_IRQ (1UL<<8) /* b23: Interrupt request */
261#define M32R_ICUCR_ISMOD00 (0UL<<4) /* b26-b27: Interrupt sense mode Edge HtoL */
262#define M32R_ICUCR_ISMOD01 (1UL<<4) /* b26-b27: Interrupt sense mode Level L */
263#define M32R_ICUCR_ISMOD10 (2UL<<4) /* b26-b27: Interrupt sense mode Edge LtoH*/
264#define M32R_ICUCR_ISMOD11 (3UL<<4) /* b26-b27: Interrupt sense mode Level H */
265#define M32R_ICUCR_ILEVEL0 (0UL<<0) /* b29-b31: Interrupt priority level 0 */
266#define M32R_ICUCR_ILEVEL1 (1UL<<0) /* b29-b31: Interrupt priority level 1 */
267#define M32R_ICUCR_ILEVEL2 (2UL<<0) /* b29-b31: Interrupt priority level 2 */
268#define M32R_ICUCR_ILEVEL3 (3UL<<0) /* b29-b31: Interrupt priority level 3 */
269#define M32R_ICUCR_ILEVEL4 (4UL<<0) /* b29-b31: Interrupt priority level 4 */
270#define M32R_ICUCR_ILEVEL5 (5UL<<0) /* b29-b31: Interrupt priority level 5 */
271#define M32R_ICUCR_ILEVEL6 (6UL<<0) /* b29-b31: Interrupt priority level 6 */
272#define M32R_ICUCR_ILEVEL7 (7UL<<0) /* b29-b31: Disable interrupt */
273#define M32R_ICUCR_ILEVEL_MASK (7UL)
274
275#define M32R_IRQ_INT0 (1) /* INT0 */
276#define M32R_IRQ_INT1 (2) /* INT1 */
277#define M32R_IRQ_INT2 (3) /* INT2 */
278#define M32R_IRQ_INT3 (4) /* INT3 */
279#define M32R_IRQ_INT4 (5) /* INT4 */
280#define M32R_IRQ_INT5 (6) /* INT5 */
281#define M32R_IRQ_INT6 (7) /* INT6 */
282#define M32R_IRQ_INT7 (8) /* INT7 */
283#define M32R_IRQ_MFT0 (16) /* MFT0 */
284#define M32R_IRQ_MFT1 (17) /* MFT1 */
285#define M32R_IRQ_MFT2 (18) /* MFT2 */
286#define M32R_IRQ_MFT3 (19) /* MFT3 */
287#define M32R_IRQ_MFT4 (20) /* MFT4 */
288#define M32R_IRQ_MFT5 (21) /* MFT5 */
289#define M32R_IRQ_DMAC0 (32) /* DMAC0 */
290#define M32R_IRQ_DMAC1 (33) /* DMAC1 */
291#define M32R_IRQ_SIO0_R (48) /* SIO0 receive */
292#define M32R_IRQ_SIO0_S (49) /* SIO0 send */
293#define M32R_IRQ_SIO1_R (50) /* SIO1 send */
294#define M32R_IRQ_SIO1_S (51) /* SIO1 receive */
295#define M32R_IRQ_IPI0 (56) /* IPI0 */
296#define M32R_IRQ_IPI1 (57) /* IPI1 */
297#define M32R_IRQ_IPI2 (58) /* IPI2 */
298#define M32R_IRQ_IPI3 (59) /* IPI3 */
299#define M32R_IRQ_IPI4 (60) /* IPI4 */
300#define M32R_IRQ_IPI5 (61) /* IPI5 */
301#define M32R_IRQ_IPI6 (62) /* IPI6 */
302#define M32R_IRQ_IPI7 (63) /* IPI7 */
303
304/*======================================================================*
305 * CPU
306 *======================================================================*/
307
308#define M32R_CPUID_PORTL (0xFFFFFFE0)
309#define M32R_MCICAR_PORTL (0xFFFFFFF0)
310#define M32R_MCDCAR_PORTL (0xFFFFFFF4)
311#define M32R_MCCR_PORTL (0xFFFFFFFC)
312
313#endif /* _ASM_M32R_M32R_MP_FPGA_ */
diff --git a/include/asm-m32r/mappi2/mappi2_pld.h b/include/asm-m32r/mappi2/mappi2_pld.h
new file mode 100644
index 000000000000..01dcdd19dbe6
--- /dev/null
+++ b/include/asm-m32r/mappi2/mappi2_pld.h
@@ -0,0 +1,151 @@
1/*
2 * include/asm/mappi2/mappi2_pld.h
3 *
4 * Definitions for Extended IO Logic on MAPPI2 board.
5 * based on m32700ut_pld.h by
6 *
7 * This file is subject to the terms and conditions of the GNU General
8 * Public License. See the file "COPYING" in the main directory of
9 * this archive for more details.
10 *
11 */
12
13#ifndef _MAPPI2_PLD_H
14#define _MAPPI2_PLD_H
15
16#ifndef __ASSEMBLY__
17/* FIXME:
18 * Some C functions use non-cache address, so can't define non-cache address.
19 */
20#define PLD_BASE (0x10c00000 /* + NONCACHE_OFFSET */)
21#define __reg8 (volatile unsigned char *)
22#define __reg16 (volatile unsigned short *)
23#define __reg32 (volatile unsigned int *)
24#else
25#define PLD_BASE (0x10c00000 + NONCACHE_OFFSET)
26#define __reg8
27#define __reg16
28#define __reg32
29#endif /* __ASSEMBLY__ */
30
31/* CFC */
32#define PLD_CFRSTCR __reg16(PLD_BASE + 0x0000)
33#define PLD_CFSTS __reg16(PLD_BASE + 0x0002)
34#define PLD_CFIMASK __reg16(PLD_BASE + 0x0004)
35#define PLD_CFBUFCR __reg16(PLD_BASE + 0x0006)
36#define PLD_CFCR0 __reg16(PLD_BASE + 0x000a)
37#define PLD_CFCR1 __reg16(PLD_BASE + 0x000c)
38
39/* MMC */
40#define PLD_MMCCR __reg16(PLD_BASE + 0x4000)
41#define PLD_MMCMOD __reg16(PLD_BASE + 0x4002)
42#define PLD_MMCSTS __reg16(PLD_BASE + 0x4006)
43#define PLD_MMCBAUR __reg16(PLD_BASE + 0x400a)
44#define PLD_MMCCMDBCUT __reg16(PLD_BASE + 0x400c)
45#define PLD_MMCCDTBCUT __reg16(PLD_BASE + 0x400e)
46#define PLD_MMCDET __reg16(PLD_BASE + 0x4010)
47#define PLD_MMCWP __reg16(PLD_BASE + 0x4012)
48#define PLD_MMCWDATA __reg16(PLD_BASE + 0x5000)
49#define PLD_MMCRDATA __reg16(PLD_BASE + 0x6000)
50#define PLD_MMCCMDDATA __reg16(PLD_BASE + 0x7000)
51#define PLD_MMCRSPDATA __reg16(PLD_BASE + 0x7006)
52
53/* Power Control of MMC and CF */
54#define PLD_CPCR __reg16(PLD_BASE + 0x14000)
55
56
57/*==== ICU ====*/
58#define M32R_IRQ_PC104 (5) /* INT4(PC/104) */
59#define M32R_IRQ_I2C (28) /* I2C-BUS */
60#if 1
61#define PLD_IRQ_CFIREQ (40) /* CFC Card Interrupt */
62#define PLD_IRQ_CFC_INSERT (41) /* CFC Card Insert */
63#define PLD_IRQ_CFC_EJECT (42) /* CFC Card Eject */
64#define PLD_IRQ_MMCCARD (43) /* MMC Card Insert */
65#define PLD_IRQ_MMCIRQ (44) /* MMC Transfer Done */
66#else
67#define PLD_IRQ_CFIREQ (34) /* CFC Card Interrupt */
68#define PLD_IRQ_CFC_INSERT (35) /* CFC Card Insert */
69#define PLD_IRQ_CFC_EJECT (36) /* CFC Card Eject */
70#define PLD_IRQ_MMCCARD (37) /* MMC Card Insert */
71#define PLD_IRQ_MMCIRQ (38) /* MMC Transfer Done */
72#endif
73
74
75#if 0
76/* LED Control
77 *
78 * 1: DIP swich side
79 * 2: Reset switch side
80 */
81#define PLD_IOLEDCR __reg16(PLD_BASE + 0x14002)
82#define PLD_IOLED_1_ON 0x001
83#define PLD_IOLED_1_OFF 0x000
84#define PLD_IOLED_2_ON 0x002
85#define PLD_IOLED_2_OFF 0x000
86
87/* DIP Switch
88 * 0: Write-protect of Flash Memory (0:protected, 1:non-protected)
89 * 1: -
90 * 2: -
91 * 3: -
92 */
93#define PLD_IOSWSTS __reg16(PLD_BASE + 0x14004)
94#define PLD_IOSWSTS_IOSW2 0x0200
95#define PLD_IOSWSTS_IOSW1 0x0100
96#define PLD_IOSWSTS_IOWP0 0x0001
97
98#endif
99
100/* CRC */
101#define PLD_CRC7DATA __reg16(PLD_BASE + 0x18000)
102#define PLD_CRC7INDATA __reg16(PLD_BASE + 0x18002)
103#define PLD_CRC16DATA __reg16(PLD_BASE + 0x18004)
104#define PLD_CRC16INDATA __reg16(PLD_BASE + 0x18006)
105#define PLD_CRC16ADATA __reg16(PLD_BASE + 0x18008)
106#define PLD_CRC16AINDATA __reg16(PLD_BASE + 0x1800a)
107
108
109#if 0
110/* RTC */
111#define PLD_RTCCR __reg16(PLD_BASE + 0x1c000)
112#define PLD_RTCBAUR __reg16(PLD_BASE + 0x1c002)
113#define PLD_RTCWRDATA __reg16(PLD_BASE + 0x1c004)
114#define PLD_RTCRDDATA __reg16(PLD_BASE + 0x1c006)
115#define PLD_RTCRSTODT __reg16(PLD_BASE + 0x1c008)
116
117/* SIO0 */
118#define PLD_ESIO0CR __reg16(PLD_BASE + 0x20000)
119#define PLD_ESIO0CR_TXEN 0x0001
120#define PLD_ESIO0CR_RXEN 0x0002
121#define PLD_ESIO0MOD0 __reg16(PLD_BASE + 0x20002)
122#define PLD_ESIO0MOD0_CTSS 0x0040
123#define PLD_ESIO0MOD0_RTSS 0x0080
124#define PLD_ESIO0MOD1 __reg16(PLD_BASE + 0x20004)
125#define PLD_ESIO0MOD1_LMFS 0x0010
126#define PLD_ESIO0STS __reg16(PLD_BASE + 0x20006)
127#define PLD_ESIO0STS_TEMP 0x0001
128#define PLD_ESIO0STS_TXCP 0x0002
129#define PLD_ESIO0STS_RXCP 0x0004
130#define PLD_ESIO0STS_TXSC 0x0100
131#define PLD_ESIO0STS_RXSC 0x0200
132#define PLD_ESIO0STS_TXREADY (PLD_ESIO0STS_TXCP | PLD_ESIO0STS_TEMP)
133#define PLD_ESIO0INTCR __reg16(PLD_BASE + 0x20008)
134#define PLD_ESIO0INTCR_TXIEN 0x0002
135#define PLD_ESIO0INTCR_RXCEN 0x0004
136#define PLD_ESIO0BAUR __reg16(PLD_BASE + 0x2000a)
137#define PLD_ESIO0TXB __reg16(PLD_BASE + 0x2000c)
138#define PLD_ESIO0RXB __reg16(PLD_BASE + 0x2000e)
139
140/* SIM Card */
141#define PLD_SCCR __reg16(PLD_BASE + 0x38000)
142#define PLD_SCMOD __reg16(PLD_BASE + 0x38004)
143#define PLD_SCSTS __reg16(PLD_BASE + 0x38006)
144#define PLD_SCINTCR __reg16(PLD_BASE + 0x38008)
145#define PLD_SCBAUR __reg16(PLD_BASE + 0x3800a)
146#define PLD_SCTXB __reg16(PLD_BASE + 0x3800c)
147#define PLD_SCRXB __reg16(PLD_BASE + 0x3800e)
148
149#endif
150
151#endif /* _MAPPI2_PLD.H */
diff --git a/include/asm-m32r/mc146818rtc.h b/include/asm-m32r/mc146818rtc.h
new file mode 100644
index 000000000000..755601d053cc
--- /dev/null
+++ b/include/asm-m32r/mc146818rtc.h
@@ -0,0 +1,32 @@
1/*
2 * Machine dependent access functions for RTC registers.
3 */
4#ifndef _ASM_MC146818RTC_H
5#define _ASM_MC146818RTC_H
6
7#include <asm/io.h>
8
9#ifndef RTC_PORT
10// #define RTC_PORT(x) (0x70 + (x))
11#define RTC_PORT(x) ((x))
12#define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */
13#endif
14
15/*
16 * The yet supported machines all access the RTC index register via
17 * an ISA port access but the way to access the date register differs ...
18 */
19#define CMOS_READ(addr) ({ \
20outb_p((addr),RTC_PORT(0)); \
21inb_p(RTC_PORT(1)); \
22})
23#define CMOS_WRITE(val, addr) ({ \
24outb_p((addr),RTC_PORT(0)); \
25outb_p((val),RTC_PORT(1)); \
26})
27
28#define RTC_IRQ 8
29#if 0
30#endif
31
32#endif /* _ASM_MC146818RTC_H */
diff --git a/include/asm-m32r/mman.h b/include/asm-m32r/mman.h
new file mode 100644
index 000000000000..011f6d9ec5cc
--- /dev/null
+++ b/include/asm-m32r/mman.h
@@ -0,0 +1,45 @@
1#ifndef __M32R_MMAN_H__
2#define __M32R_MMAN_H__
3
4/* orig : i386 2.6.0-test6 */
5
6#define PROT_READ 0x1 /* page can be read */
7#define PROT_WRITE 0x2 /* page can be written */
8#define PROT_EXEC 0x4 /* page can be executed */
9#define PROT_SEM 0x8 /* page may be used for atomic ops */
10#define PROT_NONE 0x0 /* page can not be accessed */
11#define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
12#define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
13
14#define MAP_SHARED 0x01 /* Share changes */
15#define MAP_PRIVATE 0x02 /* Changes are private */
16#define MAP_TYPE 0x0f /* Mask for type of mapping */
17#define MAP_FIXED 0x10 /* Interpret addr exactly */
18#define MAP_ANONYMOUS 0x20 /* don't use a file */
19
20#define MAP_GROWSDOWN 0x0100 /* stack-like segment */
21#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
22#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
23#define MAP_LOCKED 0x2000 /* pages are locked */
24#define MAP_NORESERVE 0x4000 /* don't check for reservations */
25#define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
26#define MAP_NONBLOCK 0x10000 /* do not block on IO */
27
28#define MS_ASYNC 1 /* sync memory asynchronously */
29#define MS_INVALIDATE 2 /* invalidate the caches */
30#define MS_SYNC 4 /* synchronous memory sync */
31
32#define MCL_CURRENT 1 /* lock all current mappings */
33#define MCL_FUTURE 2 /* lock all future mappings */
34
35#define MADV_NORMAL 0x0 /* default page-in behavior */
36#define MADV_RANDOM 0x1 /* page-in minimum required */
37#define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */
38#define MADV_WILLNEED 0x3 /* pre-fault pages */
39#define MADV_DONTNEED 0x4 /* discard these pages */
40
41/* compatibility flags */
42#define MAP_ANON MAP_ANONYMOUS
43#define MAP_FILE 0
44
45#endif /* __M32R_MMAN_H__ */
diff --git a/include/asm-m32r/mmu.h b/include/asm-m32r/mmu.h
new file mode 100644
index 000000000000..9c00eb78ee50
--- /dev/null
+++ b/include/asm-m32r/mmu.h
@@ -0,0 +1,21 @@
1#ifndef _ASM_M32R_MMU_H
2#define _ASM_M32R_MMU_H
3
4#include <linux/config.h>
5
6#if !defined(CONFIG_MMU)
7typedef struct {
8 struct vm_list_struct *vmlist;
9 unsigned long end_brk;
10} mm_context_t;
11#else
12
13/* Default "unsigned long" context */
14#ifndef CONFIG_SMP
15typedef unsigned long mm_context_t;
16#else
17typedef unsigned long mm_context_t[NR_CPUS];
18#endif
19
20#endif /* CONFIG_MMU */
21#endif /* _ASM_M32R_MMU_H */
diff --git a/include/asm-m32r/mmu_context.h b/include/asm-m32r/mmu_context.h
new file mode 100644
index 000000000000..3634c5361a9b
--- /dev/null
+++ b/include/asm-m32r/mmu_context.h
@@ -0,0 +1,170 @@
1#ifndef _ASM_M32R_MMU_CONTEXT_H
2#define _ASM_M32R_MMU_CONTEXT_H
3
4#ifdef __KERNEL__
5
6#include <linux/config.h>
7
8#include <asm/m32r.h>
9
10#define MMU_CONTEXT_ASID_MASK (0x000000FF)
11#define MMU_CONTEXT_VERSION_MASK (0xFFFFFF00)
12#define MMU_CONTEXT_FIRST_VERSION (0x00000100)
13#define NO_CONTEXT (0x00000000)
14
15
16#ifndef __ASSEMBLY__
17
18#include <linux/config.h>
19#include <asm/atomic.h>
20#include <asm/pgalloc.h>
21#include <asm/mmu.h>
22#include <asm/tlbflush.h>
23
24/*
25 * Cache of MMU context last used.
26 */
27#ifndef CONFIG_SMP
28extern unsigned long mmu_context_cache_dat;
29#define mmu_context_cache mmu_context_cache_dat
30#define mm_context(mm) mm->context
31#else /* not CONFIG_SMP */
32extern unsigned long mmu_context_cache_dat[];
33#define mmu_context_cache mmu_context_cache_dat[smp_processor_id()]
34#define mm_context(mm) mm->context[smp_processor_id()]
35#endif /* not CONFIG_SMP */
36
37#define set_tlb_tag(entry, tag) (*entry = (tag & PAGE_MASK)|get_asid())
38#define set_tlb_data(entry, data) (*entry = (data | _PAGE_PRESENT))
39
40#ifdef CONFIG_MMU
41#define enter_lazy_tlb(mm, tsk) do { } while (0)
42
43static inline void get_new_mmu_context(struct mm_struct *mm)
44{
45 unsigned long mc = ++mmu_context_cache;
46
47 if (!(mc & MMU_CONTEXT_ASID_MASK)) {
48 /* We exhaust ASID of this version.
49 Flush all TLB and start new cycle. */
50 local_flush_tlb_all();
51 /* Fix version if needed.
52 Note that we avoid version #0 to distingush NO_CONTEXT. */
53 if (!mc)
54 mmu_context_cache = mc = MMU_CONTEXT_FIRST_VERSION;
55 }
56 mm_context(mm) = mc;
57}
58
59/*
60 * Get MMU context if needed.
61 */
62static inline void get_mmu_context(struct mm_struct *mm)
63{
64 if (mm) {
65 unsigned long mc = mmu_context_cache;
66
67 /* Check if we have old version of context.
68 If it's old, we need to get new context with new version. */
69 if ((mm_context(mm) ^ mc) & MMU_CONTEXT_VERSION_MASK)
70 get_new_mmu_context(mm);
71 }
72}
73
74/*
75 * Initialize the context related info for a new mm_struct
76 * instance.
77 */
78static inline int init_new_context(struct task_struct *tsk,
79 struct mm_struct *mm)
80{
81#ifndef CONFIG_SMP
82 mm->context = NO_CONTEXT;
83#else /* CONFIG_SMP */
84 int num_cpus = num_online_cpus();
85 int i;
86
87 for (i = 0 ; i < num_cpus ; i++)
88 mm->context[i] = NO_CONTEXT;
89#endif /* CONFIG_SMP */
90
91 return 0;
92}
93
94/*
95 * Destroy context related info for an mm_struct that is about
96 * to be put to rest.
97 */
98#define destroy_context(mm) do { } while (0)
99
100static inline void set_asid(unsigned long asid)
101{
102 *(volatile unsigned long *)MASID = (asid & MMU_CONTEXT_ASID_MASK);
103}
104
105static inline unsigned long get_asid(void)
106{
107 unsigned long asid;
108
109 asid = *(volatile long *)MASID;
110 asid &= MMU_CONTEXT_ASID_MASK;
111
112 return asid;
113}
114
115/*
116 * After we have set current->mm to a new value, this activates
117 * the context for the new mm so we see the new mappings.
118 */
119static inline void activate_context(struct mm_struct *mm)
120{
121 get_mmu_context(mm);
122 set_asid(mm_context(mm) & MMU_CONTEXT_ASID_MASK);
123}
124
125static inline void switch_mm(struct mm_struct *prev,
126 struct mm_struct *next, struct task_struct *tsk)
127{
128#ifdef CONFIG_SMP
129 int cpu = smp_processor_id();
130#endif /* CONFIG_SMP */
131
132 if (prev != next) {
133#ifdef CONFIG_SMP
134 cpu_set(cpu, next->cpu_vm_mask);
135#endif /* CONFIG_SMP */
136 /* Set MPTB = next->pgd */
137 *(volatile unsigned long *)MPTB = (unsigned long)next->pgd;
138 activate_context(next);
139 }
140#ifdef CONFIG_SMP
141 else
142 if (!cpu_test_and_set(cpu, next->cpu_vm_mask))
143 activate_context(next);
144#endif /* CONFIG_SMP */
145}
146
147#define deactivate_mm(tsk, mm) do { } while (0)
148
149#define activate_mm(prev, next) \
150 switch_mm((prev), (next), NULL)
151
152#else
153#define get_mmu_context(mm) do { } while (0)
154#define init_new_context(tsk,mm) (0)
155#define destroy_context(mm) do { } while (0)
156#define set_asid(asid) do { } while (0)
157#define get_asid() (0)
158#define activate_context(mm) do { } while (0)
159#define switch_mm(prev,next,tsk) do { } while (0)
160#define deactivate_mm(mm,tsk) do { } while (0)
161#define activate_mm(prev,next) do { } while (0)
162#define enter_lazy_tlb(mm,tsk) do { } while (0)
163#endif /* CONFIG_MMU */
164
165
166#endif /* not __ASSEMBLY__ */
167
168#endif /* __KERNEL__ */
169
170#endif /* _ASM_M32R_MMU_CONTEXT_H */
diff --git a/include/asm-m32r/mmzone.h b/include/asm-m32r/mmzone.h
new file mode 100644
index 000000000000..ebf0228fec42
--- /dev/null
+++ b/include/asm-m32r/mmzone.h
@@ -0,0 +1,80 @@
1/*
2 * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002
3 *
4 */
5
6#ifndef _ASM_MMZONE_H_
7#define _ASM_MMZONE_H_
8
9#include <asm/smp.h>
10
11#ifdef CONFIG_DISCONTIGMEM
12
13extern struct pglist_data *node_data[];
14#define NODE_DATA(nid) (node_data[nid])
15
16#define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn)
17#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
18#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
19#define node_end_pfn(nid) \
20({ \
21 pg_data_t *__pgdat = NODE_DATA(nid); \
22 __pgdat->node_start_pfn + __pgdat->node_spanned_pages - 1; \
23})
24
25#define local_mapnr(kvaddr) \
26({ \
27 unsigned long __pfn = __pa(kvaddr) >> PAGE_SHIFT; \
28 (__pfn - node_start_pfn(pfn_to_nid(__pfn))); \
29})
30
31#define pfn_to_page(pfn) \
32({ \
33 unsigned long __pfn = pfn; \
34 int __node = pfn_to_nid(__pfn); \
35 &node_mem_map(__node)[node_localnr(__pfn,__node)]; \
36})
37
38#define page_to_pfn(pg) \
39({ \
40 struct page *__page = pg; \
41 struct zone *__zone = page_zone(__page); \
42 (unsigned long)(__page - __zone->zone_mem_map) \
43 + __zone->zone_start_pfn; \
44})
45#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
46/*
47 * pfn_valid should be made as fast as possible, and the current definition
48 * is valid for machines that are NUMA, but still contiguous, which is what
49 * is currently supported. A more generalised, but slower definition would
50 * be something like this - mbligh:
51 * ( pfn_to_pgdat(pfn) && ((pfn) < node_end_pfn(pfn_to_nid(pfn))) )
52 */
53#if 1 /* M32R_FIXME */
54#define pfn_valid(pfn) (1)
55#else
56#define pfn_valid(pfn) ((pfn) < num_physpages)
57#endif
58
59/*
60 * generic node memory support, the following assumptions apply:
61 */
62
63static __inline__ int pfn_to_nid(unsigned long pfn)
64{
65 int node;
66
67 for (node = 0 ; node < MAX_NUMNODES ; node++)
68 if (pfn >= node_start_pfn(node) && pfn <= node_end_pfn(node))
69 break;
70
71 return node;
72}
73
74static __inline__ struct pglist_data *pfn_to_pgdat(unsigned long pfn)
75{
76 return(NODE_DATA(pfn_to_nid(pfn)));
77}
78
79#endif /* CONFIG_DISCONTIGMEM */
80#endif /* _ASM_MMZONE_H_ */
diff --git a/include/asm-m32r/module.h b/include/asm-m32r/module.h
new file mode 100644
index 000000000000..3f2541c92a7b
--- /dev/null
+++ b/include/asm-m32r/module.h
@@ -0,0 +1,13 @@
1#ifndef _ASM_M32R_MODULE_H
2#define _ASM_M32R_MODULE_H
3
4/* $Id$ */
5
6struct mod_arch_specific { };
7
8#define Elf_Shdr Elf32_Shdr
9#define Elf_Sym Elf32_Sym
10#define Elf_Ehdr Elf32_Ehdr
11
12#endif /* _ASM_M32R_MODULE_H */
13
diff --git a/include/asm-m32r/msgbuf.h b/include/asm-m32r/msgbuf.h
new file mode 100644
index 000000000000..852ff52af4c2
--- /dev/null
+++ b/include/asm-m32r/msgbuf.h
@@ -0,0 +1,35 @@
1#ifndef _ASM_M32R_MSGBUF_H
2#define _ASM_M32R_MSGBUF_H
3
4/* $Id$ */
5
6/* orig : i386 2.4.18 */
7
8/*
9 * The msqid64_ds structure for m32r architecture.
10 * Note extra padding because this structure is passed back and forth
11 * between kernel and user space.
12 *
13 * Pad space is left for:
14 * - 64-bit time_t to solve y2038 problem
15 * - 2 miscellaneous 32-bit values
16 */
17
18struct msqid64_ds {
19 struct ipc64_perm msg_perm;
20 __kernel_time_t msg_stime; /* last msgsnd time */
21 unsigned long __unused1;
22 __kernel_time_t msg_rtime; /* last msgrcv time */
23 unsigned long __unused2;
24 __kernel_time_t msg_ctime; /* last change time */
25 unsigned long __unused3;
26 unsigned long msg_cbytes; /* current number of bytes on queue */
27 unsigned long msg_qnum; /* number of messages in queue */
28 unsigned long msg_qbytes; /* max number of bytes on queue */
29 __kernel_pid_t msg_lspid; /* pid of last msgsnd */
30 __kernel_pid_t msg_lrpid; /* last receive pid */
31 unsigned long __unused4;
32 unsigned long __unused5;
33};
34
35#endif /* _ASM_M32R_MSGBUF_H */
diff --git a/include/asm-m32r/namei.h b/include/asm-m32r/namei.h
new file mode 100644
index 000000000000..7172d3d2e260
--- /dev/null
+++ b/include/asm-m32r/namei.h
@@ -0,0 +1,21 @@
1#ifndef _ASM_M32R_NAMEI_H
2#define _ASM_M32R_NAMEI_H
3
4/* $Id$ */
5
6/* orig : i386 2.4.18 */
7
8/*
9 * linux/include/asm-m32r/namei.h
10 *
11 * Included from linux/fs/namei.c
12 */
13
14/* This dummy routine maybe changed to something useful
15 * for /usr/gnemul/ emulation stuff.
16 * Look at asm-sparc/namei.h for details.
17 */
18
19#define __emul_prefix() NULL
20
21#endif /* _ASM_M32R_NAMEI_H */
diff --git a/include/asm-m32r/numnodes.h b/include/asm-m32r/numnodes.h
new file mode 100644
index 000000000000..479a39d49f83
--- /dev/null
+++ b/include/asm-m32r/numnodes.h
@@ -0,0 +1,15 @@
1#ifndef _ASM_NUMNODES_H_
2#define _ASM_NUMNODES_H_
3
4#include <linux/config.h>
5
6#ifdef CONFIG_DISCONTIGMEM
7
8#if defined(CONFIG_CHIP_M32700)
9#define NODES_SHIFT 1 /* Max 2 Nodes */
10#endif /* CONFIG_CHIP_M32700 */
11
12#endif /* CONFIG_DISCONTIGMEM */
13
14#endif /* _ASM_NUMNODES_H_ */
15
diff --git a/include/asm-m32r/opsput/opsput_lan.h b/include/asm-m32r/opsput/opsput_lan.h
new file mode 100644
index 000000000000..7a2a839eedab
--- /dev/null
+++ b/include/asm-m32r/opsput/opsput_lan.h
@@ -0,0 +1,56 @@
1/*
2 * include/asm/opsput_lan.h
3 *
4 * OPSPUT-LAN board
5 *
6 * Copyright (c) 2002-2004 Takeo Takahashi, Mamoru Sakugawa
7 *
8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file "COPYING" in the main directory of
10 * this archive for more details.
11 *
12 * $Id: opsput_lan.h,v 1.1 2004/07/27 06:54:20 sakugawa Exp $
13 */
14
15#ifndef _OPSPUT_OPSPUT_LAN_H
16#define _OPSPUT_OPSPUT_LAN_H
17
18#include <linux/config.h>
19
20#ifndef __ASSEMBLY__
21/*
22 * C functions use non-cache address.
23 */
24#define OPSPUT_LAN_BASE (0x10000000 /* + NONCACHE_OFFSET */)
25#else
26#define OPSPUT_LAN_BASE (0x10000000 + NONCACHE_OFFSET)
27#endif /* __ASSEMBLY__ */
28
29/* ICU
30 * ICUISTS: status register
31 * ICUIREQ0: request register
32 * ICUIREQ1: request register
33 * ICUCR3: control register for CFIREQ# interrupt
34 * ICUCR4: control register for CFC Card insert interrupt
35 * ICUCR5: control register for CFC Card eject interrupt
36 * ICUCR6: control register for external interrupt
37 * ICUCR11: control register for MMC Card insert/eject interrupt
38 * ICUCR13: control register for SC error interrupt
39 * ICUCR14: control register for SC receive interrupt
40 * ICUCR15: control register for SC send interrupt
41 * ICUCR16: control register for SIO0 receive interrupt
42 * ICUCR17: control register for SIO0 send interrupt
43 */
44#define OPSPUT_LAN_IRQ_LAN (OPSPUT_LAN_PLD_IRQ_BASE + 1) /* LAN */
45#define OPSPUT_LAN_IRQ_I2C (OPSPUT_LAN_PLD_IRQ_BASE + 3) /* I2C */
46
47#define OPSPUT_LAN_ICUISTS __reg16(OPSPUT_LAN_BASE + 0xc0002)
48#define OPSPUT_LAN_ICUISTS_VECB_MASK (0xf000)
49#define OPSPUT_LAN_VECB(x) ((x) & OPSPUT_LAN_ICUISTS_VECB_MASK)
50#define OPSPUT_LAN_ICUISTS_ISN_MASK (0x07c0)
51#define OPSPUT_LAN_ICUISTS_ISN(x) ((x) & OPSPUT_LAN_ICUISTS_ISN_MASK)
52#define OPSPUT_LAN_ICUIREQ0 __reg16(OPSPUT_LAN_BASE + 0xc0004)
53#define OPSPUT_LAN_ICUCR1 __reg16(OPSPUT_LAN_BASE + 0xc0010)
54#define OPSPUT_LAN_ICUCR3 __reg16(OPSPUT_LAN_BASE + 0xc0014)
55
56#endif /* _OPSPUT_OPSPUT_LAN_H */
diff --git a/include/asm-m32r/opsput/opsput_lcd.h b/include/asm-m32r/opsput/opsput_lcd.h
new file mode 100644
index 000000000000..3a883e3d7187
--- /dev/null
+++ b/include/asm-m32r/opsput/opsput_lcd.h
@@ -0,0 +1,59 @@
1/*
2 * include/asm/opsput_lcd.h
3 *
4 * OPSPUT-LCD board
5 *
6 * Copyright (c) 2002 Takeo Takahashi
7 *
8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file "COPYING" in the main directory of
10 * this archive for more details.
11 *
12 * $Id: opsput_lcd.h,v 1.1 2004/07/27 06:54:20 sakugawa Exp $
13 */
14
15#ifndef _OPSPUT_OPSPUT_LCD_H
16#define _OPSPUT_OPSPUT_LCD_H
17
18#include <linux/config.h>
19
20#ifndef __ASSEMBLY__
21/*
22 * C functions use non-cache address.
23 */
24#define OPSPUT_LCD_BASE (0x10000000 /* + NONCACHE_OFFSET */)
25#else
26#define OPSPUT_LCD_BASE (0x10000000 + NONCACHE_OFFSET)
27#endif /* __ASSEMBLY__ */
28
29/*
30 * ICU
31 */
32#define OPSPUT_LCD_IRQ_BAT_INT (OPSPUT_LCD_PLD_IRQ_BASE + 1)
33#define OPSPUT_LCD_IRQ_USB_INT1 (OPSPUT_LCD_PLD_IRQ_BASE + 2)
34#define OPSPUT_LCD_IRQ_AUDT0 (OPSPUT_LCD_PLD_IRQ_BASE + 3)
35#define OPSPUT_LCD_IRQ_AUDT2 (OPSPUT_LCD_PLD_IRQ_BASE + 4)
36#define OPSPUT_LCD_IRQ_BATSIO_RCV (OPSPUT_LCD_PLD_IRQ_BASE + 16)
37#define OPSPUT_LCD_IRQ_BATSIO_SND (OPSPUT_LCD_PLD_IRQ_BASE + 17)
38#define OPSPUT_LCD_IRQ_ASNDSIO_RCV (OPSPUT_LCD_PLD_IRQ_BASE + 18)
39#define OPSPUT_LCD_IRQ_ASNDSIO_SND (OPSPUT_LCD_PLD_IRQ_BASE + 19)
40#define OPSPUT_LCD_IRQ_ACNLSIO_SND (OPSPUT_LCD_PLD_IRQ_BASE + 21)
41
42#define OPSPUT_LCD_ICUISTS __reg16(OPSPUT_LCD_BASE + 0x300002)
43#define OPSPUT_LCD_ICUISTS_VECB_MASK (0xf000)
44#define OPSPUT_LCD_VECB(x) ((x) & OPSPUT_LCD_ICUISTS_VECB_MASK)
45#define OPSPUT_LCD_ICUISTS_ISN_MASK (0x07c0)
46#define OPSPUT_LCD_ICUISTS_ISN(x) ((x) & OPSPUT_LCD_ICUISTS_ISN_MASK)
47#define OPSPUT_LCD_ICUIREQ0 __reg16(OPSPUT_LCD_BASE + 0x300004)
48#define OPSPUT_LCD_ICUIREQ1 __reg16(OPSPUT_LCD_BASE + 0x300006)
49#define OPSPUT_LCD_ICUCR1 __reg16(OPSPUT_LCD_BASE + 0x300020)
50#define OPSPUT_LCD_ICUCR2 __reg16(OPSPUT_LCD_BASE + 0x300022)
51#define OPSPUT_LCD_ICUCR3 __reg16(OPSPUT_LCD_BASE + 0x300024)
52#define OPSPUT_LCD_ICUCR4 __reg16(OPSPUT_LCD_BASE + 0x300026)
53#define OPSPUT_LCD_ICUCR16 __reg16(OPSPUT_LCD_BASE + 0x300030)
54#define OPSPUT_LCD_ICUCR17 __reg16(OPSPUT_LCD_BASE + 0x300032)
55#define OPSPUT_LCD_ICUCR18 __reg16(OPSPUT_LCD_BASE + 0x300034)
56#define OPSPUT_LCD_ICUCR19 __reg16(OPSPUT_LCD_BASE + 0x300036)
57#define OPSPUT_LCD_ICUCR21 __reg16(OPSPUT_LCD_BASE + 0x30003a)
58
59#endif /* _OPSPUT_OPSPUT_LCD_H */
diff --git a/include/asm-m32r/opsput/opsput_pld.h b/include/asm-m32r/opsput/opsput_pld.h
new file mode 100644
index 000000000000..2018e6925035
--- /dev/null
+++ b/include/asm-m32r/opsput/opsput_pld.h
@@ -0,0 +1,259 @@
1/*
2 * include/asm/opsput/opsput_pld.h
3 *
4 * Definitions for Programable Logic Device(PLD) on OPSPUT board.
5 *
6 * Copyright (c) 2002 Takeo Takahashi
7 *
8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file "COPYING" in the main directory of
10 * this archive for more details.
11 *
12 * $Id: opsput_pld.h,v 1.1 2004/07/27 06:54:20 sakugawa Exp $
13 */
14
15#ifndef _OPSPUT_OPSPUT_PLD_H
16#define _OPSPUT_OPSPUT_PLD_H
17
18#include <linux/config.h>
19
20#define PLD_PLAT_BASE 0x1cc00000
21
22#ifndef __ASSEMBLY__
23/*
24 * C functions use non-cache address.
25 */
26#define PLD_BASE (PLD_PLAT_BASE /* + NONCACHE_OFFSET */)
27#define __reg8 (volatile unsigned char *)
28#define __reg16 (volatile unsigned short *)
29#define __reg32 (volatile unsigned int *)
30#else
31#define PLD_BASE (PLD_PLAT_BASE + NONCACHE_OFFSET)
32#define __reg8
33#define __reg16
34#define __reg32
35#endif /* __ASSEMBLY__ */
36
37/* CFC */
38#define PLD_CFRSTCR __reg16(PLD_BASE + 0x0000)
39#define PLD_CFSTS __reg16(PLD_BASE + 0x0002)
40#define PLD_CFIMASK __reg16(PLD_BASE + 0x0004)
41#define PLD_CFBUFCR __reg16(PLD_BASE + 0x0006)
42#define PLD_CFVENCR __reg16(PLD_BASE + 0x0008)
43#define PLD_CFCR0 __reg16(PLD_BASE + 0x000a)
44#define PLD_CFCR1 __reg16(PLD_BASE + 0x000c)
45#define PLD_IDERSTCR __reg16(PLD_BASE + 0x0010)
46
47/* MMC */
48#define PLD_MMCCR __reg16(PLD_BASE + 0x4000)
49#define PLD_MMCMOD __reg16(PLD_BASE + 0x4002)
50#define PLD_MMCSTS __reg16(PLD_BASE + 0x4006)
51#define PLD_MMCBAUR __reg16(PLD_BASE + 0x400a)
52#define PLD_MMCCMDBCUT __reg16(PLD_BASE + 0x400c)
53#define PLD_MMCCDTBCUT __reg16(PLD_BASE + 0x400e)
54#define PLD_MMCDET __reg16(PLD_BASE + 0x4010)
55#define PLD_MMCWP __reg16(PLD_BASE + 0x4012)
56#define PLD_MMCWDATA __reg16(PLD_BASE + 0x5000)
57#define PLD_MMCRDATA __reg16(PLD_BASE + 0x6000)
58#define PLD_MMCCMDDATA __reg16(PLD_BASE + 0x7000)
59#define PLD_MMCRSPDATA __reg16(PLD_BASE + 0x7006)
60
61/* ICU
62 * ICUISTS: status register
63 * ICUIREQ0: request register
64 * ICUIREQ1: request register
65 * ICUCR3: control register for CFIREQ# interrupt
66 * ICUCR4: control register for CFC Card insert interrupt
67 * ICUCR5: control register for CFC Card eject interrupt
68 * ICUCR6: control register for external interrupt
69 * ICUCR11: control register for MMC Card insert/eject interrupt
70 * ICUCR13: control register for SC error interrupt
71 * ICUCR14: control register for SC receive interrupt
72 * ICUCR15: control register for SC send interrupt
73 * ICUCR16: control register for SIO0 receive interrupt
74 * ICUCR17: control register for SIO0 send interrupt
75 */
76#if !defined(CONFIG_PLAT_USRV)
77#define PLD_IRQ_INT0 (OPSPUT_PLD_IRQ_BASE + 0) /* None */
78#define PLD_IRQ_INT1 (OPSPUT_PLD_IRQ_BASE + 1) /* reserved */
79#define PLD_IRQ_INT2 (OPSPUT_PLD_IRQ_BASE + 2) /* reserved */
80#define PLD_IRQ_CFIREQ (OPSPUT_PLD_IRQ_BASE + 3) /* CF IREQ */
81#define PLD_IRQ_CFC_INSERT (OPSPUT_PLD_IRQ_BASE + 4) /* CF Insert */
82#define PLD_IRQ_CFC_EJECT (OPSPUT_PLD_IRQ_BASE + 5) /* CF Eject */
83#define PLD_IRQ_EXINT (OPSPUT_PLD_IRQ_BASE + 6) /* EXINT */
84#define PLD_IRQ_INT7 (OPSPUT_PLD_IRQ_BASE + 7) /* reserved */
85#define PLD_IRQ_INT8 (OPSPUT_PLD_IRQ_BASE + 8) /* reserved */
86#define PLD_IRQ_INT9 (OPSPUT_PLD_IRQ_BASE + 9) /* reserved */
87#define PLD_IRQ_INT10 (OPSPUT_PLD_IRQ_BASE + 10) /* reserved */
88#define PLD_IRQ_MMCCARD (OPSPUT_PLD_IRQ_BASE + 11) /* MMC Insert/Eject */
89#define PLD_IRQ_INT12 (OPSPUT_PLD_IRQ_BASE + 12) /* reserved */
90#define PLD_IRQ_SC_ERROR (OPSPUT_PLD_IRQ_BASE + 13) /* SC error */
91#define PLD_IRQ_SC_RCV (OPSPUT_PLD_IRQ_BASE + 14) /* SC receive */
92#define PLD_IRQ_SC_SND (OPSPUT_PLD_IRQ_BASE + 15) /* SC send */
93#define PLD_IRQ_SIO0_RCV (OPSPUT_PLD_IRQ_BASE + 16) /* SIO receive */
94#define PLD_IRQ_SIO0_SND (OPSPUT_PLD_IRQ_BASE + 17) /* SIO send */
95#define PLD_IRQ_INT18 (OPSPUT_PLD_IRQ_BASE + 18) /* reserved */
96#define PLD_IRQ_INT19 (OPSPUT_PLD_IRQ_BASE + 19) /* reserved */
97#define PLD_IRQ_INT20 (OPSPUT_PLD_IRQ_BASE + 20) /* reserved */
98#define PLD_IRQ_INT21 (OPSPUT_PLD_IRQ_BASE + 21) /* reserved */
99#define PLD_IRQ_INT22 (OPSPUT_PLD_IRQ_BASE + 22) /* reserved */
100#define PLD_IRQ_INT23 (OPSPUT_PLD_IRQ_BASE + 23) /* reserved */
101#define PLD_IRQ_INT24 (OPSPUT_PLD_IRQ_BASE + 24) /* reserved */
102#define PLD_IRQ_INT25 (OPSPUT_PLD_IRQ_BASE + 25) /* reserved */
103#define PLD_IRQ_INT26 (OPSPUT_PLD_IRQ_BASE + 26) /* reserved */
104#define PLD_IRQ_INT27 (OPSPUT_PLD_IRQ_BASE + 27) /* reserved */
105#define PLD_IRQ_INT28 (OPSPUT_PLD_IRQ_BASE + 28) /* reserved */
106#define PLD_IRQ_INT29 (OPSPUT_PLD_IRQ_BASE + 29) /* reserved */
107#define PLD_IRQ_INT30 (OPSPUT_PLD_IRQ_BASE + 30) /* reserved */
108#define PLD_IRQ_INT31 (OPSPUT_PLD_IRQ_BASE + 31) /* reserved */
109
110#else /* CONFIG_PLAT_USRV */
111
112#define PLD_IRQ_INT0 (OPSPUT_PLD_IRQ_BASE + 0) /* None */
113#define PLD_IRQ_INT1 (OPSPUT_PLD_IRQ_BASE + 1) /* reserved */
114#define PLD_IRQ_INT2 (OPSPUT_PLD_IRQ_BASE + 2) /* reserved */
115#define PLD_IRQ_CF0 (OPSPUT_PLD_IRQ_BASE + 3) /* CF0# */
116#define PLD_IRQ_CF1 (OPSPUT_PLD_IRQ_BASE + 4) /* CF1# */
117#define PLD_IRQ_CF2 (OPSPUT_PLD_IRQ_BASE + 5) /* CF2# */
118#define PLD_IRQ_CF3 (OPSPUT_PLD_IRQ_BASE + 6) /* CF3# */
119#define PLD_IRQ_CF4 (OPSPUT_PLD_IRQ_BASE + 7) /* CF4# */
120#define PLD_IRQ_INT8 (OPSPUT_PLD_IRQ_BASE + 8) /* reserved */
121#define PLD_IRQ_INT9 (OPSPUT_PLD_IRQ_BASE + 9) /* reserved */
122#define PLD_IRQ_INT10 (OPSPUT_PLD_IRQ_BASE + 10) /* reserved */
123#define PLD_IRQ_INT11 (OPSPUT_PLD_IRQ_BASE + 11) /* reserved */
124#define PLD_IRQ_UART0 (OPSPUT_PLD_IRQ_BASE + 12) /* UARTIRQ0 */
125#define PLD_IRQ_UART1 (OPSPUT_PLD_IRQ_BASE + 13) /* UARTIRQ1 */
126#define PLD_IRQ_INT14 (OPSPUT_PLD_IRQ_BASE + 14) /* reserved */
127#define PLD_IRQ_INT15 (OPSPUT_PLD_IRQ_BASE + 15) /* reserved */
128#define PLD_IRQ_SNDINT (OPSPUT_PLD_IRQ_BASE + 16) /* SNDINT# */
129#define PLD_IRQ_INT17 (OPSPUT_PLD_IRQ_BASE + 17) /* reserved */
130#define PLD_IRQ_INT18 (OPSPUT_PLD_IRQ_BASE + 18) /* reserved */
131#define PLD_IRQ_INT19 (OPSPUT_PLD_IRQ_BASE + 19) /* reserved */
132#define PLD_IRQ_INT20 (OPSPUT_PLD_IRQ_BASE + 20) /* reserved */
133#define PLD_IRQ_INT21 (OPSPUT_PLD_IRQ_BASE + 21) /* reserved */
134#define PLD_IRQ_INT22 (OPSPUT_PLD_IRQ_BASE + 22) /* reserved */
135#define PLD_IRQ_INT23 (OPSPUT_PLD_IRQ_BASE + 23) /* reserved */
136#define PLD_IRQ_INT24 (OPSPUT_PLD_IRQ_BASE + 24) /* reserved */
137#define PLD_IRQ_INT25 (OPSPUT_PLD_IRQ_BASE + 25) /* reserved */
138#define PLD_IRQ_INT26 (OPSPUT_PLD_IRQ_BASE + 26) /* reserved */
139#define PLD_IRQ_INT27 (OPSPUT_PLD_IRQ_BASE + 27) /* reserved */
140#define PLD_IRQ_INT28 (OPSPUT_PLD_IRQ_BASE + 28) /* reserved */
141#define PLD_IRQ_INT29 (OPSPUT_PLD_IRQ_BASE + 29) /* reserved */
142#define PLD_IRQ_INT30 (OPSPUT_PLD_IRQ_BASE + 30) /* reserved */
143
144#endif /* CONFIG_PLAT_USRV */
145
146#define PLD_ICUISTS __reg16(PLD_BASE + 0x8002)
147#define PLD_ICUISTS_VECB_MASK (0xf000)
148#define PLD_ICUISTS_VECB(x) ((x) & PLD_ICUISTS_VECB_MASK)
149#define PLD_ICUISTS_ISN_MASK (0x07c0)
150#define PLD_ICUISTS_ISN(x) ((x) & PLD_ICUISTS_ISN_MASK)
151#define PLD_ICUIREQ0 __reg16(PLD_BASE + 0x8004)
152#define PLD_ICUIREQ1 __reg16(PLD_BASE + 0x8006)
153#define PLD_ICUCR1 __reg16(PLD_BASE + 0x8100)
154#define PLD_ICUCR2 __reg16(PLD_BASE + 0x8102)
155#define PLD_ICUCR3 __reg16(PLD_BASE + 0x8104)
156#define PLD_ICUCR4 __reg16(PLD_BASE + 0x8106)
157#define PLD_ICUCR5 __reg16(PLD_BASE + 0x8108)
158#define PLD_ICUCR6 __reg16(PLD_BASE + 0x810a)
159#define PLD_ICUCR7 __reg16(PLD_BASE + 0x810c)
160#define PLD_ICUCR8 __reg16(PLD_BASE + 0x810e)
161#define PLD_ICUCR9 __reg16(PLD_BASE + 0x8110)
162#define PLD_ICUCR10 __reg16(PLD_BASE + 0x8112)
163#define PLD_ICUCR11 __reg16(PLD_BASE + 0x8114)
164#define PLD_ICUCR12 __reg16(PLD_BASE + 0x8116)
165#define PLD_ICUCR13 __reg16(PLD_BASE + 0x8118)
166#define PLD_ICUCR14 __reg16(PLD_BASE + 0x811a)
167#define PLD_ICUCR15 __reg16(PLD_BASE + 0x811c)
168#define PLD_ICUCR16 __reg16(PLD_BASE + 0x811e)
169#define PLD_ICUCR17 __reg16(PLD_BASE + 0x8120)
170#define PLD_ICUCR_IEN (0x1000)
171#define PLD_ICUCR_IREQ (0x0100)
172#define PLD_ICUCR_ISMOD00 (0x0000) /* Low edge */
173#define PLD_ICUCR_ISMOD01 (0x0010) /* Low level */
174#define PLD_ICUCR_ISMOD02 (0x0020) /* High edge */
175#define PLD_ICUCR_ISMOD03 (0x0030) /* High level */
176#define PLD_ICUCR_ILEVEL0 (0x0000)
177#define PLD_ICUCR_ILEVEL1 (0x0001)
178#define PLD_ICUCR_ILEVEL2 (0x0002)
179#define PLD_ICUCR_ILEVEL3 (0x0003)
180#define PLD_ICUCR_ILEVEL4 (0x0004)
181#define PLD_ICUCR_ILEVEL5 (0x0005)
182#define PLD_ICUCR_ILEVEL6 (0x0006)
183#define PLD_ICUCR_ILEVEL7 (0x0007)
184
185/* Power Control of MMC and CF */
186#define PLD_CPCR __reg16(PLD_BASE + 0x14000)
187#define PLD_CPCR_CF 0x0001
188#define PLD_CPCR_MMC 0x0002
189
190/* LED Control
191 *
192 * 1: DIP swich side
193 * 2: Reset switch side
194 */
195#define PLD_IOLEDCR __reg16(PLD_BASE + 0x14002)
196#define PLD_IOLED_1_ON 0x001
197#define PLD_IOLED_1_OFF 0x000
198#define PLD_IOLED_2_ON 0x002
199#define PLD_IOLED_2_OFF 0x000
200
201/* DIP Switch
202 * 0: Write-protect of Flash Memory (0:protected, 1:non-protected)
203 * 1: -
204 * 2: -
205 * 3: -
206 */
207#define PLD_IOSWSTS __reg16(PLD_BASE + 0x14004)
208#define PLD_IOSWSTS_IOSW2 0x0200
209#define PLD_IOSWSTS_IOSW1 0x0100
210#define PLD_IOSWSTS_IOWP0 0x0001
211
212/* CRC */
213#define PLD_CRC7DATA __reg16(PLD_BASE + 0x18000)
214#define PLD_CRC7INDATA __reg16(PLD_BASE + 0x18002)
215#define PLD_CRC16DATA __reg16(PLD_BASE + 0x18004)
216#define PLD_CRC16INDATA __reg16(PLD_BASE + 0x18006)
217#define PLD_CRC16ADATA __reg16(PLD_BASE + 0x18008)
218#define PLD_CRC16AINDATA __reg16(PLD_BASE + 0x1800a)
219
220/* RTC */
221#define PLD_RTCCR __reg16(PLD_BASE + 0x1c000)
222#define PLD_RTCBAUR __reg16(PLD_BASE + 0x1c002)
223#define PLD_RTCWRDATA __reg16(PLD_BASE + 0x1c004)
224#define PLD_RTCRDDATA __reg16(PLD_BASE + 0x1c006)
225#define PLD_RTCRSTODT __reg16(PLD_BASE + 0x1c008)
226
227/* SIO0 */
228#define PLD_ESIO0CR __reg16(PLD_BASE + 0x20000)
229#define PLD_ESIO0CR_TXEN 0x0001
230#define PLD_ESIO0CR_RXEN 0x0002
231#define PLD_ESIO0MOD0 __reg16(PLD_BASE + 0x20002)
232#define PLD_ESIO0MOD0_CTSS 0x0040
233#define PLD_ESIO0MOD0_RTSS 0x0080
234#define PLD_ESIO0MOD1 __reg16(PLD_BASE + 0x20004)
235#define PLD_ESIO0MOD1_LMFS 0x0010
236#define PLD_ESIO0STS __reg16(PLD_BASE + 0x20006)
237#define PLD_ESIO0STS_TEMP 0x0001
238#define PLD_ESIO0STS_TXCP 0x0002
239#define PLD_ESIO0STS_RXCP 0x0004
240#define PLD_ESIO0STS_TXSC 0x0100
241#define PLD_ESIO0STS_RXSC 0x0200
242#define PLD_ESIO0STS_TXREADY (PLD_ESIO0STS_TXCP | PLD_ESIO0STS_TEMP)
243#define PLD_ESIO0INTCR __reg16(PLD_BASE + 0x20008)
244#define PLD_ESIO0INTCR_TXIEN 0x0002
245#define PLD_ESIO0INTCR_RXCEN 0x0004
246#define PLD_ESIO0BAUR __reg16(PLD_BASE + 0x2000a)
247#define PLD_ESIO0TXB __reg16(PLD_BASE + 0x2000c)
248#define PLD_ESIO0RXB __reg16(PLD_BASE + 0x2000e)
249
250/* SIM Card */
251#define PLD_SCCR __reg16(PLD_BASE + 0x38000)
252#define PLD_SCMOD __reg16(PLD_BASE + 0x38004)
253#define PLD_SCSTS __reg16(PLD_BASE + 0x38006)
254#define PLD_SCINTCR __reg16(PLD_BASE + 0x38008)
255#define PLD_SCBAUR __reg16(PLD_BASE + 0x3800a)
256#define PLD_SCTXB __reg16(PLD_BASE + 0x3800c)
257#define PLD_SCRXB __reg16(PLD_BASE + 0x3800e)
258
259#endif /* _OPSPUT_OPSPUT_PLD.H */
diff --git a/include/asm-m32r/page.h b/include/asm-m32r/page.h
new file mode 100644
index 000000000000..1c6abb9f3f1f
--- /dev/null
+++ b/include/asm-m32r/page.h
@@ -0,0 +1,115 @@
1#ifndef _ASM_M32R_PAGE_H
2#define _ASM_M32R_PAGE_H
3
4#include <linux/config.h>
5
6/* PAGE_SHIFT determines the page size */
7#define PAGE_SHIFT 12
8#define PAGE_SIZE (1UL << PAGE_SHIFT)
9#define PAGE_MASK (~(PAGE_SIZE-1))
10
11#ifdef __KERNEL__
12#ifndef __ASSEMBLY__
13
14extern void clear_page(void *to);
15extern void copy_page(void *to, void *from);
16
17#define clear_user_page(page, vaddr, pg) clear_page(page)
18#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
19
20#define alloc_zeroed_user_highpage(vma, vaddr) alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vma, vaddr)
21#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
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 pmd; } pmd_t;
28typedef struct { unsigned long pgd; } pgd_t;
29#define pte_val(x) ((x).pte)
30#define PTE_MASK PAGE_MASK
31
32typedef struct { unsigned long pgprot; } pgprot_t;
33
34#define pmd_val(x) ((x).pmd)
35#define pgd_val(x) ((x).pgd)
36#define pgprot_val(x) ((x).pgprot)
37
38#define __pte(x) ((pte_t) { (x) } )
39#define __pmd(x) ((pmd_t) { (x) } )
40#define __pgd(x) ((pgd_t) { (x) } )
41#define __pgprot(x) ((pgprot_t) { (x) } )
42
43#endif /* !__ASSEMBLY__ */
44
45/* to align the pointer to the (next) page boundary */
46#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
47
48/*
49 * This handles the memory map.. We could make this a config
50 * option, but too many people screw it up, and too few need
51 * it.
52 *
53 * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
54 * a virtual address space of one gigabyte, which limits the
55 * amount of physical memory you can use to about 950MB.
56 *
57 * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
58 * and CONFIG_HIGHMEM64G options in the kernel configuration.
59 */
60
61
62/* This handles the memory map.. */
63
64#ifndef __ASSEMBLY__
65
66/* Pure 2^n version of get_order */
67static __inline__ int get_order(unsigned long size)
68{
69 int order;
70
71 size = (size - 1) >> (PAGE_SHIFT - 1);
72 order = -1;
73 do {
74 size >>= 1;
75 order++;
76 } while (size);
77
78 return order;
79}
80
81#endif /* __ASSEMBLY__ */
82
83#define __MEMORY_START CONFIG_MEMORY_START
84#define __MEMORY_SIZE CONFIG_MEMORY_SIZE
85
86#ifdef CONFIG_MMU
87#define __PAGE_OFFSET (0x80000000)
88#else
89#define __PAGE_OFFSET (0x00000000)
90#endif
91
92#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
93#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET)
94#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET))
95
96#ifndef CONFIG_DISCONTIGMEM
97#define PFN_BASE (CONFIG_MEMORY_START >> PAGE_SHIFT)
98#define pfn_to_page(pfn) (mem_map + ((pfn) - PFN_BASE))
99#define page_to_pfn(page) \
100 ((unsigned long)((page) - mem_map) + PFN_BASE)
101#define pfn_valid(pfn) (((pfn) - PFN_BASE) < max_mapnr)
102#endif /* !CONFIG_DISCONTIGMEM */
103
104#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
105#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
106
107#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
108 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC )
109
110#define devmem_is_allowed(x) 1
111
112#endif /* __KERNEL__ */
113
114#endif /* _ASM_M32R_PAGE_H */
115
diff --git a/include/asm-m32r/param.h b/include/asm-m32r/param.h
new file mode 100644
index 000000000000..750b938ccb52
--- /dev/null
+++ b/include/asm-m32r/param.h
@@ -0,0 +1,27 @@
1#ifndef _ASM_M32R_PARAM_H
2#define _ASM_M32R_PARAM_H
3
4/* $Id$ */
5
6/* orig : i386 2.5.67 */
7
8#ifdef __KERNEL__
9# define HZ 100 /* Internal kernel timer frequency */
10# define USER_HZ 100 /* .. some user interfaces are in "ticks" */
11# define CLOCKS_PER_SEC (USER_HZ) /* like times() */
12#endif
13
14#ifndef HZ
15#define HZ 100
16#endif
17
18#define EXEC_PAGESIZE 4096
19
20#ifndef NOGROUP
21#define NOGROUP (-1)
22#endif
23
24#define MAXHOSTNAMELEN 64 /* max length of hostname */
25
26#endif /* _ASM_M32R_PARAM_H */
27
diff --git a/include/asm-m32r/pci.h b/include/asm-m32r/pci.h
new file mode 100644
index 000000000000..00d7b6f39a33
--- /dev/null
+++ b/include/asm-m32r/pci.h
@@ -0,0 +1,10 @@
1#ifndef _ASM_M32R_PCI_H
2#define _ASM_M32R_PCI_H
3
4/* $Id$ */
5
6#include <asm-generic/pci.h>
7
8#define PCI_DMA_BUS_IS_PHYS (1)
9
10#endif /* _ASM_M32R_PCI_H */
diff --git a/include/asm-m32r/percpu.h b/include/asm-m32r/percpu.h
new file mode 100644
index 000000000000..e3169301fe66
--- /dev/null
+++ b/include/asm-m32r/percpu.h
@@ -0,0 +1,6 @@
1#ifndef __ARCH_M32R_PERCPU__
2#define __ARCH_M32R_PERCPU__
3
4#include <asm-generic/percpu.h>
5
6#endif /* __ARCH_M32R_PERCPU__ */
diff --git a/include/asm-m32r/pgalloc.h b/include/asm-m32r/pgalloc.h
new file mode 100644
index 000000000000..6da309b6fda7
--- /dev/null
+++ b/include/asm-m32r/pgalloc.h
@@ -0,0 +1,78 @@
1#ifndef _ASM_M32R_PGALLOC_H
2#define _ASM_M32R_PGALLOC_H
3
4/* $Id$ */
5
6#include <linux/config.h>
7#include <linux/mm.h>
8
9#include <asm/io.h>
10
11#define pmd_populate_kernel(mm, pmd, pte) \
12 set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
13
14static __inline__ void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
15 struct page *pte)
16{
17 set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte)));
18}
19
20/*
21 * Allocate and free page tables.
22 */
23static __inline__ pgd_t *pgd_alloc(struct mm_struct *mm)
24{
25 pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
26
27 return pgd;
28}
29
30static __inline__ void pgd_free(pgd_t *pgd)
31{
32 free_page((unsigned long)pgd);
33}
34
35static __inline__ pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
36 unsigned long address)
37{
38 pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
39
40 return pte;
41}
42
43static __inline__ struct page *pte_alloc_one(struct mm_struct *mm,
44 unsigned long address)
45{
46 struct page *pte = alloc_page(GFP_KERNEL|__GFP_ZERO);
47
48
49 return pte;
50}
51
52static __inline__ void pte_free_kernel(pte_t *pte)
53{
54 free_page((unsigned long)pte);
55}
56
57static __inline__ void pte_free(struct page *pte)
58{
59 __free_page(pte);
60}
61
62#define __pte_free_tlb(tlb, pte) pte_free((pte))
63
64/*
65 * allocating and freeing a pmd is trivial: the 1-entry pmd is
66 * inside the pgd, so has no extra memory associated with it.
67 * (In the PAE case we free the pmds as part of the pgd.)
68 */
69
70#define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
71#define pmd_free(x) do { } while (0)
72#define __pmd_free_tlb(tlb, x) do { } while (0)
73#define pgd_populate(mm, pmd, pte) BUG()
74
75#define check_pgt_cache() do { } while (0)
76
77#endif /* _ASM_M32R_PGALLOC_H */
78
diff --git a/include/asm-m32r/pgtable-2level.h b/include/asm-m32r/pgtable-2level.h
new file mode 100644
index 000000000000..861727c20e8f
--- /dev/null
+++ b/include/asm-m32r/pgtable-2level.h
@@ -0,0 +1,78 @@
1#ifndef _ASM_M32R_PGTABLE_2LEVEL_H
2#define _ASM_M32R_PGTABLE_2LEVEL_H
3
4#ifdef __KERNEL__
5
6#include <linux/config.h>
7
8/*
9 * traditional M32R two-level paging structure:
10 */
11
12#define PGDIR_SHIFT 22
13#define PTRS_PER_PGD 1024
14
15/*
16 * the M32R is two-level, so we don't really have any
17 * PMD directory physically.
18 */
19#define PMD_SHIFT 22
20#define PTRS_PER_PMD 1
21
22#define PTRS_PER_PTE 1024
23
24#define pte_ERROR(e) \
25 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
26#define pmd_ERROR(e) \
27 printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
28#define pgd_ERROR(e) \
29 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
30
31/*
32 * The "pgd_xxx()" functions here are trivial for a folded two-level
33 * setup: the pgd is never bad, and a pmd always exists (as it's folded
34 * into the pgd entry)
35 */
36static inline int pgd_none(pgd_t pgd) { return 0; }
37static inline int pgd_bad(pgd_t pgd) { return 0; }
38static inline int pgd_present(pgd_t pgd) { return 1; }
39#define pgd_clear(xp) do { } while (0)
40
41/*
42 * Certain architectures need to do special things when PTEs
43 * within a page table are directly modified. Thus, the following
44 * hook is made available.
45 */
46#define set_pte(pteptr, pteval) (*(pteptr) = pteval)
47#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
48#define set_pte_atomic(pteptr, pteval) set_pte(pteptr, pteval)
49/*
50 * (pmds are folded into pgds so this doesnt get actually called,
51 * but the define is needed for a generic inline function.)
52 */
53#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
54#define set_pgd(pgdptr, pgdval) (*(pgdptr) = pgdval)
55
56#define pgd_page(pgd) \
57((unsigned long) __va(pgd_val(pgd) & PAGE_MASK))
58
59static inline pmd_t *pmd_offset(pgd_t * dir, unsigned long address)
60{
61 return (pmd_t *) dir;
62}
63
64#define ptep_get_and_clear(mm,addr,xp) __pte(xchg(&(xp)->pte, 0))
65#define pte_same(a, b) (pte_val(a) == pte_val(b))
66#define pte_page(x) pfn_to_page(pte_pfn(x))
67#define pte_none(x) (!pte_val(x))
68#define pte_pfn(x) (pte_val(x) >> PAGE_SHIFT)
69#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
70#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
71
72#define PTE_FILE_MAX_BITS 29
73#define pte_to_pgoff(pte) (((pte_val(pte) >> 2) & 0xef) | (((pte_val(pte) >> 10)) << 7))
74#define pgoff_to_pte(off) ((pte_t) { (((off) & 0xef) << 2) | (((off) >> 7) << 10) | _PAGE_FILE })
75
76#endif /* __KERNEL__ */
77
78#endif /* _ASM_M32R_PGTABLE_2LEVEL_H */
diff --git a/include/asm-m32r/pgtable.h b/include/asm-m32r/pgtable.h
new file mode 100644
index 000000000000..70a0eb68fdf6
--- /dev/null
+++ b/include/asm-m32r/pgtable.h
@@ -0,0 +1,400 @@
1#ifndef _ASM_M32R_PGTABLE_H
2#define _ASM_M32R_PGTABLE_H
3
4#include <asm-generic/4level-fixup.h>
5
6#ifdef __KERNEL__
7/*
8 * The Linux memory management assumes a three-level page table setup. On
9 * the M32R, we use that, but "fold" the mid level into the top-level page
10 * table, so that we physically have the same two-level page table as the
11 * M32R mmu expects.
12 *
13 * This file contains the functions and defines necessary to modify and use
14 * the M32R page table tree.
15 */
16
17/* CAUTION!: If you change macro definitions in this file, you might have to
18 * change arch/m32r/mmu.S manually.
19 */
20
21#ifndef __ASSEMBLY__
22
23#include <linux/config.h>
24#include <linux/threads.h>
25#include <asm/processor.h>
26#include <asm/addrspace.h>
27#include <asm/bitops.h>
28#include <asm/page.h>
29
30extern pgd_t swapper_pg_dir[1024];
31extern void paging_init(void);
32
33/*
34 * ZERO_PAGE is a global shared page that is always zero: used
35 * for zero-mapped memory areas etc..
36 */
37extern unsigned long empty_zero_page[1024];
38#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
39
40#endif /* !__ASSEMBLY__ */
41
42#ifndef __ASSEMBLY__
43#include <asm/pgtable-2level.h>
44#endif
45
46#define pgtable_cache_init() do { } while (0)
47
48#define PMD_SIZE (1UL << PMD_SHIFT)
49#define PMD_MASK (~(PMD_SIZE - 1))
50#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
51#define PGDIR_MASK (~(PGDIR_SIZE - 1))
52
53#define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE)
54#define FIRST_USER_PGD_NR 0
55
56#ifndef __ASSEMBLY__
57/* Just any arbitrary offset to the start of the vmalloc VM area: the
58 * current 8MB value just means that there will be a 8MB "hole" after the
59 * physical memory until the kernel virtual memory starts. That means that
60 * any out-of-bounds memory accesses will hopefully be caught.
61 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
62 * area for the same reason. ;)
63 */
64#define VMALLOC_START KSEG2
65#define VMALLOC_END KSEG3
66
67/*
68 * M32R TLB format
69 *
70 * [0] [1:19] [20:23] [24:31]
71 * +-----------------------+----+-------------+
72 * | VPN |0000| ASID |
73 * +-----------------------+----+-------------+
74 * +-+---------------------+----+-+---+-+-+-+-+
75 * |0 PPN |0000|N|AC |L|G|V| |
76 * +-+---------------------+----+-+---+-+-+-+-+
77 * RWX
78 */
79
80#define _PAGE_BIT_DIRTY 0 /* software: page changed */
81#define _PAGE_BIT_FILE 0 /* when !present: nonlinear file
82 mapping */
83#define _PAGE_BIT_PRESENT 1 /* Valid: page is valid */
84#define _PAGE_BIT_GLOBAL 2 /* Global */
85#define _PAGE_BIT_LARGE 3 /* Large */
86#define _PAGE_BIT_EXEC 4 /* Execute */
87#define _PAGE_BIT_WRITE 5 /* Write */
88#define _PAGE_BIT_READ 6 /* Read */
89#define _PAGE_BIT_NONCACHABLE 7 /* Non cachable */
90#define _PAGE_BIT_ACCESSED 8 /* software: page referenced */
91#define _PAGE_BIT_PROTNONE 9 /* software: if not present */
92
93#define _PAGE_DIRTY (1UL << _PAGE_BIT_DIRTY)
94#define _PAGE_FILE (1UL << _PAGE_BIT_FILE)
95#define _PAGE_PRESENT (1UL << _PAGE_BIT_PRESENT)
96#define _PAGE_GLOBAL (1UL << _PAGE_BIT_GLOBAL)
97#define _PAGE_LARGE (1UL << _PAGE_BIT_LARGE)
98#define _PAGE_EXEC (1UL << _PAGE_BIT_EXEC)
99#define _PAGE_WRITE (1UL << _PAGE_BIT_WRITE)
100#define _PAGE_READ (1UL << _PAGE_BIT_READ)
101#define _PAGE_NONCACHABLE (1UL << _PAGE_BIT_NONCACHABLE)
102#define _PAGE_ACCESSED (1UL << _PAGE_BIT_ACCESSED)
103#define _PAGE_PROTNONE (1UL << _PAGE_BIT_PROTNONE)
104
105#define _PAGE_TABLE \
106 ( _PAGE_PRESENT | _PAGE_WRITE | _PAGE_READ | _PAGE_ACCESSED \
107 | _PAGE_DIRTY )
108#define _KERNPG_TABLE \
109 ( _PAGE_PRESENT | _PAGE_WRITE | _PAGE_READ | _PAGE_ACCESSED \
110 | _PAGE_DIRTY )
111#define _PAGE_CHG_MASK \
112 ( PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY )
113
114#ifdef CONFIG_MMU
115#define PAGE_NONE \
116 __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
117#define PAGE_SHARED \
118 __pgprot(_PAGE_PRESENT | _PAGE_WRITE | _PAGE_READ | _PAGE_ACCESSED)
119#define PAGE_SHARED_EXEC \
120 __pgprot(_PAGE_PRESENT | _PAGE_EXEC | _PAGE_WRITE | _PAGE_READ \
121 | _PAGE_ACCESSED)
122#define PAGE_COPY \
123 __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_ACCESSED)
124#define PAGE_COPY_EXEC \
125 __pgprot(_PAGE_PRESENT | _PAGE_EXEC | _PAGE_READ | _PAGE_ACCESSED)
126#define PAGE_READONLY \
127 __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_ACCESSED)
128#define PAGE_READONLY_EXEC \
129 __pgprot(_PAGE_PRESENT | _PAGE_EXEC | _PAGE_READ | _PAGE_ACCESSED)
130
131#define __PAGE_KERNEL \
132 ( _PAGE_PRESENT | _PAGE_EXEC | _PAGE_WRITE | _PAGE_READ | _PAGE_DIRTY \
133 | _PAGE_ACCESSED )
134#define __PAGE_KERNEL_RO ( __PAGE_KERNEL & ~_PAGE_WRITE )
135#define __PAGE_KERNEL_NOCACHE ( __PAGE_KERNEL | _PAGE_NONCACHABLE)
136
137#define MAKE_GLOBAL(x) __pgprot((x) | _PAGE_GLOBAL)
138
139#define PAGE_KERNEL MAKE_GLOBAL(__PAGE_KERNEL)
140#define PAGE_KERNEL_RO MAKE_GLOBAL(__PAGE_KERNEL_RO)
141#define PAGE_KERNEL_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_NOCACHE)
142
143#else
144#define PAGE_NONE __pgprot(0)
145#define PAGE_SHARED __pgprot(0)
146#define PAGE_SHARED_EXEC __pgprot(0)
147#define PAGE_COPY __pgprot(0)
148#define PAGE_COPY_EXEC __pgprot(0)
149#define PAGE_READONLY __pgprot(0)
150#define PAGE_READONLY_EXEC __pgprot(0)
151
152#define PAGE_KERNEL __pgprot(0)
153#define PAGE_KERNEL_RO __pgprot(0)
154#define PAGE_KERNEL_NOCACHE __pgprot(0)
155#endif /* CONFIG_MMU */
156
157 /* xwr */
158#define __P000 PAGE_NONE
159#define __P001 PAGE_READONLY
160#define __P010 PAGE_COPY
161#define __P011 PAGE_COPY
162#define __P100 PAGE_READONLY_EXEC
163#define __P101 PAGE_READONLY_EXEC
164#define __P110 PAGE_COPY_EXEC
165#define __P111 PAGE_COPY_EXEC
166
167#define __S000 PAGE_NONE
168#define __S001 PAGE_READONLY
169#define __S010 PAGE_SHARED
170#define __S011 PAGE_SHARED
171#define __S100 PAGE_READONLY_EXEC
172#define __S101 PAGE_READONLY_EXEC
173#define __S110 PAGE_SHARED_EXEC
174#define __S111 PAGE_SHARED_EXEC
175
176/* page table for 0-4MB for everybody */
177
178#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE))
179#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
180
181#define pmd_none(x) (!pmd_val(x))
182#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
183#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
184#define pmd_bad(x) ((pmd_val(x) & ~PAGE_MASK) != _KERNPG_TABLE)
185
186#define pages_to_mb(x) ((x) >> (20 - PAGE_SHIFT))
187
188/*
189 * The following only work if pte_present() is true.
190 * Undefined behaviour if not..
191 */
192static inline int pte_read(pte_t pte)
193{
194 return pte_val(pte) & _PAGE_READ;
195}
196
197static inline int pte_exec(pte_t pte)
198{
199 return pte_val(pte) & _PAGE_EXEC;
200}
201
202static inline int pte_dirty(pte_t pte)
203{
204 return pte_val(pte) & _PAGE_DIRTY;
205}
206
207static inline int pte_young(pte_t pte)
208{
209 return pte_val(pte) & _PAGE_ACCESSED;
210}
211
212static inline int pte_write(pte_t pte)
213{
214 return pte_val(pte) & _PAGE_WRITE;
215}
216
217/*
218 * The following only works if pte_present() is not true.
219 */
220static inline int pte_file(pte_t pte)
221{
222 return pte_val(pte) & _PAGE_FILE;
223}
224
225static inline pte_t pte_rdprotect(pte_t pte)
226{
227 pte_val(pte) &= ~_PAGE_READ;
228 return pte;
229}
230
231static inline pte_t pte_exprotect(pte_t pte)
232{
233 pte_val(pte) &= ~_PAGE_EXEC;
234 return pte;
235}
236
237static inline pte_t pte_mkclean(pte_t pte)
238{
239 pte_val(pte) &= ~_PAGE_DIRTY;
240 return pte;
241}
242
243static inline pte_t pte_mkold(pte_t pte)
244{
245 pte_val(pte) &= ~_PAGE_ACCESSED;
246 return pte;
247}
248
249static inline pte_t pte_wrprotect(pte_t pte)
250{
251 pte_val(pte) &= ~_PAGE_WRITE;
252 return pte;
253}
254
255static inline pte_t pte_mkread(pte_t pte)
256{
257 pte_val(pte) |= _PAGE_READ;
258 return pte;
259}
260
261static inline pte_t pte_mkexec(pte_t pte)
262{
263 pte_val(pte) |= _PAGE_EXEC;
264 return pte;
265}
266
267static inline pte_t pte_mkdirty(pte_t pte)
268{
269 pte_val(pte) |= _PAGE_DIRTY;
270 return pte;
271}
272
273static inline pte_t pte_mkyoung(pte_t pte)
274{
275 pte_val(pte) |= _PAGE_ACCESSED;
276 return pte;
277}
278
279static inline pte_t pte_mkwrite(pte_t pte)
280{
281 pte_val(pte) |= _PAGE_WRITE;
282 return pte;
283}
284
285static inline int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
286{
287 return test_and_clear_bit(_PAGE_BIT_DIRTY, ptep);
288}
289
290static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
291{
292 return test_and_clear_bit(_PAGE_BIT_ACCESSED, ptep);
293}
294
295static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
296{
297 clear_bit(_PAGE_BIT_WRITE, ptep);
298}
299
300/*
301 * Macro and implementation to make a page protection as uncachable.
302 */
303static inline pgprot_t pgprot_noncached(pgprot_t _prot)
304{
305 unsigned long prot = pgprot_val(_prot);
306
307 prot |= _PAGE_NONCACHABLE;
308 return __pgprot(prot);
309}
310
311#define pgprot_writecombine(prot) pgprot_noncached(prot)
312
313/*
314 * Conversion functions: convert a page and protection to a page entry,
315 * and a page entry and page directory to the page they refer to.
316 */
317#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), pgprot)
318
319static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
320{
321 set_pte(&pte, __pte((pte_val(pte) & _PAGE_CHG_MASK) \
322 | pgprot_val(newprot)));
323
324 return pte;
325}
326
327#define page_pte(page) page_pte_prot(page, __pgprot(0))
328
329/*
330 * Conversion functions: convert a page and protection to a page entry,
331 * and a page entry and page directory to the page they refer to.
332 */
333
334static inline void pmd_set(pmd_t * pmdp, pte_t * ptep)
335{
336 pmd_val(*pmdp) = (((unsigned long) ptep) & PAGE_MASK);
337}
338
339#define pmd_page_kernel(pmd) \
340 ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
341
342#ifndef CONFIG_DISCONTIGMEM
343#define pmd_page(pmd) (mem_map + ((pmd_val(pmd) >> PAGE_SHIFT) - PFN_BASE))
344#endif /* !CONFIG_DISCONTIGMEM */
345
346/* to find an entry in a page-table-directory. */
347#define pgd_index(address) \
348 (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
349
350#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
351
352/* to find an entry in a kernel page-table-directory */
353#define pgd_offset_k(address) pgd_offset(&init_mm, address)
354
355#define pmd_index(address) \
356 (((address) >> PMD_SHIFT) & (PTRS_PER_PMD - 1))
357
358#define pte_index(address) \
359 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
360#define pte_offset_kernel(dir, address) \
361 ((pte_t *)pmd_page_kernel(*(dir)) + pte_index(address))
362#define pte_offset_map(dir, address) \
363 ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
364#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
365#define pte_unmap(pte) do { } while (0)
366#define pte_unmap_nested(pte) do { } while (0)
367
368/* Encode and de-code a swap entry */
369#define __swp_type(x) (((x).val >> 2) & 0x3f)
370#define __swp_offset(x) ((x).val >> 10)
371#define __swp_entry(type, offset) \
372 ((swp_entry_t) { ((type) << 2) | ((offset) << 10) })
373#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
374#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
375
376#endif /* !__ASSEMBLY__ */
377
378/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
379#define kern_addr_valid(addr) (1)
380
381#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
382 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
383
384#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
385 remap_pfn_range(vma, vaddr, pfn, size, prot)
386
387#define MK_IOSPACE_PFN(space, pfn) (pfn)
388#define GET_IOSPACE(pfn) 0
389#define GET_PFN(pfn) (pfn)
390
391#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
392#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
393#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
394#define __HAVE_ARCH_PTEP_SET_WRPROTECT
395#define __HAVE_ARCH_PTE_SAME
396#include <asm-generic/pgtable.h>
397
398#endif /* __KERNEL__ */
399
400#endif /* _ASM_M32R_PGTABLE_H */
diff --git a/include/asm-m32r/poll.h b/include/asm-m32r/poll.h
new file mode 100644
index 000000000000..43b7acf732d5
--- /dev/null
+++ b/include/asm-m32r/poll.h
@@ -0,0 +1,31 @@
1#ifndef _ASM_M32R_POLL_H
2#define _ASM_M32R_POLL_H
3
4/*
5 * poll(2) bit definitions. Based on <asm-i386/poll.h>.
6 *
7 * Modified 2004
8 * Hirokazu Takata <takata at linux-m32r.org>
9 */
10
11#define POLLIN 0x0001
12#define POLLPRI 0x0002
13#define POLLOUT 0x0004
14#define POLLERR 0x0008
15#define POLLHUP 0x0010
16#define POLLNVAL 0x0020
17
18#define POLLRDNORM 0x0040
19#define POLLRDBAND 0x0080
20#define POLLWRNORM 0x0100
21#define POLLWRBAND 0x0200
22#define POLLMSG 0x0400
23#define POLLREMOVE 0x1000
24
25struct pollfd {
26 int fd;
27 short events;
28 short revents;
29};
30
31#endif /* _ASM_M32R_POLL_H */
diff --git a/include/asm-m32r/posix_types.h b/include/asm-m32r/posix_types.h
new file mode 100644
index 000000000000..47e7e85a3dc3
--- /dev/null
+++ b/include/asm-m32r/posix_types.h
@@ -0,0 +1,126 @@
1#ifndef _ASM_M32R_POSIX_TYPES_H
2#define _ASM_M32R_POSIX_TYPES_H
3
4/* $Id$ */
5
6/* orig : i386, sh 2.4.18 */
7
8/*
9 * This file is generally used by user-level software, so you need to
10 * be a little careful about namespace pollution etc. Also, we cannot
11 * assume GCC is being used.
12 */
13
14typedef unsigned long __kernel_ino_t;
15typedef unsigned short __kernel_mode_t;
16typedef unsigned short __kernel_nlink_t;
17typedef long __kernel_off_t;
18typedef int __kernel_pid_t;
19typedef unsigned short __kernel_ipc_pid_t;
20typedef unsigned short __kernel_uid_t;
21typedef unsigned short __kernel_gid_t;
22typedef unsigned int __kernel_size_t;
23typedef int __kernel_ssize_t;
24typedef int __kernel_ptrdiff_t;
25typedef long __kernel_time_t;
26typedef long __kernel_suseconds_t;
27typedef long __kernel_clock_t;
28typedef int __kernel_timer_t;
29typedef int __kernel_clockid_t;
30typedef int __kernel_daddr_t;
31typedef char * __kernel_caddr_t;
32typedef unsigned short __kernel_uid16_t;
33typedef unsigned short __kernel_gid16_t;
34typedef unsigned int __kernel_uid32_t;
35typedef unsigned int __kernel_gid32_t;
36
37typedef unsigned short __kernel_old_uid_t;
38typedef unsigned short __kernel_old_gid_t;
39typedef unsigned short __kernel_old_dev_t;
40
41#ifdef __GNUC__
42typedef long long __kernel_loff_t;
43#endif
44
45typedef struct {
46#if defined(__KERNEL__) || defined(__USE_ALL)
47 int val[2];
48#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
49 int __val[2];
50#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
51} __kernel_fsid_t;
52
53#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
54
55#undef __FD_SET
56static __inline__ void __FD_SET(unsigned long __fd, __kernel_fd_set *__fdsetp)
57{
58 unsigned long __tmp = __fd / __NFDBITS;
59 unsigned long __rem = __fd % __NFDBITS;
60 __fdsetp->fds_bits[__tmp] |= (1UL<<__rem);
61}
62
63#undef __FD_CLR
64static __inline__ void __FD_CLR(unsigned long __fd, __kernel_fd_set *__fdsetp)
65{
66 unsigned long __tmp = __fd / __NFDBITS;
67 unsigned long __rem = __fd % __NFDBITS;
68 __fdsetp->fds_bits[__tmp] &= ~(1UL<<__rem);
69}
70
71
72#undef __FD_ISSET
73static __inline__ int __FD_ISSET(unsigned long __fd, const __kernel_fd_set *__p)
74{
75 unsigned long __tmp = __fd / __NFDBITS;
76 unsigned long __rem = __fd % __NFDBITS;
77 return (__p->fds_bits[__tmp] & (1UL<<__rem)) != 0;
78}
79
80/*
81 * This will unroll the loop for the normal constant case (8 ints,
82 * for a 256-bit fd_set)
83 */
84#undef __FD_ZERO
85static __inline__ void __FD_ZERO(__kernel_fd_set *__p)
86{
87 unsigned long *__tmp = __p->fds_bits;
88 int __i;
89
90 if (__builtin_constant_p(__FDSET_LONGS)) {
91 switch (__FDSET_LONGS) {
92 case 16:
93 __tmp[ 0] = 0; __tmp[ 1] = 0;
94 __tmp[ 2] = 0; __tmp[ 3] = 0;
95 __tmp[ 4] = 0; __tmp[ 5] = 0;
96 __tmp[ 6] = 0; __tmp[ 7] = 0;
97 __tmp[ 8] = 0; __tmp[ 9] = 0;
98 __tmp[10] = 0; __tmp[11] = 0;
99 __tmp[12] = 0; __tmp[13] = 0;
100 __tmp[14] = 0; __tmp[15] = 0;
101 return;
102
103 case 8:
104 __tmp[ 0] = 0; __tmp[ 1] = 0;
105 __tmp[ 2] = 0; __tmp[ 3] = 0;
106 __tmp[ 4] = 0; __tmp[ 5] = 0;
107 __tmp[ 6] = 0; __tmp[ 7] = 0;
108 return;
109
110 case 4:
111 __tmp[ 0] = 0; __tmp[ 1] = 0;
112 __tmp[ 2] = 0; __tmp[ 3] = 0;
113 return;
114 }
115 }
116 __i = __FDSET_LONGS;
117 while (__i) {
118 __i--;
119 *__tmp = 0;
120 __tmp++;
121 }
122}
123
124#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */
125
126#endif /* _ASM_M32R_POSIX_TYPES_H */
diff --git a/include/asm-m32r/processor.h b/include/asm-m32r/processor.h
new file mode 100644
index 000000000000..09fd1813e780
--- /dev/null
+++ b/include/asm-m32r/processor.h
@@ -0,0 +1,143 @@
1#ifndef _ASM_M32R_PROCESSOR_H
2#define _ASM_M32R_PROCESSOR_H
3
4/*
5 * include/asm-m32r/processor.h
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 *
11 * Copyright (C) 1994 Linus Torvalds
12 * Copyright (C) 2001 Hiroyuki Kondo, Hirokazu Takata, and Hitoshi Yamamoto
13 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
14 */
15
16#include <linux/kernel.h>
17#include <linux/config.h>
18#include <asm/cache.h>
19#include <asm/ptrace.h> /* pt_regs */
20
21/*
22 * Default implementation of macro that returns current
23 * instruction pointer ("program counter").
24 */
25#define current_text_addr() ({ __label__ _l; _l: &&_l; })
26
27/*
28 * CPU type and hardware bug flags. Kept separately for each CPU.
29 * Members of this structure are referenced in head.S, so think twice
30 * before touching them. [mj]
31 */
32
33struct cpuinfo_m32r {
34 unsigned long pgtable_cache_sz;
35 unsigned long cpu_clock;
36 unsigned long bus_clock;
37 unsigned long timer_divide;
38 unsigned long loops_per_jiffy;
39};
40
41/*
42 * capabilities of CPUs
43 */
44
45extern struct cpuinfo_m32r boot_cpu_data;
46
47#ifdef CONFIG_SMP
48extern struct cpuinfo_m32r cpu_data[];
49#define current_cpu_data cpu_data[smp_processor_id()]
50#else
51#define cpu_data (&boot_cpu_data)
52#define current_cpu_data boot_cpu_data
53#endif
54
55/*
56 * User space process size: 2GB (default).
57 */
58#ifdef CONFIG_MMU
59#define TASK_SIZE (0x80000000UL)
60#else
61#define TASK_SIZE (0x00400000UL)
62#endif
63
64/* This decides where the kernel will search for a free chunk of vm
65 * space during mmap's.
66 */
67#define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE / 3)
68
69typedef struct {
70 unsigned long seg;
71} mm_segment_t;
72
73#define MAX_TRAPS 10
74
75struct debug_trap {
76 int nr_trap;
77 unsigned long addr[MAX_TRAPS];
78 unsigned long insn[MAX_TRAPS];
79};
80
81struct thread_struct {
82 unsigned long address;
83 unsigned long trap_no; /* Trap number */
84 unsigned long error_code; /* Error code of trap */
85 unsigned long lr; /* saved pc */
86 unsigned long sp; /* user stack pointer */
87 struct debug_trap debug_trap;
88};
89
90#define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack)
91
92#define INIT_THREAD { \
93 .sp = INIT_SP, \
94}
95
96/*
97 * Do necessary setup to start up a newly executed thread.
98 */
99
100/* User process Backup PSW */
101#define USERPS_BPSW (M32R_PSW_BSM|M32R_PSW_BIE|M32R_PSW_BPM)
102
103#define start_thread(regs, new_pc, new_spu) \
104 do { \
105 set_fs(USER_DS); \
106 regs->psw = (regs->psw | USERPS_BPSW) & 0x0000FFFFUL; \
107 regs->bpc = new_pc; \
108 regs->spu = new_spu; \
109 } while (0)
110
111/* Forward declaration, a strange C thing */
112struct task_struct;
113struct mm_struct;
114
115/* Free all resources held by a thread. */
116extern void release_thread(struct task_struct *);
117
118#define prepare_to_copy(tsk) do { } while (0)
119
120/*
121 * create a kernel thread without removing it from tasklists
122 */
123extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
124
125/* Copy and release all segment info associated with a VM */
126extern void copy_segments(struct task_struct *p, struct mm_struct * mm);
127extern void release_segments(struct mm_struct * mm);
128
129extern unsigned long thread_saved_pc(struct task_struct *);
130
131/* Copy and release all segment info associated with a VM */
132#define copy_segments(p, mm) do { } while (0)
133#define release_segments(mm) do { } while (0)
134
135unsigned long get_wchan(struct task_struct *p);
136#define KSTK_EIP(tsk) ((tsk)->thread.lr)
137#define KSTK_ESP(tsk) ((tsk)->thread.sp)
138
139#define THREAD_SIZE (2*PAGE_SIZE)
140
141#define cpu_relax() barrier()
142
143#endif /* _ASM_M32R_PROCESSOR_H */
diff --git a/include/asm-m32r/ptrace.h b/include/asm-m32r/ptrace.h
new file mode 100644
index 000000000000..976417126b2d
--- /dev/null
+++ b/include/asm-m32r/ptrace.h
@@ -0,0 +1,165 @@
1#ifndef _ASM_M32R_PTRACE_H
2#define _ASM_M32R_PTRACE_H
3
4/*
5 * linux/include/asm-m32r/ptrace.h
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 *
11 * M32R version:
12 * Copyright (C) 2001-2002, 2004 Hirokazu Takata <takata at linux-m32r.org>
13 */
14
15#include <linux/config.h>
16#include <asm/m32r.h> /* M32R_PSW_BSM, M32R_PSW_BPM */
17
18/* 0 - 13 are integer registers (general purpose registers). */
19#define PT_R4 0
20#define PT_R5 1
21#define PT_R6 2
22#define PT_REGS 3
23#define PT_R0 4
24#define PT_R1 5
25#define PT_R2 6
26#define PT_R3 7
27#define PT_R7 8
28#define PT_R8 9
29#define PT_R9 10
30#define PT_R10 11
31#define PT_R11 12
32#define PT_R12 13
33#define PT_SYSCNR 14
34#define PT_R13 PT_FP
35#define PT_R14 PT_LR
36#define PT_R15 PT_SP
37
38/* processor status and miscellaneous context registers. */
39#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
40#define PT_ACC0H 15
41#define PT_ACC0L 16
42#define PT_ACC1H 17
43#define PT_ACC1L 18
44#define PT_ACCH PT_ACC0H
45#define PT_ACCL PT_ACC0L
46#define PT_PSW 19
47#define PT_BPC 20
48#define PT_BBPSW 21
49#define PT_BBPC 22
50#define PT_SPU 23
51#define PT_FP 24
52#define PT_LR 25
53#define PT_SPI 26
54#define PT_ORIGR0 27
55#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
56#define PT_ACCH 15
57#define PT_ACCL 16
58#define PT_PSW 17
59#define PT_BPC 18
60#define PT_BBPSW 19
61#define PT_BBPC 20
62#define PT_SPU 21
63#define PT_FP 22
64#define PT_LR 23
65#define PT_SPI 24
66#define PT_ORIGR0 25
67#else
68#error unknown isa conifiguration
69#endif
70
71/* virtual pt_reg entry for gdb */
72#define PT_PC 30
73#define PT_CBR 31
74#define PT_EVB 32
75
76
77/* Control registers. */
78#define SPR_CR0 PT_PSW
79#define SPR_CR1 PT_CBR /* read only */
80#define SPR_CR2 PT_SPI
81#define SPR_CR3 PT_SPU
82#define SPR_CR4
83#define SPR_CR5 PT_EVB /* part of M32R/E, M32R/I core only */
84#define SPR_CR6 PT_BPC
85#define SPR_CR7
86#define SPR_CR8 PT_BBPSW
87#define SPR_CR9
88#define SPR_CR10
89#define SPR_CR11
90#define SPR_CR12
91#define SPR_CR13 PT_WR
92#define SPR_CR14 PT_BBPC
93#define SPR_CR15
94
95/* this struct defines the way the registers are stored on the
96 stack during a system call. */
97struct pt_regs {
98 /* Saved main processor registers. */
99 unsigned long r4;
100 unsigned long r5;
101 unsigned long r6;
102 struct pt_regs *pt_regs;
103 unsigned long r0;
104 unsigned long r1;
105 unsigned long r2;
106 unsigned long r3;
107 unsigned long r7;
108 unsigned long r8;
109 unsigned long r9;
110 unsigned long r10;
111 unsigned long r11;
112 unsigned long r12;
113 long syscall_nr;
114
115 /* Saved main processor status and miscellaneous context registers. */
116#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
117 unsigned long acc0h;
118 unsigned long acc0l;
119 unsigned long acc1h;
120 unsigned long acc1l;
121#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
122 unsigned long acch;
123 unsigned long accl;
124#else
125#error unknown isa configuration
126#endif
127 unsigned long psw;
128 unsigned long bpc; /* saved PC for TRAP syscalls */
129 unsigned long bbpsw;
130 unsigned long bbpc;
131 unsigned long spu; /* saved user stack */
132 unsigned long fp;
133 unsigned long lr; /* saved PC for JL syscalls */
134 unsigned long spi; /* saved kernel stack */
135 unsigned long orig_r0;
136};
137
138/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
139#define PTRACE_GETREGS 12
140#define PTRACE_SETREGS 13
141
142#define PTRACE_OLDSETOPTIONS 21
143
144/* options set using PTRACE_SETOPTIONS */
145#define PTRACE_O_TRACESYSGOOD 0x00000001
146
147#ifdef __KERNEL__
148#if defined(CONFIG_ISA_M32R2) || defined(CONFIG_CHIP_VDEC2)
149#define user_mode(regs) ((M32R_PSW_BPM & (regs)->psw) != 0)
150#elif defined(CONFIG_ISA_M32R)
151#define user_mode(regs) ((M32R_PSW_BSM & (regs)->psw) != 0)
152#else
153#error unknown isa configuration
154#endif
155
156#define instruction_pointer(regs) ((regs)->bpc)
157#define profile_pc(regs) instruction_pointer(regs)
158
159extern void show_regs(struct pt_regs *);
160
161extern void withdraw_debug_trap(struct pt_regs *regs);
162
163#endif /* __KERNEL */
164
165#endif /* _ASM_M32R_PTRACE_H */
diff --git a/include/asm-m32r/resource.h b/include/asm-m32r/resource.h
new file mode 100644
index 000000000000..b1ce766e37a0
--- /dev/null
+++ b/include/asm-m32r/resource.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_M32R_RESOURCE_H
2#define _ASM_M32R_RESOURCE_H
3
4#include <asm-generic/resource.h>
5
6#endif /* _ASM_M32R_RESOURCE_H */
diff --git a/include/asm-m32r/rtc.h b/include/asm-m32r/rtc.h
new file mode 100644
index 000000000000..ec3cdf666c68
--- /dev/null
+++ b/include/asm-m32r/rtc.h
@@ -0,0 +1,70 @@
1/* $Id: rtc.h,v 1.1.1.1 2004/03/25 04:29:22 hitoshiy Exp $ */
2
3#ifndef __RTC_H__
4#define __RTC_H__
5
6
7#include <linux/config.h>
8
9 /* Dallas DS1302 clock/calendar register numbers. */
10# define RTC_SECONDS 0
11# define RTC_MINUTES 1
12# define RTC_HOURS 2
13# define RTC_DAY_OF_MONTH 3
14# define RTC_MONTH 4
15# define RTC_WEEKDAY 5
16# define RTC_YEAR 6
17# define RTC_CONTROL 7
18
19 /* Bits in CONTROL register. */
20# define RTC_CONTROL_WRITEPROTECT 0x80
21# define RTC_TRICKLECHARGER 8
22
23 /* Bits in TRICKLECHARGER register TCS TCS TCS TCS DS DS RS RS. */
24# define RTC_TCR_PATTERN 0xA0 /* 1010xxxx */
25# define RTC_TCR_1DIOD 0x04 /* xxxx01xx */
26# define RTC_TCR_2DIOD 0x08 /* xxxx10xx */
27# define RTC_TCR_DISABLED 0x00 /* xxxxxx00 Disabled */
28# define RTC_TCR_2KOHM 0x01 /* xxxxxx01 2KOhm */
29# define RTC_TCR_4KOHM 0x02 /* xxxxxx10 4kOhm */
30# define RTC_TCR_8KOHM 0x03 /* xxxxxx11 8kOhm */
31
32#ifdef CONFIG_DS1302
33extern unsigned char ds1302_readreg(int reg);
34extern void ds1302_writereg(int reg, unsigned char val);
35extern int ds1302_init(void);
36# define CMOS_READ(x) ds1302_readreg(x)
37# define CMOS_WRITE(val,reg) ds1302_writereg(reg,val)
38# define RTC_INIT() ds1302_init()
39#else
40 /* No RTC configured so we shouldn't try to access any. */
41# define CMOS_READ(x) 42
42# define CMOS_WRITE(x,y)
43# define RTC_INIT() (-1)
44#endif
45
46/*
47 * The struct used to pass data via the following ioctl. Similar to the
48 * struct tm in <time.h>, but it needs to be here so that the kernel
49 * source is self contained, allowing cross-compiles, etc. etc.
50 */
51struct rtc_time {
52 int tm_sec;
53 int tm_min;
54 int tm_hour;
55 int tm_mday;
56 int tm_mon;
57 int tm_year;
58 int tm_wday;
59 int tm_yday;
60 int tm_isdst;
61};
62
63/* ioctl() calls that are permitted to the /dev/rtc interface. */
64#define RTC_MAGIC 'p'
65#define RTC_RD_TIME _IOR(RTC_MAGIC, 0x09, struct rtc_time) /* Read RTC time. */
66#define RTC_SET_TIME _IOW(RTC_MAGIC, 0x0a, struct rtc_time) /* Set RTC time. */
67#define RTC_SET_CHARGE _IOW(RTC_MAGIC, 0x0b, int)
68#define RTC_MAX_IOCTL 0x0b
69
70#endif /* __RTC_H__ */
diff --git a/include/asm-m32r/scatterlist.h b/include/asm-m32r/scatterlist.h
new file mode 100644
index 000000000000..09a10e43bf0f
--- /dev/null
+++ b/include/asm-m32r/scatterlist.h
@@ -0,0 +1,18 @@
1#ifndef _ASM_M32R_SCATTERLIST_H
2#define _ASM_M32R_SCATTERLIST_H
3
4/* $Id$ */
5
6struct scatterlist {
7 char * address; /* Location data is to be transferred to, NULL for
8 * highmem page */
9 struct page * page; /* Location for highmem page, if any */
10 unsigned int offset;/* for highmem, page offset */
11
12 dma_addr_t dma_address;
13 unsigned int length;
14};
15
16#define ISA_DMA_THRESHOLD (0x1fffffff)
17
18#endif /* _ASM_M32R_SCATTERLIST_H */
diff --git a/include/asm-m32r/sections.h b/include/asm-m32r/sections.h
new file mode 100644
index 000000000000..6b969e53b806
--- /dev/null
+++ b/include/asm-m32r/sections.h
@@ -0,0 +1,8 @@
1#ifndef _M32R_SECTIONS_H
2#define _M32R_SECTIONS_H
3
4/* nothing to see, move along */
5#include <asm-generic/sections.h>
6
7#endif /* _M32R_SECTIONS_H */
8
diff --git a/include/asm-m32r/segment.h b/include/asm-m32r/segment.h
new file mode 100644
index 000000000000..e45db68e6c2d
--- /dev/null
+++ b/include/asm-m32r/segment.h
@@ -0,0 +1,14 @@
1#ifndef _ASM_M32R_SEGMENT_H
2#define _ASM_M32R_SEGMENT_H
3
4/* $Id$ */
5
6/* orig : i386 (2.4.18) */
7
8#define __KERNEL_CS 0x10
9#define __KERNEL_DS 0x18
10
11#define __USER_CS 0x23
12#define __USER_DS 0x2B
13
14#endif /* _ASM_M32R_SEGMENT_H */
diff --git a/include/asm-m32r/semaphore.h b/include/asm-m32r/semaphore.h
new file mode 100644
index 000000000000..53e3c60f21ec
--- /dev/null
+++ b/include/asm-m32r/semaphore.h
@@ -0,0 +1,205 @@
1#ifndef _ASM_M32R_SEMAPHORE_H
2#define _ASM_M32R_SEMAPHORE_H
3
4#include <linux/linkage.h>
5
6#ifdef __KERNEL__
7
8/*
9 * SMP- and interrupt-safe semaphores..
10 *
11 * Copyright (C) 1996 Linus Torvalds
12 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
13 */
14
15#include <linux/config.h>
16#include <linux/wait.h>
17#include <linux/rwsem.h>
18#include <asm/assembler.h>
19#include <asm/system.h>
20#include <asm/atomic.h>
21
22struct semaphore {
23 atomic_t count;
24 int sleepers;
25 wait_queue_head_t wait;
26};
27
28#define __SEMAPHORE_INITIALIZER(name, n) \
29{ \
30 .count = ATOMIC_INIT(n), \
31 .sleepers = 0, \
32 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
33}
34
35#define __MUTEX_INITIALIZER(name) \
36 __SEMAPHORE_INITIALIZER(name,1)
37
38#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
39 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
40
41#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
42#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
43
44static inline void sema_init (struct semaphore *sem, int val)
45{
46/*
47 * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
48 *
49 * i'd rather use the more flexible initialization above, but sadly
50 * GCC 2.7.2.3 emits a bogus warning. EGCS doesnt. Oh well.
51 */
52 atomic_set(&sem->count, val);
53 sem->sleepers = 0;
54 init_waitqueue_head(&sem->wait);
55}
56
57static inline void init_MUTEX (struct semaphore *sem)
58{
59 sema_init(sem, 1);
60}
61
62static inline void init_MUTEX_LOCKED (struct semaphore *sem)
63{
64 sema_init(sem, 0);
65}
66
67asmlinkage void __down_failed(void /* special register calling convention */);
68asmlinkage int __down_failed_interruptible(void /* params in registers */);
69asmlinkage int __down_failed_trylock(void /* params in registers */);
70asmlinkage void __up_wakeup(void /* special register calling convention */);
71
72asmlinkage void __down(struct semaphore * sem);
73asmlinkage int __down_interruptible(struct semaphore * sem);
74asmlinkage int __down_trylock(struct semaphore * sem);
75asmlinkage void __up(struct semaphore * sem);
76
77/*
78 * Atomically decrement the semaphore's count. If it goes negative,
79 * block the calling thread in the TASK_UNINTERRUPTIBLE state.
80 */
81static inline void down(struct semaphore * sem)
82{
83 unsigned long flags;
84 long count;
85
86 might_sleep();
87 local_irq_save(flags);
88 __asm__ __volatile__ (
89 "# down \n\t"
90 DCACHE_CLEAR("%0", "r4", "%1")
91 M32R_LOCK" %0, @%1; \n\t"
92 "addi %0, #-1; \n\t"
93 M32R_UNLOCK" %0, @%1; \n\t"
94 : "=&r" (count)
95 : "r" (&sem->count)
96 : "memory"
97#ifdef CONFIG_CHIP_M32700_TS1
98 , "r4"
99#endif /* CONFIG_CHIP_M32700_TS1 */
100 );
101 local_irq_restore(flags);
102
103 if (unlikely(count < 0))
104 __down(sem);
105}
106
107/*
108 * Interruptible try to acquire a semaphore. If we obtained
109 * it, return zero. If we were interrupted, returns -EINTR
110 */
111static inline int down_interruptible(struct semaphore * sem)
112{
113 unsigned long flags;
114 long count;
115 int result = 0;
116
117 might_sleep();
118 local_irq_save(flags);
119 __asm__ __volatile__ (
120 "# down_interruptible \n\t"
121 DCACHE_CLEAR("%0", "r4", "%1")
122 M32R_LOCK" %0, @%1; \n\t"
123 "addi %0, #-1; \n\t"
124 M32R_UNLOCK" %0, @%1; \n\t"
125 : "=&r" (count)
126 : "r" (&sem->count)
127 : "memory"
128#ifdef CONFIG_CHIP_M32700_TS1
129 , "r4"
130#endif /* CONFIG_CHIP_M32700_TS1 */
131 );
132 local_irq_restore(flags);
133
134 if (unlikely(count < 0))
135 result = __down_interruptible(sem);
136
137 return result;
138}
139
140/*
141 * Non-blockingly attempt to down() a semaphore.
142 * Returns zero if we acquired it
143 */
144static inline int down_trylock(struct semaphore * sem)
145{
146 unsigned long flags;
147 long count;
148 int result = 0;
149
150 local_irq_save(flags);
151 __asm__ __volatile__ (
152 "# down_trylock \n\t"
153 DCACHE_CLEAR("%0", "r4", "%1")
154 M32R_LOCK" %0, @%1; \n\t"
155 "addi %0, #-1; \n\t"
156 M32R_UNLOCK" %0, @%1; \n\t"
157 : "=&r" (count)
158 : "r" (&sem->count)
159 : "memory"
160#ifdef CONFIG_CHIP_M32700_TS1
161 , "r4"
162#endif /* CONFIG_CHIP_M32700_TS1 */
163 );
164 local_irq_restore(flags);
165
166 if (unlikely(count < 0))
167 result = __down_trylock(sem);
168
169 return result;
170}
171
172/*
173 * Note! This is subtle. We jump to wake people up only if
174 * the semaphore was negative (== somebody was waiting on it).
175 * The default case (no contention) will result in NO
176 * jumps for both down() and up().
177 */
178static inline void up(struct semaphore * sem)
179{
180 unsigned long flags;
181 long count;
182
183 local_irq_save(flags);
184 __asm__ __volatile__ (
185 "# up \n\t"
186 DCACHE_CLEAR("%0", "r4", "%1")
187 M32R_LOCK" %0, @%1; \n\t"
188 "addi %0, #1; \n\t"
189 M32R_UNLOCK" %0, @%1; \n\t"
190 : "=&r" (count)
191 : "r" (&sem->count)
192 : "memory"
193#ifdef CONFIG_CHIP_M32700_TS1
194 , "r4"
195#endif /* CONFIG_CHIP_M32700_TS1 */
196 );
197 local_irq_restore(flags);
198
199 if (unlikely(count <= 0))
200 __up(sem);
201}
202
203#endif /* __KERNEL__ */
204
205#endif /* _ASM_M32R_SEMAPHORE_H */
diff --git a/include/asm-m32r/sembuf.h b/include/asm-m32r/sembuf.h
new file mode 100644
index 000000000000..e69018e6ff71
--- /dev/null
+++ b/include/asm-m32r/sembuf.h
@@ -0,0 +1,29 @@
1#ifndef _ASM_M32R_SEMBUF_H
2#define _ASM_M32R_SEMBUF_H
3
4/* $Id$ */
5
6/* orig : i386 2.4.18 */
7
8/*
9 * The semid64_ds structure for m32r architecture.
10 * Note extra padding because this structure is passed back and forth
11 * between kernel and user space.
12 *
13 * Pad space is left for:
14 * - 64-bit time_t to solve y2038 problem
15 * - 2 miscellaneous 32-bit values
16 */
17
18struct semid64_ds {
19 struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
20 __kernel_time_t sem_otime; /* last semop time */
21 unsigned long __unused1;
22 __kernel_time_t sem_ctime; /* last change time */
23 unsigned long __unused2;
24 unsigned long sem_nsems; /* no. of semaphores in array */
25 unsigned long __unused3;
26 unsigned long __unused4;
27};
28
29#endif /* _ASM_M32R_SEMBUF_H */
diff --git a/include/asm-m32r/serial.h b/include/asm-m32r/serial.h
new file mode 100644
index 000000000000..1bf480f58493
--- /dev/null
+++ b/include/asm-m32r/serial.h
@@ -0,0 +1,10 @@
1#ifndef _ASM_M32R_SERIAL_H
2#define _ASM_M32R_SERIAL_H
3
4/* include/asm-m32r/serial.h */
5
6#include <linux/config.h>
7
8#define BASE_BAUD 115200
9
10#endif /* _ASM_M32R_SERIAL_H */
diff --git a/include/asm-m32r/setup.h b/include/asm-m32r/setup.h
new file mode 100644
index 000000000000..5f028dc26a9b
--- /dev/null
+++ b/include/asm-m32r/setup.h
@@ -0,0 +1,33 @@
1/*
2 * This is set up by the setup-routine at boot-time
3 */
4#define PARAM ((unsigned char *)empty_zero_page)
5
6#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000))
7#define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004))
8#define ORIG_ROOT_DEV (*(unsigned long *) (PARAM+0x008))
9#define LOADER_TYPE (*(unsigned long *) (PARAM+0x00c))
10#define INITRD_START (*(unsigned long *) (PARAM+0x010))
11#define INITRD_SIZE (*(unsigned long *) (PARAM+0x014))
12
13#define M32R_CPUCLK (*(unsigned long *) (PARAM+0x018))
14#define M32R_BUSCLK (*(unsigned long *) (PARAM+0x01c))
15#define M32R_TIMER_DIVIDE (*(unsigned long *) (PARAM+0x020))
16
17#define COMMAND_LINE ((char *) (PARAM+0x100))
18
19#define SCREEN_INFO (*(struct screen_info *) (PARAM+0x200))
20
21#define COMMAND_LINE_SIZE (512)
22
23#define RAMDISK_IMAGE_START_MASK (0x07FF)
24#define RAMDISK_PROMPT_FLAG (0x8000)
25#define RAMDISK_LOAD_FLAG (0x4000)
26
27#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
28#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
29#define PFN_PHYS(x) ((x) << PAGE_SHIFT)
30
31extern unsigned long memory_start;
32extern unsigned long memory_end;
33
diff --git a/include/asm-m32r/shmbuf.h b/include/asm-m32r/shmbuf.h
new file mode 100644
index 000000000000..b84e897fa87b
--- /dev/null
+++ b/include/asm-m32r/shmbuf.h
@@ -0,0 +1,46 @@
1#ifndef _ASM_M32R_SHMBUF_H
2#define _ASM_M32R_SHMBUF_H
3
4/* $Id$ */
5
6/* orig : i386 2.4.18 */
7
8/*
9 * The shmid64_ds structure for M32R architecture.
10 * Note extra padding because this structure is passed back and forth
11 * between kernel and user space.
12 *
13 * Pad space is left for:
14 * - 64-bit time_t to solve y2038 problem
15 * - 2 miscellaneous 32-bit values
16 */
17
18struct shmid64_ds {
19 struct ipc64_perm shm_perm; /* operation perms */
20 size_t shm_segsz; /* size of segment (bytes) */
21 __kernel_time_t shm_atime; /* last attach time */
22 unsigned long __unused1;
23 __kernel_time_t shm_dtime; /* last detach time */
24 unsigned long __unused2;
25 __kernel_time_t shm_ctime; /* last change time */
26 unsigned long __unused3;
27 __kernel_pid_t shm_cpid; /* pid of creator */
28 __kernel_pid_t shm_lpid; /* pid of last operator */
29 unsigned long shm_nattch; /* no. of current attaches */
30 unsigned long __unused4;
31 unsigned long __unused5;
32};
33
34struct shminfo64 {
35 unsigned long shmmax;
36 unsigned long shmmin;
37 unsigned long shmmni;
38 unsigned long shmseg;
39 unsigned long shmall;
40 unsigned long __unused1;
41 unsigned long __unused2;
42 unsigned long __unused3;
43 unsigned long __unused4;
44};
45
46#endif /* _ASM_M32R_SHMBUF_H */
diff --git a/include/asm-m32r/shmparam.h b/include/asm-m32r/shmparam.h
new file mode 100644
index 000000000000..db0019ba955d
--- /dev/null
+++ b/include/asm-m32r/shmparam.h
@@ -0,0 +1,8 @@
1#ifndef _ASM_M32R_SHMPARAM_H
2#define _ASM_M32R_SHMPARAM_H
3
4/* $Id$ */
5
6#define SHMLBA PAGE_SIZE /* attach addr a multiple of this */
7
8#endif /* _ASM_M32R_SHMPARAM_H */
diff --git a/include/asm-m32r/sigcontext.h b/include/asm-m32r/sigcontext.h
new file mode 100644
index 000000000000..c233e2def2a3
--- /dev/null
+++ b/include/asm-m32r/sigcontext.h
@@ -0,0 +1,50 @@
1#ifndef _ASM_M32R_SIGCONTEXT_H
2#define _ASM_M32R_SIGCONTEXT_H
3
4/* $Id$ */
5
6#include <linux/config.h>
7
8struct sigcontext {
9 /* CPU registers */
10 /* Saved main processor registers. */
11 unsigned long sc_r4;
12 unsigned long sc_r5;
13 unsigned long sc_r6;
14 struct pt_regs *sc_pt_regs;
15 unsigned long sc_r0;
16 unsigned long sc_r1;
17 unsigned long sc_r2;
18 unsigned long sc_r3;
19 unsigned long sc_r7;
20 unsigned long sc_r8;
21 unsigned long sc_r9;
22 unsigned long sc_r10;
23 unsigned long sc_r11;
24 unsigned long sc_r12;
25
26 /* Saved main processor status and miscellaneous context registers. */
27#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
28 unsigned long sc_acc0h;
29 unsigned long sc_acc0l;
30 unsigned long sc_acc1h;
31 unsigned long sc_acc1l;
32#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
33 unsigned long sc_acch;
34 unsigned long sc_accl;
35#else
36#error unknown isa configuration
37#endif
38 unsigned long sc_psw;
39 unsigned long sc_bpc; /* saved PC for TRAP syscalls */
40 unsigned long sc_bbpsw;
41 unsigned long sc_bbpc;
42 unsigned long sc_spu; /* saved user stack */
43 unsigned long sc_fp;
44 unsigned long sc_lr; /* saved PC for JL syscalls */
45 unsigned long sc_spi; /* saved kernel stack */
46
47 unsigned long oldmask;
48};
49
50#endif /* _ASM_M32R_SIGCONTEXT_H */
diff --git a/include/asm-m32r/siginfo.h b/include/asm-m32r/siginfo.h
new file mode 100644
index 000000000000..482202f2e77f
--- /dev/null
+++ b/include/asm-m32r/siginfo.h
@@ -0,0 +1,8 @@
1#ifndef _M32R_SIGINFO_H
2#define _M32R_SIGINFO_H
3
4/* $Id$ */
5
6#include <asm-generic/siginfo.h>
7
8#endif /* _M32R_SIGINFO_H */
diff --git a/include/asm-m32r/signal.h b/include/asm-m32r/signal.h
new file mode 100644
index 000000000000..ce46eaea4494
--- /dev/null
+++ b/include/asm-m32r/signal.h
@@ -0,0 +1,200 @@
1#ifndef _ASM_M32R_SIGNAL_H
2#define _ASM_M32R_SIGNAL_H
3
4/* $Id$ */
5
6/* orig : i386 2.4.18 */
7
8#include <linux/types.h>
9#include <linux/linkage.h>
10#include <linux/time.h>
11#include <linux/compiler.h>
12
13/* Avoid too many header ordering problems. */
14struct siginfo;
15
16#ifdef __KERNEL__
17/* Most things should be clean enough to redefine this at will, if care
18 is taken to make libc match. */
19
20#define _NSIG 64
21#define _NSIG_BPW 32
22#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
23
24typedef unsigned long old_sigset_t; /* at least 32 bits */
25
26typedef struct {
27 unsigned long sig[_NSIG_WORDS];
28} sigset_t;
29
30#else
31/* Here we must cater to libcs that poke about in kernel headers. */
32
33#define NSIG 32
34typedef unsigned long sigset_t;
35
36#endif /* __KERNEL__ */
37
38#define SIGHUP 1
39#define SIGINT 2
40#define SIGQUIT 3
41#define SIGILL 4
42#define SIGTRAP 5
43#define SIGABRT 6
44#define SIGIOT 6
45#define SIGBUS 7
46#define SIGFPE 8
47#define SIGKILL 9
48#define SIGUSR1 10
49#define SIGSEGV 11
50#define SIGUSR2 12
51#define SIGPIPE 13
52#define SIGALRM 14
53#define SIGTERM 15
54#define SIGSTKFLT 16
55#define SIGCHLD 17
56#define SIGCONT 18
57#define SIGSTOP 19
58#define SIGTSTP 20
59#define SIGTTIN 21
60#define SIGTTOU 22
61#define SIGURG 23
62#define SIGXCPU 24
63#define SIGXFSZ 25
64#define SIGVTALRM 26
65#define SIGPROF 27
66#define SIGWINCH 28
67#define SIGIO 29
68#define SIGPOLL SIGIO
69/*
70#define SIGLOST 29
71*/
72#define SIGPWR 30
73#define SIGSYS 31
74#define SIGUNUSED 31
75
76/* These should not be considered constants from userland. */
77#define SIGRTMIN 32
78#define SIGRTMAX _NSIG
79
80/*
81 * SA_FLAGS values:
82 *
83 * SA_ONSTACK indicates that a registered stack_t will be used.
84 * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the
85 * SA_RESTART flag to get restarting signals (which were the default long ago)
86 * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
87 * SA_RESETHAND clears the handler when the signal is delivered.
88 * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
89 * SA_NODEFER prevents the current signal from being masked in the handler.
90 *
91 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
92 * Unix names RESETHAND and NODEFER respectively.
93 */
94#define SA_NOCLDSTOP 0x00000001u
95#define SA_NOCLDWAIT 0x00000002u
96#define SA_SIGINFO 0x00000004u
97#define SA_ONSTACK 0x08000000u
98#define SA_RESTART 0x10000000u
99#define SA_NODEFER 0x40000000u
100#define SA_RESETHAND 0x80000000u
101
102#define SA_NOMASK SA_NODEFER
103#define SA_ONESHOT SA_RESETHAND
104#define SA_INTERRUPT 0x20000000 /* dummy -- ignored */
105
106#define SA_RESTORER 0x04000000
107
108/*
109 * sigaltstack controls
110 */
111#define SS_ONSTACK 1
112#define SS_DISABLE 2
113
114#define MINSIGSTKSZ 2048
115#define SIGSTKSZ 8192
116
117#ifdef __KERNEL__
118
119/*
120 * These values of sa_flags are used only by the kernel as part of the
121 * irq handling routines.
122 *
123 * SA_INTERRUPT is also used by the irq handling routines.
124 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
125 */
126#define SA_PROBE SA_ONESHOT
127#define SA_SAMPLE_RANDOM SA_RESTART
128#define SA_SHIRQ 0x04000000
129#endif
130
131#define SIG_BLOCK 0 /* for blocking signals */
132#define SIG_UNBLOCK 1 /* for unblocking signals */
133#define SIG_SETMASK 2 /* for setting the signal mask */
134
135/* Type of a signal handler. */
136typedef void __signalfn_t(int);
137typedef __signalfn_t __user *__sighandler_t;
138
139typedef void __restorefn_t(void);
140typedef __restorefn_t __user *__sigrestore_t;
141
142#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
143#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
144#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
145
146#ifdef __KERNEL__
147struct old_sigaction {
148 __sighandler_t sa_handler;
149 old_sigset_t sa_mask;
150 unsigned long sa_flags;
151 __sigrestore_t sa_restorer;
152};
153
154struct sigaction {
155 __sighandler_t sa_handler;
156 unsigned long sa_flags;
157 __sigrestore_t sa_restorer;
158 sigset_t sa_mask; /* mask last for extensibility */
159};
160
161struct k_sigaction {
162 struct sigaction sa;
163};
164#else
165/* Here we must cater to libcs that poke about in kernel headers. */
166
167struct sigaction {
168 union {
169 __sighandler_t _sa_handler;
170 void (*_sa_sigaction)(int, struct siginfo *, void *);
171 } _u;
172 sigset_t sa_mask;
173 unsigned long sa_flags;
174 void (*sa_restorer)(void);
175};
176
177#define sa_handler _u._sa_handler
178#define sa_sigaction _u._sa_sigaction
179
180#endif /* __KERNEL__ */
181
182typedef struct sigaltstack {
183 void __user *ss_sp;
184 int ss_flags;
185 size_t ss_size;
186} stack_t;
187
188#ifdef __KERNEL__
189#include <asm/sigcontext.h>
190
191#undef __HAVE_ARCH_SIG_BITOPS
192
193struct pt_regs;
194extern int FASTCALL(do_signal(struct pt_regs *regs, sigset_t *oldset));
195
196#define ptrace_signal_deliver(regs, cookie) do { } while (0)
197
198#endif /* __KERNEL__ */
199
200#endif /* _ASM_M32R_SIGNAL_H */
diff --git a/include/asm-m32r/smp.h b/include/asm-m32r/smp.h
new file mode 100644
index 000000000000..8cd4d0da4be1
--- /dev/null
+++ b/include/asm-m32r/smp.h
@@ -0,0 +1,118 @@
1#ifndef _ASM_M32R_SMP_H
2#define _ASM_M32R_SMP_H
3
4/* $Id$ */
5
6#include <linux/config.h>
7
8#ifdef CONFIG_SMP
9#ifndef __ASSEMBLY__
10
11#include <linux/cpumask.h>
12#include <linux/spinlock.h>
13#include <linux/threads.h>
14#include <asm/m32r.h>
15
16#define PHYSID_ARRAY_SIZE 1
17
18struct physid_mask
19{
20 unsigned long mask[PHYSID_ARRAY_SIZE];
21};
22
23typedef struct physid_mask physid_mask_t;
24
25#define physid_set(physid, map) set_bit(physid, (map).mask)
26#define physid_clear(physid, map) clear_bit(physid, (map).mask)
27#define physid_isset(physid, map) test_bit(physid, (map).mask)
28#define physid_test_and_set(physid, map) test_and_set_bit(physid, (map).mask)
29
30#define physids_and(dst, src1, src2) bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
31#define physids_or(dst, src1, src2) bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
32#define physids_clear(map) bitmap_zero((map).mask, MAX_APICS)
33#define physids_complement(dst, src) bitmap_complement((dst).mask,(src).mask, MAX_APICS)
34#define physids_empty(map) bitmap_empty((map).mask, MAX_APICS)
35#define physids_equal(map1, map2) bitmap_equal((map1).mask, (map2).mask, MAX_APICS)
36#define physids_weight(map) bitmap_weight((map).mask, MAX_APICS)
37#define physids_shift_right(d, s, n) bitmap_shift_right((d).mask, (s).mask, n, MAX_APICS)
38#define physids_shift_left(d, s, n) bitmap_shift_left((d).mask, (s).mask, n, MAX_APICS)
39#define physids_coerce(map) ((map).mask[0])
40
41#define physids_promote(physids) \
42 ({ \
43 physid_mask_t __physid_mask = PHYSID_MASK_NONE; \
44 __physid_mask.mask[0] = physids; \
45 __physid_mask; \
46 })
47
48#define physid_mask_of_physid(physid) \
49 ({ \
50 physid_mask_t __physid_mask = PHYSID_MASK_NONE; \
51 physid_set(physid, __physid_mask); \
52 __physid_mask; \
53 })
54
55#define PHYSID_MASK_ALL { {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} }
56#define PHYSID_MASK_NONE { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} }
57
58extern physid_mask_t phys_cpu_present_map;
59
60/*
61 * Some lowlevel functions might want to know about
62 * the real CPU ID <-> CPU # mapping.
63 */
64extern volatile int physid_2_cpu[NR_CPUS];
65extern volatile int cpu_2_physid[NR_CPUS];
66#define physid_to_cpu(physid) physid_2_cpu[physid]
67#define cpu_to_physid(cpu_id) cpu_2_physid[cpu_id]
68
69#define smp_processor_id() (current_thread_info()->cpu)
70
71extern cpumask_t cpu_callout_map;
72#define cpu_possible_map cpu_callout_map
73
74static __inline__ int hard_smp_processor_id(void)
75{
76 return (int)*(volatile long *)M32R_CPUID_PORTL;
77}
78
79static __inline__ int cpu_logical_map(int cpu)
80{
81 return cpu;
82}
83
84static __inline__ int cpu_number_map(int cpu)
85{
86 return cpu;
87}
88
89static __inline__ unsigned int num_booting_cpus(void)
90{
91 return cpus_weight(cpu_callout_map);
92}
93
94extern void smp_send_timer(void);
95extern unsigned long send_IPI_mask_phys(cpumask_t, int, int);
96
97#endif /* not __ASSEMBLY__ */
98
99#define NO_PROC_ID (0xff) /* No processor magic marker */
100
101#define PROC_CHANGE_PENALTY (15) /* Schedule penalty */
102
103/*
104 * M32R-mp IPI
105 */
106#define RESCHEDULE_IPI (M32R_IRQ_IPI0-M32R_IRQ_IPI0)
107#define INVALIDATE_TLB_IPI (M32R_IRQ_IPI1-M32R_IRQ_IPI0)
108#define CALL_FUNCTION_IPI (M32R_IRQ_IPI2-M32R_IRQ_IPI0)
109#define LOCAL_TIMER_IPI (M32R_IRQ_IPI3-M32R_IRQ_IPI0)
110#define INVALIDATE_CACHE_IPI (M32R_IRQ_IPI4-M32R_IRQ_IPI0)
111#define CPU_BOOT_IPI (M32R_IRQ_IPI5-M32R_IRQ_IPI0)
112
113#define IPI_SHIFT (0)
114#define NR_IPIS (8)
115
116#endif /* CONFIG_SMP */
117
118#endif /* _ASM_M32R_SMP_H */
diff --git a/include/asm-m32r/socket.h b/include/asm-m32r/socket.h
new file mode 100644
index 000000000000..159519d99042
--- /dev/null
+++ b/include/asm-m32r/socket.h
@@ -0,0 +1,50 @@
1#ifndef _ASM_M32R_SOCKET_H
2#define _ASM_M32R_SOCKET_H
3
4#include <asm/sockios.h>
5
6/* For setsockoptions(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_M32R_SOCKET_H */
diff --git a/include/asm-m32r/sockios.h b/include/asm-m32r/sockios.h
new file mode 100644
index 000000000000..147a118442ac
--- /dev/null
+++ b/include/asm-m32r/sockios.h
@@ -0,0 +1,14 @@
1#ifndef _ASM_M32R_SOCKIOS_H
2#define _ASM_M32R_SOCKIOS_H
3
4/* $Id$ */
5
6/* Socket-level I/O control calls. */
7#define FIOSETOWN 0x8901
8#define SIOCSPGRP 0x8902
9#define FIOGETOWN 0x8903
10#define SIOCGPGRP 0x8904
11#define SIOCATMARK 0x8905
12#define SIOCGSTAMP 0x8906 /* Get stamp */
13
14#endif /* _ASM_M32R_SOCKIOS_H */
diff --git a/include/asm-m32r/spinlock.h b/include/asm-m32r/spinlock.h
new file mode 100644
index 000000000000..6608d8371c50
--- /dev/null
+++ b/include/asm-m32r/spinlock.h
@@ -0,0 +1,380 @@
1#ifndef _ASM_M32R_SPINLOCK_H
2#define _ASM_M32R_SPINLOCK_H
3
4/*
5 * linux/include/asm-m32r/spinlock.h
6 *
7 * M32R version:
8 * Copyright (C) 2001, 2002 Hitoshi Yamamoto
9 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
10 */
11
12#include <linux/config.h> /* CONFIG_DEBUG_SPINLOCK, CONFIG_SMP */
13#include <linux/compiler.h>
14#include <asm/atomic.h>
15#include <asm/page.h>
16
17extern int printk(const char * fmt, ...)
18 __attribute__ ((format (printf, 1, 2)));
19
20#define RW_LOCK_BIAS 0x01000000
21#define RW_LOCK_BIAS_STR "0x01000000"
22
23/*
24 * Your basic SMP spinlocks, allowing only a single CPU anywhere
25 */
26
27typedef struct {
28 volatile int slock;
29#ifdef CONFIG_DEBUG_SPINLOCK
30 unsigned magic;
31#endif
32#ifdef CONFIG_PREEMPT
33 unsigned int break_lock;
34#endif
35} spinlock_t;
36
37#define SPINLOCK_MAGIC 0xdead4ead
38
39#ifdef CONFIG_DEBUG_SPINLOCK
40#define SPINLOCK_MAGIC_INIT , SPINLOCK_MAGIC
41#else
42#define SPINLOCK_MAGIC_INIT /* */
43#endif
44
45#define SPIN_LOCK_UNLOCKED (spinlock_t) { 1 SPINLOCK_MAGIC_INIT }
46
47#define spin_lock_init(x) do { *(x) = SPIN_LOCK_UNLOCKED; } while(0)
48
49/*
50 * Simple spin lock operations. There are two variants, one clears IRQ's
51 * on the local processor, one does not.
52 *
53 * We make no fairness assumptions. They have a cost.
54 */
55
56#define spin_is_locked(x) (*(volatile int *)(&(x)->slock) <= 0)
57#define spin_unlock_wait(x) do { barrier(); } while(spin_is_locked(x))
58#define _raw_spin_lock_flags(lock, flags) _raw_spin_lock(lock)
59
60/**
61 * _raw_spin_trylock - Try spin lock and return a result
62 * @lock: Pointer to the lock variable
63 *
64 * _raw_spin_trylock() tries to get the lock and returns a result.
65 * On the m32r, the result value is 1 (= Success) or 0 (= Failure).
66 */
67static inline int _raw_spin_trylock(spinlock_t *lock)
68{
69 int oldval;
70 unsigned long tmp1, tmp2;
71
72 /*
73 * lock->slock : =1 : unlock
74 * : <=0 : lock
75 * {
76 * oldval = lock->slock; <--+ need atomic operation
77 * lock->slock = 0; <--+
78 * }
79 */
80 __asm__ __volatile__ (
81 "# spin_trylock \n\t"
82 "ldi %1, #0; \n\t"
83 "mvfc %2, psw; \n\t"
84 "clrpsw #0x40 -> nop; \n\t"
85 DCACHE_CLEAR("%0", "r6", "%3")
86 "lock %0, @%3; \n\t"
87 "unlock %1, @%3; \n\t"
88 "mvtc %2, psw; \n\t"
89 : "=&r" (oldval), "=&r" (tmp1), "=&r" (tmp2)
90 : "r" (&lock->slock)
91 : "memory"
92#ifdef CONFIG_CHIP_M32700_TS1
93 , "r6"
94#endif /* CONFIG_CHIP_M32700_TS1 */
95 );
96
97 return (oldval > 0);
98}
99
100static inline void _raw_spin_lock(spinlock_t *lock)
101{
102 unsigned long tmp0, tmp1;
103
104#ifdef CONFIG_DEBUG_SPINLOCK
105 if (unlikely(lock->magic != SPINLOCK_MAGIC)) {
106 printk("pc: %p\n", __builtin_return_address(0));
107 BUG();
108 }
109#endif
110 /*
111 * lock->slock : =1 : unlock
112 * : <=0 : lock
113 *
114 * for ( ; ; ) {
115 * lock->slock -= 1; <-- need atomic operation
116 * if (lock->slock == 0) break;
117 * for ( ; lock->slock <= 0 ; );
118 * }
119 */
120 __asm__ __volatile__ (
121 "# spin_lock \n\t"
122 ".fillinsn \n"
123 "1: \n\t"
124 "mvfc %1, psw; \n\t"
125 "clrpsw #0x40 -> nop; \n\t"
126 DCACHE_CLEAR("%0", "r6", "%2")
127 "lock %0, @%2; \n\t"
128 "addi %0, #-1; \n\t"
129 "unlock %0, @%2; \n\t"
130 "mvtc %1, psw; \n\t"
131 "bltz %0, 2f; \n\t"
132 LOCK_SECTION_START(".balign 4 \n\t")
133 ".fillinsn \n"
134 "2: \n\t"
135 "ld %0, @%2; \n\t"
136 "bgtz %0, 1b; \n\t"
137 "bra 2b; \n\t"
138 LOCK_SECTION_END
139 : "=&r" (tmp0), "=&r" (tmp1)
140 : "r" (&lock->slock)
141 : "memory"
142#ifdef CONFIG_CHIP_M32700_TS1
143 , "r6"
144#endif /* CONFIG_CHIP_M32700_TS1 */
145 );
146}
147
148static inline void _raw_spin_unlock(spinlock_t *lock)
149{
150#ifdef CONFIG_DEBUG_SPINLOCK
151 BUG_ON(lock->magic != SPINLOCK_MAGIC);
152 BUG_ON(!spin_is_locked(lock));
153#endif
154 mb();
155 lock->slock = 1;
156}
157
158/*
159 * Read-write spinlocks, allowing multiple readers
160 * but only one writer.
161 *
162 * NOTE! it is quite common to have readers in interrupts
163 * but no interrupt writers. For those circumstances we
164 * can "mix" irq-safe locks - any writer needs to get a
165 * irq-safe write-lock, but readers can get non-irqsafe
166 * read-locks.
167 */
168typedef struct {
169 volatile int lock;
170#ifdef CONFIG_DEBUG_SPINLOCK
171 unsigned magic;
172#endif
173#ifdef CONFIG_PREEMPT
174 unsigned int break_lock;
175#endif
176} rwlock_t;
177
178#define RWLOCK_MAGIC 0xdeaf1eed
179
180#ifdef CONFIG_DEBUG_SPINLOCK
181#define RWLOCK_MAGIC_INIT , RWLOCK_MAGIC
182#else
183#define RWLOCK_MAGIC_INIT /* */
184#endif
185
186#define RW_LOCK_UNLOCKED (rwlock_t) { RW_LOCK_BIAS RWLOCK_MAGIC_INIT }
187
188#define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
189
190/**
191 * read_can_lock - would read_trylock() succeed?
192 * @lock: the rwlock in question.
193 */
194#define read_can_lock(x) ((int)(x)->lock > 0)
195
196/**
197 * write_can_lock - would write_trylock() succeed?
198 * @lock: the rwlock in question.
199 */
200#define write_can_lock(x) ((x)->lock == RW_LOCK_BIAS)
201
202/*
203 * On x86, we implement read-write locks as a 32-bit counter
204 * with the high bit (sign) being the "contended" bit.
205 *
206 * The inline assembly is non-obvious. Think about it.
207 *
208 * Changed to use the same technique as rw semaphores. See
209 * semaphore.h for details. -ben
210 */
211/* the spinlock helpers are in arch/i386/kernel/semaphore.c */
212
213static inline void _raw_read_lock(rwlock_t *rw)
214{
215 unsigned long tmp0, tmp1;
216
217#ifdef CONFIG_DEBUG_SPINLOCK
218 BUG_ON(rw->magic != RWLOCK_MAGIC);
219#endif
220 /*
221 * rw->lock : >0 : unlock
222 * : <=0 : lock
223 *
224 * for ( ; ; ) {
225 * rw->lock -= 1; <-- need atomic operation
226 * if (rw->lock >= 0) break;
227 * rw->lock += 1; <-- need atomic operation
228 * for ( ; rw->lock <= 0 ; );
229 * }
230 */
231 __asm__ __volatile__ (
232 "# read_lock \n\t"
233 ".fillinsn \n"
234 "1: \n\t"
235 "mvfc %1, psw; \n\t"
236 "clrpsw #0x40 -> nop; \n\t"
237 DCACHE_CLEAR("%0", "r6", "%2")
238 "lock %0, @%2; \n\t"
239 "addi %0, #-1; \n\t"
240 "unlock %0, @%2; \n\t"
241 "mvtc %1, psw; \n\t"
242 "bltz %0, 2f; \n\t"
243 LOCK_SECTION_START(".balign 4 \n\t")
244 ".fillinsn \n"
245 "2: \n\t"
246 "clrpsw #0x40 -> nop; \n\t"
247 DCACHE_CLEAR("%0", "r6", "%2")
248 "lock %0, @%2; \n\t"
249 "addi %0, #1; \n\t"
250 "unlock %0, @%2; \n\t"
251 "mvtc %1, psw; \n\t"
252 ".fillinsn \n"
253 "3: \n\t"
254 "ld %0, @%2; \n\t"
255 "bgtz %0, 1b; \n\t"
256 "bra 3b; \n\t"
257 LOCK_SECTION_END
258 : "=&r" (tmp0), "=&r" (tmp1)
259 : "r" (&rw->lock)
260 : "memory"
261#ifdef CONFIG_CHIP_M32700_TS1
262 , "r6"
263#endif /* CONFIG_CHIP_M32700_TS1 */
264 );
265}
266
267static inline void _raw_write_lock(rwlock_t *rw)
268{
269 unsigned long tmp0, tmp1, tmp2;
270
271#ifdef CONFIG_DEBUG_SPINLOCK
272 BUG_ON(rw->magic != RWLOCK_MAGIC);
273#endif
274 /*
275 * rw->lock : =RW_LOCK_BIAS_STR : unlock
276 * : !=RW_LOCK_BIAS_STR : lock
277 *
278 * for ( ; ; ) {
279 * rw->lock -= RW_LOCK_BIAS_STR; <-- need atomic operation
280 * if (rw->lock == 0) break;
281 * rw->lock += RW_LOCK_BIAS_STR; <-- need atomic operation
282 * for ( ; rw->lock != RW_LOCK_BIAS_STR ; ) ;
283 * }
284 */
285 __asm__ __volatile__ (
286 "# write_lock \n\t"
287 "seth %1, #high(" RW_LOCK_BIAS_STR "); \n\t"
288 "or3 %1, %1, #low(" RW_LOCK_BIAS_STR "); \n\t"
289 ".fillinsn \n"
290 "1: \n\t"
291 "mvfc %2, psw; \n\t"
292 "clrpsw #0x40 -> nop; \n\t"
293 DCACHE_CLEAR("%0", "r7", "%3")
294 "lock %0, @%3; \n\t"
295 "sub %0, %1; \n\t"
296 "unlock %0, @%3; \n\t"
297 "mvtc %2, psw; \n\t"
298 "bnez %0, 2f; \n\t"
299 LOCK_SECTION_START(".balign 4 \n\t")
300 ".fillinsn \n"
301 "2: \n\t"
302 "clrpsw #0x40 -> nop; \n\t"
303 DCACHE_CLEAR("%0", "r7", "%3")
304 "lock %0, @%3; \n\t"
305 "add %0, %1; \n\t"
306 "unlock %0, @%3; \n\t"
307 "mvtc %2, psw; \n\t"
308 ".fillinsn \n"
309 "3: \n\t"
310 "ld %0, @%3; \n\t"
311 "beq %0, %1, 1b; \n\t"
312 "bra 3b; \n\t"
313 LOCK_SECTION_END
314 : "=&r" (tmp0), "=&r" (tmp1), "=&r" (tmp2)
315 : "r" (&rw->lock)
316 : "memory"
317#ifdef CONFIG_CHIP_M32700_TS1
318 , "r7"
319#endif /* CONFIG_CHIP_M32700_TS1 */
320 );
321}
322
323static inline void _raw_read_unlock(rwlock_t *rw)
324{
325 unsigned long tmp0, tmp1;
326
327 __asm__ __volatile__ (
328 "# read_unlock \n\t"
329 "mvfc %1, psw; \n\t"
330 "clrpsw #0x40 -> nop; \n\t"
331 DCACHE_CLEAR("%0", "r6", "%2")
332 "lock %0, @%2; \n\t"
333 "addi %0, #1; \n\t"
334 "unlock %0, @%2; \n\t"
335 "mvtc %1, psw; \n\t"
336 : "=&r" (tmp0), "=&r" (tmp1)
337 : "r" (&rw->lock)
338 : "memory"
339#ifdef CONFIG_CHIP_M32700_TS1
340 , "r6"
341#endif /* CONFIG_CHIP_M32700_TS1 */
342 );
343}
344
345static inline void _raw_write_unlock(rwlock_t *rw)
346{
347 unsigned long tmp0, tmp1, tmp2;
348
349 __asm__ __volatile__ (
350 "# write_unlock \n\t"
351 "seth %1, #high(" RW_LOCK_BIAS_STR "); \n\t"
352 "or3 %1, %1, #low(" RW_LOCK_BIAS_STR "); \n\t"
353 "mvfc %2, psw; \n\t"
354 "clrpsw #0x40 -> nop; \n\t"
355 DCACHE_CLEAR("%0", "r7", "%3")
356 "lock %0, @%3; \n\t"
357 "add %0, %1; \n\t"
358 "unlock %0, @%3; \n\t"
359 "mvtc %2, psw; \n\t"
360 : "=&r" (tmp0), "=&r" (tmp1), "=&r" (tmp2)
361 : "r" (&rw->lock)
362 : "memory"
363#ifdef CONFIG_CHIP_M32700_TS1
364 , "r7"
365#endif /* CONFIG_CHIP_M32700_TS1 */
366 );
367}
368
369#define _raw_read_trylock(lock) generic_raw_read_trylock(lock)
370
371static inline int _raw_write_trylock(rwlock_t *lock)
372{
373 atomic_t *count = (atomic_t *)lock;
374 if (atomic_sub_and_test(RW_LOCK_BIAS, count))
375 return 1;
376 atomic_add(RW_LOCK_BIAS, count);
377 return 0;
378}
379
380#endif /* _ASM_M32R_SPINLOCK_H */
diff --git a/include/asm-m32r/stat.h b/include/asm-m32r/stat.h
new file mode 100644
index 000000000000..05748fef4c8e
--- /dev/null
+++ b/include/asm-m32r/stat.h
@@ -0,0 +1,91 @@
1#ifndef _ASM_M32R_STAT_H
2#define _ASM_M32R_STAT_H
3
4/* $Id$ */
5
6/* orig : i386 2.4.18 */
7
8#include <asm/byteorder.h>
9
10struct __old_kernel_stat {
11 unsigned short st_dev;
12 unsigned short st_ino;
13 unsigned short st_mode;
14 unsigned short st_nlink;
15 unsigned short st_uid;
16 unsigned short st_gid;
17 unsigned short st_rdev;
18 unsigned long st_size;
19 unsigned long st_atime;
20 unsigned long st_mtime;
21 unsigned long st_ctime;
22};
23
24#define STAT_HAVE_NSEC 1
25
26struct stat {
27 unsigned short st_dev;
28 unsigned short __pad1;
29 unsigned long st_ino;
30 unsigned short st_mode;
31 unsigned short st_nlink;
32 unsigned short st_uid;
33 unsigned short st_gid;
34 unsigned short st_rdev;
35 unsigned short __pad2;
36 unsigned long st_size;
37 unsigned long st_blksize;
38 unsigned long st_blocks;
39 unsigned long st_atime;
40 unsigned long st_atime_nsec;
41 unsigned long st_mtime;
42 unsigned long st_mtime_nsec;
43 unsigned long st_ctime;
44 unsigned long st_ctime_nsec;
45 unsigned long __unused4;
46 unsigned long __unused5;
47};
48
49/* This matches struct stat64 in glibc2.1, hence the absolutely
50 * insane amounts of padding around dev_t's.
51 */
52struct stat64 {
53 unsigned long long st_dev;
54 unsigned char __pad0[4];
55#define STAT64_HAS_BROKEN_ST_INO
56 unsigned long __st_ino;
57
58 unsigned int st_mode;
59 unsigned int st_nlink;
60
61 unsigned long st_uid;
62 unsigned long st_gid;
63
64 unsigned long long st_rdev;
65 unsigned char __pad3[4];
66
67 long long st_size;
68 unsigned long st_blksize;
69
70#if defined(__BIG_ENDIAN)
71 unsigned long __pad4; /* future possible st_blocks high bits */
72 unsigned long st_blocks; /* Number 512-byte blocks allocated. */
73#elif defined(__LITTLE_ENDIAN)
74 unsigned long st_blocks; /* Number 512-byte blocks allocated. */
75 unsigned long __pad4; /* future possible st_blocks high bits */
76#else
77#error no endian defined
78#endif
79 unsigned long st_atime;
80 unsigned long st_atime_nsec;
81
82 unsigned long st_mtime;
83 unsigned long st_mtime_nsec;
84
85 unsigned long st_ctime;
86 unsigned long st_ctime_nsec;
87
88 unsigned long long st_ino;
89};
90
91#endif /* _ASM_M32R_STAT_H */
diff --git a/include/asm-m32r/statfs.h b/include/asm-m32r/statfs.h
new file mode 100644
index 000000000000..6eb4c6007e6b
--- /dev/null
+++ b/include/asm-m32r/statfs.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_M32R_STATFS_H
2#define _ASM_M32R_STATFS_H
3
4#include <asm-generic/statfs.h>
5
6#endif /* _ASM_M32R_STATFS_H */
diff --git a/include/asm-m32r/string.h b/include/asm-m32r/string.h
new file mode 100644
index 000000000000..cb54bcc2e677
--- /dev/null
+++ b/include/asm-m32r/string.h
@@ -0,0 +1,15 @@
1#ifndef _ASM_M32R_STRING_H
2#define _ASM_M32R_STRING_H
3
4/* $Id$ */
5
6#define __HAVE_ARCH_STRLEN
7extern size_t strlen(const char * s);
8
9#define __HAVE_ARCH_MEMCPY
10extern void *memcpy(void *__to, __const__ void *__from, size_t __n);
11
12#define __HAVE_ARCH_MEMSET
13extern void *memset(void *__s, int __c, size_t __count);
14
15#endif /* _ASM_M32R_STRING_H */
diff --git a/include/asm-m32r/syscall.h b/include/asm-m32r/syscall.h
new file mode 100644
index 000000000000..d8d4b2c7a7d4
--- /dev/null
+++ b/include/asm-m32r/syscall.h
@@ -0,0 +1,11 @@
1#ifndef _ASM_M32R_SYSCALL_H
2#define _ASM_M32R_SYSCALL_H
3
4/* $Id$ */
5
6/* Definitions for the system call vector. */
7#define SYSCALL_VECTOR "2"
8#define SYSCALL_VECTOR_ADDRESS "0xa0"
9
10#endif /* _ASM_M32R_SYSCALL_H */
11
diff --git a/include/asm-m32r/system.h b/include/asm-m32r/system.h
new file mode 100644
index 000000000000..73348c3f858b
--- /dev/null
+++ b/include/asm-m32r/system.h
@@ -0,0 +1,299 @@
1#ifndef _ASM_M32R_SYSTEM_H
2#define _ASM_M32R_SYSTEM_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * Copyright (C) 2001 by Hiroyuki Kondo, Hirokazu Takata, and Hitoshi Yamamoto
10 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
11 */
12
13#include <linux/config.h>
14
15#ifdef __KERNEL__
16
17/*
18 * switch_to(prev, next) should switch from task `prev' to `next'
19 * `prev' will never be the same as `next'.
20 *
21 * `next' and `prev' should be struct task_struct, but it isn't always defined
22 */
23
24#ifndef CONFIG_SMP
25#define prepare_to_switch() do { } while(0)
26#endif /* not CONFIG_SMP */
27
28#define switch_to(prev, next, last) do { \
29 register unsigned long arg0 __asm__ ("r0") = (unsigned long)prev; \
30 register unsigned long arg1 __asm__ ("r1") = (unsigned long)next; \
31 register unsigned long *oldsp __asm__ ("r2") = &(prev->thread.sp); \
32 register unsigned long *newsp __asm__ ("r3") = &(next->thread.sp); \
33 register unsigned long *oldlr __asm__ ("r4") = &(prev->thread.lr); \
34 register unsigned long *newlr __asm__ ("r5") = &(next->thread.lr); \
35 register struct task_struct *__last __asm__ ("r6"); \
36 __asm__ __volatile__ ( \
37 "st r8, @-r15 \n\t" \
38 "st r9, @-r15 \n\t" \
39 "st r10, @-r15 \n\t" \
40 "st r11, @-r15 \n\t" \
41 "st r12, @-r15 \n\t" \
42 "st r13, @-r15 \n\t" \
43 "st r14, @-r15 \n\t" \
44 "seth r14, #high(1f) \n\t" \
45 "or3 r14, r14, #low(1f) \n\t" \
46 "st r14, @r4 ; store old LR \n\t" \
47 "st r15, @r2 ; store old SP \n\t" \
48 "ld r15, @r3 ; load new SP \n\t" \
49 "st r0, @-r15 ; store 'prev' onto new stack \n\t" \
50 "ld r14, @r5 ; load new LR \n\t" \
51 "jmp r14 \n\t" \
52 ".fillinsn \n " \
53 "1: \n\t" \
54 "ld r6, @r15+ ; load 'prev' from new stack \n\t" \
55 "ld r14, @r15+ \n\t" \
56 "ld r13, @r15+ \n\t" \
57 "ld r12, @r15+ \n\t" \
58 "ld r11, @r15+ \n\t" \
59 "ld r10, @r15+ \n\t" \
60 "ld r9, @r15+ \n\t" \
61 "ld r8, @r15+ \n\t" \
62 : "=&r" (__last) \
63 : "r" (arg0), "r" (arg1), "r" (oldsp), "r" (newsp), \
64 "r" (oldlr), "r" (newlr) \
65 : "memory" \
66 ); \
67 last = __last; \
68} while(0)
69
70/* Interrupt Control */
71#if !defined(CONFIG_CHIP_M32102)
72#define local_irq_enable() \
73 __asm__ __volatile__ ("setpsw #0x40 -> nop": : :"memory")
74#define local_irq_disable() \
75 __asm__ __volatile__ ("clrpsw #0x40 -> nop": : :"memory")
76#else /* CONFIG_CHIP_M32102 */
77static inline void local_irq_enable(void)
78{
79 unsigned long tmpreg;
80 __asm__ __volatile__(
81 "mvfc %0, psw; \n\t"
82 "or3 %0, %0, #0x0040; \n\t"
83 "mvtc %0, psw; \n\t"
84 : "=&r" (tmpreg) : : "cbit", "memory");
85}
86
87static inline void local_irq_disable(void)
88{
89 unsigned long tmpreg0, tmpreg1;
90 __asm__ __volatile__(
91 "ld24 %0, #0 ; Use 32-bit insn. \n\t"
92 "mvfc %1, psw ; No interrupt can be accepted here. \n\t"
93 "mvtc %0, psw \n\t"
94 "and3 %0, %1, #0xffbf \n\t"
95 "mvtc %0, psw \n\t"
96 : "=&r" (tmpreg0), "=&r" (tmpreg1) : : "cbit", "memory");
97}
98#endif /* CONFIG_CHIP_M32102 */
99
100#define local_save_flags(x) \
101 __asm__ __volatile__("mvfc %0,psw" : "=r"(x) : /* no input */)
102
103#define local_irq_restore(x) \
104 __asm__ __volatile__("mvtc %0,psw" : /* no outputs */ \
105 : "r" (x) : "cbit", "memory")
106
107#if !defined(CONFIG_CHIP_M32102)
108#define local_irq_save(x) \
109 __asm__ __volatile__( \
110 "mvfc %0, psw; \n\t" \
111 "clrpsw #0x40 -> nop; \n\t" \
112 : "=r" (x) : /* no input */ : "memory")
113#else /* CONFIG_CHIP_M32102 */
114#define local_irq_save(x) \
115 ({ \
116 unsigned long tmpreg; \
117 __asm__ __volatile__( \
118 "ld24 %1, #0 \n\t" \
119 "mvfc %0, psw \n\t" \
120 "mvtc %1, psw \n\t" \
121 "and3 %1, %0, #0xffbf \n\t" \
122 "mvtc %1, psw \n\t" \
123 : "=r" (x), "=&r" (tmpreg) \
124 : : "cbit", "memory"); \
125 })
126#endif /* CONFIG_CHIP_M32102 */
127
128#define irqs_disabled() \
129 ({ \
130 unsigned long flags; \
131 local_save_flags(flags); \
132 !(flags & 0x40); \
133 })
134
135#endif /* __KERNEL__ */
136
137#define nop() __asm__ __volatile__ ("nop" : : )
138
139#define xchg(ptr,x) \
140 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
141
142#define tas(ptr) (xchg((ptr),1))
143
144#ifdef CONFIG_SMP
145extern void __xchg_called_with_bad_pointer(void);
146#endif
147
148#ifdef CONFIG_CHIP_M32700_TS1
149#define DCACHE_CLEAR(reg0, reg1, addr) \
150 "seth "reg1", #high(dcache_dummy); \n\t" \
151 "or3 "reg1", "reg1", #low(dcache_dummy); \n\t" \
152 "lock "reg0", @"reg1"; \n\t" \
153 "add3 "reg0", "addr", #0x1000; \n\t" \
154 "ld "reg0", @"reg0"; \n\t" \
155 "add3 "reg0", "addr", #0x2000; \n\t" \
156 "ld "reg0", @"reg0"; \n\t" \
157 "unlock "reg0", @"reg1"; \n\t"
158 /* FIXME: This workaround code cannot handle kenrel modules
159 * correctly under SMP environment.
160 */
161#else /* CONFIG_CHIP_M32700_TS1 */
162#define DCACHE_CLEAR(reg0, reg1, addr)
163#endif /* CONFIG_CHIP_M32700_TS1 */
164
165static __inline__ unsigned long __xchg(unsigned long x, volatile void * ptr,
166 int size)
167{
168 unsigned long flags;
169 unsigned long tmp = 0;
170
171 local_irq_save(flags);
172
173 switch (size) {
174#ifndef CONFIG_SMP
175 case 1:
176 __asm__ __volatile__ (
177 "ldb %0, @%2 \n\t"
178 "stb %1, @%2 \n\t"
179 : "=&r" (tmp) : "r" (x), "r" (ptr) : "memory");
180 break;
181 case 2:
182 __asm__ __volatile__ (
183 "ldh %0, @%2 \n\t"
184 "sth %1, @%2 \n\t"
185 : "=&r" (tmp) : "r" (x), "r" (ptr) : "memory");
186 break;
187 case 4:
188 __asm__ __volatile__ (
189 "ld %0, @%2 \n\t"
190 "st %1, @%2 \n\t"
191 : "=&r" (tmp) : "r" (x), "r" (ptr) : "memory");
192 break;
193#else /* CONFIG_SMP */
194 case 4:
195 __asm__ __volatile__ (
196 DCACHE_CLEAR("%0", "r4", "%2")
197 "lock %0, @%2; \n\t"
198 "unlock %1, @%2; \n\t"
199 : "=&r" (tmp) : "r" (x), "r" (ptr)
200 : "memory"
201#ifdef CONFIG_CHIP_M32700_TS1
202 , "r4"
203#endif /* CONFIG_CHIP_M32700_TS1 */
204 );
205 break;
206 default:
207 __xchg_called_with_bad_pointer();
208#endif /* CONFIG_SMP */
209 }
210
211 local_irq_restore(flags);
212
213 return (tmp);
214}
215
216/*
217 * Memory barrier.
218 *
219 * mb() prevents loads and stores being reordered across this point.
220 * rmb() prevents loads being reordered across this point.
221 * wmb() prevents stores being reordered across this point.
222 */
223#define mb() barrier()
224#define rmb() mb()
225#define wmb() mb()
226
227/**
228 * read_barrier_depends - Flush all pending reads that subsequents reads
229 * depend on.
230 *
231 * No data-dependent reads from memory-like regions are ever reordered
232 * over this barrier. All reads preceding this primitive are guaranteed
233 * to access memory (but not necessarily other CPUs' caches) before any
234 * reads following this primitive that depend on the data return by
235 * any of the preceding reads. This primitive is much lighter weight than
236 * rmb() on most CPUs, and is never heavier weight than is
237 * rmb().
238 *
239 * These ordering constraints are respected by both the local CPU
240 * and the compiler.
241 *
242 * Ordering is not guaranteed by anything other than these primitives,
243 * not even by data dependencies. See the documentation for
244 * memory_barrier() for examples and URLs to more information.
245 *
246 * For example, the following code would force ordering (the initial
247 * value of "a" is zero, "b" is one, and "p" is "&a"):
248 *
249 * <programlisting>
250 * CPU 0 CPU 1
251 *
252 * b = 2;
253 * memory_barrier();
254 * p = &b; q = p;
255 * read_barrier_depends();
256 * d = *q;
257 * </programlisting>
258 *
259 *
260 * because the read of "*q" depends on the read of "p" and these
261 * two reads are separated by a read_barrier_depends(). However,
262 * the following code, with the same initial values for "a" and "b":
263 *
264 * <programlisting>
265 * CPU 0 CPU 1
266 *
267 * a = 2;
268 * memory_barrier();
269 * b = 3; y = b;
270 * read_barrier_depends();
271 * x = a;
272 * </programlisting>
273 *
274 * does not enforce ordering, since there is no data dependency between
275 * the read of "a" and the read of "b". Therefore, on some CPUs, such
276 * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()
277 * in cases like thiswhere there are no data dependencies.
278 **/
279
280#define read_barrier_depends() do { } while (0)
281
282#ifdef CONFIG_SMP
283#define smp_mb() mb()
284#define smp_rmb() rmb()
285#define smp_wmb() wmb()
286#define smp_read_barrier_depends() read_barrier_depends()
287#else
288#define smp_mb() barrier()
289#define smp_rmb() barrier()
290#define smp_wmb() barrier()
291#define smp_read_barrier_depends() do { } while (0)
292#endif
293
294#define set_mb(var, value) do { xchg(&var, value); } while (0)
295#define set_wmb(var, value) do { var = value; wmb(); } while (0)
296
297#define arch_align_stack(x) (x)
298
299#endif /* _ASM_M32R_SYSTEM_H */
diff --git a/include/asm-m32r/termbits.h b/include/asm-m32r/termbits.h
new file mode 100644
index 000000000000..5ace3702df75
--- /dev/null
+++ b/include/asm-m32r/termbits.h
@@ -0,0 +1,176 @@
1#ifndef _ASM_M32R_TERMBITS_H
2#define _ASM_M32R_TERMBITS_H
3
4/* $Id$ */
5
6#include <linux/posix_types.h>
7
8typedef unsigned char cc_t;
9typedef unsigned int speed_t;
10typedef unsigned int tcflag_t;
11
12#define NCCS 19
13struct termios {
14 tcflag_t c_iflag; /* input mode flags */
15 tcflag_t c_oflag; /* output mode flags */
16 tcflag_t c_cflag; /* control mode flags */
17 tcflag_t c_lflag; /* local mode flags */
18 cc_t c_line; /* line discipline */
19 cc_t c_cc[NCCS]; /* control characters */
20};
21
22/* c_cc characters */
23#define VINTR 0
24#define VQUIT 1
25#define VERASE 2
26#define VKILL 3
27#define VEOF 4
28#define VTIME 5
29#define VMIN 6
30#define VSWTC 7
31#define VSTART 8
32#define VSTOP 9
33#define VSUSP 10
34#define VEOL 11
35#define VREPRINT 12
36#define VDISCARD 13
37#define VWERASE 14
38#define VLNEXT 15
39#define VEOL2 16
40
41/* c_iflag bits */
42#define IGNBRK 0000001
43#define BRKINT 0000002
44#define IGNPAR 0000004
45#define PARMRK 0000010
46#define INPCK 0000020
47#define ISTRIP 0000040
48#define INLCR 0000100
49#define IGNCR 0000200
50#define ICRNL 0000400
51#define IUCLC 0001000
52#define IXON 0002000
53#define IXANY 0004000
54#define IXOFF 0010000
55#define IMAXBEL 0020000
56#define IUTF8 0040000
57
58/* c_oflag bits */
59#define OPOST 0000001
60#define OLCUC 0000002
61#define ONLCR 0000004
62#define OCRNL 0000010
63#define ONOCR 0000020
64#define ONLRET 0000040
65#define OFILL 0000100
66#define OFDEL 0000200
67#define NLDLY 0000400
68#define NL0 0000000
69#define NL1 0000400
70#define CRDLY 0003000
71#define CR0 0000000
72#define CR1 0001000
73#define CR2 0002000
74#define CR3 0003000
75#define TABDLY 0014000
76#define TAB0 0000000
77#define TAB1 0004000
78#define TAB2 0010000
79#define TAB3 0014000
80#define XTABS 0014000
81#define BSDLY 0020000
82#define BS0 0000000
83#define BS1 0020000
84#define VTDLY 0040000
85#define VT0 0000000
86#define VT1 0040000
87#define FFDLY 0100000
88#define FF0 0000000
89#define FF1 0100000
90
91/* c_cflag bit meaning */
92#define CBAUD 0010017
93#define B0 0000000 /* hang up */
94#define B50 0000001
95#define B75 0000002
96#define B110 0000003
97#define B134 0000004
98#define B150 0000005
99#define B200 0000006
100#define B300 0000007
101#define B600 0000010
102#define B1200 0000011
103#define B1800 0000012
104#define B2400 0000013
105#define B4800 0000014
106#define B9600 0000015
107#define B19200 0000016
108#define B38400 0000017
109#define EXTA B19200
110#define EXTB B38400
111#define CSIZE 0000060
112#define CS5 0000000
113#define CS6 0000020
114#define CS7 0000040
115#define CS8 0000060
116#define CSTOPB 0000100
117#define CREAD 0000200
118#define PARENB 0000400
119#define PARODD 0001000
120#define HUPCL 0002000
121#define CLOCAL 0004000
122#define CBAUDEX 0010000
123#define B57600 0010001
124#define B115200 0010002
125#define B230400 0010003
126#define B460800 0010004
127#define B500000 0010005
128#define B576000 0010006
129#define B921600 0010007
130#define B1000000 0010010
131#define B1152000 0010011
132#define B1500000 0010012
133#define B2000000 0010013
134#define B2500000 0010014
135#define B3000000 0010015
136#define B3500000 0010016
137#define B4000000 0010017
138#define CIBAUD 002003600000 /* input baud rate (not used) */
139#define CTVB 004000000000 /* VisioBraille Terminal flow control */
140#define CMSPAR 010000000000 /* mark or space (stick) parity */
141#define CRTSCTS 020000000000 /* flow control */
142
143/* c_lflag bits */
144#define ISIG 0000001
145#define ICANON 0000002
146#define XCASE 0000004
147#define ECHO 0000010
148#define ECHOE 0000020
149#define ECHOK 0000040
150#define ECHONL 0000100
151#define NOFLSH 0000200
152#define TOSTOP 0000400
153#define ECHOCTL 0001000
154#define ECHOPRT 0002000
155#define ECHOKE 0004000
156#define FLUSHO 0010000
157#define PENDIN 0040000
158#define IEXTEN 0100000
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_M32R_TERMBITS_H */
diff --git a/include/asm-m32r/termios.h b/include/asm-m32r/termios.h
new file mode 100644
index 000000000000..fc99d2e178d8
--- /dev/null
+++ b/include/asm-m32r/termios.h
@@ -0,0 +1,109 @@
1#ifndef _M32R_TERMIOS_H
2#define _M32R_TERMIOS_H
3
4/* orig : i386 2.6.0-test5 */
5
6#include <asm/termbits.h>
7#include <asm/ioctls.h>
8
9struct winsize {
10 unsigned short ws_row;
11 unsigned short ws_col;
12 unsigned short ws_xpixel;
13 unsigned short ws_ypixel;
14};
15
16#define NCC 8
17struct termio {
18 unsigned short c_iflag; /* input mode flags */
19 unsigned short c_oflag; /* output mode flags */
20 unsigned short c_cflag; /* control mode flags */
21 unsigned short c_lflag; /* local mode flags */
22 unsigned char c_line; /* line discipline */
23 unsigned char c_cc[NCC]; /* control characters */
24};
25
26/* modem lines */
27#define TIOCM_LE 0x001
28#define TIOCM_DTR 0x002
29#define TIOCM_RTS 0x004
30#define TIOCM_ST 0x008
31#define TIOCM_SR 0x010
32#define TIOCM_CTS 0x020
33#define TIOCM_CAR 0x040
34#define TIOCM_RNG 0x080
35#define TIOCM_DSR 0x100
36#define TIOCM_CD TIOCM_CAR
37#define TIOCM_RI TIOCM_RNG
38#define TIOCM_OUT1 0x2000
39#define TIOCM_OUT2 0x4000
40#define TIOCM_LOOP 0x8000
41
42/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
43
44/* line disciplines */
45#define N_TTY 0
46#define N_SLIP 1
47#define N_MOUSE 2
48#define N_PPP 3
49#define N_STRIP 4
50#define N_AX25 5
51#define N_X25 6 /* X.25 async */
52#define N_6PACK 7
53#define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
54#define N_R3964 9 /* Reserved for Simatic R3964 module */
55#define N_PROFIBUS_FDL 10 /* Reserved for Profibus <Dave@mvhi.com> */
56#define N_IRDA 11 /* Linux IR - http://irda.sourceforge.net/ */
57#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */
58#define N_HDLC 13 /* synchronous HDLC */
59#define N_SYNC_PPP 14 /* synchronous PPP */
60#define N_HCI 15 /* Bluetooth HCI UART */
61
62#ifdef __KERNEL__
63#include <linux/module.h>
64
65/* intr=^C quit=^\ erase=del kill=^U
66 eof=^D vtime=\0 vmin=\1 sxtc=\0
67 start=^Q stop=^S susp=^Z eol=\0
68 reprint=^R discard=^U werase=^W lnext=^V
69 eol2=\0
70*/
71#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
72
73/*
74 * Translate a "termio" structure into a "termios". Ugh.
75 */
76#define SET_LOW_TERMIOS_BITS(termios, termio, x) { \
77 unsigned short __tmp; \
78 get_user(__tmp,&(termio)->x); \
79 *(unsigned short *) &(termios)->x = __tmp; \
80}
81
82#define user_termio_to_kernel_termios(termios, termio) \
83({ \
84 SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
85 SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
86 SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
87 SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
88 copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
89})
90
91/*
92 * Translate a "termios" structure into a "termio". Ugh.
93 */
94#define kernel_termios_to_user_termio(termio, termios) \
95({ \
96 put_user((termios)->c_iflag, &(termio)->c_iflag); \
97 put_user((termios)->c_oflag, &(termio)->c_oflag); \
98 put_user((termios)->c_cflag, &(termio)->c_cflag); \
99 put_user((termios)->c_lflag, &(termio)->c_lflag); \
100 put_user((termios)->c_line, &(termio)->c_line); \
101 copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
102})
103
104#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
105#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
106
107#endif /* __KERNEL__ */
108
109#endif /* _M32R_TERMIOS_H */
diff --git a/include/asm-m32r/thread_info.h b/include/asm-m32r/thread_info.h
new file mode 100644
index 000000000000..9f3a0fcf6e2b
--- /dev/null
+++ b/include/asm-m32r/thread_info.h
@@ -0,0 +1,182 @@
1#ifndef _ASM_M32R_THREAD_INFO_H
2#define _ASM_M32R_THREAD_INFO_H
3
4/* thread_info.h: m32r low-level thread information
5 *
6 * Copyright (C) 2002 David Howells (dhowells@redhat.com)
7 * - Incorporating suggestions made by Linus Torvalds and Dave Miller
8 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
9 */
10
11#ifdef __KERNEL__
12
13#ifndef __ASSEMBLY__
14#include <asm/processor.h>
15#endif
16
17/*
18 * low level task data that entry.S needs immediate access to
19 * - this struct should fit entirely inside of one cache line
20 * - this struct shares the supervisor stack pages
21 * - if the contents of this structure are changed, the assembly constants must also be changed
22 */
23#ifndef __ASSEMBLY__
24
25struct thread_info {
26 struct task_struct *task; /* main task structure */
27 struct exec_domain *exec_domain; /* execution domain */
28 unsigned long flags; /* low level flags */
29 unsigned long status; /* thread-synchronous flags */
30 __u32 cpu; /* current CPU */
31 __s32 preempt_count; /* 0 => preemptable, <0 => BUG */
32
33 mm_segment_t addr_limit; /* thread address space:
34 0-0xBFFFFFFF for user-thread
35 0-0xFFFFFFFF for kernel-thread
36 */
37 struct restart_block restart_block;
38
39 __u8 supervisor_stack[0];
40};
41
42#else /* !__ASSEMBLY__ */
43
44/* offsets into the thread_info struct for assembly code access */
45#define TI_TASK 0x00000000
46#define TI_EXEC_DOMAIN 0x00000004
47#define TI_FLAGS 0x00000008
48#define TI_STATUS 0x0000000C
49#define TI_CPU 0x00000010
50#define TI_PRE_COUNT 0x00000014
51#define TI_ADDR_LIMIT 0x00000018
52#define TI_RESTART_BLOCK 0x000001C
53
54#endif
55
56#define PREEMPT_ACTIVE 0x10000000
57
58/*
59 * macros/functions for gaining access to the thread information structure
60 *
61 * preempt_count needs to be 1 initially, until the scheduler is functional.
62 */
63#ifndef __ASSEMBLY__
64
65#define INIT_THREAD_INFO(tsk) \
66{ \
67 .task = &tsk, \
68 .exec_domain = &default_exec_domain, \
69 .flags = 0, \
70 .cpu = 0, \
71 .preempt_count = 1, \
72 .addr_limit = KERNEL_DS, \
73 .restart_block = { \
74 .fn = do_no_restart_syscall, \
75 }, \
76}
77
78#define init_thread_info (init_thread_union.thread_info)
79#define init_stack (init_thread_union.stack)
80
81#define THREAD_SIZE (2*PAGE_SIZE)
82
83/* how to get the thread information struct from C */
84static inline struct thread_info *current_thread_info(void)
85{
86 struct thread_info *ti;
87
88 __asm__ __volatile__ (
89 "ldi %0, #%1 \n\t"
90 "and %0, sp \n\t"
91 : "=r" (ti) : "i" (~(THREAD_SIZE - 1))
92 );
93
94 return ti;
95}
96
97/* thread information allocation */
98#if 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#define TI_FLAG_FAULT_CODE_SHIFT 28
117
118static inline void set_thread_fault_code(unsigned int val)
119{
120 struct thread_info *ti = current_thread_info();
121 ti->flags = (ti->flags & (~0 >> (32 - TI_FLAG_FAULT_CODE_SHIFT)))
122 | (val << TI_FLAG_FAULT_CODE_SHIFT);
123}
124
125static inline unsigned int get_thread_fault_code(void)
126{
127 struct thread_info *ti = current_thread_info();
128 return ti->flags >> TI_FLAG_FAULT_CODE_SHIFT;
129}
130
131#else /* !__ASSEMBLY__ */
132
133#define THREAD_SIZE 8192
134
135/* how to get the thread information struct from ASM */
136#define GET_THREAD_INFO(reg) GET_THREAD_INFO reg
137 .macro GET_THREAD_INFO reg
138 ldi \reg, #-THREAD_SIZE
139 and \reg, sp
140 .endm
141
142#endif
143
144/*
145 * thread information flags
146 * - these are process state flags that various assembly files may need to access
147 * - pending work-to-be-done flags are in LSW
148 * - other flags in MSW
149 */
150#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
151#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
152#define TIF_SIGPENDING 2 /* signal pending */
153#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
154#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
155#define TIF_IRET 5 /* return with iret */
156#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
157 /* 31..28 fault code */
158#define TIF_MEMDIE 17
159
160#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
161#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
162#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
163#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
164#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
165#define _TIF_IRET (1<<TIF_IRET)
166#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
167
168#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
169#define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
170
171/*
172 * Thread-synchronous status.
173 *
174 * This is different from the flags in that nobody else
175 * ever touches our thread-synchronous status, so we don't
176 * have to worry about atomic accesses.
177 */
178#define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */
179
180#endif /* __KERNEL__ */
181
182#endif /* _ASM_M32R_THREAD_INFO_H */
diff --git a/include/asm-m32r/timex.h b/include/asm-m32r/timex.h
new file mode 100644
index 000000000000..abf12e7ffbf3
--- /dev/null
+++ b/include/asm-m32r/timex.h
@@ -0,0 +1,34 @@
1#ifndef _ASM_M32R_TIMEX_H
2#define _ASM_M32R_TIMEX_H
3
4/* $Id$ */
5
6/*
7 * linux/include/asm-m32r/timex.h
8 *
9 * m32r architecture timex specifications
10 */
11
12#include <linux/config.h>
13
14#define CLOCK_TICK_RATE (CONFIG_BUS_CLOCK / CONFIG_TIMER_DIVIDE)
15#define CLOCK_TICK_FACTOR 20 /* Factor of both 1000000 and CLOCK_TICK_RATE */
16#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
17 (1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
18 << (SHIFT_SCALE-SHIFT_HZ)) / HZ)
19
20#ifdef __KERNEL__
21/*
22 * Standard way to access the cycle counter.
23 * Currently only used on SMP.
24 */
25
26typedef unsigned long long cycles_t;
27
28static __inline__ cycles_t get_cycles (void)
29{
30 return 0;
31}
32#endif /* __KERNEL__ */
33
34#endif /* _ASM_M32R_TIMEX_H */
diff --git a/include/asm-m32r/tlb.h b/include/asm-m32r/tlb.h
new file mode 100644
index 000000000000..c7ebd8d48f3b
--- /dev/null
+++ b/include/asm-m32r/tlb.h
@@ -0,0 +1,20 @@
1#ifndef _M32R_TLB_H
2#define _M32R_TLB_H
3
4/*
5 * x86 doesn't need any special per-pte or
6 * per-vma handling..
7 */
8#define tlb_start_vma(tlb, vma) do { } while (0)
9#define tlb_end_vma(tlb, vma) do { } while (0)
10#define __tlb_remove_tlb_entry(tlb, pte, address) do { } while (0)
11
12/*
13 * .. because we flush the whole mm when it
14 * fills up.
15 */
16#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm)
17
18#include <asm-generic/tlb.h>
19
20#endif /* _M32R_TLB_H */
diff --git a/include/asm-m32r/tlbflush.h b/include/asm-m32r/tlbflush.h
new file mode 100644
index 000000000000..bc7c407dbd92
--- /dev/null
+++ b/include/asm-m32r/tlbflush.h
@@ -0,0 +1,102 @@
1#ifndef _ASM_M32R_TLBFLUSH_H
2#define _ASM_M32R_TLBFLUSH_H
3
4#include <linux/config.h>
5#include <asm/m32r.h>
6
7/*
8 * TLB flushing:
9 *
10 * - flush_tlb() flushes the current mm struct TLBs
11 * - flush_tlb_all() flushes all processes TLBs
12 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
13 * - flush_tlb_page(vma, vmaddr) flushes one page
14 * - flush_tlb_range(vma, start, end) flushes a range of pages
15 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
16 * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
17 */
18
19extern void local_flush_tlb_all(void);
20extern void local_flush_tlb_mm(struct mm_struct *);
21extern void local_flush_tlb_page(struct vm_area_struct *, unsigned long);
22extern void local_flush_tlb_range(struct vm_area_struct *, unsigned long,
23 unsigned long);
24
25#ifndef CONFIG_SMP
26#ifdef CONFIG_MMU
27#define flush_tlb_all() local_flush_tlb_all()
28#define flush_tlb_mm(mm) local_flush_tlb_mm(mm)
29#define flush_tlb_page(vma, page) local_flush_tlb_page(vma, page)
30#define flush_tlb_range(vma, start, end) \
31 local_flush_tlb_range(vma, start, end)
32#define flush_tlb_kernel_range(start, end) local_flush_tlb_all()
33#else /* CONFIG_MMU */
34#define flush_tlb_all() do { } while (0)
35#define flush_tlb_mm(mm) do { } while (0)
36#define flush_tlb_page(vma, vmaddr) do { } while (0)
37#define flush_tlb_range(vma, start, end) do { } while (0)
38#endif /* CONFIG_MMU */
39#else /* CONFIG_SMP */
40extern void smp_flush_tlb_all(void);
41extern void smp_flush_tlb_mm(struct mm_struct *);
42extern void smp_flush_tlb_page(struct vm_area_struct *, unsigned long);
43extern void smp_flush_tlb_range(struct vm_area_struct *, unsigned long,
44 unsigned long);
45
46#define flush_tlb_all() smp_flush_tlb_all()
47#define flush_tlb_mm(mm) smp_flush_tlb_mm(mm)
48#define flush_tlb_page(vma, page) smp_flush_tlb_page(vma, page)
49#define flush_tlb_range(vma, start, end) \
50 smp_flush_tlb_range(vma, start, end)
51#define flush_tlb_kernel_range(start, end) smp_flush_tlb_all()
52#endif /* CONFIG_SMP */
53
54static __inline__ void __flush_tlb_page(unsigned long page)
55{
56 unsigned int tmpreg0, tmpreg1, tmpreg2;
57
58 __asm__ __volatile__ (
59 "seth %0, #high(%4) \n\t"
60 "st %3, @(%5, %0) \n\t"
61 "ldi %1, #1 \n\t"
62 "st %1, @(%6, %0) \n\t"
63 "add3 %1, %0, %7 \n\t"
64 ".fillinsn \n"
65 "1: \n\t"
66 "ld %2, @(%6, %0) \n\t"
67 "bnez %2, 1b \n\t"
68 "ld %0, @%1+ \n\t"
69 "ld %1, @%1 \n\t"
70 "st %2, @+%0 \n\t"
71 "st %2, @+%1 \n\t"
72 : "=&r" (tmpreg0), "=&r" (tmpreg1), "=&r" (tmpreg2)
73 : "r" (page), "i" (MMU_REG_BASE), "i" (MSVA_offset),
74 "i" (MTOP_offset), "i" (MIDXI_offset)
75 : "memory"
76 );
77}
78
79static __inline__ void __flush_tlb_all(void)
80{
81 unsigned int tmpreg0, tmpreg1;
82
83 __asm__ __volatile__ (
84 "seth %0, #high(%2) \n\t"
85 "or3 %0, %0, #low(%2) \n\t"
86 "ldi %1, #0xc \n\t"
87 "st %1, @%0 \n\t"
88 ".fillinsn \n"
89 "1: \n\t"
90 "ld %1, @%0 \n\t"
91 "bnez %1, 1b \n\t"
92 : "=&r" (tmpreg0), "=&r" (tmpreg1)
93 : "i" (MTOP) : "memory"
94 );
95}
96
97#define flush_tlb_pgtables(mm, start, end) do { } while (0)
98
99extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t);
100
101#endif /* _ASM_M32R_TLBFLUSH_H */
102
diff --git a/include/asm-m32r/topology.h b/include/asm-m32r/topology.h
new file mode 100644
index 000000000000..299a89d91bde
--- /dev/null
+++ b/include/asm-m32r/topology.h
@@ -0,0 +1,48 @@
1/*
2 * linux/include/asm-generic/topology.h
3 *
4 * Written by: Matthew Dobson, IBM Corporation
5 *
6 * Copyright (C) 2002, IBM Corp.
7 *
8 * All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
18 * NON INFRINGEMENT. See the GNU General Public License for more
19 * details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * Send feedback to <colpatch@us.ibm.com>
26 */
27#ifndef _ASM_M32R_TOPOLOGY_H
28#define _ASM_M32R_TOPOLOGY_H
29
30/* Other architectures wishing to use this simple topology API should fill
31 in the below functions as appropriate in their own <asm/topology.h> file. */
32
33#define cpu_to_node(cpu) (0)
34
35#ifndef parent_node
36#define parent_node(node) (0)
37#endif
38#ifndef node_to_cpumask
39#define node_to_cpumask(node) (cpu_online_map)
40#endif
41#ifndef node_to_first_cpu
42#define node_to_first_cpu(node) (0)
43#endif
44#ifndef pcibus_to_cpumask
45#define pcibus_to_cpumask(bus) (cpu_online_map)
46#endif
47
48#endif /* _ASM_M32R_TOPOLOGY_H */
diff --git a/include/asm-m32r/types.h b/include/asm-m32r/types.h
new file mode 100644
index 000000000000..ca0a887d2237
--- /dev/null
+++ b/include/asm-m32r/types.h
@@ -0,0 +1,64 @@
1#ifndef _ASM_M32R_TYPES_H
2#define _ASM_M32R_TYPES_H
3
4#ifndef __ASSEMBLY__
5
6/* $Id$ */
7
8/* orig : i386 2.4.18 */
9
10typedef unsigned short umode_t;
11
12/*
13 * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
14 * header files exported to user space
15 */
16
17typedef __signed__ char __s8;
18typedef unsigned char __u8;
19
20typedef __signed__ short __s16;
21typedef unsigned short __u16;
22
23typedef __signed__ int __s32;
24typedef unsigned int __u32;
25
26#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
27typedef __signed__ long long __s64;
28typedef unsigned long long __u64;
29#endif
30#endif /* __ASSEMBLY__ */
31
32/*
33 * These aren't exported outside the kernel to avoid name space clashes
34 */
35#ifdef __KERNEL__
36
37#define BITS_PER_LONG 32
38
39#ifndef __ASSEMBLY__
40
41typedef signed char s8;
42typedef unsigned char u8;
43
44typedef signed short s16;
45typedef unsigned short u16;
46
47typedef signed int s32;
48typedef unsigned int u32;
49
50typedef signed long long s64;
51typedef unsigned long long u64;
52
53/* DMA addresses are 32-bits wide. */
54
55typedef u32 dma_addr_t;
56typedef u64 dma64_addr_t;
57
58typedef unsigned short kmem_bufctl_t;
59
60#endif /* __ASSEMBLY__ */
61
62#endif /* __KERNEL__ */
63
64#endif /* _ASM_M32R_TYPES_H */
diff --git a/include/asm-m32r/uaccess.h b/include/asm-m32r/uaccess.h
new file mode 100644
index 000000000000..bbb8ac4018a0
--- /dev/null
+++ b/include/asm-m32r/uaccess.h
@@ -0,0 +1,753 @@
1#ifndef _ASM_M32R_UACCESS_H
2#define _ASM_M32R_UACCESS_H
3
4/*
5 * linux/include/asm-m32r/uaccess.h
6 *
7 * M32R version.
8 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
9 */
10
11#undef UACCESS_DEBUG
12
13#ifdef UACCESS_DEBUG
14#define UAPRINTK(args...) printk(args)
15#else
16#define UAPRINTK(args...)
17#endif /* UACCESS_DEBUG */
18
19/*
20 * User space memory access functions
21 */
22#include <linux/config.h>
23#include <linux/errno.h>
24#include <linux/thread_info.h>
25#include <asm/page.h>
26
27#define VERIFY_READ 0
28#define VERIFY_WRITE 1
29
30/*
31 * The fs value determines whether argument validity checking should be
32 * performed or not. If get_fs() == USER_DS, checking is performed, with
33 * get_fs() == KERNEL_DS, checking is bypassed.
34 *
35 * For historical reasons, these macros are grossly misnamed.
36 */
37
38#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
39
40#ifdef CONFIG_MMU
41#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
42#define USER_DS MAKE_MM_SEG(PAGE_OFFSET)
43#else
44#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
45#define USER_DS MAKE_MM_SEG(0xFFFFFFFF)
46#endif /* CONFIG_MMU */
47
48#define get_ds() (KERNEL_DS)
49#ifdef CONFIG_MMU
50#define get_fs() (current_thread_info()->addr_limit)
51#define set_fs(x) (current_thread_info()->addr_limit = (x))
52#else
53static inline mm_segment_t get_fs(void)
54{
55 return USER_DS;
56}
57
58static inline void set_fs(mm_segment_t s)
59{
60}
61#endif /* CONFIG_MMU */
62
63#define segment_eq(a,b) ((a).seg == (b).seg)
64
65#define __addr_ok(addr) \
66 ((unsigned long)(addr) < (current_thread_info()->addr_limit.seg))
67
68/*
69 * Test whether a block of memory is a valid user space address.
70 * Returns 0 if the range is valid, nonzero otherwise.
71 *
72 * This is equivalent to the following test:
73 * (u33)addr + (u33)size >= (u33)current->addr_limit.seg
74 *
75 * This needs 33-bit arithmetic. We have a carry...
76 */
77#define __range_ok(addr,size) ({ \
78 unsigned long flag, sum; \
79 __chk_user_ptr(addr); \
80 asm ( \
81 " cmpu %1, %1 ; clear cbit\n" \
82 " addx %1, %3 ; set cbit if overflow\n" \
83 " subx %0, %0\n" \
84 " cmpu %4, %1\n" \
85 " subx %0, %5\n" \
86 : "=&r"(flag), "=r"(sum) \
87 : "1"(addr), "r"((int)(size)), \
88 "r"(current_thread_info()->addr_limit.seg), "r"(0) \
89 : "cbit" ); \
90 flag; })
91
92/**
93 * access_ok: - Checks if a user space pointer is valid
94 * @type: Type of access: %VERIFY_READ or %VERIFY_WRITE. Note that
95 * %VERIFY_WRITE is a superset of %VERIFY_READ - if it is safe
96 * to write to a block, it is always safe to read from it.
97 * @addr: User space pointer to start of block to check
98 * @size: Size of block to check
99 *
100 * Context: User context only. This function may sleep.
101 *
102 * Checks if a pointer to a block of memory in user space is valid.
103 *
104 * Returns true (nonzero) if the memory block may be valid, false (zero)
105 * if it is definitely invalid.
106 *
107 * Note that, depending on architecture, this function probably just
108 * checks that the pointer is in the user space range - after calling
109 * this function, memory access functions may still return -EFAULT.
110 */
111#ifdef CONFIG_MMU
112#define access_ok(type,addr,size) (likely(__range_ok(addr,size) == 0))
113#else
114static inline int access_ok(int type, const void *addr, unsigned long size)
115{
116 extern unsigned long memory_start, memory_end;
117 unsigned long val = (unsigned long)addr;
118
119 return ((val >= memory_start) && ((val + size) < memory_end));
120}
121#endif /* CONFIG_MMU */
122
123/**
124 * verify_area: - Obsolete/deprecated and will go away soon,
125 * use access_ok() instead.
126 * @type: Type of access: %VERIFY_READ or %VERIFY_WRITE
127 * @addr: User space pointer to start of block to check
128 * @size: Size of block to check
129 *
130 * Context: User context only. This function may sleep.
131 *
132 * This function has been replaced by access_ok().
133 *
134 * Checks if a pointer to a block of memory in user space is valid.
135 *
136 * Returns zero if the memory block may be valid, -EFAULT
137 * if it is definitely invalid.
138 *
139 * See access_ok() for more details.
140 */
141static inline int __deprecated verify_area(int type, const void __user *addr,
142 unsigned long size)
143{
144 return access_ok(type, addr, size) ? 0 : -EFAULT;
145}
146
147
148/*
149 * The exception table consists of pairs of addresses: the first is the
150 * address of an instruction that is allowed to fault, and the second is
151 * the address at which the program should continue. No registers are
152 * modified, so it is entirely up to the continuation code to figure out
153 * what to do.
154 *
155 * All the routines below use bits of fixup code that are out of line
156 * with the main instruction path. This means when everything is well,
157 * we don't even have to jump over them. Further, they do not intrude
158 * on our cache or tlb entries.
159 */
160
161struct exception_table_entry
162{
163 unsigned long insn, fixup;
164};
165
166extern int fixup_exception(struct pt_regs *regs);
167
168/*
169 * These are the main single-value transfer routines. They automatically
170 * use the right size if we just have the right pointer type.
171 *
172 * This gets kind of ugly. We want to return _two_ values in "get_user()"
173 * and yet we don't want to do any pointers, because that is too much
174 * of a performance impact. Thus we have a few rather ugly macros here,
175 * and hide all the uglyness from the user.
176 *
177 * The "__xxx" versions of the user access functions are versions that
178 * do not verify the address space, that must have been done previously
179 * with a separate "access_ok()" call (this is used when we do multiple
180 * accesses to the same area of user memory).
181 */
182
183extern void __get_user_1(void);
184extern void __get_user_2(void);
185extern void __get_user_4(void);
186
187#ifndef MODULE
188#define __get_user_x(size,ret,x,ptr) \
189 __asm__ __volatile__( \
190 " mv r0, %0\n" \
191 " mv r1, %1\n" \
192 " bl __get_user_" #size "\n" \
193 " mv %0, r0\n" \
194 " mv %1, r1\n" \
195 : "=r"(ret), "=r"(x) \
196 : "0"(ptr) \
197 : "r0", "r1", "r14" )
198#else /* MODULE */
199/*
200 * Use "jl" instead of "bl" for MODULE
201 */
202#define __get_user_x(size,ret,x,ptr) \
203 __asm__ __volatile__( \
204 " mv r0, %0\n" \
205 " mv r1, %1\n" \
206 " seth lr, #high(__get_user_" #size ")\n" \
207 " or3 lr, lr, #low(__get_user_" #size ")\n" \
208 " jl lr\n" \
209 " mv %0, r0\n" \
210 " mv %1, r1\n" \
211 : "=r"(ret), "=r"(x) \
212 : "0"(ptr) \
213 : "r0", "r1", "r14" )
214#endif
215
216/* Careful: we have to cast the result to the type of the pointer for sign
217 reasons */
218/**
219 * get_user: - Get a simple variable from user space.
220 * @x: Variable to store result.
221 * @ptr: Source address, in user space.
222 *
223 * Context: User context only. This function may sleep.
224 *
225 * This macro copies a single simple variable from user space to kernel
226 * space. It supports simple types like char and int, but not larger
227 * data types like structures or arrays.
228 *
229 * @ptr must have pointer-to-simple-variable type, and the result of
230 * dereferencing @ptr must be assignable to @x without a cast.
231 *
232 * Returns zero on success, or -EFAULT on error.
233 * On error, the variable @x is set to zero.
234 */
235#define get_user(x,ptr) \
236({ int __ret_gu,__val_gu; \
237 __chk_user_ptr(ptr); \
238 switch(sizeof (*(ptr))) { \
239 case 1: __get_user_x(1,__ret_gu,__val_gu,ptr); break; \
240 case 2: __get_user_x(2,__ret_gu,__val_gu,ptr); break; \
241 case 4: __get_user_x(4,__ret_gu,__val_gu,ptr); break; \
242 default: __get_user_x(X,__ret_gu,__val_gu,ptr); break; \
243 } \
244 (x) = (__typeof__(*(ptr)))__val_gu; \
245 __ret_gu; \
246})
247
248extern void __put_user_bad(void);
249
250/**
251 * put_user: - Write a simple value into user space.
252 * @x: Value to copy to user space.
253 * @ptr: Destination address, in user space.
254 *
255 * Context: User context only. This function may sleep.
256 *
257 * This macro copies a single simple value from kernel space to user
258 * space. It supports simple types like char and int, but not larger
259 * data types like structures or arrays.
260 *
261 * @ptr must have pointer-to-simple-variable type, and @x must be assignable
262 * to the result of dereferencing @ptr.
263 *
264 * Returns zero on success, or -EFAULT on error.
265 */
266#define put_user(x,ptr) \
267 __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
268
269
270/**
271 * __get_user: - Get a simple variable from user space, with less checking.
272 * @x: Variable to store result.
273 * @ptr: Source address, in user space.
274 *
275 * Context: User context only. This function may sleep.
276 *
277 * This macro copies a single simple variable from user space to kernel
278 * space. It supports simple types like char and int, but not larger
279 * data types like structures or arrays.
280 *
281 * @ptr must have pointer-to-simple-variable type, and the result of
282 * dereferencing @ptr must be assignable to @x without a cast.
283 *
284 * Caller must check the pointer with access_ok() before calling this
285 * function.
286 *
287 * Returns zero on success, or -EFAULT on error.
288 * On error, the variable @x is set to zero.
289 */
290#define __get_user(x,ptr) \
291 __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
292
293
294/**
295 * __put_user: - Write a simple value into user space, with less checking.
296 * @x: Value to copy to user space.
297 * @ptr: Destination address, in user space.
298 *
299 * Context: User context only. This function may sleep.
300 *
301 * This macro copies a single simple value from kernel space to user
302 * space. It supports simple types like char and int, but not larger
303 * data types like structures or arrays.
304 *
305 * @ptr must have pointer-to-simple-variable type, and @x must be assignable
306 * to the result of dereferencing @ptr.
307 *
308 * Caller must check the pointer with access_ok() before calling this
309 * function.
310 *
311 * Returns zero on success, or -EFAULT on error.
312 */
313#define __put_user(x,ptr) \
314 __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
315
316#define __put_user_nocheck(x,ptr,size) \
317({ \
318 long __pu_err; \
319 __put_user_size((x),(ptr),(size),__pu_err); \
320 __pu_err; \
321})
322
323
324#define __put_user_check(x,ptr,size) \
325({ \
326 long __pu_err = -EFAULT; \
327 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
328 might_sleep(); \
329 if (access_ok(VERIFY_WRITE,__pu_addr,size)) \
330 __put_user_size((x),__pu_addr,(size),__pu_err); \
331 __pu_err; \
332})
333
334#if defined(__LITTLE_ENDIAN__)
335#define __put_user_u64(x, addr, err) \
336 __asm__ __volatile__( \
337 " .fillinsn\n" \
338 "1: st %L1,@%2\n" \
339 " .fillinsn\n" \
340 "2: st %H1,@(4,%2)\n" \
341 " .fillinsn\n" \
342 "3:\n" \
343 ".section .fixup,\"ax\"\n" \
344 " .balign 4\n" \
345 "4: ldi %0,%3\n" \
346 " seth r14,#high(3b)\n" \
347 " or3 r14,r14,#low(3b)\n" \
348 " jmp r14\n" \
349 ".previous\n" \
350 ".section __ex_table,\"a\"\n" \
351 " .balign 4\n" \
352 " .long 1b,4b\n" \
353 " .long 2b,4b\n" \
354 ".previous" \
355 : "=r"(err) \
356 : "r"(x), "r"(addr), "i"(-EFAULT), "0"(err) \
357 : "r14", "memory")
358
359#elif defined(__BIG_ENDIAN__)
360#define __put_user_u64(x, addr, err) \
361 __asm__ __volatile__( \
362 " .fillinsn\n" \
363 "1: st %H1,@%2\n" \
364 " .fillinsn\n" \
365 "2: st %L1,@(4,%2)\n" \
366 " .fillinsn\n" \
367 "3:\n" \
368 ".section .fixup,\"ax\"\n" \
369 " .balign 4\n" \
370 "4: ldi %0,%3\n" \
371 " seth r14,#high(3b)\n" \
372 " or3 r14,r14,#low(3b)\n" \
373 " jmp r14\n" \
374 ".previous\n" \
375 ".section __ex_table,\"a\"\n" \
376 " .balign 4\n" \
377 " .long 1b,4b\n" \
378 " .long 2b,4b\n" \
379 ".previous" \
380 : "=r"(err) \
381 : "r"(x), "r"(addr), "i"(-EFAULT), "0"(err) \
382 : "r14", "memory")
383#else
384#error no endian defined
385#endif
386
387#define __put_user_size(x,ptr,size,retval) \
388do { \
389 retval = 0; \
390 __chk_user_ptr(ptr); \
391 switch (size) { \
392 case 1: __put_user_asm(x,ptr,retval,"b"); break; \
393 case 2: __put_user_asm(x,ptr,retval,"h"); break; \
394 case 4: __put_user_asm(x,ptr,retval,""); break; \
395 case 8: __put_user_u64((__typeof__(*ptr))(x),ptr,retval); break;\
396 default: __put_user_bad(); \
397 } \
398} while (0)
399
400struct __large_struct { unsigned long buf[100]; };
401#define __m(x) (*(struct __large_struct *)(x))
402
403/*
404 * Tell gcc we read from memory instead of writing: this is because
405 * we do not write to any memory gcc knows about, so there are no
406 * aliasing issues.
407 */
408#define __put_user_asm(x, addr, err, itype) \
409 __asm__ __volatile__( \
410 " .fillinsn\n" \
411 "1: st"itype" %1,@%2\n" \
412 " .fillinsn\n" \
413 "2:\n" \
414 ".section .fixup,\"ax\"\n" \
415 " .balign 4\n" \
416 "3: ldi %0,%3\n" \
417 " seth r14,#high(2b)\n" \
418 " or3 r14,r14,#low(2b)\n" \
419 " jmp r14\n" \
420 ".previous\n" \
421 ".section __ex_table,\"a\"\n" \
422 " .balign 4\n" \
423 " .long 1b,3b\n" \
424 ".previous" \
425 : "=r"(err) \
426 : "r"(x), "r"(addr), "i"(-EFAULT), "0"(err) \
427 : "r14", "memory")
428
429#define __get_user_nocheck(x,ptr,size) \
430({ \
431 long __gu_err, __gu_val; \
432 __get_user_size(__gu_val,(ptr),(size),__gu_err); \
433 (x) = (__typeof__(*(ptr)))__gu_val; \
434 __gu_err; \
435})
436
437extern long __get_user_bad(void);
438
439#define __get_user_size(x,ptr,size,retval) \
440do { \
441 retval = 0; \
442 __chk_user_ptr(ptr); \
443 switch (size) { \
444 case 1: __get_user_asm(x,ptr,retval,"ub"); break; \
445 case 2: __get_user_asm(x,ptr,retval,"uh"); break; \
446 case 4: __get_user_asm(x,ptr,retval,""); break; \
447 default: (x) = __get_user_bad(); \
448 } \
449} while (0)
450
451#define __get_user_asm(x, addr, err, itype) \
452 __asm__ __volatile__( \
453 " .fillinsn\n" \
454 "1: ld"itype" %1,@%2\n" \
455 " .fillinsn\n" \
456 "2:\n" \
457 ".section .fixup,\"ax\"\n" \
458 " .balign 4\n" \
459 "3: ldi %0,%3\n" \
460 " seth r14,#high(2b)\n" \
461 " or3 r14,r14,#low(2b)\n" \
462 " jmp r14\n" \
463 ".previous\n" \
464 ".section __ex_table,\"a\"\n" \
465 " .balign 4\n" \
466 " .long 1b,3b\n" \
467 ".previous" \
468 : "=r"(err), "=&r"(x) \
469 : "r"(addr), "i"(-EFAULT), "0"(err) \
470 : "r14", "memory")
471
472/*
473 * Here we special-case 1, 2 and 4-byte copy_*_user invocations. On a fault
474 * we return the initial request size (1, 2 or 4), as copy_*_user should do.
475 * If a store crosses a page boundary and gets a fault, the m32r will not write
476 * anything, so this is accurate.
477 */
478
479
480/*
481 * Copy To/From Userspace
482 */
483
484/* Generic arbitrary sized copy. */
485/* Return the number of bytes NOT copied. */
486#define __copy_user(to,from,size) \
487do { \
488 unsigned long __dst, __src, __c; \
489 __asm__ __volatile__ ( \
490 " mv r14, %0\n" \
491 " or r14, %1\n" \
492 " beq %0, %1, 9f\n" \
493 " beqz %2, 9f\n" \
494 " and3 r14, r14, #3\n" \
495 " bnez r14, 2f\n" \
496 " and3 %2, %2, #3\n" \
497 " beqz %3, 2f\n" \
498 " addi %0, #-4 ; word_copy \n" \
499 " .fillinsn\n" \
500 "0: ld r14, @%1+\n" \
501 " addi %3, #-1\n" \
502 " .fillinsn\n" \
503 "1: st r14, @+%0\n" \
504 " bnez %3, 0b\n" \
505 " beqz %2, 9f\n" \
506 " addi %0, #4\n" \
507 " .fillinsn\n" \
508 "2: ldb r14, @%1 ; byte_copy \n" \
509 " .fillinsn\n" \
510 "3: stb r14, @%0\n" \
511 " addi %1, #1\n" \
512 " addi %2, #-1\n" \
513 " addi %0, #1\n" \
514 " bnez %2, 2b\n" \
515 " .fillinsn\n" \
516 "9:\n" \
517 ".section .fixup,\"ax\"\n" \
518 " .balign 4\n" \
519 "5: addi %3, #1\n" \
520 " addi %1, #-4\n" \
521 " .fillinsn\n" \
522 "6: slli %3, #2\n" \
523 " add %2, %3\n" \
524 " addi %0, #4\n" \
525 " .fillinsn\n" \
526 "7: seth r14, #high(9b)\n" \
527 " or3 r14, r14, #low(9b)\n" \
528 " jmp r14\n" \
529 ".previous\n" \
530 ".section __ex_table,\"a\"\n" \
531 " .balign 4\n" \
532 " .long 0b,6b\n" \
533 " .long 1b,5b\n" \
534 " .long 2b,9b\n" \
535 " .long 3b,9b\n" \
536 ".previous\n" \
537 : "=&r"(__dst), "=&r"(__src), "=&r"(size), "=&r"(__c) \
538 : "0"(to), "1"(from), "2"(size), "3"(size / 4) \
539 : "r14", "memory"); \
540} while (0)
541
542#define __copy_user_zeroing(to,from,size) \
543do { \
544 unsigned long __dst, __src, __c; \
545 __asm__ __volatile__ ( \
546 " mv r14, %0\n" \
547 " or r14, %1\n" \
548 " beq %0, %1, 9f\n" \
549 " beqz %2, 9f\n" \
550 " and3 r14, r14, #3\n" \
551 " bnez r14, 2f\n" \
552 " and3 %2, %2, #3\n" \
553 " beqz %3, 2f\n" \
554 " addi %0, #-4 ; word_copy \n" \
555 " .fillinsn\n" \
556 "0: ld r14, @%1+\n" \
557 " addi %3, #-1\n" \
558 " .fillinsn\n" \
559 "1: st r14, @+%0\n" \
560 " bnez %3, 0b\n" \
561 " beqz %2, 9f\n" \
562 " addi %0, #4\n" \
563 " .fillinsn\n" \
564 "2: ldb r14, @%1 ; byte_copy \n" \
565 " .fillinsn\n" \
566 "3: stb r14, @%0\n" \
567 " addi %1, #1\n" \
568 " addi %2, #-1\n" \
569 " addi %0, #1\n" \
570 " bnez %2, 2b\n" \
571 " .fillinsn\n" \
572 "9:\n" \
573 ".section .fixup,\"ax\"\n" \
574 " .balign 4\n" \
575 "5: addi %3, #1\n" \
576 " addi %1, #-4\n" \
577 " .fillinsn\n" \
578 "6: slli %3, #2\n" \
579 " add %2, %3\n" \
580 " addi %0, #4\n" \
581 " .fillinsn\n" \
582 "7: ldi r14, #0 ; store zero \n" \
583 " .fillinsn\n" \
584 "8: addi %2, #-1\n" \
585 " stb r14, @%0 ; ACE? \n" \
586 " addi %0, #1\n" \
587 " bnez %2, 8b\n" \
588 " seth r14, #high(9b)\n" \
589 " or3 r14, r14, #low(9b)\n" \
590 " jmp r14\n" \
591 ".previous\n" \
592 ".section __ex_table,\"a\"\n" \
593 " .balign 4\n" \
594 " .long 0b,6b\n" \
595 " .long 1b,5b\n" \
596 " .long 2b,7b\n" \
597 " .long 3b,7b\n" \
598 ".previous\n" \
599 : "=&r"(__dst), "=&r"(__src), "=&r"(size), "=&r"(__c) \
600 : "0"(to), "1"(from), "2"(size), "3"(size / 4) \
601 : "r14", "memory"); \
602} while (0)
603
604
605/* We let the __ versions of copy_from/to_user inline, because they're often
606 * used in fast paths and have only a small space overhead.
607 */
608static inline unsigned long __generic_copy_from_user_nocheck(void *to,
609 const void __user *from, unsigned long n)
610{
611 __copy_user_zeroing(to,from,n);
612 return n;
613}
614
615static inline unsigned long __generic_copy_to_user_nocheck(void __user *to,
616 const void *from, unsigned long n)
617{
618 __copy_user(to,from,n);
619 return n;
620}
621
622unsigned long __generic_copy_to_user(void *, const void *, unsigned long);
623unsigned long __generic_copy_from_user(void *, const void *, unsigned long);
624
625/**
626 * __copy_to_user: - Copy a block of data into user space, with less checking.
627 * @to: Destination address, in user space.
628 * @from: Source address, in kernel space.
629 * @n: Number of bytes to copy.
630 *
631 * Context: User context only. This function may sleep.
632 *
633 * Copy data from kernel space to user space. Caller must check
634 * the specified block with access_ok() before calling this function.
635 *
636 * Returns number of bytes that could not be copied.
637 * On success, this will be zero.
638 */
639#define __copy_to_user(to,from,n) \
640 __generic_copy_to_user_nocheck((to),(from),(n))
641
642#define __copy_to_user_inatomic __copy_to_user
643#define __copy_from_user_inatomic __copy_from_user
644
645/**
646 * copy_to_user: - Copy a block of data into user space.
647 * @to: Destination address, in user space.
648 * @from: Source address, in kernel space.
649 * @n: Number of bytes to copy.
650 *
651 * Context: User context only. This function may sleep.
652 *
653 * Copy data from kernel space to user space.
654 *
655 * Returns number of bytes that could not be copied.
656 * On success, this will be zero.
657 */
658#define copy_to_user(to,from,n) \
659({ \
660 might_sleep(); \
661 __generic_copy_to_user((to),(from),(n)); \
662})
663
664/**
665 * __copy_from_user: - Copy a block of data from user space, with less checking. * @to: Destination address, in kernel space.
666 * @from: Source address, in user space.
667 * @n: Number of bytes to copy.
668 *
669 * Context: User context only. This function may sleep.
670 *
671 * Copy data from user space to kernel space. Caller must check
672 * the specified block with access_ok() before calling this function.
673 *
674 * Returns number of bytes that could not be copied.
675 * On success, this will be zero.
676 *
677 * If some data could not be copied, this function will pad the copied
678 * data to the requested size using zero bytes.
679 */
680#define __copy_from_user(to,from,n) \
681 __generic_copy_from_user_nocheck((to),(from),(n))
682
683/**
684 * copy_from_user: - Copy a block of data from user space.
685 * @to: Destination address, in kernel space.
686 * @from: Source address, in user space.
687 * @n: Number of bytes to copy.
688 *
689 * Context: User context only. This function may sleep.
690 *
691 * Copy data from user space to kernel space.
692 *
693 * Returns number of bytes that could not be copied.
694 * On success, this will be zero.
695 *
696 * If some data could not be copied, this function will pad the copied
697 * data to the requested size using zero bytes.
698 */
699#define copy_from_user(to,from,n) \
700({ \
701 might_sleep(); \
702__generic_copy_from_user((to),(from),(n)); \
703})
704
705long __must_check strncpy_from_user(char *dst, const char __user *src,
706 long count);
707long __must_check __strncpy_from_user(char *dst,
708 const char __user *src, long count);
709
710/**
711 * __clear_user: - Zero a block of memory in user space, with less checking.
712 * @to: Destination address, in user space.
713 * @n: Number of bytes to zero.
714 *
715 * Zero a block of memory in user space. Caller must check
716 * the specified block with access_ok() before calling this function.
717 *
718 * Returns number of bytes that could not be cleared.
719 * On success, this will be zero.
720 */
721unsigned long __clear_user(void __user *mem, unsigned long len);
722
723/**
724 * clear_user: - Zero a block of memory in user space.
725 * @to: Destination address, in user space.
726 * @n: Number of bytes to zero.
727 *
728 * Zero a block of memory in user space. Caller must check
729 * the specified block with access_ok() before calling this function.
730 *
731 * Returns number of bytes that could not be cleared.
732 * On success, this will be zero.
733 */
734unsigned long clear_user(void __user *mem, unsigned long len);
735
736/**
737 * strlen_user: - Get the size of a string in user space.
738 * @str: The string to measure.
739 *
740 * Context: User context only. This function may sleep.
741 *
742 * Get the size of a NUL-terminated string in user space.
743 *
744 * Returns the size of the string INCLUDING the terminating NUL.
745 * On exception, returns 0.
746 *
747 * If there is a limit on the length of a valid string, you may wish to
748 * consider using strnlen_user() instead.
749 */
750#define strlen_user(str) strnlen_user(str, ~0UL >> 1)
751long strnlen_user(const char __user *str, long n);
752
753#endif /* _ASM_M32R_UACCESS_H */
diff --git a/include/asm-m32r/ucontext.h b/include/asm-m32r/ucontext.h
new file mode 100644
index 000000000000..2de709a5c53c
--- /dev/null
+++ b/include/asm-m32r/ucontext.h
@@ -0,0 +1,14 @@
1#ifndef _ASM_M32R_UCONTEXT_H
2#define _ASM_M32R_UCONTEXT_H
3
4/* orig : i386 2.4.18 */
5
6struct ucontext {
7 unsigned long uc_flags;
8 struct ucontext *uc_link;
9 stack_t uc_stack;
10 struct sigcontext uc_mcontext;
11 sigset_t uc_sigmask; /* mask last for extensibility */
12};
13
14#endif /* _ASM_M32R_UCONTEXT_H */
diff --git a/include/asm-m32r/unaligned.h b/include/asm-m32r/unaligned.h
new file mode 100644
index 000000000000..3aef9ac8d3aa
--- /dev/null
+++ b/include/asm-m32r/unaligned.h
@@ -0,0 +1,25 @@
1#ifndef _ASM_M32R_UNALIGNED_H
2#define _ASM_M32R_UNALIGNED_H
3
4/* $Id$ */
5
6/* orig : generic 2.4.18 */
7
8/*
9 * For the benefit of those who are trying to port Linux to another
10 * architecture, here are some C-language equivalents.
11 */
12
13#include <asm/string.h>
14
15
16#define get_unaligned(ptr) \
17 ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; })
18
19#define put_unaligned(val, ptr) \
20 ({ __typeof__(*(ptr)) __tmp = (val); \
21 memmove((ptr), &__tmp, sizeof(*(ptr))); \
22 (void)0; })
23
24
25#endif /* _ASM_M32R_UNALIGNED_H */
diff --git a/include/asm-m32r/unistd.h b/include/asm-m32r/unistd.h
new file mode 100644
index 000000000000..8552d8f45ab1
--- /dev/null
+++ b/include/asm-m32r/unistd.h
@@ -0,0 +1,474 @@
1#ifndef _ASM_M32R_UNISTD_H
2#define _ASM_M32R_UNISTD_H
3
4/* $Id$ */
5
6#include <asm/syscall.h> /* SYSCALL_* */
7
8/*
9 * This file contains the system call numbers.
10 */
11
12#define __NR_restart_syscall 0
13#define __NR_exit 1
14#define __NR_fork 2
15#define __NR_read 3
16#define __NR_write 4
17#define __NR_open 5
18#define __NR_close 6
19#define __NR_waitpid 7
20#define __NR_creat 8
21#define __NR_link 9
22#define __NR_unlink 10
23#define __NR_execve 11
24#define __NR_chdir 12
25#define __NR_time 13
26#define __NR_mknod 14
27#define __NR_chmod 15
28/* 16 is unused */
29/* 17 is unused */
30/* 18 is unused */
31#define __NR_lseek 19
32#define __NR_getpid 20
33#define __NR_mount 21
34#define __NR_umount 22
35/* 23 is unused */
36/* 24 is unused */
37#define __NR_stime 25
38#define __NR_ptrace 26
39#define __NR_alarm 27
40/* 28 is unused */
41#define __NR_pause 29
42#define __NR_utime 30
43/* 31 is unused */
44#define __NR_cachectl 32 /* old #define __NR_gtty 32*/
45#define __NR_access 33
46/* 34 is unused */
47/* 35 is unused */
48#define __NR_sync 36
49#define __NR_kill 37
50#define __NR_rename 38
51#define __NR_mkdir 39
52#define __NR_rmdir 40
53#define __NR_dup 41
54#define __NR_pipe 42
55#define __NR_times 43
56/* 44 is unused */
57#define __NR_brk 45
58/* 46 is unused */
59/* 47 is unused (getgid16) */
60/* 48 is unused */
61/* 49 is unused */
62/* 50 is unused */
63#define __NR_acct 51
64#define __NR_umount2 52
65/* 53 is unused */
66#define __NR_ioctl 54
67/* 55 is unused (fcntl) */
68/* 56 is unused */
69#define __NR_setpgid 57
70/* 58 is unused */
71/* 59 is unused */
72#define __NR_umask 60
73#define __NR_chroot 61
74#define __NR_ustat 62
75#define __NR_dup2 63
76#define __NR_getppid 64
77#define __NR_getpgrp 65
78#define __NR_setsid 66
79/* 67 is unused */
80/* 68 is unused*/
81/* 69 is unused*/
82/* 70 is unused */
83/* 71 is unused */
84/* 72 is unused */
85/* 73 is unused */
86#define __NR_sethostname 74
87#define __NR_setrlimit 75
88/* 76 is unused (old getrlimit) */
89#define __NR_getrusage 77
90#define __NR_gettimeofday 78
91#define __NR_settimeofday 79
92/* 80 is unused */
93/* 81 is unused */
94/* 82 is unused */
95#define __NR_symlink 83
96/* 84 is unused */
97#define __NR_readlink 85
98#define __NR_uselib 86
99#define __NR_swapon 87
100#define __NR_reboot 88
101/* 89 is unused */
102/* 90 is unused */
103#define __NR_munmap 91
104#define __NR_truncate 92
105#define __NR_ftruncate 93
106#define __NR_fchmod 94
107/* 95 is unused */
108#define __NR_getpriority 96
109#define __NR_setpriority 97
110/* 98 is unused */
111#define __NR_statfs 99
112#define __NR_fstatfs 100
113/* 101 is unused */
114#define __NR_socketcall 102
115#define __NR_syslog 103
116#define __NR_setitimer 104
117#define __NR_getitimer 105
118#define __NR_stat 106
119#define __NR_lstat 107
120#define __NR_fstat 108
121/* 109 is unused */
122/* 110 is unused */
123#define __NR_vhangup 111
124/* 112 is unused */
125/* 113 is unused */
126#define __NR_wait4 114
127#define __NR_swapoff 115
128#define __NR_sysinfo 116
129#define __NR_ipc 117
130#define __NR_fsync 118
131/* 119 is unused */
132#define __NR_clone 120
133#define __NR_setdomainname 121
134#define __NR_uname 122
135/* 123 is unused */
136#define __NR_adjtimex 124
137#define __NR_mprotect 125
138/* 126 is unused */
139/* 127 is unused */
140#define __NR_init_module 128
141#define __NR_delete_module 129
142/* 130 is unused */
143#define __NR_quotactl 131
144#define __NR_getpgid 132
145#define __NR_fchdir 133
146#define __NR_bdflush 134
147#define __NR_sysfs 135
148#define __NR_personality 136
149/* 137 is unused */
150/* 138 is unused */
151/* 139 is unused */
152#define __NR__llseek 140
153#define __NR_getdents 141
154#define __NR__newselect 142
155#define __NR_flock 143
156#define __NR_msync 144
157#define __NR_readv 145
158#define __NR_writev 146
159#define __NR_getsid 147
160#define __NR_fdatasync 148
161#define __NR__sysctl 149
162#define __NR_mlock 150
163#define __NR_munlock 151
164#define __NR_mlockall 152
165#define __NR_munlockall 153
166#define __NR_sched_setparam 154
167#define __NR_sched_getparam 155
168#define __NR_sched_setscheduler 156
169#define __NR_sched_getscheduler 157
170#define __NR_sched_yield 158
171#define __NR_sched_get_priority_max 159
172#define __NR_sched_get_priority_min 160
173#define __NR_sched_rr_get_interval 161
174#define __NR_nanosleep 162
175#define __NR_mremap 163
176/* 164 is unused */
177/* 165 is unused */
178#define __NR_tas 166
179/* 167 is unused */
180#define __NR_poll 168
181#define __NR_nfsservctl 169
182/* 170 is unused */
183/* 171 is unused */
184#define __NR_prctl 172
185#define __NR_rt_sigreturn 173
186#define __NR_rt_sigaction 174
187#define __NR_rt_sigprocmask 175
188#define __NR_rt_sigpending 176
189#define __NR_rt_sigtimedwait 177
190#define __NR_rt_sigqueueinfo 178
191#define __NR_rt_sigsuspend 179
192#define __NR_pread64 180
193#define __NR_pwrite64 181
194/* 182 is unused */
195#define __NR_getcwd 183
196#define __NR_capget 184
197#define __NR_capset 185
198#define __NR_sigaltstack 186
199#define __NR_sendfile 187
200/* 188 is unused */
201/* 189 is unused */
202#define __NR_vfork 190
203#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
204#define __NR_mmap2 192
205#define __NR_truncate64 193
206#define __NR_ftruncate64 194
207#define __NR_stat64 195
208#define __NR_lstat64 196
209#define __NR_fstat64 197
210#define __NR_lchown32 198
211#define __NR_getuid32 199
212#define __NR_getgid32 200
213#define __NR_geteuid32 201
214#define __NR_getegid32 202
215#define __NR_setreuid32 203
216#define __NR_setregid32 204
217#define __NR_getgroups32 205
218#define __NR_setgroups32 206
219#define __NR_fchown32 207
220#define __NR_setresuid32 208
221#define __NR_getresuid32 209
222#define __NR_setresgid32 210
223#define __NR_getresgid32 211
224#define __NR_chown32 212
225#define __NR_setuid32 213
226#define __NR_setgid32 214
227#define __NR_setfsuid32 215
228#define __NR_setfsgid32 216
229#define __NR_pivot_root 217
230#define __NR_mincore 218
231#define __NR_madvise 219
232#define __NR_getdents64 220
233#define __NR_fcntl64 221
234/* 222 is unused */
235/* 223 is unused */
236#define __NR_gettid 224
237#define __NR_readahead 225
238#define __NR_setxattr 226
239#define __NR_lsetxattr 227
240#define __NR_fsetxattr 228
241#define __NR_getxattr 229
242#define __NR_lgetxattr 230
243#define __NR_fgetxattr 231
244#define __NR_listxattr 232
245#define __NR_llistxattr 233
246#define __NR_flistxattr 234
247#define __NR_removexattr 235
248#define __NR_lremovexattr 236
249#define __NR_fremovexattr 237
250#define __NR_tkill 238
251#define __NR_sendfile64 239
252#define __NR_futex 240
253#define __NR_sched_setaffinity 241
254#define __NR_sched_getaffinity 242
255#define __NR_set_thread_area 243
256#define __NR_get_thread_area 244
257#define __NR_io_setup 245
258#define __NR_io_destroy 246
259#define __NR_io_getevents 247
260#define __NR_io_submit 248
261#define __NR_io_cancel 249
262#define __NR_fadvise64 250
263/* 251 is unused */
264#define __NR_exit_group 252
265#define __NR_lookup_dcookie 253
266#define __NR_epoll_create 254
267#define __NR_epoll_ctl 255
268#define __NR_epoll_wait 256
269#define __NR_remap_file_pages 257
270#define __NR_set_tid_address 258
271#define __NR_timer_create 259
272#define __NR_timer_settime (__NR_timer_create+1)
273#define __NR_timer_gettime (__NR_timer_create+2)
274#define __NR_timer_getoverrun (__NR_timer_create+3)
275#define __NR_timer_delete (__NR_timer_create+4)
276#define __NR_clock_settime (__NR_timer_create+5)
277#define __NR_clock_gettime (__NR_timer_create+6)
278#define __NR_clock_getres (__NR_timer_create+7)
279#define __NR_clock_nanosleep (__NR_timer_create+8)
280#define __NR_statfs64 268
281#define __NR_fstatfs64 269
282#define __NR_tgkill 270
283#define __NR_utimes 271
284#define __NR_fadvise64_64 272
285#define __NR_vserver 273
286#define __NR_mbind 274
287#define __NR_get_mempolicy 275
288#define __NR_set_mempolicy 276
289#define __NR_mq_open 277
290#define __NR_mq_unlink (__NR_mq_open+1)
291#define __NR_mq_timedsend (__NR_mq_open+2)
292#define __NR_mq_timedreceive (__NR_mq_open+3)
293#define __NR_mq_notify (__NR_mq_open+4)
294#define __NR_mq_getsetattr (__NR_mq_open+5)
295#define __NR_sys_kexec_load 283
296#define __NR_waitid 284
297
298#define NR_syscalls 285
299
300/* user-visible error numbers are in the range -1 - -124: see
301 * <asm-m32r/errno.h>
302 */
303
304#define __syscall_return(type, res) \
305do { \
306 if ((unsigned long)(res) >= (unsigned long)(-(124 + 1))) { \
307 /* Avoid using "res" which is declared to be in register r0; \
308 errno might expand to a function call and clobber it. */ \
309 int __err = -(res); \
310 errno = __err; \
311 res = -1; \
312 } \
313 return (type) (res); \
314} while (0)
315
316#define _syscall0(type,name) \
317type name(void) \
318{ \
319register long __scno __asm__ ("r7") = __NR_##name; \
320register long __res __asm__("r0"); \
321__asm__ __volatile__ (\
322 "trap #" SYSCALL_VECTOR \
323 : "=r" (__res) \
324 : "r" (__scno) \
325 : "memory"); \
326__syscall_return(type,__res); \
327}
328
329#define _syscall1(type,name,type1,arg1) \
330type name(type1 arg1) \
331{ \
332register long __scno __asm__ ("r7") = __NR_##name; \
333register long __res __asm__ ("r0") = (long)(arg1); \
334__asm__ __volatile__ (\
335 "trap #" SYSCALL_VECTOR \
336 : "=r" (__res) \
337 : "r" (__scno), "0" (__res) \
338 : "memory"); \
339__syscall_return(type,__res); \
340}
341
342#define _syscall2(type,name,type1,arg1,type2,arg2) \
343type name(type1 arg1,type2 arg2) \
344{ \
345register long __scno __asm__ ("r7") = __NR_##name; \
346register long __arg2 __asm__ ("r1") = (long)(arg2); \
347register long __res __asm__ ("r0") = (long)(arg1); \
348__asm__ __volatile__ (\
349 "trap #" SYSCALL_VECTOR \
350 : "=r" (__res) \
351 : "r" (__scno), "0" (__res), "r" (__arg2) \
352 : "memory"); \
353__syscall_return(type,__res); \
354}
355
356#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
357type name(type1 arg1,type2 arg2,type3 arg3) \
358{ \
359register long __scno __asm__ ("r7") = __NR_##name; \
360register long __arg3 __asm__ ("r2") = (long)(arg3); \
361register long __arg2 __asm__ ("r1") = (long)(arg2); \
362register long __res __asm__ ("r0") = (long)(arg1); \
363__asm__ __volatile__ (\
364 "trap #" SYSCALL_VECTOR \
365 : "=r" (__res) \
366 : "r" (__scno), "0" (__res), "r" (__arg2), \
367 "r" (__arg3) \
368 : "memory"); \
369__syscall_return(type,__res); \
370}
371
372#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
373type name(type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
374{ \
375register long __scno __asm__ ("r7") = __NR_##name; \
376register long __arg4 __asm__ ("r3") = (long)(arg4); \
377register long __arg3 __asm__ ("r2") = (long)(arg3); \
378register long __arg2 __asm__ ("r1") = (long)(arg2); \
379register long __res __asm__ ("r0") = (long)(arg1); \
380__asm__ __volatile__ (\
381 "trap #" SYSCALL_VECTOR \
382 : "=r" (__res) \
383 : "r" (__scno), "0" (__res), "r" (__arg2), \
384 "r" (__arg3), "r" (__arg4) \
385 : "memory"); \
386__syscall_return(type,__res); \
387}
388
389#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
390 type5,arg5) \
391type name(type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
392{ \
393register long __scno __asm__ ("r7") = __NR_##name; \
394register long __arg5 __asm__ ("r4") = (long)(arg5); \
395register long __arg4 __asm__ ("r3") = (long)(arg4); \
396register long __arg3 __asm__ ("r2") = (long)(arg3); \
397register long __arg2 __asm__ ("r1") = (long)(arg2); \
398register long __res __asm__ ("r0") = (long)(arg1); \
399__asm__ __volatile__ (\
400 "trap #" SYSCALL_VECTOR \
401 : "=r" (__res) \
402 : "r" (__scno), "0" (__res), "r" (__arg2), \
403 "r" (__arg3), "r" (__arg4), "r" (__arg5) \
404 : "memory"); \
405__syscall_return(type,__res); \
406}
407
408#ifdef __KERNEL__
409#define __ARCH_WANT_IPC_PARSE_VERSION
410#define __ARCH_WANT_STAT64
411#define __ARCH_WANT_SYS_ALARM
412#define __ARCH_WANT_SYS_GETHOSTNAME
413#define __ARCH_WANT_SYS_PAUSE
414#define __ARCH_WANT_SYS_TIME
415#define __ARCH_WANT_SYS_UTIME
416#define __ARCH_WANT_SYS_WAITPID
417#define __ARCH_WANT_SYS_SOCKETCALL
418#define __ARCH_WANT_SYS_FADVISE64
419#define __ARCH_WANT_SYS_GETPGRP
420#define __ARCH_WANT_SYS_LLSEEK
421#define __ARCH_WANT_SYS_OLD_GETRLIMIT /*will be unused*/
422#define __ARCH_WANT_SYS_OLDUMOUNT
423#define __ARCH_WANT_SYS_RT_SIGACTION
424#endif
425
426#ifdef __KERNEL_SYSCALLS__
427
428#include <linux/compiler.h>
429#include <linux/types.h>
430#include <linux/linkage.h>
431#include <asm/ptrace.h>
432
433/*
434 * we need this inline - forking from kernel space will result
435 * in NO COPY ON WRITE (!!!), until an execve is executed. This
436 * is no problem, but for the stack. This is handled by not letting
437 * main() use the stack at all after fork(). Thus, no function
438 * calls - which means inline code for fork too, as otherwise we
439 * would use the stack upon exit from 'fork()'.
440 *
441 * Actually only pause and fork are needed inline, so that there
442 * won't be any messing with the stack from main(), but we define
443 * some others too.
444 */
445static __inline__ _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
446
447asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
448 unsigned long prot, unsigned long flags,
449 unsigned long fd, unsigned long pgoff);
450asmlinkage int sys_execve(struct pt_regs regs);
451asmlinkage int sys_clone(struct pt_regs regs);
452asmlinkage int sys_fork(struct pt_regs regs);
453asmlinkage int sys_vfork(struct pt_regs regs);
454asmlinkage int sys_pipe(unsigned long __user *fildes);
455asmlinkage int sys_ptrace(long request, long pid, long addr, long data);
456struct sigaction;
457asmlinkage long sys_rt_sigaction(int sig,
458 const struct sigaction __user *act,
459 struct sigaction __user *oact,
460 size_t sigsetsize);
461
462#endif /* __KERNEL_SYSCALLS__ */
463
464/*
465 * "Conditional" syscalls
466 *
467 * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
468 * but it doesn't work on all toolchains, so we just do it by hand
469 */
470#ifndef cond_syscall
471#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall")
472#endif
473
474#endif /* _ASM_M32R_UNISTD_H */
diff --git a/include/asm-m32r/user.h b/include/asm-m32r/user.h
new file mode 100644
index 000000000000..2ffd0c65a782
--- /dev/null
+++ b/include/asm-m32r/user.h
@@ -0,0 +1,59 @@
1#ifndef _ASM_M32R_USER_H
2#define _ASM_M32R_USER_H
3
4/* $Id$ */
5
6/* orig : sh 2.4.18
7 * mod : remove fpu registers
8 */
9
10#include <linux/types.h>
11#include <asm/processor.h>
12#include <asm/ptrace.h>
13#include <asm/page.h>
14
15/*
16 * Core file format: The core file is written in such a way that gdb
17 * can understand it and provide useful information to the user (under
18 * linux we use the `trad-core' bfd).
19 *
20 * The actual file contents are as follows:
21 * UPAGE: 1 page consisting of a user struct that tells gdb
22 * what is present in the file. Directly after this is a
23 * copy of the task_struct, which is currently not used by gdb,
24 * but it may come in handy at some point. All of the registers
25 * are stored as part of the upage. The upage should always be
26 * only one page.
27 * DATA: The data area is stored. We use current->end_text to
28 * current->brk to pick up all of the user variables, plus any memory
29 * that may have been sbrk'ed. No attempt is made to determine if a
30 * page is demand-zero or if a page is totally unused, we just cover
31 * the entire range. All of the addresses are rounded in such a way
32 * that an integral number of pages is written.
33 * STACK: We need the stack information in order to get a meaningful
34 * backtrace. We need to write the data from usp to
35 * current->start_stack, so we round each of these off in order to be
36 * able to write an integer number of pages.
37 */
38
39struct user {
40 struct pt_regs regs; /* entire machine state */
41 size_t u_tsize; /* text size (pages) */
42 size_t u_dsize; /* data size (pages) */
43 size_t u_ssize; /* stack size (pages) */
44 unsigned long start_code; /* text starting address */
45 unsigned long start_data; /* data starting address */
46 unsigned long start_stack; /* stack starting address */
47 long int signal; /* signal causing core dump */
48 struct regs * u_ar0; /* help gdb find registers */
49 unsigned long magic; /* identifies a core file */
50 char u_comm[32]; /* user command name */
51};
52
53#define NBPG PAGE_SIZE
54#define UPAGES 1
55#define HOST_TEXT_START_ADDR (u.start_code)
56#define HOST_DATA_START_ADDR (u.start_data)
57#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
58
59#endif /* _ASM_M32R_USER_H */
diff --git a/include/asm-m32r/vga.h b/include/asm-m32r/vga.h
new file mode 100644
index 000000000000..d0f4b6eed7a3
--- /dev/null
+++ b/include/asm-m32r/vga.h
@@ -0,0 +1,22 @@
1#ifndef _ASM_M32R_VGA_H
2#define _ASM_M32R_VGA_H
3
4/* $Id$ */
5
6/*
7 * Access to VGA videoram
8 *
9 * (c) 1998 Martin Mares <mj@ucw.cz>
10 */
11
12/*
13 * On the PC, we can just recalculate addresses and then
14 * access the videoram directly without any black magic.
15 */
16
17#define VGA_MAP_MEM(x) (unsigned long)phys_to_virt(x)
18
19#define vga_readb(x) (*(x))
20#define vga_writeb(x,y) (*(y) = (x))
21
22#endif /* _ASM_M32R_VGA_H */
diff --git a/include/asm-m32r/xor.h b/include/asm-m32r/xor.h
new file mode 100644
index 000000000000..fd960dc9bf76
--- /dev/null
+++ b/include/asm-m32r/xor.h
@@ -0,0 +1,8 @@
1#ifndef _ASM_M32R_XOR_H
2#define _ASM_M32R_XOR_H
3
4/* $Id$ */
5
6#include <asm-generic/xor.h>
7
8#endif /* _ASM_M32R_XOR_H */