aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh64
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-01-28 16:52:50 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-01-28 16:52:50 -0500
commite189f3495c4e30fc84fc9241096edf3932e23439 (patch)
tree5916c89ace81537a02ae01869386ba6caafdab9c /arch/sh64
parentf4798748dee00c807a63f5518f08b3df161e0f6d (diff)
parent6582d7b7376aa587d74b08c74457dc28abc1a9fa (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6: (197 commits) sh: add spi header and r2d platform data V3 sh: update r7780rp interrupt code sh: remove consistent alloc stuff from the machine vector sh: use declared coherent memory for dreamcast pci ethernet adapter sh: declared coherent memory support V2 sh: Add support for SDK7780 board. sh: constify function pointer tables sh: Kill off -traditional for linker script. cdrom: Add support for Sega Dreamcast GD-ROM. sh: Kill off hs7751rvoip reference from arch/sh/Kconfig. sh: Drop r7780rp_defconfig, use r7780mp_defconfig as kbuild default. sh: Kill off dead HS771RVoIP board support. sh: r7785rp: Fix up DECLARE_INTC_DESC() arg mismatch. sh: r7785rp: Hook up the rest of the HL7785 FPGA IRQ vectors. sh: r2d - enable sm501 usb host function sh: remove voyagergx sh: r2d - add lcd planel timings to sm501 platform data sh: Add OHCI and UDC platform devices for SH7720. sh: intc - remove default interrupt priority tables sh: Correct pte size mismatch for X2 TLB. ...
Diffstat (limited to 'arch/sh64')
-rw-r--r--arch/sh64/Kconfig295
-rw-r--r--arch/sh64/Kconfig.debug33
-rw-r--r--arch/sh64/Makefile111
-rw-r--r--arch/sh64/boot/Makefile20
-rw-r--r--arch/sh64/boot/compressed/Makefile46
-rw-r--r--arch/sh64/boot/compressed/cache.c39
-rw-r--r--arch/sh64/boot/compressed/head.S164
-rw-r--r--arch/sh64/boot/compressed/install.sh56
-rw-r--r--arch/sh64/boot/compressed/misc.c250
-rw-r--r--arch/sh64/boot/compressed/vmlinux.lds.S64
-rw-r--r--arch/sh64/configs/cayman_defconfig1126
-rw-r--r--arch/sh64/configs/harp_defconfig745
-rw-r--r--arch/sh64/configs/sim_defconfig558
-rw-r--r--arch/sh64/kernel/Makefile36
-rw-r--r--arch/sh64/kernel/alphanum.c43
-rw-r--r--arch/sh64/kernel/asm-offsets.c33
-rw-r--r--arch/sh64/kernel/dma.c297
-rw-r--r--arch/sh64/kernel/early_printk.c99
-rw-r--r--arch/sh64/kernel/entry.S2102
-rw-r--r--arch/sh64/kernel/fpu.c170
-rw-r--r--arch/sh64/kernel/head.S372
-rw-r--r--arch/sh64/kernel/init_task.c46
-rw-r--r--arch/sh64/kernel/irq.c115
-rw-r--r--arch/sh64/kernel/irq_intc.c272
-rw-r--r--arch/sh64/kernel/led.c40
-rw-r--r--arch/sh64/kernel/module.c161
-rw-r--r--arch/sh64/kernel/pci_sh5.c536
-rw-r--r--arch/sh64/kernel/pci_sh5.h107
-rw-r--r--arch/sh64/kernel/pcibios.c168
-rw-r--r--arch/sh64/kernel/process.c691
-rw-r--r--arch/sh64/kernel/ptrace.c332
-rw-r--r--arch/sh64/kernel/semaphore.c140
-rw-r--r--arch/sh64/kernel/setup.c379
-rw-r--r--arch/sh64/kernel/sh_ksyms.c62
-rw-r--r--arch/sh64/kernel/signal.c750
-rw-r--r--arch/sh64/kernel/switchto.S198
-rw-r--r--arch/sh64/kernel/sys_sh64.c304
-rw-r--r--arch/sh64/kernel/syscalls.S381
-rw-r--r--arch/sh64/kernel/time.c593
-rw-r--r--arch/sh64/kernel/traps.c982
-rw-r--r--arch/sh64/kernel/unwind.c326
-rw-r--r--arch/sh64/kernel/vmlinux.lds.S140
-rw-r--r--arch/sh64/lib/.gitignore1
-rw-r--r--arch/sh64/lib/Makefile19
-rw-r--r--arch/sh64/lib/c-checksum.c217
-rw-r--r--arch/sh64/lib/copy_user_memcpy.S217
-rw-r--r--arch/sh64/lib/dbg.c430
-rw-r--r--arch/sh64/lib/io.c128
-rw-r--r--arch/sh64/lib/iomap.c54
-rw-r--r--arch/sh64/lib/memcpy.c81
-rw-r--r--arch/sh64/lib/page_clear.S54
-rw-r--r--arch/sh64/lib/page_copy.S91
-rw-r--r--arch/sh64/lib/panic.c58
-rw-r--r--arch/sh64/lib/udelay.c59
-rw-r--r--arch/sh64/mach-cayman/Makefile11
-rw-r--r--arch/sh64/mach-cayman/iomap.c22
-rw-r--r--arch/sh64/mach-cayman/irq.c195
-rw-r--r--arch/sh64/mach-cayman/led.c51
-rw-r--r--arch/sh64/mach-cayman/setup.c239
-rw-r--r--arch/sh64/mach-harp/Makefile1
-rw-r--r--arch/sh64/mach-harp/setup.c129
-rw-r--r--arch/sh64/mach-sim/Makefile1
-rw-r--r--arch/sh64/mach-sim/setup.c126
-rw-r--r--arch/sh64/mm/Makefile44
-rw-r--r--arch/sh64/mm/cache.c1032
-rw-r--r--arch/sh64/mm/consistent.c53
-rw-r--r--arch/sh64/mm/extable.c80
-rw-r--r--arch/sh64/mm/fault.c602
-rw-r--r--arch/sh64/mm/hugetlbpage.c105
-rw-r--r--arch/sh64/mm/init.c189
-rw-r--r--arch/sh64/mm/ioremap.c388
-rw-r--r--arch/sh64/mm/tlb.c166
-rw-r--r--arch/sh64/mm/tlbmiss.c279
-rw-r--r--arch/sh64/oprofile/Makefile12
-rw-r--r--arch/sh64/oprofile/op_model_null.c23
75 files changed, 0 insertions, 18539 deletions
diff --git a/arch/sh64/Kconfig b/arch/sh64/Kconfig
deleted file mode 100644
index 6884d5a518ad..000000000000
--- a/arch/sh64/Kconfig
+++ /dev/null
@@ -1,295 +0,0 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5
6mainmenu "Linux/SH64 Kernel Configuration"
7
8config SUPERH
9 bool
10 default y
11
12config SUPERH64
13 bool
14 default y
15
16config MMU
17 bool
18 default y
19
20config QUICKLIST
21 def_bool y
22
23config RWSEM_GENERIC_SPINLOCK
24 bool
25 default y
26
27config GENERIC_FIND_NEXT_BIT
28 bool
29 default y
30
31config GENERIC_HWEIGHT
32 bool
33 default y
34
35config GENERIC_CALIBRATE_DELAY
36 bool
37 default y
38
39config GENERIC_HARDIRQS
40 bool
41 default y
42
43config GENERIC_IRQ_PROBE
44 bool
45 default y
46
47config RWSEM_XCHGADD_ALGORITHM
48 bool
49
50config ARCH_HAS_ILOG2_U32
51 bool
52 default n
53
54config ARCH_HAS_ILOG2_U64
55 bool
56 default n
57
58config ARCH_NO_VIRT_TO_BUS
59 def_bool y
60
61source init/Kconfig
62
63menu "System type"
64
65choice
66 prompt "SuperH system type"
67 default SH_SIMULATOR
68
69config SH_SIMULATOR
70 bool "Simulator"
71
72config SH_CAYMAN
73 bool "Cayman"
74
75config SH_HARP
76 bool "ST50-Harp"
77
78endchoice
79
80choice
81 prompt "Processor family"
82 default CPU_SH5
83
84config CPU_SH5
85 bool "SH-5"
86
87endchoice
88
89choice
90 prompt "Processor type"
91
92config CPU_SUBTYPE_SH5_101
93 bool "SH5-101"
94 depends on CPU_SH5
95
96config CPU_SUBTYPE_SH5_103
97 bool "SH5-103"
98 depends on CPU_SH5
99
100endchoice
101
102choice
103 prompt "Endianness"
104 default LITTLE_ENDIAN
105
106config LITTLE_ENDIAN
107 bool "Little-Endian"
108
109config BIG_ENDIAN
110 bool "Big-Endian"
111
112endchoice
113
114config SH_FPU
115 bool "FPU support"
116 default y
117
118config SH64_FPU_DENORM_FLUSH
119 depends on SH_FPU
120 bool "Flush floating point denorms to zero"
121
122choice
123 prompt "Page table levels"
124 default SH64_PGTABLE_2_LEVEL
125
126config SH64_PGTABLE_2_LEVEL
127 bool "2"
128
129config SH64_PGTABLE_3_LEVEL
130 bool "3"
131
132endchoice
133
134choice
135 prompt "HugeTLB page size"
136 depends on HUGETLB_PAGE && MMU
137 default HUGETLB_PAGE_SIZE_64K
138
139config HUGETLB_PAGE_SIZE_64K
140 bool "64K"
141
142config HUGETLB_PAGE_SIZE_1MB
143 bool "1MB"
144
145config HUGETLB_PAGE_SIZE_512MB
146 bool "512MB"
147
148endchoice
149
150config SH64_USER_MISALIGNED_FIXUP
151 bool "Fixup misaligned loads/stores occurring in user mode"
152
153comment "Memory options"
154
155config CACHED_MEMORY_OFFSET
156 hex "Cached Area Offset"
157 default "20000000"
158
159config MEMORY_START
160 hex "Physical memory start address"
161 default "80000000"
162
163config MEMORY_SIZE_IN_MB
164 int "Memory size (in MB)"
165 default "8" if SH_SIMULATOR
166 default "64"
167
168comment "Cache options"
169
170choice
171 prompt "DCache mode"
172 default DCACHE_DISABLED if SH_SIMULATOR
173 default DCACHE_WRITE_BACK
174
175config DCACHE_WRITE_BACK
176 bool "Write-back"
177 depends on !SH_SIMULATOR
178
179config DCACHE_WRITE_THROUGH
180 bool "Write-through"
181 depends on !SH_SIMULATOR
182
183config DCACHE_DISABLED
184 bool "Disabled"
185
186endchoice
187
188config ICACHE_DISABLED
189 bool "ICache Disabling"
190
191config PCIDEVICE_MEMORY_START
192 hex
193 default "C0000000"
194
195config DEVICE_MEMORY_START
196 hex
197 default "E0000000"
198
199config FLASH_MEMORY_START
200 hex "Flash memory/on-chip devices start address"
201 default "00000000"
202
203config PCI_BLOCK_START
204 hex "PCI block start address"
205 default "40000000"
206
207comment "CPU Subtype specific options"
208
209config SH64_ID2815_WORKAROUND
210 bool "Include workaround for SH5-101 cut2 silicon defect ID2815"
211
212comment "Misc options"
213
214config HEARTBEAT
215 bool "Heartbeat LED"
216 depends on SH_CAYMAN
217
218config HDSP253_LED
219 bool "Support for HDSP-253 LED"
220 depends on SH_CAYMAN
221
222config SH_DMA
223 tristate "DMA controller (DMAC) support"
224
225config PREEMPT
226 bool "Preemptible Kernel (EXPERIMENTAL)"
227 depends on EXPERIMENTAL
228
229source "mm/Kconfig"
230
231endmenu
232
233menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)"
234
235config ISA
236 bool
237
238config SBUS
239 bool
240
241config PCI
242 bool "PCI support"
243 depends on SH_CAYMAN
244 help
245 Find out whether you have a PCI motherboard. PCI is the name of a
246 bus system, i.e. the way the CPU talks to the other stuff inside
247 your box. Other bus systems are ISA, EISA, MicroChannel (MCA) or
248 VESA. If you have PCI, say Y, otherwise N.
249
250 The PCI-HOWTO, available from
251 <http://www.tldp.org/docs.html#howto>, contains valuable
252 information about which PCI hardware does work under Linux and which
253 doesn't.
254
255config SH_PCIDMA_NONCOHERENT
256 bool "Cache and PCI noncoherent"
257 depends on PCI
258 default y
259 help
260 Enable this option if your platform does not have a CPU cache which
261 remains coherent with PCI DMA. It is safest to say 'Y', although you
262 will see better performance if you can say 'N', because the PCI DMA
263 code will not have to flush the CPU's caches. If you have a PCI host
264 bridge integrated with your SH CPU, refer carefully to the chip specs
265 to see if you can say 'N' here. Otherwise, leave it as 'Y'.
266
267source "drivers/pci/Kconfig"
268
269source "drivers/pcmcia/Kconfig"
270
271source "drivers/pci/hotplug/Kconfig"
272
273endmenu
274
275menu "Executable file formats"
276
277source "fs/Kconfig.binfmt"
278
279endmenu
280
281source "net/Kconfig"
282
283source "drivers/Kconfig"
284
285source "fs/Kconfig"
286
287source "kernel/Kconfig.instrumentation"
288
289source "arch/sh64/Kconfig.debug"
290
291source "security/Kconfig"
292
293source "crypto/Kconfig"
294
295source "lib/Kconfig"
diff --git a/arch/sh64/Kconfig.debug b/arch/sh64/Kconfig.debug
deleted file mode 100644
index 05c07c4e4ed6..000000000000
--- a/arch/sh64/Kconfig.debug
+++ /dev/null
@@ -1,33 +0,0 @@
1menu "Kernel hacking"
2
3source "lib/Kconfig.debug"
4
5config EARLY_PRINTK
6 bool "Early SCIF console support"
7
8config SH64_PROC_TLB
9 bool "Debug: report TLB fill/purge activity through /proc/tlb"
10 depends on PROC_FS
11
12config SH64_PROC_ASIDS
13 bool "Debug: report ASIDs through /proc/asids"
14 depends on PROC_FS
15
16config SH64_SR_WATCH
17 bool "Debug: set SR.WATCH to enable hardware watchpoints and trace"
18
19config POOR_MANS_STRACE
20 bool "Debug: enable rudimentary strace facility"
21 help
22 This option allows system calls to be traced to the console. It also
23 aids in detecting kernel stack underflow. It is useful for debugging
24 early-userland problems (e.g. init incurring fatal exceptions.)
25
26config SH_ALPHANUMERIC
27 bool "Enable debug outputs to on-board alphanumeric display"
28 depends on SH_CAYMAN
29
30config SH_NO_BSS_INIT
31 bool "Avoid zeroing BSS (to speed-up startup on suitable platforms)"
32
33endmenu
diff --git a/arch/sh64/Makefile b/arch/sh64/Makefile
deleted file mode 100644
index 8dac7e1a2be6..000000000000
--- a/arch/sh64/Makefile
+++ /dev/null
@@ -1,111 +0,0 @@
1#
2# This file is subject to the terms and conditions of the GNU General Public
3# License. See the file "COPYING" in the main directory of this archive
4# for more details.
5#
6# Copyright (C) 2000, 2001 Paolo Alberelli
7# Copyright (C) 2003, 2004 Paul Mundt
8#
9# This file is included by the global makefile so that you can add your own
10# architecture-specific flags and dependencies. Remember to do have actions
11# for "archclean" and "archdep" for cleaning up and making dependencies for
12# this architecture
13#
14
15cpu-y := -mb
16cpu-$(CONFIG_LITTLE_ENDIAN) := -ml
17
18cpu-$(CONFIG_CPU_SH5) += -m5-32media-nofpu
19
20ifdef CONFIG_LITTLE_ENDIAN
21LDFLAGS_vmlinux += --defsym 'jiffies=jiffies_64'
22LDFLAGS += -EL -mshlelf32_linux
23else
24LDFLAGS_vmlinux += --defsym 'jiffies=jiffies_64+4'
25LDFLAGS += -EB -mshelf32_linux
26endif
27
28# No requirements for endianess support from AFLAGS, 'as' always run through gcc
29KBUILD_CFLAGS += $(cpu-y)
30
31LDFLAGS_vmlinux += --defsym phys_stext=_stext-$(CONFIG_CACHED_MEMORY_OFFSET) \
32 --defsym phys_stext_shmedia=phys_stext+1 \
33 -e phys_stext_shmedia
34
35OBJCOPYFLAGS := -O binary -R .note -R .comment -R .stab -R .stabstr -S
36
37#
38# arch/sh64/defconfig never had any hope of being
39# frequently updated, so use one that does
40#
41KBUILD_DEFCONFIG := cayman_defconfig
42
43KBUILD_IMAGE := arch/$(ARCH)/boot/zImage
44
45ifdef LOADADDR
46LINKFLAGS += -Ttext $(word 1,$(LOADADDR))
47endif
48
49machine-$(CONFIG_SH_CAYMAN) := cayman
50machine-$(CONFIG_SH_SIMULATOR) := sim
51machine-$(CONFIG_SH_HARP) := harp
52
53head-y := arch/$(ARCH)/kernel/head.o arch/$(ARCH)/kernel/init_task.o
54
55core-y += arch/sh64/kernel/ arch/sh64/mm/
56
57ifneq ($(machine-y),)
58core-y += arch/sh64/mach-$(machine-y)/
59endif
60
61LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
62libs-y += arch/$(ARCH)/lib/ $(LIBGCC)
63
64drivers-$(CONFIG_OPROFILE) += arch/sh64/oprofile/
65
66boot := arch/$(ARCH)/boot
67
68zImage: vmlinux
69 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
70
71compressed: zImage
72
73archclean:
74 $(Q)$(MAKE) $(clean)=$(boot)
75
76archprepare: arch/$(ARCH)/lib/syscalltab.h
77
78define filechk_gen-syscalltab
79 (set -e; \
80 echo "/*"; \
81 echo " * DO NOT MODIFY."; \
82 echo " *"; \
83 echo " * This file was generated by arch/$(ARCH)/Makefile"; \
84 echo " * Any changes will be reverted at build time."; \
85 echo " */"; \
86 echo ""; \
87 echo "#ifndef __SYSCALLTAB_H"; \
88 echo "#define __SYSCALLTAB_H"; \
89 echo ""; \
90 echo "#include <linux/kernel.h>"; \
91 echo ""; \
92 echo "struct syscall_info {"; \
93 echo " const char *name;"; \
94 echo "} syscall_info_table[] = {"; \
95 sed -e '/^.*\.long /!d;s// { "/;s/\(\([^/]*\)\/\)\{1\}.*/\2/; \
96 s/[ \t]*$$//g;s/$$/" },/;s/\("\)sys_/\1/g'; \
97 echo "};"; \
98 echo ""; \
99 echo "#define NUM_SYSCALL_INFO_ENTRIES ARRAY_SIZE(syscall_info_table)"; \
100 echo ""; \
101 echo "#endif /* __SYSCALLTAB_H */" )
102endef
103
104arch/$(ARCH)/lib/syscalltab.h: arch/sh64/kernel/syscalls.S
105 $(call filechk,gen-syscalltab)
106
107CLEAN_FILES += arch/$(ARCH)/lib/syscalltab.h
108
109define archhelp
110 @echo '* zImage - Compressed kernel image'
111endef
diff --git a/arch/sh64/boot/Makefile b/arch/sh64/boot/Makefile
deleted file mode 100644
index fb71087b7b8a..000000000000
--- a/arch/sh64/boot/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
1#
2# arch/sh64/boot/Makefile
3#
4# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive
6# for more details.
7#
8# Copyright (C) 2002 Stuart Menefy
9#
10
11targets := zImage
12subdir- := compressed
13
14$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
15 $(call if_changed,objcopy)
16 @echo 'Kernel: $@ is ready'
17
18$(obj)/compressed/vmlinux: FORCE
19 $(Q)$(MAKE) $(build)=$(obj)/compressed $@
20
diff --git a/arch/sh64/boot/compressed/Makefile b/arch/sh64/boot/compressed/Makefile
deleted file mode 100644
index 9cd216718856..000000000000
--- a/arch/sh64/boot/compressed/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
1#
2# linux/arch/sh64/boot/compressed/Makefile
3#
4# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive
6# for more details.
7#
8# Copyright (C) 2002 Stuart Menefy
9# Copyright (C) 2004 Paul Mundt
10#
11# create a compressed vmlinux image from the original vmlinux
12#
13
14targets := vmlinux vmlinux.bin vmlinux.bin.gz \
15 head.o misc.o cache.o piggy.o vmlinux.lds
16
17EXTRA_AFLAGS := -traditional
18
19OBJECTS := $(obj)/head.o $(obj)/misc.o $(obj)/cache.o
20
21#
22# ZIMAGE_OFFSET is the load offset of the compression loader
23# (4M for the kernel plus 64K for this loader)
24#
25ZIMAGE_OFFSET = $(shell printf "0x%8x" $$[$(CONFIG_MEMORY_START)+0x400000+0x10000])
26
27LDFLAGS_vmlinux := -Ttext $(ZIMAGE_OFFSET) -e startup \
28 -T $(obj)/../../kernel/vmlinux.lds \
29 --no-warn-mismatch
30
31$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o FORCE
32 $(call if_changed,ld)
33 @:
34
35$(obj)/vmlinux.bin: vmlinux FORCE
36 $(call if_changed,objcopy)
37
38$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
39 $(call if_changed,gzip)
40
41LDFLAGS_piggy.o := -r --format binary --oformat elf32-sh64-linux -T
42OBJCOPYFLAGS += -R .empty_zero_page
43
44$(obj)/piggy.o: $(obj)/vmlinux.lds $(obj)/vmlinux.bin.gz FORCE
45 $(call if_changed,ld)
46
diff --git a/arch/sh64/boot/compressed/cache.c b/arch/sh64/boot/compressed/cache.c
deleted file mode 100644
index 708707355ffa..000000000000
--- a/arch/sh64/boot/compressed/cache.c
+++ /dev/null
@@ -1,39 +0,0 @@
1/*
2 * arch/shmedia/boot/compressed/cache.c -- simple cache management functions
3 *
4 * Code extracted from sh-ipl+g, sh-stub.c, which has the copyright:
5 *
6 * This is originally based on an m68k software stub written by Glenn
7 * Engel at HP, but has changed quite a bit.
8 *
9 * Modifications for the SH by Ben Lee and Steve Chamberlain
10 *
11****************************************************************************
12
13 THIS SOFTWARE IS NOT COPYRIGHTED
14
15 HP offers the following for use in the public domain. HP makes no
16 warranty with regard to the software or it's performance and the
17 user accepts the software "AS IS" with all faults.
18
19 HP DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD
20 TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22
23****************************************************************************/
24
25#define CACHE_ENABLE 0
26#define CACHE_DISABLE 1
27
28int cache_control(unsigned int command)
29{
30 volatile unsigned int *p = (volatile unsigned int *) 0x80000000;
31 int i;
32
33 for (i = 0; i < (32 * 1024); i += 32) {
34 (void *) *p;
35 p += (32 / sizeof (int));
36 }
37
38 return 0;
39}
diff --git a/arch/sh64/boot/compressed/head.S b/arch/sh64/boot/compressed/head.S
deleted file mode 100644
index 82040b1a29cf..000000000000
--- a/arch/sh64/boot/compressed/head.S
+++ /dev/null
@@ -1,164 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/shmedia/boot/compressed/head.S
7 *
8 * Copied from
9 * arch/shmedia/kernel/head.S
10 * which carried the copyright:
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 * Modification for compressed loader:
14 * Copyright (C) 2002 Stuart Menefy (stuart.menefy@st.com)
15 */
16
17#include <linux/linkage.h>
18#include <asm/registers.h>
19#include <asm/cache.h>
20#include <asm/mmu_context.h>
21
22/*
23 * Fixed TLB entries to identity map the beginning of RAM
24 */
25#define MMUIR_TEXT_H 0x0000000000000003 | CONFIG_MEMORY_START
26 /* Enabled, Shared, ASID 0, Eff. Add. 0xA0000000 */
27#define MMUIR_TEXT_L 0x000000000000009a | CONFIG_MEMORY_START
28 /* 512 Mb, Cacheable (Write-back), execute, Not User, Ph. Add. */
29
30#define MMUDR_CACHED_H 0x0000000000000003 | CONFIG_MEMORY_START
31 /* Enabled, Shared, ASID 0, Eff. Add. 0xA0000000 */
32#define MMUDR_CACHED_L 0x000000000000015a | CONFIG_MEMORY_START
33 /* 512 Mb, Cacheable (Write-back), read/write, Not User, Ph. Add. */
34
35#define ICCR0_INIT_VAL ICCR0_ON | ICCR0_ICI /* ICE + ICI */
36#define ICCR1_INIT_VAL ICCR1_NOLOCK /* No locking */
37
38#if 1
39#define OCCR0_INIT_VAL OCCR0_ON | OCCR0_OCI | OCCR0_WB /* OCE + OCI + WB */
40#else
41#define OCCR0_INIT_VAL OCCR0_OFF
42#endif
43#define OCCR1_INIT_VAL OCCR1_NOLOCK /* No locking */
44
45 .text
46
47 .global startup
48startup:
49 /*
50 * Prevent speculative fetch on device memory due to
51 * uninitialized target registers.
52 * This must be executed before the first branch.
53 */
54 ptabs/u ZERO, tr0
55 ptabs/u ZERO, tr1
56 ptabs/u ZERO, tr2
57 ptabs/u ZERO, tr3
58 ptabs/u ZERO, tr4
59 ptabs/u ZERO, tr5
60 ptabs/u ZERO, tr6
61 ptabs/u ZERO, tr7
62 synci
63
64 /*
65 * Set initial TLB entries for cached and uncached regions.
66 * Note: PTA/BLINK is PIC code, PTABS/BLINK isn't !
67 */
68 /* Clear ITLBs */
69 pta 1f, tr1
70 movi ITLB_FIXED, r21
71 movi ITLB_LAST_VAR_UNRESTRICTED+TLB_STEP, r22
721: putcfg r21, 0, ZERO /* Clear MMUIR[n].PTEH.V */
73 addi r21, TLB_STEP, r21
74 bne r21, r22, tr1
75
76 /* Clear DTLBs */
77 pta 1f, tr1
78 movi DTLB_FIXED, r21
79 movi DTLB_LAST_VAR_UNRESTRICTED+TLB_STEP, r22
801: putcfg r21, 0, ZERO /* Clear MMUDR[n].PTEH.V */
81 addi r21, TLB_STEP, r21
82 bne r21, r22, tr1
83
84 /* Map one big (512Mb) page for ITLB */
85 movi ITLB_FIXED, r21
86 movi MMUIR_TEXT_L, r22 /* PTEL first */
87 putcfg r21, 1, r22 /* Set MMUIR[0].PTEL */
88 movi MMUIR_TEXT_H, r22 /* PTEH last */
89 putcfg r21, 0, r22 /* Set MMUIR[0].PTEH */
90
91 /* Map one big CACHED (512Mb) page for DTLB */
92 movi DTLB_FIXED, r21
93 movi MMUDR_CACHED_L, r22 /* PTEL first */
94 putcfg r21, 1, r22 /* Set MMUDR[0].PTEL */
95 movi MMUDR_CACHED_H, r22 /* PTEH last */
96 putcfg r21, 0, r22 /* Set MMUDR[0].PTEH */
97
98 /* ICache */
99 movi ICCR_BASE, r21
100 movi ICCR0_INIT_VAL, r22
101 movi ICCR1_INIT_VAL, r23
102 putcfg r21, ICCR_REG0, r22
103 putcfg r21, ICCR_REG1, r23
104 synci
105
106 /* OCache */
107 movi OCCR_BASE, r21
108 movi OCCR0_INIT_VAL, r22
109 movi OCCR1_INIT_VAL, r23
110 putcfg r21, OCCR_REG0, r22
111 putcfg r21, OCCR_REG1, r23
112 synco
113
114 /*
115 * Enable the MMU.
116 * From here-on code can be non-PIC.
117 */
118 movi SR_HARMLESS | SR_ENABLE_MMU, r22
119 putcon r22, SSR
120 movi 1f, r22
121 putcon r22, SPC
122 synco
123 rte /* And now go into the hyperspace ... */
1241: /* ... that's the next instruction ! */
125
126 /* Set initial stack pointer */
127 movi datalabel stack_start, r0
128 ld.l r0, 0, r15
129
130 /*
131 * Clear bss
132 */
133 pt 1f, tr1
134 movi datalabel __bss_start, r22
135 movi datalabel _end, r23
1361: st.l r22, 0, ZERO
137 addi r22, 4, r22
138 bne r22, r23, tr1
139
140 /*
141 * Decompress the kernel.
142 */
143 pt decompress_kernel, tr0
144 blink tr0, r18
145
146 /*
147 * Disable the MMU.
148 */
149 movi SR_HARMLESS, r22
150 putcon r22, SSR
151 movi 1f, r22
152 putcon r22, SPC
153 synco
154 rte /* And now go into the hyperspace ... */
1551: /* ... that's the next instruction ! */
156
157 /* Jump into the decompressed kernel */
158 movi datalabel (CONFIG_MEMORY_START + 0x2000)+1, r19
159 ptabs r19, tr0
160 blink tr0, r18
161
162 /* Shouldn't return here, but just in case, loop forever */
163 pt 1f, tr0
1641: blink tr0, ZERO
diff --git a/arch/sh64/boot/compressed/install.sh b/arch/sh64/boot/compressed/install.sh
deleted file mode 100644
index 90589f0fec12..000000000000
--- a/arch/sh64/boot/compressed/install.sh
+++ /dev/null
@@ -1,56 +0,0 @@
1#!/bin/sh
2#
3# arch/sh/boot/install.sh
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) 1995 by Linus Torvalds
10#
11# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
12# Adapted from code in arch/i386/boot/install.sh by Russell King
13# Adapted from code in arch/arm/boot/install.sh by Stuart Menefy
14#
15# "make install" script for sh architecture
16#
17# Arguments:
18# $1 - kernel version
19# $2 - kernel image file
20# $3 - kernel map file
21# $4 - default install path (blank if root directory)
22#
23
24# User may have a custom install script
25
26if [ -x /sbin/installkernel ]; then
27 exec /sbin/installkernel "$@"
28fi
29
30if [ "$2" = "zImage" ]; then
31# Compressed install
32 echo "Installing compressed kernel"
33 if [ -f $4/vmlinuz-$1 ]; then
34 mv $4/vmlinuz-$1 $4/vmlinuz.old
35 fi
36
37 if [ -f $4/System.map-$1 ]; then
38 mv $4/System.map-$1 $4/System.old
39 fi
40
41 cat $2 > $4/vmlinuz-$1
42 cp $3 $4/System.map-$1
43else
44# Normal install
45 echo "Installing normal kernel"
46 if [ -f $4/vmlinux-$1 ]; then
47 mv $4/vmlinux-$1 $4/vmlinux.old
48 fi
49
50 if [ -f $4/System.map ]; then
51 mv $4/System.map $4/System.old
52 fi
53
54 cat $2 > $4/vmlinux-$1
55 cp $3 $4/System.map
56fi
diff --git a/arch/sh64/boot/compressed/misc.c b/arch/sh64/boot/compressed/misc.c
deleted file mode 100644
index aea00c53ce29..000000000000
--- a/arch/sh64/boot/compressed/misc.c
+++ /dev/null
@@ -1,250 +0,0 @@
1/*
2 * arch/sh64/boot/compressed/misc.c
3 *
4 * This is a collection of several routines from gzip-1.0.3
5 * adapted for Linux.
6 *
7 * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
8 *
9 * Adapted for SHmedia from sh by Stuart Menefy, May 2002
10 */
11
12#include <asm/uaccess.h>
13
14/* cache.c */
15#define CACHE_ENABLE 0
16#define CACHE_DISABLE 1
17int cache_control(unsigned int command);
18
19/*
20 * gzip declarations
21 */
22
23#define OF(args) args
24#define STATIC static
25
26#undef memset
27#undef memcpy
28#define memzero(s, n) memset ((s), 0, (n))
29
30typedef unsigned char uch;
31typedef unsigned short ush;
32typedef unsigned long ulg;
33
34#define WSIZE 0x8000 /* Window size must be at least 32k, */
35 /* and a power of two */
36
37static uch *inbuf; /* input buffer */
38static uch window[WSIZE]; /* Sliding window buffer */
39
40static unsigned insize = 0; /* valid bytes in inbuf */
41static unsigned inptr = 0; /* index of next byte to be processed in inbuf */
42static unsigned outcnt = 0; /* bytes in output buffer */
43
44/* gzip flag byte */
45#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
46#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
47#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
48#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
49#define COMMENT 0x10 /* bit 4 set: file comment present */
50#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
51#define RESERVED 0xC0 /* bit 6,7: reserved */
52
53#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
54
55/* Diagnostic functions */
56#ifdef DEBUG
57# define Assert(cond,msg) {if(!(cond)) error(msg);}
58# define Trace(x) fprintf x
59# define Tracev(x) {if (verbose) fprintf x ;}
60# define Tracevv(x) {if (verbose>1) fprintf x ;}
61# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
62# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
63#else
64# define Assert(cond,msg)
65# define Trace(x)
66# define Tracev(x)
67# define Tracevv(x)
68# define Tracec(c,x)
69# define Tracecv(c,x)
70#endif
71
72static int fill_inbuf(void);
73static void flush_window(void);
74static void error(char *m);
75static void gzip_mark(void **);
76static void gzip_release(void **);
77
78extern char input_data[];
79extern int input_len;
80
81static long bytes_out = 0;
82static uch *output_data;
83static unsigned long output_ptr = 0;
84
85static void *malloc(int size);
86static void free(void *where);
87static void error(char *m);
88static void gzip_mark(void **);
89static void gzip_release(void **);
90
91static void puts(const char *);
92
93extern int _text; /* Defined in vmlinux.lds.S */
94extern int _end;
95static unsigned long free_mem_ptr;
96static unsigned long free_mem_end_ptr;
97
98#define HEAP_SIZE 0x10000
99
100#include "../../../../lib/inflate.c"
101
102static void *malloc(int size)
103{
104 void *p;
105
106 if (size < 0)
107 error("Malloc error\n");
108 if (free_mem_ptr == 0)
109 error("Memory error\n");
110
111 free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
112
113 p = (void *) free_mem_ptr;
114 free_mem_ptr += size;
115
116 if (free_mem_ptr >= free_mem_end_ptr)
117 error("\nOut of memory\n");
118
119 return p;
120}
121
122static void free(void *where)
123{ /* Don't care */
124}
125
126static void gzip_mark(void **ptr)
127{
128 *ptr = (void *) free_mem_ptr;
129}
130
131static void gzip_release(void **ptr)
132{
133 free_mem_ptr = (long) *ptr;
134}
135
136void puts(const char *s)
137{
138}
139
140void *memset(void *s, int c, size_t n)
141{
142 int i;
143 char *ss = (char *) s;
144
145 for (i = 0; i < n; i++)
146 ss[i] = c;
147 return s;
148}
149
150void *memcpy(void *__dest, __const void *__src, size_t __n)
151{
152 int i;
153 char *d = (char *) __dest, *s = (char *) __src;
154
155 for (i = 0; i < __n; i++)
156 d[i] = s[i];
157 return __dest;
158}
159
160/* ===========================================================================
161 * Fill the input buffer. This is called only when the buffer is empty
162 * and at least one byte is really needed.
163 */
164static int fill_inbuf(void)
165{
166 if (insize != 0) {
167 error("ran out of input data\n");
168 }
169
170 inbuf = input_data;
171 insize = input_len;
172 inptr = 1;
173 return inbuf[0];
174}
175
176/* ===========================================================================
177 * Write the output window window[0..outcnt-1] and update crc and bytes_out.
178 * (Used for the decompressed data only.)
179 */
180static void flush_window(void)
181{
182 ulg c = crc; /* temporary variable */
183 unsigned n;
184 uch *in, *out, ch;
185
186 in = window;
187 out = &output_data[output_ptr];
188 for (n = 0; n < outcnt; n++) {
189 ch = *out++ = *in++;
190 c = crc_32_tab[((int) c ^ ch) & 0xff] ^ (c >> 8);
191 }
192 crc = c;
193 bytes_out += (ulg) outcnt;
194 output_ptr += (ulg) outcnt;
195 outcnt = 0;
196 puts(".");
197}
198
199static void error(char *x)
200{
201 puts("\n\n");
202 puts(x);
203 puts("\n\n -- System halted");
204
205 while (1) ; /* Halt */
206}
207
208#define STACK_SIZE (4096)
209long __attribute__ ((aligned(8))) user_stack[STACK_SIZE];
210long *stack_start = &user_stack[STACK_SIZE];
211
212void decompress_kernel(void)
213{
214 output_data = (uch *) (CONFIG_MEMORY_START + 0x2000);
215 free_mem_ptr = (unsigned long) &_end;
216 free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
217
218 makecrc();
219 puts("Uncompressing Linux... ");
220 cache_control(CACHE_ENABLE);
221 gunzip();
222 puts("\n");
223
224#if 0
225 /* When booting from ROM may want to do something like this if the
226 * boot loader doesn't.
227 */
228
229 /* Set up the parameters and command line */
230 {
231 volatile unsigned int *parambase =
232 (int *) (CONFIG_MEMORY_START + 0x1000);
233
234 parambase[0] = 0x1; /* MOUNT_ROOT_RDONLY */
235 parambase[1] = 0x0; /* RAMDISK_FLAGS */
236 parambase[2] = 0x0200; /* ORIG_ROOT_DEV */
237 parambase[3] = 0x0; /* LOADER_TYPE */
238 parambase[4] = 0x0; /* INITRD_START */
239 parambase[5] = 0x0; /* INITRD_SIZE */
240 parambase[6] = 0;
241
242 strcpy((char *) ((int) parambase + 0x100),
243 "console=ttySC0,38400");
244 }
245#endif
246
247 puts("Ok, booting the kernel.\n");
248
249 cache_control(CACHE_DISABLE);
250}
diff --git a/arch/sh64/boot/compressed/vmlinux.lds.S b/arch/sh64/boot/compressed/vmlinux.lds.S
deleted file mode 100644
index 59c2ef4aeda5..000000000000
--- a/arch/sh64/boot/compressed/vmlinux.lds.S
+++ /dev/null
@@ -1,64 +0,0 @@
1/*
2 * ld script to make compressed SuperH/shmedia Linux kernel+decompression
3 * bootstrap
4 * Modified by Stuart Menefy from arch/sh/vmlinux.lds.S written by Niibe Yutaka
5 */
6
7
8#ifdef CONFIG_LITTLE_ENDIAN
9/* OUTPUT_FORMAT("elf32-sh64l-linux", "elf32-sh64l-linux", "elf32-sh64l-linux") */
10#define NOP 0x6ff0fff0
11#else
12/* OUTPUT_FORMAT("elf32-sh64", "elf32-sh64", "elf32-sh64") */
13#define NOP 0xf0fff06f
14#endif
15
16OUTPUT_FORMAT("elf32-sh64-linux")
17OUTPUT_ARCH(sh)
18ENTRY(_start)
19
20#define ALIGNED_GAP(section, align) (((ADDR(section)+SIZEOF(section)+(align)-1) & ~((align)-1))-ADDR(section))
21#define FOLLOWING(section, align) AT (LOADADDR(section) + ALIGNED_GAP(section,align))
22
23SECTIONS
24{
25 _text = .; /* Text and read-only data */
26
27 .text : {
28 *(.text)
29 *(.text64)
30 *(.text..SHmedia32)
31 *(.fixup)
32 *(.gnu.warning)
33 } = NOP
34 . = ALIGN(4);
35 .rodata : { *(.rodata) }
36
37 /* There is no 'real' reason for eight byte alignment, four would work
38 * as well, but gdb downloads much (*4) faster with this.
39 */
40 . = ALIGN(8);
41 .image : { *(.image) }
42 . = ALIGN(4);
43 _etext = .; /* End of text section */
44
45 .data : /* Data */
46 FOLLOWING(.image, 4)
47 {
48 _data = .;
49 *(.data)
50 }
51 _data_image = LOADADDR(.data);/* Address of data section in ROM */
52
53 _edata = .; /* End of data section */
54
55 .stack : { stack = .; _stack = .; }
56
57 . = ALIGN(4);
58 __bss_start = .; /* BSS */
59 .bss : {
60 *(.bss)
61 }
62 . = ALIGN(4);
63 _end = . ;
64}
diff --git a/arch/sh64/configs/cayman_defconfig b/arch/sh64/configs/cayman_defconfig
deleted file mode 100644
index 75552bb01405..000000000000
--- a/arch/sh64/configs/cayman_defconfig
+++ /dev/null
@@ -1,1126 +0,0 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.24-rc1
4# Fri Nov 2 14:35:27 2007
5#
6CONFIG_SUPERH=y
7CONFIG_SUPERH64=y
8CONFIG_MMU=y
9CONFIG_QUICKLIST=y
10CONFIG_RWSEM_GENERIC_SPINLOCK=y
11CONFIG_GENERIC_FIND_NEXT_BIT=y
12CONFIG_GENERIC_HWEIGHT=y
13CONFIG_GENERIC_CALIBRATE_DELAY=y
14CONFIG_GENERIC_HARDIRQS=y
15CONFIG_GENERIC_IRQ_PROBE=y
16# CONFIG_ARCH_HAS_ILOG2_U32 is not set
17# CONFIG_ARCH_HAS_ILOG2_U64 is not set
18CONFIG_ARCH_NO_VIRT_TO_BUS=y
19CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
20
21#
22# General setup
23#
24CONFIG_EXPERIMENTAL=y
25CONFIG_BROKEN_ON_SMP=y
26CONFIG_LOCK_KERNEL=y
27CONFIG_INIT_ENV_ARG_LIMIT=32
28CONFIG_LOCALVERSION=""
29CONFIG_LOCALVERSION_AUTO=y
30CONFIG_SWAP=y
31# CONFIG_SYSVIPC is not set
32CONFIG_POSIX_MQUEUE=y
33# CONFIG_BSD_PROCESS_ACCT is not set
34# CONFIG_TASKSTATS is not set
35# CONFIG_USER_NS is not set
36# CONFIG_AUDIT is not set
37# CONFIG_IKCONFIG is not set
38CONFIG_LOG_BUF_SHIFT=14
39# CONFIG_CGROUPS is not set
40CONFIG_FAIR_GROUP_SCHED=y
41CONFIG_FAIR_USER_SCHED=y
42# CONFIG_FAIR_CGROUP_SCHED is not set
43CONFIG_SYSFS_DEPRECATED=y
44# CONFIG_RELAY is not set
45# CONFIG_BLK_DEV_INITRD is not set
46# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
47CONFIG_SYSCTL=y
48# CONFIG_EMBEDDED is not set
49CONFIG_UID16=y
50CONFIG_SYSCTL_SYSCALL=y
51CONFIG_KALLSYMS=y
52# CONFIG_KALLSYMS_ALL is not set
53# CONFIG_KALLSYMS_EXTRA_PASS is not set
54CONFIG_HOTPLUG=y
55CONFIG_PRINTK=y
56CONFIG_BUG=y
57CONFIG_ELF_CORE=y
58CONFIG_BASE_FULL=y
59CONFIG_FUTEX=y
60CONFIG_ANON_INODES=y
61CONFIG_EPOLL=y
62CONFIG_SIGNALFD=y
63CONFIG_EVENTFD=y
64CONFIG_SHMEM=y
65CONFIG_VM_EVENT_COUNTERS=y
66CONFIG_SLAB=y
67# CONFIG_SLUB is not set
68# CONFIG_SLOB is not set
69CONFIG_RT_MUTEXES=y
70# CONFIG_TINY_SHMEM is not set
71CONFIG_BASE_SMALL=0
72CONFIG_MODULES=y
73CONFIG_MODULE_UNLOAD=y
74# CONFIG_MODULE_FORCE_UNLOAD is not set
75# CONFIG_MODVERSIONS is not set
76# CONFIG_MODULE_SRCVERSION_ALL is not set
77CONFIG_KMOD=y
78CONFIG_BLOCK=y
79# CONFIG_LBD is not set
80# CONFIG_BLK_DEV_IO_TRACE is not set
81# CONFIG_LSF is not set
82# CONFIG_BLK_DEV_BSG is not set
83
84#
85# IO Schedulers
86#
87CONFIG_IOSCHED_NOOP=y
88CONFIG_IOSCHED_AS=y
89CONFIG_IOSCHED_DEADLINE=y
90CONFIG_IOSCHED_CFQ=y
91# CONFIG_DEFAULT_AS is not set
92# CONFIG_DEFAULT_DEADLINE is not set
93CONFIG_DEFAULT_CFQ=y
94# CONFIG_DEFAULT_NOOP is not set
95CONFIG_DEFAULT_IOSCHED="cfq"
96
97#
98# System type
99#
100# CONFIG_SH_SIMULATOR is not set
101CONFIG_SH_CAYMAN=y
102# CONFIG_SH_HARP is not set
103CONFIG_CPU_SH5=y
104CONFIG_CPU_SUBTYPE_SH5_101=y
105# CONFIG_CPU_SUBTYPE_SH5_103 is not set
106CONFIG_LITTLE_ENDIAN=y
107# CONFIG_BIG_ENDIAN is not set
108CONFIG_SH_FPU=y
109# CONFIG_SH64_FPU_DENORM_FLUSH is not set
110CONFIG_SH64_PGTABLE_2_LEVEL=y
111# CONFIG_SH64_PGTABLE_3_LEVEL is not set
112CONFIG_HUGETLB_PAGE_SIZE_64K=y
113# CONFIG_HUGETLB_PAGE_SIZE_1MB is not set
114# CONFIG_HUGETLB_PAGE_SIZE_512MB is not set
115CONFIG_SH64_USER_MISALIGNED_FIXUP=y
116
117#
118# Memory options
119#
120CONFIG_CACHED_MEMORY_OFFSET=0x20000000
121CONFIG_MEMORY_START=0x80000000
122CONFIG_MEMORY_SIZE_IN_MB=128
123
124#
125# Cache options
126#
127CONFIG_DCACHE_WRITE_BACK=y
128# CONFIG_DCACHE_WRITE_THROUGH is not set
129# CONFIG_DCACHE_DISABLED is not set
130# CONFIG_ICACHE_DISABLED is not set
131CONFIG_PCIDEVICE_MEMORY_START=C0000000
132CONFIG_DEVICE_MEMORY_START=E0000000
133CONFIG_FLASH_MEMORY_START=0x00000000
134CONFIG_PCI_BLOCK_START=0x40000000
135
136#
137# CPU Subtype specific options
138#
139CONFIG_SH64_ID2815_WORKAROUND=y
140
141#
142# Misc options
143#
144CONFIG_HEARTBEAT=y
145CONFIG_HDSP253_LED=y
146# CONFIG_SH_DMA is not set
147CONFIG_PREEMPT=y
148CONFIG_SELECT_MEMORY_MODEL=y
149CONFIG_FLATMEM_MANUAL=y
150# CONFIG_DISCONTIGMEM_MANUAL is not set
151# CONFIG_SPARSEMEM_MANUAL is not set
152CONFIG_FLATMEM=y
153CONFIG_FLAT_NODE_MEM_MAP=y
154# CONFIG_SPARSEMEM_STATIC is not set
155# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
156CONFIG_SPLIT_PTLOCK_CPUS=4
157# CONFIG_RESOURCES_64BIT is not set
158CONFIG_ZONE_DMA_FLAG=0
159CONFIG_NR_QUICK=1
160
161#
162# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
163#
164CONFIG_PCI=y
165CONFIG_SH_PCIDMA_NONCOHERENT=y
166# CONFIG_ARCH_SUPPORTS_MSI is not set
167# CONFIG_PCI_DEBUG is not set
168# CONFIG_PCCARD is not set
169# CONFIG_HOTPLUG_PCI is not set
170
171#
172# Executable file formats
173#
174CONFIG_BINFMT_ELF=y
175# CONFIG_BINFMT_MISC is not set
176
177#
178# Networking
179#
180CONFIG_NET=y
181
182#
183# Networking options
184#
185CONFIG_PACKET=y
186# CONFIG_PACKET_MMAP is not set
187CONFIG_UNIX=y
188CONFIG_XFRM=y
189# CONFIG_XFRM_USER is not set
190# CONFIG_XFRM_SUB_POLICY is not set
191# CONFIG_XFRM_MIGRATE is not set
192# CONFIG_NET_KEY is not set
193CONFIG_INET=y
194# CONFIG_IP_MULTICAST is not set
195# CONFIG_IP_ADVANCED_ROUTER is not set
196CONFIG_IP_FIB_HASH=y
197CONFIG_IP_PNP=y
198# CONFIG_IP_PNP_DHCP is not set
199# CONFIG_IP_PNP_BOOTP is not set
200# CONFIG_IP_PNP_RARP is not set
201# CONFIG_NET_IPIP is not set
202# CONFIG_NET_IPGRE is not set
203# CONFIG_ARPD is not set
204# CONFIG_SYN_COOKIES is not set
205# CONFIG_INET_AH is not set
206# CONFIG_INET_ESP is not set
207# CONFIG_INET_IPCOMP is not set
208# CONFIG_INET_XFRM_TUNNEL is not set
209# CONFIG_INET_TUNNEL is not set
210CONFIG_INET_XFRM_MODE_TRANSPORT=y
211CONFIG_INET_XFRM_MODE_TUNNEL=y
212CONFIG_INET_XFRM_MODE_BEET=y
213# CONFIG_INET_LRO is not set
214CONFIG_INET_DIAG=y
215CONFIG_INET_TCP_DIAG=y
216# CONFIG_TCP_CONG_ADVANCED is not set
217CONFIG_TCP_CONG_CUBIC=y
218CONFIG_DEFAULT_TCP_CONG="cubic"
219# CONFIG_TCP_MD5SIG is not set
220# CONFIG_IPV6 is not set
221# CONFIG_INET6_XFRM_TUNNEL is not set
222# CONFIG_INET6_TUNNEL is not set
223# CONFIG_NETWORK_SECMARK is not set
224# CONFIG_NETFILTER is not set
225# CONFIG_IP_DCCP is not set
226# CONFIG_IP_SCTP is not set
227# CONFIG_TIPC is not set
228# CONFIG_ATM is not set
229# CONFIG_BRIDGE is not set
230# CONFIG_VLAN_8021Q is not set
231# CONFIG_DECNET is not set
232# CONFIG_LLC2 is not set
233# CONFIG_IPX is not set
234# CONFIG_ATALK is not set
235# CONFIG_X25 is not set
236# CONFIG_LAPB is not set
237# CONFIG_ECONET is not set
238# CONFIG_WAN_ROUTER is not set
239# CONFIG_NET_SCHED is not set
240
241#
242# Network testing
243#
244# CONFIG_NET_PKTGEN is not set
245# CONFIG_HAMRADIO is not set
246# CONFIG_IRDA is not set
247# CONFIG_BT is not set
248# CONFIG_AF_RXRPC is not set
249
250#
251# Wireless
252#
253# CONFIG_CFG80211 is not set
254# CONFIG_WIRELESS_EXT is not set
255# CONFIG_MAC80211 is not set
256# CONFIG_IEEE80211 is not set
257# CONFIG_RFKILL is not set
258# CONFIG_NET_9P is not set
259
260#
261# Device Drivers
262#
263
264#
265# Generic Driver Options
266#
267CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
268CONFIG_STANDALONE=y
269CONFIG_PREVENT_FIRMWARE_BUILD=y
270# CONFIG_FW_LOADER is not set
271# CONFIG_DEBUG_DRIVER is not set
272# CONFIG_DEBUG_DEVRES is not set
273# CONFIG_SYS_HYPERVISOR is not set
274# CONFIG_CONNECTOR is not set
275# CONFIG_MTD is not set
276# CONFIG_PARPORT is not set
277CONFIG_BLK_DEV=y
278# CONFIG_BLK_CPQ_CISS_DA is not set
279# CONFIG_BLK_DEV_DAC960 is not set
280# CONFIG_BLK_DEV_UMEM is not set
281# CONFIG_BLK_DEV_COW_COMMON is not set
282CONFIG_BLK_DEV_LOOP=y
283# CONFIG_BLK_DEV_CRYPTOLOOP is not set
284# CONFIG_BLK_DEV_NBD is not set
285# CONFIG_BLK_DEV_SX8 is not set
286CONFIG_BLK_DEV_RAM=y
287CONFIG_BLK_DEV_RAM_COUNT=16
288CONFIG_BLK_DEV_RAM_SIZE=4096
289CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
290# CONFIG_CDROM_PKTCDVD is not set
291# CONFIG_ATA_OVER_ETH is not set
292CONFIG_MISC_DEVICES=y
293# CONFIG_PHANTOM is not set
294# CONFIG_EEPROM_93CX6 is not set
295# CONFIG_SGI_IOC4 is not set
296# CONFIG_TIFM_CORE is not set
297# CONFIG_IDE is not set
298
299#
300# SCSI device support
301#
302# CONFIG_RAID_ATTRS is not set
303CONFIG_SCSI=y
304CONFIG_SCSI_DMA=y
305# CONFIG_SCSI_TGT is not set
306# CONFIG_SCSI_NETLINK is not set
307CONFIG_SCSI_PROC_FS=y
308
309#
310# SCSI support type (disk, tape, CD-ROM)
311#
312CONFIG_BLK_DEV_SD=y
313# CONFIG_CHR_DEV_ST is not set
314# CONFIG_CHR_DEV_OSST is not set
315# CONFIG_BLK_DEV_SR is not set
316# CONFIG_CHR_DEV_SG is not set
317# CONFIG_CHR_DEV_SCH is not set
318
319#
320# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
321#
322CONFIG_SCSI_MULTI_LUN=y
323# CONFIG_SCSI_CONSTANTS is not set
324# CONFIG_SCSI_LOGGING is not set
325# CONFIG_SCSI_SCAN_ASYNC is not set
326CONFIG_SCSI_WAIT_SCAN=m
327
328#
329# SCSI Transports
330#
331CONFIG_SCSI_SPI_ATTRS=y
332# CONFIG_SCSI_FC_ATTRS is not set
333# CONFIG_SCSI_ISCSI_ATTRS is not set
334# CONFIG_SCSI_SAS_LIBSAS is not set
335# CONFIG_SCSI_SRP_ATTRS is not set
336CONFIG_SCSI_LOWLEVEL=y
337# CONFIG_ISCSI_TCP is not set
338# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
339# CONFIG_SCSI_3W_9XXX is not set
340# CONFIG_SCSI_ACARD is not set
341# CONFIG_SCSI_AACRAID is not set
342# CONFIG_SCSI_AIC7XXX is not set
343# CONFIG_SCSI_AIC7XXX_OLD is not set
344# CONFIG_SCSI_AIC79XX is not set
345# CONFIG_SCSI_AIC94XX is not set
346# CONFIG_SCSI_ARCMSR is not set
347# CONFIG_MEGARAID_NEWGEN is not set
348# CONFIG_MEGARAID_LEGACY is not set
349# CONFIG_MEGARAID_SAS is not set
350# CONFIG_SCSI_HPTIOP is not set
351# CONFIG_SCSI_DMX3191D is not set
352# CONFIG_SCSI_FUTURE_DOMAIN is not set
353# CONFIG_SCSI_IPS is not set
354# CONFIG_SCSI_INITIO is not set
355# CONFIG_SCSI_INIA100 is not set
356# CONFIG_SCSI_STEX is not set
357CONFIG_SCSI_SYM53C8XX_2=y
358CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
359CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
360CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
361CONFIG_SCSI_SYM53C8XX_MMIO=y
362# CONFIG_SCSI_QLOGIC_1280 is not set
363# CONFIG_SCSI_QLA_FC is not set
364# CONFIG_SCSI_QLA_ISCSI is not set
365# CONFIG_SCSI_LPFC is not set
366# CONFIG_SCSI_DC395x is not set
367# CONFIG_SCSI_DC390T is not set
368# CONFIG_SCSI_NSP32 is not set
369# CONFIG_SCSI_DEBUG is not set
370# CONFIG_SCSI_SRP is not set
371# CONFIG_ATA is not set
372# CONFIG_MD is not set
373# CONFIG_FUSION is not set
374
375#
376# IEEE 1394 (FireWire) support
377#
378# CONFIG_FIREWIRE is not set
379# CONFIG_IEEE1394 is not set
380# CONFIG_I2O is not set
381CONFIG_NETDEVICES=y
382# CONFIG_NETDEVICES_MULTIQUEUE is not set
383# CONFIG_DUMMY is not set
384# CONFIG_BONDING is not set
385# CONFIG_MACVLAN is not set
386# CONFIG_EQUALIZER is not set
387# CONFIG_TUN is not set
388# CONFIG_VETH is not set
389# CONFIG_IP1000 is not set
390# CONFIG_ARCNET is not set
391# CONFIG_PHYLIB is not set
392CONFIG_NET_ETHERNET=y
393# CONFIG_MII is not set
394# CONFIG_STNIC is not set
395# CONFIG_HAPPYMEAL is not set
396# CONFIG_SUNGEM is not set
397# CONFIG_CASSINI is not set
398# CONFIG_NET_VENDOR_3COM is not set
399# CONFIG_SMC91X is not set
400# CONFIG_SMC911X is not set
401CONFIG_NET_TULIP=y
402# CONFIG_DE2104X is not set
403CONFIG_TULIP=y
404# CONFIG_TULIP_MWI is not set
405# CONFIG_TULIP_MMIO is not set
406# CONFIG_TULIP_NAPI is not set
407# CONFIG_DE4X5 is not set
408# CONFIG_WINBOND_840 is not set
409# CONFIG_DM9102 is not set
410# CONFIG_ULI526X is not set
411# CONFIG_HP100 is not set
412# CONFIG_IBM_NEW_EMAC_ZMII is not set
413# CONFIG_IBM_NEW_EMAC_RGMII is not set
414# CONFIG_IBM_NEW_EMAC_TAH is not set
415# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
416CONFIG_NET_PCI=y
417# CONFIG_PCNET32 is not set
418# CONFIG_AMD8111_ETH is not set
419# CONFIG_ADAPTEC_STARFIRE is not set
420# CONFIG_B44 is not set
421# CONFIG_FORCEDETH is not set
422# CONFIG_EEPRO100 is not set
423# CONFIG_E100 is not set
424# CONFIG_FEALNX is not set
425# CONFIG_NATSEMI is not set
426# CONFIG_NE2K_PCI is not set
427# CONFIG_8139CP is not set
428# CONFIG_8139TOO is not set
429# CONFIG_SIS900 is not set
430# CONFIG_EPIC100 is not set
431# CONFIG_SUNDANCE is not set
432# CONFIG_TLAN is not set
433# CONFIG_VIA_RHINE is not set
434# CONFIG_SC92031 is not set
435CONFIG_NETDEV_1000=y
436# CONFIG_ACENIC is not set
437# CONFIG_DL2K is not set
438# CONFIG_E1000 is not set
439# CONFIG_E1000E is not set
440# CONFIG_NS83820 is not set
441# CONFIG_HAMACHI is not set
442# CONFIG_YELLOWFIN is not set
443# CONFIG_R8169 is not set
444# CONFIG_SIS190 is not set
445# CONFIG_SKGE is not set
446# CONFIG_SKY2 is not set
447# CONFIG_SK98LIN is not set
448# CONFIG_VIA_VELOCITY is not set
449# CONFIG_TIGON3 is not set
450# CONFIG_BNX2 is not set
451# CONFIG_QLA3XXX is not set
452# CONFIG_ATL1 is not set
453CONFIG_NETDEV_10000=y
454# CONFIG_CHELSIO_T1 is not set
455# CONFIG_CHELSIO_T3 is not set
456# CONFIG_IXGBE is not set
457# CONFIG_IXGB is not set
458# CONFIG_S2IO is not set
459# CONFIG_MYRI10GE is not set
460# CONFIG_NETXEN_NIC is not set
461# CONFIG_NIU is not set
462# CONFIG_MLX4_CORE is not set
463# CONFIG_TEHUTI is not set
464# CONFIG_TR is not set
465
466#
467# Wireless LAN
468#
469# CONFIG_WLAN_PRE80211 is not set
470# CONFIG_WLAN_80211 is not set
471# CONFIG_WAN is not set
472# CONFIG_FDDI is not set
473# CONFIG_HIPPI is not set
474# CONFIG_PPP is not set
475# CONFIG_SLIP is not set
476# CONFIG_NET_FC is not set
477# CONFIG_SHAPER is not set
478# CONFIG_NETCONSOLE is not set
479# CONFIG_NETPOLL is not set
480# CONFIG_NET_POLL_CONTROLLER is not set
481# CONFIG_ISDN is not set
482# CONFIG_PHONE is not set
483
484#
485# Input device support
486#
487CONFIG_INPUT=y
488# CONFIG_INPUT_FF_MEMLESS is not set
489# CONFIG_INPUT_POLLDEV is not set
490
491#
492# Userland interfaces
493#
494CONFIG_INPUT_MOUSEDEV=y
495CONFIG_INPUT_MOUSEDEV_PSAUX=y
496CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
497CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
498# CONFIG_INPUT_JOYDEV is not set
499# CONFIG_INPUT_EVDEV is not set
500# CONFIG_INPUT_EVBUG is not set
501
502#
503# Input Device Drivers
504#
505CONFIG_INPUT_KEYBOARD=y
506CONFIG_KEYBOARD_ATKBD=y
507# CONFIG_KEYBOARD_SUNKBD is not set
508# CONFIG_KEYBOARD_LKKBD is not set
509# CONFIG_KEYBOARD_XTKBD is not set
510# CONFIG_KEYBOARD_NEWTON is not set
511# CONFIG_KEYBOARD_STOWAWAY is not set
512CONFIG_INPUT_MOUSE=y
513CONFIG_MOUSE_PS2=y
514CONFIG_MOUSE_PS2_ALPS=y
515CONFIG_MOUSE_PS2_LOGIPS2PP=y
516CONFIG_MOUSE_PS2_SYNAPTICS=y
517CONFIG_MOUSE_PS2_LIFEBOOK=y
518CONFIG_MOUSE_PS2_TRACKPOINT=y
519# CONFIG_MOUSE_PS2_TOUCHKIT is not set
520# CONFIG_MOUSE_SERIAL is not set
521# CONFIG_MOUSE_APPLETOUCH is not set
522# CONFIG_MOUSE_VSXXXAA is not set
523# CONFIG_INPUT_JOYSTICK is not set
524# CONFIG_INPUT_TABLET is not set
525# CONFIG_INPUT_TOUCHSCREEN is not set
526# CONFIG_INPUT_MISC is not set
527
528#
529# Hardware I/O ports
530#
531CONFIG_SERIO=y
532CONFIG_SERIO_I8042=y
533CONFIG_SERIO_SERPORT=y
534# CONFIG_SERIO_PCIPS2 is not set
535CONFIG_SERIO_LIBPS2=y
536# CONFIG_SERIO_RAW is not set
537# CONFIG_GAMEPORT is not set
538
539#
540# Character devices
541#
542CONFIG_VT=y
543CONFIG_VT_CONSOLE=y
544CONFIG_HW_CONSOLE=y
545# CONFIG_VT_HW_CONSOLE_BINDING is not set
546# CONFIG_SERIAL_NONSTANDARD is not set
547
548#
549# Serial drivers
550#
551# CONFIG_SERIAL_8250 is not set
552
553#
554# Non-8250 serial port support
555#
556CONFIG_SERIAL_SH_SCI=y
557CONFIG_SERIAL_SH_SCI_NR_UARTS=2
558CONFIG_SERIAL_SH_SCI_CONSOLE=y
559CONFIG_SERIAL_CORE=y
560CONFIG_SERIAL_CORE_CONSOLE=y
561# CONFIG_SERIAL_JSM is not set
562CONFIG_UNIX98_PTYS=y
563CONFIG_LEGACY_PTYS=y
564CONFIG_LEGACY_PTY_COUNT=256
565# CONFIG_IPMI_HANDLER is not set
566CONFIG_HW_RANDOM=y
567# CONFIG_R3964 is not set
568# CONFIG_APPLICOM is not set
569# CONFIG_RAW_DRIVER is not set
570# CONFIG_TCG_TPM is not set
571CONFIG_DEVPORT=y
572CONFIG_I2C=m
573CONFIG_I2C_BOARDINFO=y
574# CONFIG_I2C_CHARDEV is not set
575
576#
577# I2C Algorithms
578#
579# CONFIG_I2C_ALGOBIT is not set
580# CONFIG_I2C_ALGOPCF is not set
581# CONFIG_I2C_ALGOPCA is not set
582
583#
584# I2C Hardware Bus support
585#
586# CONFIG_I2C_ALI1535 is not set
587# CONFIG_I2C_ALI1563 is not set
588# CONFIG_I2C_ALI15X3 is not set
589# CONFIG_I2C_AMD756 is not set
590# CONFIG_I2C_AMD8111 is not set
591# CONFIG_I2C_I801 is not set
592# CONFIG_I2C_I810 is not set
593# CONFIG_I2C_PIIX4 is not set
594# CONFIG_I2C_NFORCE2 is not set
595# CONFIG_I2C_OCORES is not set
596# CONFIG_I2C_PARPORT_LIGHT is not set
597# CONFIG_I2C_PROSAVAGE is not set
598# CONFIG_I2C_SAVAGE4 is not set
599# CONFIG_I2C_SIMTEC is not set
600# CONFIG_I2C_SIS5595 is not set
601# CONFIG_I2C_SIS630 is not set
602# CONFIG_I2C_SIS96X is not set
603# CONFIG_I2C_TAOS_EVM is not set
604# CONFIG_I2C_STUB is not set
605# CONFIG_I2C_VIA is not set
606# CONFIG_I2C_VIAPRO is not set
607# CONFIG_I2C_VOODOO3 is not set
608
609#
610# Miscellaneous I2C Chip support
611#
612# CONFIG_SENSORS_DS1337 is not set
613# CONFIG_SENSORS_DS1374 is not set
614# CONFIG_DS1682 is not set
615# CONFIG_SENSORS_EEPROM is not set
616# CONFIG_SENSORS_PCF8574 is not set
617# CONFIG_SENSORS_PCA9539 is not set
618# CONFIG_SENSORS_PCF8591 is not set
619# CONFIG_SENSORS_MAX6875 is not set
620# CONFIG_SENSORS_TSL2550 is not set
621# CONFIG_I2C_DEBUG_CORE is not set
622# CONFIG_I2C_DEBUG_ALGO is not set
623# CONFIG_I2C_DEBUG_BUS is not set
624# CONFIG_I2C_DEBUG_CHIP is not set
625
626#
627# SPI support
628#
629# CONFIG_SPI is not set
630# CONFIG_SPI_MASTER is not set
631# CONFIG_W1 is not set
632# CONFIG_POWER_SUPPLY is not set
633CONFIG_HWMON=y
634# CONFIG_HWMON_VID is not set
635# CONFIG_SENSORS_AD7418 is not set
636# CONFIG_SENSORS_ADM1021 is not set
637# CONFIG_SENSORS_ADM1025 is not set
638# CONFIG_SENSORS_ADM1026 is not set
639# CONFIG_SENSORS_ADM1029 is not set
640# CONFIG_SENSORS_ADM1031 is not set
641# CONFIG_SENSORS_ADM9240 is not set
642# CONFIG_SENSORS_ADT7470 is not set
643# CONFIG_SENSORS_ATXP1 is not set
644# CONFIG_SENSORS_DS1621 is not set
645# CONFIG_SENSORS_F71805F is not set
646# CONFIG_SENSORS_F71882FG is not set
647# CONFIG_SENSORS_F75375S is not set
648# CONFIG_SENSORS_GL518SM is not set
649# CONFIG_SENSORS_GL520SM is not set
650# CONFIG_SENSORS_IT87 is not set
651# CONFIG_SENSORS_LM63 is not set
652# CONFIG_SENSORS_LM75 is not set
653# CONFIG_SENSORS_LM77 is not set
654# CONFIG_SENSORS_LM78 is not set
655# CONFIG_SENSORS_LM80 is not set
656# CONFIG_SENSORS_LM83 is not set
657# CONFIG_SENSORS_LM85 is not set
658# CONFIG_SENSORS_LM87 is not set
659# CONFIG_SENSORS_LM90 is not set
660# CONFIG_SENSORS_LM92 is not set
661# CONFIG_SENSORS_LM93 is not set
662# CONFIG_SENSORS_MAX1619 is not set
663# CONFIG_SENSORS_MAX6650 is not set
664# CONFIG_SENSORS_PC87360 is not set
665# CONFIG_SENSORS_PC87427 is not set
666# CONFIG_SENSORS_SIS5595 is not set
667# CONFIG_SENSORS_DME1737 is not set
668# CONFIG_SENSORS_SMSC47M1 is not set
669# CONFIG_SENSORS_SMSC47M192 is not set
670# CONFIG_SENSORS_SMSC47B397 is not set
671# CONFIG_SENSORS_THMC50 is not set
672# CONFIG_SENSORS_VIA686A is not set
673# CONFIG_SENSORS_VT1211 is not set
674# CONFIG_SENSORS_VT8231 is not set
675# CONFIG_SENSORS_W83781D is not set
676# CONFIG_SENSORS_W83791D is not set
677# CONFIG_SENSORS_W83792D is not set
678# CONFIG_SENSORS_W83793 is not set
679# CONFIG_SENSORS_W83L785TS is not set
680# CONFIG_SENSORS_W83627HF is not set
681# CONFIG_SENSORS_W83627EHF is not set
682# CONFIG_HWMON_DEBUG_CHIP is not set
683CONFIG_WATCHDOG=y
684# CONFIG_WATCHDOG_NOWAYOUT is not set
685
686#
687# Watchdog Device Drivers
688#
689# CONFIG_SOFT_WATCHDOG is not set
690
691#
692# PCI-based Watchdog Cards
693#
694# CONFIG_PCIPCWATCHDOG is not set
695# CONFIG_WDTPCI is not set
696
697#
698# Sonics Silicon Backplane
699#
700CONFIG_SSB_POSSIBLE=y
701# CONFIG_SSB is not set
702
703#
704# Multifunction device drivers
705#
706# CONFIG_MFD_SM501 is not set
707
708#
709# Multimedia devices
710#
711CONFIG_VIDEO_DEV=m
712# CONFIG_VIDEO_V4L1 is not set
713# CONFIG_VIDEO_V4L1_COMPAT is not set
714CONFIG_VIDEO_V4L2=y
715CONFIG_VIDEO_CAPTURE_DRIVERS=y
716# CONFIG_VIDEO_ADV_DEBUG is not set
717CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
718# CONFIG_VIDEO_VIVI is not set
719# CONFIG_VIDEO_SAA5246A is not set
720# CONFIG_VIDEO_SAA5249 is not set
721# CONFIG_VIDEO_SAA7134 is not set
722# CONFIG_VIDEO_HEXIUM_ORION is not set
723# CONFIG_VIDEO_HEXIUM_GEMINI is not set
724# CONFIG_VIDEO_CX88 is not set
725# CONFIG_VIDEO_CX23885 is not set
726# CONFIG_VIDEO_CAFE_CCIC is not set
727# CONFIG_RADIO_ADAPTERS is not set
728CONFIG_DVB_CORE=y
729# CONFIG_DVB_CORE_ATTACH is not set
730CONFIG_DVB_CAPTURE_DRIVERS=y
731
732#
733# Supported SAA7146 based PCI Adapters
734#
735
736#
737# Supported FlexCopII (B2C2) Adapters
738#
739# CONFIG_DVB_B2C2_FLEXCOP is not set
740
741#
742# Supported BT878 Adapters
743#
744
745#
746# Supported Pluto2 Adapters
747#
748# CONFIG_DVB_PLUTO2 is not set
749
750#
751# Supported DVB Frontends
752#
753
754#
755# Customise DVB Frontends
756#
757# CONFIG_DVB_FE_CUSTOMISE is not set
758
759#
760# DVB-S (satellite) frontends
761#
762# CONFIG_DVB_STV0299 is not set
763# CONFIG_DVB_CX24110 is not set
764# CONFIG_DVB_CX24123 is not set
765# CONFIG_DVB_TDA8083 is not set
766# CONFIG_DVB_MT312 is not set
767# CONFIG_DVB_VES1X93 is not set
768# CONFIG_DVB_S5H1420 is not set
769# CONFIG_DVB_TDA10086 is not set
770
771#
772# DVB-T (terrestrial) frontends
773#
774# CONFIG_DVB_SP8870 is not set
775# CONFIG_DVB_SP887X is not set
776# CONFIG_DVB_CX22700 is not set
777# CONFIG_DVB_CX22702 is not set
778# CONFIG_DVB_L64781 is not set
779# CONFIG_DVB_TDA1004X is not set
780# CONFIG_DVB_NXT6000 is not set
781# CONFIG_DVB_MT352 is not set
782# CONFIG_DVB_ZL10353 is not set
783# CONFIG_DVB_DIB3000MB is not set
784# CONFIG_DVB_DIB3000MC is not set
785# CONFIG_DVB_DIB7000M is not set
786# CONFIG_DVB_DIB7000P is not set
787
788#
789# DVB-C (cable) frontends
790#
791# CONFIG_DVB_VES1820 is not set
792# CONFIG_DVB_TDA10021 is not set
793# CONFIG_DVB_TDA10023 is not set
794# CONFIG_DVB_STV0297 is not set
795
796#
797# ATSC (North American/Korean Terrestrial/Cable DTV) frontends
798#
799# CONFIG_DVB_NXT200X is not set
800# CONFIG_DVB_OR51211 is not set
801# CONFIG_DVB_OR51132 is not set
802# CONFIG_DVB_BCM3510 is not set
803# CONFIG_DVB_LGDT330X is not set
804# CONFIG_DVB_S5H1409 is not set
805
806#
807# Tuners/PLL support
808#
809# CONFIG_DVB_PLL is not set
810# CONFIG_DVB_TDA826X is not set
811# CONFIG_DVB_TDA827X is not set
812# CONFIG_DVB_TUNER_QT1010 is not set
813# CONFIG_DVB_TUNER_MT2060 is not set
814# CONFIG_DVB_TUNER_MT2266 is not set
815# CONFIG_DVB_TUNER_MT2131 is not set
816# CONFIG_DVB_TUNER_DIB0070 is not set
817
818#
819# Miscellaneous devices
820#
821# CONFIG_DVB_LNBP21 is not set
822# CONFIG_DVB_ISL6421 is not set
823# CONFIG_DVB_TUA6100 is not set
824CONFIG_DAB=y
825
826#
827# Graphics support
828#
829# CONFIG_DRM is not set
830# CONFIG_VGASTATE is not set
831CONFIG_VIDEO_OUTPUT_CONTROL=y
832CONFIG_FB=y
833CONFIG_FIRMWARE_EDID=y
834# CONFIG_FB_DDC is not set
835CONFIG_FB_CFB_FILLRECT=y
836CONFIG_FB_CFB_COPYAREA=y
837CONFIG_FB_CFB_IMAGEBLIT=y
838# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
839# CONFIG_FB_SYS_FILLRECT is not set
840# CONFIG_FB_SYS_COPYAREA is not set
841# CONFIG_FB_SYS_IMAGEBLIT is not set
842# CONFIG_FB_SYS_FOPS is not set
843CONFIG_FB_DEFERRED_IO=y
844# CONFIG_FB_SVGALIB is not set
845# CONFIG_FB_MACMODES is not set
846# CONFIG_FB_BACKLIGHT is not set
847CONFIG_FB_MODE_HELPERS=y
848# CONFIG_FB_TILEBLITTING is not set
849
850#
851# Frame buffer hardware drivers
852#
853# CONFIG_FB_CIRRUS is not set
854# CONFIG_FB_PM2 is not set
855# CONFIG_FB_CYBER2000 is not set
856# CONFIG_FB_ASILIANT is not set
857# CONFIG_FB_IMSTT is not set
858# CONFIG_FB_S1D13XXX is not set
859# CONFIG_FB_NVIDIA is not set
860# CONFIG_FB_RIVA is not set
861# CONFIG_FB_MATROX is not set
862# CONFIG_FB_RADEON is not set
863# CONFIG_FB_ATY128 is not set
864# CONFIG_FB_ATY is not set
865# CONFIG_FB_S3 is not set
866# CONFIG_FB_SAVAGE is not set
867# CONFIG_FB_SIS is not set
868# CONFIG_FB_NEOMAGIC is not set
869CONFIG_FB_KYRO=y
870# CONFIG_FB_3DFX is not set
871# CONFIG_FB_VOODOO1 is not set
872# CONFIG_FB_VT8623 is not set
873# CONFIG_FB_TRIDENT is not set
874# CONFIG_FB_ARK is not set
875# CONFIG_FB_PM3 is not set
876# CONFIG_FB_VIRTUAL is not set
877# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
878
879#
880# Display device support
881#
882# CONFIG_DISPLAY_SUPPORT is not set
883
884#
885# Console display driver support
886#
887CONFIG_DUMMY_CONSOLE=y
888CONFIG_FRAMEBUFFER_CONSOLE=y
889# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
890# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
891CONFIG_FONTS=y
892# CONFIG_FONT_8x8 is not set
893CONFIG_FONT_8x16=y
894# CONFIG_FONT_6x11 is not set
895# CONFIG_FONT_7x14 is not set
896# CONFIG_FONT_PEARL_8x8 is not set
897# CONFIG_FONT_ACORN_8x8 is not set
898# CONFIG_FONT_MINI_4x6 is not set
899# CONFIG_FONT_SUN8x16 is not set
900# CONFIG_FONT_SUN12x22 is not set
901# CONFIG_FONT_10x18 is not set
902CONFIG_LOGO=y
903# CONFIG_LOGO_LINUX_MONO is not set
904# CONFIG_LOGO_LINUX_VGA16 is not set
905# CONFIG_LOGO_LINUX_CLUT224 is not set
906# CONFIG_LOGO_SUPERH_MONO is not set
907# CONFIG_LOGO_SUPERH_VGA16 is not set
908CONFIG_LOGO_SUPERH_CLUT224=y
909
910#
911# Sound
912#
913# CONFIG_SOUND is not set
914CONFIG_HID_SUPPORT=y
915CONFIG_HID=y
916# CONFIG_HID_DEBUG is not set
917# CONFIG_HIDRAW is not set
918CONFIG_USB_SUPPORT=y
919CONFIG_USB_ARCH_HAS_HCD=y
920CONFIG_USB_ARCH_HAS_OHCI=y
921CONFIG_USB_ARCH_HAS_EHCI=y
922# CONFIG_USB is not set
923
924#
925# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
926#
927
928#
929# USB Gadget Support
930#
931# CONFIG_USB_GADGET is not set
932# CONFIG_MMC is not set
933# CONFIG_NEW_LEDS is not set
934# CONFIG_INFINIBAND is not set
935# CONFIG_RTC_CLASS is not set
936
937#
938# Userspace I/O
939#
940# CONFIG_UIO is not set
941
942#
943# File systems
944#
945CONFIG_EXT2_FS=y
946# CONFIG_EXT2_FS_XATTR is not set
947# CONFIG_EXT2_FS_XIP is not set
948CONFIG_EXT3_FS=y
949CONFIG_EXT3_FS_XATTR=y
950# CONFIG_EXT3_FS_POSIX_ACL is not set
951# CONFIG_EXT3_FS_SECURITY is not set
952# CONFIG_EXT4DEV_FS is not set
953CONFIG_JBD=y
954# CONFIG_JBD_DEBUG is not set
955CONFIG_FS_MBCACHE=y
956# CONFIG_REISERFS_FS is not set
957# CONFIG_JFS_FS is not set
958# CONFIG_FS_POSIX_ACL is not set
959# CONFIG_XFS_FS is not set
960# CONFIG_GFS2_FS is not set
961# CONFIG_OCFS2_FS is not set
962CONFIG_MINIX_FS=y
963CONFIG_ROMFS_FS=y
964CONFIG_INOTIFY=y
965CONFIG_INOTIFY_USER=y
966# CONFIG_QUOTA is not set
967CONFIG_DNOTIFY=y
968# CONFIG_AUTOFS_FS is not set
969# CONFIG_AUTOFS4_FS is not set
970# CONFIG_FUSE_FS is not set
971
972#
973# CD-ROM/DVD Filesystems
974#
975# CONFIG_ISO9660_FS is not set
976# CONFIG_UDF_FS is not set
977
978#
979# DOS/FAT/NT Filesystems
980#
981# CONFIG_MSDOS_FS is not set
982# CONFIG_VFAT_FS is not set
983# CONFIG_NTFS_FS is not set
984
985#
986# Pseudo filesystems
987#
988CONFIG_PROC_FS=y
989CONFIG_PROC_KCORE=y
990CONFIG_PROC_SYSCTL=y
991CONFIG_SYSFS=y
992CONFIG_TMPFS=y
993# CONFIG_TMPFS_POSIX_ACL is not set
994CONFIG_HUGETLBFS=y
995CONFIG_HUGETLB_PAGE=y
996# CONFIG_CONFIGFS_FS is not set
997
998#
999# Miscellaneous filesystems
1000#
1001# CONFIG_ADFS_FS is not set
1002# CONFIG_AFFS_FS is not set
1003# CONFIG_HFS_FS is not set
1004# CONFIG_HFSPLUS_FS is not set
1005# CONFIG_BEFS_FS is not set
1006# CONFIG_BFS_FS is not set
1007# CONFIG_EFS_FS is not set
1008# CONFIG_CRAMFS is not set
1009# CONFIG_VXFS_FS is not set
1010# CONFIG_HPFS_FS is not set
1011# CONFIG_QNX4FS_FS is not set
1012# CONFIG_SYSV_FS is not set
1013# CONFIG_UFS_FS is not set
1014CONFIG_NETWORK_FILESYSTEMS=y
1015CONFIG_NFS_FS=y
1016CONFIG_NFS_V3=y
1017# CONFIG_NFS_V3_ACL is not set
1018# CONFIG_NFS_V4 is not set
1019# CONFIG_NFS_DIRECTIO is not set
1020# CONFIG_NFSD is not set
1021CONFIG_ROOT_NFS=y
1022CONFIG_LOCKD=y
1023CONFIG_LOCKD_V4=y
1024CONFIG_NFS_COMMON=y
1025CONFIG_SUNRPC=y
1026# CONFIG_SUNRPC_BIND34 is not set
1027# CONFIG_RPCSEC_GSS_KRB5 is not set
1028# CONFIG_RPCSEC_GSS_SPKM3 is not set
1029# CONFIG_SMB_FS is not set
1030# CONFIG_CIFS is not set
1031# CONFIG_NCP_FS is not set
1032# CONFIG_CODA_FS is not set
1033# CONFIG_AFS_FS is not set
1034
1035#
1036# Partition Types
1037#
1038CONFIG_PARTITION_ADVANCED=y
1039# CONFIG_ACORN_PARTITION is not set
1040# CONFIG_OSF_PARTITION is not set
1041# CONFIG_AMIGA_PARTITION is not set
1042# CONFIG_ATARI_PARTITION is not set
1043# CONFIG_MAC_PARTITION is not set
1044CONFIG_MSDOS_PARTITION=y
1045# CONFIG_BSD_DISKLABEL is not set
1046# CONFIG_MINIX_SUBPARTITION is not set
1047# CONFIG_SOLARIS_X86_PARTITION is not set
1048# CONFIG_UNIXWARE_DISKLABEL is not set
1049# CONFIG_LDM_PARTITION is not set
1050# CONFIG_SGI_PARTITION is not set
1051# CONFIG_ULTRIX_PARTITION is not set
1052# CONFIG_SUN_PARTITION is not set
1053# CONFIG_KARMA_PARTITION is not set
1054# CONFIG_EFI_PARTITION is not set
1055# CONFIG_SYSV68_PARTITION is not set
1056# CONFIG_NLS is not set
1057# CONFIG_DLM is not set
1058CONFIG_INSTRUMENTATION=y
1059# CONFIG_PROFILING is not set
1060# CONFIG_MARKERS is not set
1061
1062#
1063# Kernel hacking
1064#
1065# CONFIG_PRINTK_TIME is not set
1066CONFIG_ENABLE_WARN_DEPRECATED=y
1067CONFIG_ENABLE_MUST_CHECK=y
1068CONFIG_MAGIC_SYSRQ=y
1069# CONFIG_UNUSED_SYMBOLS is not set
1070CONFIG_DEBUG_FS=y
1071# CONFIG_HEADERS_CHECK is not set
1072CONFIG_DEBUG_KERNEL=y
1073# CONFIG_DEBUG_SHIRQ is not set
1074CONFIG_DETECT_SOFTLOCKUP=y
1075CONFIG_SCHED_DEBUG=y
1076CONFIG_SCHEDSTATS=y
1077# CONFIG_TIMER_STATS is not set
1078# CONFIG_DEBUG_SLAB is not set
1079# CONFIG_DEBUG_RT_MUTEXES is not set
1080# CONFIG_RT_MUTEX_TESTER is not set
1081# CONFIG_DEBUG_SPINLOCK is not set
1082# CONFIG_DEBUG_MUTEXES is not set
1083# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1084# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1085# CONFIG_DEBUG_KOBJECT is not set
1086CONFIG_DEBUG_BUGVERBOSE=y
1087# CONFIG_DEBUG_INFO is not set
1088# CONFIG_DEBUG_VM is not set
1089# CONFIG_DEBUG_LIST is not set
1090# CONFIG_DEBUG_SG is not set
1091CONFIG_FRAME_POINTER=y
1092CONFIG_FORCED_INLINING=y
1093# CONFIG_BOOT_PRINTK_DELAY is not set
1094# CONFIG_RCU_TORTURE_TEST is not set
1095# CONFIG_FAULT_INJECTION is not set
1096# CONFIG_SAMPLES is not set
1097# CONFIG_EARLY_PRINTK is not set
1098CONFIG_SH64_PROC_TLB=y
1099CONFIG_SH64_PROC_ASIDS=y
1100CONFIG_SH64_SR_WATCH=y
1101# CONFIG_POOR_MANS_STRACE is not set
1102# CONFIG_SH_ALPHANUMERIC is not set
1103# CONFIG_SH_NO_BSS_INIT is not set
1104
1105#
1106# Security options
1107#
1108# CONFIG_KEYS is not set
1109# CONFIG_SECURITY is not set
1110# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1111# CONFIG_CRYPTO is not set
1112
1113#
1114# Library routines
1115#
1116CONFIG_BITREVERSE=y
1117# CONFIG_CRC_CCITT is not set
1118# CONFIG_CRC16 is not set
1119# CONFIG_CRC_ITU_T is not set
1120CONFIG_CRC32=y
1121# CONFIG_CRC7 is not set
1122# CONFIG_LIBCRC32C is not set
1123CONFIG_PLIST=y
1124CONFIG_HAS_IOMEM=y
1125CONFIG_HAS_IOPORT=y
1126CONFIG_HAS_DMA=y
diff --git a/arch/sh64/configs/harp_defconfig b/arch/sh64/configs/harp_defconfig
deleted file mode 100644
index ba302cd0c285..000000000000
--- a/arch/sh64/configs/harp_defconfig
+++ /dev/null
@@ -1,745 +0,0 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.24-rc1
4# Fri Nov 2 14:35:57 2007
5#
6CONFIG_SUPERH=y
7CONFIG_SUPERH64=y
8CONFIG_MMU=y
9CONFIG_QUICKLIST=y
10CONFIG_RWSEM_GENERIC_SPINLOCK=y
11CONFIG_GENERIC_FIND_NEXT_BIT=y
12CONFIG_GENERIC_HWEIGHT=y
13CONFIG_GENERIC_CALIBRATE_DELAY=y
14CONFIG_GENERIC_HARDIRQS=y
15CONFIG_GENERIC_IRQ_PROBE=y
16# CONFIG_ARCH_HAS_ILOG2_U32 is not set
17# CONFIG_ARCH_HAS_ILOG2_U64 is not set
18CONFIG_ARCH_NO_VIRT_TO_BUS=y
19CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
20
21#
22# General setup
23#
24CONFIG_EXPERIMENTAL=y
25CONFIG_BROKEN_ON_SMP=y
26CONFIG_LOCK_KERNEL=y
27CONFIG_INIT_ENV_ARG_LIMIT=32
28CONFIG_LOCALVERSION=""
29CONFIG_LOCALVERSION_AUTO=y
30CONFIG_SWAP=y
31# CONFIG_SYSVIPC is not set
32CONFIG_POSIX_MQUEUE=y
33# CONFIG_BSD_PROCESS_ACCT is not set
34# CONFIG_TASKSTATS is not set
35# CONFIG_USER_NS is not set
36# CONFIG_AUDIT is not set
37# CONFIG_IKCONFIG is not set
38CONFIG_LOG_BUF_SHIFT=14
39# CONFIG_CGROUPS is not set
40CONFIG_FAIR_GROUP_SCHED=y
41CONFIG_FAIR_USER_SCHED=y
42# CONFIG_FAIR_CGROUP_SCHED is not set
43CONFIG_SYSFS_DEPRECATED=y
44# CONFIG_RELAY is not set
45# CONFIG_BLK_DEV_INITRD is not set
46# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
47CONFIG_SYSCTL=y
48# CONFIG_EMBEDDED is not set
49CONFIG_UID16=y
50CONFIG_SYSCTL_SYSCALL=y
51CONFIG_KALLSYMS=y
52# CONFIG_KALLSYMS_ALL is not set
53# CONFIG_KALLSYMS_EXTRA_PASS is not set
54CONFIG_HOTPLUG=y
55CONFIG_PRINTK=y
56CONFIG_BUG=y
57CONFIG_ELF_CORE=y
58CONFIG_BASE_FULL=y
59CONFIG_FUTEX=y
60CONFIG_ANON_INODES=y
61CONFIG_EPOLL=y
62CONFIG_SIGNALFD=y
63CONFIG_EVENTFD=y
64CONFIG_SHMEM=y
65CONFIG_VM_EVENT_COUNTERS=y
66CONFIG_SLAB=y
67# CONFIG_SLUB is not set
68# CONFIG_SLOB is not set
69CONFIG_RT_MUTEXES=y
70# CONFIG_TINY_SHMEM is not set
71CONFIG_BASE_SMALL=0
72# CONFIG_MODULES is not set
73CONFIG_BLOCK=y
74# CONFIG_LBD is not set
75# CONFIG_BLK_DEV_IO_TRACE is not set
76# CONFIG_LSF is not set
77# CONFIG_BLK_DEV_BSG is not set
78
79#
80# IO Schedulers
81#
82CONFIG_IOSCHED_NOOP=y
83CONFIG_IOSCHED_AS=y
84CONFIG_IOSCHED_DEADLINE=y
85CONFIG_IOSCHED_CFQ=y
86# CONFIG_DEFAULT_AS is not set
87# CONFIG_DEFAULT_DEADLINE is not set
88CONFIG_DEFAULT_CFQ=y
89# CONFIG_DEFAULT_NOOP is not set
90CONFIG_DEFAULT_IOSCHED="cfq"
91
92#
93# System type
94#
95# CONFIG_SH_SIMULATOR is not set
96# CONFIG_SH_CAYMAN is not set
97CONFIG_SH_HARP=y
98CONFIG_CPU_SH5=y
99CONFIG_CPU_SUBTYPE_SH5_101=y
100# CONFIG_CPU_SUBTYPE_SH5_103 is not set
101CONFIG_LITTLE_ENDIAN=y
102# CONFIG_BIG_ENDIAN is not set
103CONFIG_SH_FPU=y
104# CONFIG_SH64_FPU_DENORM_FLUSH is not set
105CONFIG_SH64_PGTABLE_2_LEVEL=y
106# CONFIG_SH64_PGTABLE_3_LEVEL is not set
107CONFIG_HUGETLB_PAGE_SIZE_64K=y
108# CONFIG_HUGETLB_PAGE_SIZE_1MB is not set
109# CONFIG_HUGETLB_PAGE_SIZE_512MB is not set
110CONFIG_SH64_USER_MISALIGNED_FIXUP=y
111
112#
113# Memory options
114#
115CONFIG_CACHED_MEMORY_OFFSET=0x20000000
116CONFIG_MEMORY_START=0x80000000
117CONFIG_MEMORY_SIZE_IN_MB=128
118
119#
120# Cache options
121#
122CONFIG_DCACHE_WRITE_BACK=y
123# CONFIG_DCACHE_WRITE_THROUGH is not set
124# CONFIG_DCACHE_DISABLED is not set
125# CONFIG_ICACHE_DISABLED is not set
126CONFIG_PCIDEVICE_MEMORY_START=C0000000
127CONFIG_DEVICE_MEMORY_START=E0000000
128CONFIG_FLASH_MEMORY_START=0x00000000
129CONFIG_PCI_BLOCK_START=0x40000000
130
131#
132# CPU Subtype specific options
133#
134CONFIG_SH64_ID2815_WORKAROUND=y
135
136#
137# Misc options
138#
139# CONFIG_SH_DMA is not set
140CONFIG_PREEMPT=y
141CONFIG_SELECT_MEMORY_MODEL=y
142CONFIG_FLATMEM_MANUAL=y
143# CONFIG_DISCONTIGMEM_MANUAL is not set
144# CONFIG_SPARSEMEM_MANUAL is not set
145CONFIG_FLATMEM=y
146CONFIG_FLAT_NODE_MEM_MAP=y
147# CONFIG_SPARSEMEM_STATIC is not set
148# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
149CONFIG_SPLIT_PTLOCK_CPUS=4
150# CONFIG_RESOURCES_64BIT is not set
151CONFIG_ZONE_DMA_FLAG=0
152CONFIG_NR_QUICK=1
153
154#
155# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
156#
157# CONFIG_ARCH_SUPPORTS_MSI is not set
158# CONFIG_PCCARD is not set
159
160#
161# Executable file formats
162#
163CONFIG_BINFMT_ELF=y
164# CONFIG_BINFMT_MISC is not set
165
166#
167# Networking
168#
169CONFIG_NET=y
170
171#
172# Networking options
173#
174CONFIG_PACKET=y
175# CONFIG_PACKET_MMAP is not set
176CONFIG_UNIX=y
177CONFIG_XFRM=y
178# CONFIG_XFRM_USER is not set
179# CONFIG_XFRM_SUB_POLICY is not set
180# CONFIG_XFRM_MIGRATE is not set
181# CONFIG_NET_KEY is not set
182CONFIG_INET=y
183# CONFIG_IP_MULTICAST is not set
184# CONFIG_IP_ADVANCED_ROUTER is not set
185CONFIG_IP_FIB_HASH=y
186CONFIG_IP_PNP=y
187# CONFIG_IP_PNP_DHCP is not set
188# CONFIG_IP_PNP_BOOTP is not set
189# CONFIG_IP_PNP_RARP is not set
190# CONFIG_NET_IPIP is not set
191# CONFIG_NET_IPGRE is not set
192# CONFIG_ARPD is not set
193# CONFIG_SYN_COOKIES is not set
194# CONFIG_INET_AH is not set
195# CONFIG_INET_ESP is not set
196# CONFIG_INET_IPCOMP is not set
197# CONFIG_INET_XFRM_TUNNEL is not set
198# CONFIG_INET_TUNNEL is not set
199CONFIG_INET_XFRM_MODE_TRANSPORT=y
200CONFIG_INET_XFRM_MODE_TUNNEL=y
201CONFIG_INET_XFRM_MODE_BEET=y
202# CONFIG_INET_LRO is not set
203CONFIG_INET_DIAG=y
204CONFIG_INET_TCP_DIAG=y
205# CONFIG_TCP_CONG_ADVANCED is not set
206CONFIG_TCP_CONG_CUBIC=y
207CONFIG_DEFAULT_TCP_CONG="cubic"
208# CONFIG_TCP_MD5SIG is not set
209# CONFIG_IPV6 is not set
210# CONFIG_INET6_XFRM_TUNNEL is not set
211# CONFIG_INET6_TUNNEL is not set
212# CONFIG_NETWORK_SECMARK is not set
213# CONFIG_NETFILTER is not set
214# CONFIG_IP_DCCP is not set
215# CONFIG_IP_SCTP is not set
216# CONFIG_TIPC is not set
217# CONFIG_ATM is not set
218# CONFIG_BRIDGE is not set
219# CONFIG_VLAN_8021Q is not set
220# CONFIG_DECNET is not set
221# CONFIG_LLC2 is not set
222# CONFIG_IPX is not set
223# CONFIG_ATALK is not set
224# CONFIG_X25 is not set
225# CONFIG_LAPB is not set
226# CONFIG_ECONET is not set
227# CONFIG_WAN_ROUTER is not set
228# CONFIG_NET_SCHED is not set
229
230#
231# Network testing
232#
233# CONFIG_NET_PKTGEN is not set
234# CONFIG_HAMRADIO is not set
235# CONFIG_IRDA is not set
236# CONFIG_BT is not set
237# CONFIG_AF_RXRPC is not set
238
239#
240# Wireless
241#
242# CONFIG_CFG80211 is not set
243# CONFIG_WIRELESS_EXT is not set
244# CONFIG_MAC80211 is not set
245# CONFIG_IEEE80211 is not set
246# CONFIG_RFKILL is not set
247# CONFIG_NET_9P is not set
248
249#
250# Device Drivers
251#
252
253#
254# Generic Driver Options
255#
256CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
257CONFIG_STANDALONE=y
258CONFIG_PREVENT_FIRMWARE_BUILD=y
259# CONFIG_FW_LOADER is not set
260# CONFIG_DEBUG_DRIVER is not set
261# CONFIG_DEBUG_DEVRES is not set
262# CONFIG_SYS_HYPERVISOR is not set
263# CONFIG_CONNECTOR is not set
264# CONFIG_MTD is not set
265# CONFIG_PARPORT is not set
266CONFIG_BLK_DEV=y
267# CONFIG_BLK_DEV_COW_COMMON is not set
268CONFIG_BLK_DEV_LOOP=y
269# CONFIG_BLK_DEV_CRYPTOLOOP is not set
270# CONFIG_BLK_DEV_NBD is not set
271CONFIG_BLK_DEV_RAM=y
272CONFIG_BLK_DEV_RAM_COUNT=16
273CONFIG_BLK_DEV_RAM_SIZE=4096
274CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
275# CONFIG_CDROM_PKTCDVD is not set
276# CONFIG_ATA_OVER_ETH is not set
277CONFIG_MISC_DEVICES=y
278# CONFIG_EEPROM_93CX6 is not set
279# CONFIG_IDE is not set
280
281#
282# SCSI device support
283#
284# CONFIG_RAID_ATTRS is not set
285CONFIG_SCSI=y
286CONFIG_SCSI_DMA=y
287# CONFIG_SCSI_TGT is not set
288# CONFIG_SCSI_NETLINK is not set
289CONFIG_SCSI_PROC_FS=y
290
291#
292# SCSI support type (disk, tape, CD-ROM)
293#
294CONFIG_BLK_DEV_SD=y
295# CONFIG_CHR_DEV_ST is not set
296# CONFIG_CHR_DEV_OSST is not set
297# CONFIG_BLK_DEV_SR is not set
298# CONFIG_CHR_DEV_SG is not set
299# CONFIG_CHR_DEV_SCH is not set
300
301#
302# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
303#
304CONFIG_SCSI_MULTI_LUN=y
305# CONFIG_SCSI_CONSTANTS is not set
306# CONFIG_SCSI_LOGGING is not set
307# CONFIG_SCSI_SCAN_ASYNC is not set
308
309#
310# SCSI Transports
311#
312CONFIG_SCSI_SPI_ATTRS=y
313# CONFIG_SCSI_FC_ATTRS is not set
314# CONFIG_SCSI_ISCSI_ATTRS is not set
315# CONFIG_SCSI_SAS_LIBSAS is not set
316# CONFIG_SCSI_SRP_ATTRS is not set
317CONFIG_SCSI_LOWLEVEL=y
318# CONFIG_ISCSI_TCP is not set
319# CONFIG_SCSI_DEBUG is not set
320# CONFIG_ATA is not set
321# CONFIG_MD is not set
322CONFIG_NETDEVICES=y
323# CONFIG_NETDEVICES_MULTIQUEUE is not set
324# CONFIG_DUMMY is not set
325# CONFIG_BONDING is not set
326# CONFIG_MACVLAN is not set
327# CONFIG_EQUALIZER is not set
328# CONFIG_TUN is not set
329# CONFIG_VETH is not set
330# CONFIG_PHYLIB is not set
331CONFIG_NET_ETHERNET=y
332# CONFIG_MII is not set
333# CONFIG_STNIC is not set
334# CONFIG_SMC91X is not set
335# CONFIG_SMC911X is not set
336# CONFIG_IBM_NEW_EMAC_ZMII is not set
337# CONFIG_IBM_NEW_EMAC_RGMII is not set
338# CONFIG_IBM_NEW_EMAC_TAH is not set
339# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
340# CONFIG_B44 is not set
341CONFIG_NETDEV_1000=y
342CONFIG_NETDEV_10000=y
343
344#
345# Wireless LAN
346#
347# CONFIG_WLAN_PRE80211 is not set
348# CONFIG_WLAN_80211 is not set
349# CONFIG_WAN is not set
350# CONFIG_PPP is not set
351# CONFIG_SLIP is not set
352# CONFIG_SHAPER is not set
353# CONFIG_NETCONSOLE is not set
354# CONFIG_NETPOLL is not set
355# CONFIG_NET_POLL_CONTROLLER is not set
356# CONFIG_ISDN is not set
357# CONFIG_PHONE is not set
358
359#
360# Input device support
361#
362CONFIG_INPUT=y
363# CONFIG_INPUT_FF_MEMLESS is not set
364# CONFIG_INPUT_POLLDEV is not set
365
366#
367# Userland interfaces
368#
369CONFIG_INPUT_MOUSEDEV=y
370# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
371CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
372CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
373# CONFIG_INPUT_JOYDEV is not set
374# CONFIG_INPUT_EVDEV is not set
375# CONFIG_INPUT_EVBUG is not set
376
377#
378# Input Device Drivers
379#
380# CONFIG_INPUT_KEYBOARD is not set
381# CONFIG_INPUT_MOUSE is not set
382# CONFIG_INPUT_JOYSTICK is not set
383# CONFIG_INPUT_TABLET is not set
384# CONFIG_INPUT_TOUCHSCREEN is not set
385# CONFIG_INPUT_MISC is not set
386
387#
388# Hardware I/O ports
389#
390# CONFIG_SERIO is not set
391# CONFIG_GAMEPORT is not set
392
393#
394# Character devices
395#
396CONFIG_VT=y
397CONFIG_VT_CONSOLE=y
398CONFIG_HW_CONSOLE=y
399# CONFIG_VT_HW_CONSOLE_BINDING is not set
400# CONFIG_SERIAL_NONSTANDARD is not set
401
402#
403# Serial drivers
404#
405# CONFIG_SERIAL_8250 is not set
406
407#
408# Non-8250 serial port support
409#
410CONFIG_SERIAL_SH_SCI=y
411CONFIG_SERIAL_SH_SCI_NR_UARTS=2
412CONFIG_SERIAL_SH_SCI_CONSOLE=y
413CONFIG_SERIAL_CORE=y
414CONFIG_SERIAL_CORE_CONSOLE=y
415CONFIG_UNIX98_PTYS=y
416CONFIG_LEGACY_PTYS=y
417CONFIG_LEGACY_PTY_COUNT=256
418# CONFIG_IPMI_HANDLER is not set
419CONFIG_HW_RANDOM=y
420# CONFIG_R3964 is not set
421# CONFIG_RAW_DRIVER is not set
422# CONFIG_TCG_TPM is not set
423# CONFIG_I2C is not set
424
425#
426# SPI support
427#
428# CONFIG_SPI is not set
429# CONFIG_SPI_MASTER is not set
430# CONFIG_W1 is not set
431# CONFIG_POWER_SUPPLY is not set
432CONFIG_HWMON=y
433# CONFIG_HWMON_VID is not set
434# CONFIG_SENSORS_F71805F is not set
435# CONFIG_SENSORS_F71882FG is not set
436# CONFIG_SENSORS_IT87 is not set
437# CONFIG_SENSORS_PC87360 is not set
438# CONFIG_SENSORS_PC87427 is not set
439# CONFIG_SENSORS_SMSC47M1 is not set
440# CONFIG_SENSORS_SMSC47B397 is not set
441# CONFIG_SENSORS_VT1211 is not set
442# CONFIG_SENSORS_W83627HF is not set
443# CONFIG_SENSORS_W83627EHF is not set
444# CONFIG_HWMON_DEBUG_CHIP is not set
445CONFIG_WATCHDOG=y
446# CONFIG_WATCHDOG_NOWAYOUT is not set
447
448#
449# Watchdog Device Drivers
450#
451# CONFIG_SOFT_WATCHDOG is not set
452
453#
454# Sonics Silicon Backplane
455#
456CONFIG_SSB_POSSIBLE=y
457# CONFIG_SSB is not set
458
459#
460# Multifunction device drivers
461#
462# CONFIG_MFD_SM501 is not set
463
464#
465# Multimedia devices
466#
467# CONFIG_VIDEO_DEV is not set
468# CONFIG_DVB_CORE is not set
469CONFIG_DAB=y
470
471#
472# Graphics support
473#
474# CONFIG_VGASTATE is not set
475CONFIG_VIDEO_OUTPUT_CONTROL=y
476CONFIG_FB=y
477CONFIG_FIRMWARE_EDID=y
478# CONFIG_FB_DDC is not set
479# CONFIG_FB_CFB_FILLRECT is not set
480# CONFIG_FB_CFB_COPYAREA is not set
481# CONFIG_FB_CFB_IMAGEBLIT is not set
482# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
483# CONFIG_FB_SYS_FILLRECT is not set
484# CONFIG_FB_SYS_COPYAREA is not set
485# CONFIG_FB_SYS_IMAGEBLIT is not set
486# CONFIG_FB_SYS_FOPS is not set
487CONFIG_FB_DEFERRED_IO=y
488# CONFIG_FB_SVGALIB is not set
489# CONFIG_FB_MACMODES is not set
490# CONFIG_FB_BACKLIGHT is not set
491CONFIG_FB_MODE_HELPERS=y
492# CONFIG_FB_TILEBLITTING is not set
493
494#
495# Frame buffer hardware drivers
496#
497# CONFIG_FB_S1D13XXX is not set
498# CONFIG_FB_VIRTUAL is not set
499# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
500
501#
502# Display device support
503#
504# CONFIG_DISPLAY_SUPPORT is not set
505
506#
507# Console display driver support
508#
509CONFIG_DUMMY_CONSOLE=y
510CONFIG_FRAMEBUFFER_CONSOLE=y
511# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
512# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
513CONFIG_FONTS=y
514# CONFIG_FONT_8x8 is not set
515CONFIG_FONT_8x16=y
516# CONFIG_FONT_6x11 is not set
517# CONFIG_FONT_7x14 is not set
518# CONFIG_FONT_PEARL_8x8 is not set
519# CONFIG_FONT_ACORN_8x8 is not set
520# CONFIG_FONT_MINI_4x6 is not set
521# CONFIG_FONT_SUN8x16 is not set
522# CONFIG_FONT_SUN12x22 is not set
523# CONFIG_FONT_10x18 is not set
524CONFIG_LOGO=y
525# CONFIG_LOGO_LINUX_MONO is not set
526# CONFIG_LOGO_LINUX_VGA16 is not set
527# CONFIG_LOGO_LINUX_CLUT224 is not set
528# CONFIG_LOGO_SUPERH_MONO is not set
529# CONFIG_LOGO_SUPERH_VGA16 is not set
530CONFIG_LOGO_SUPERH_CLUT224=y
531
532#
533# Sound
534#
535# CONFIG_SOUND is not set
536CONFIG_HID_SUPPORT=y
537CONFIG_HID=y
538# CONFIG_HID_DEBUG is not set
539# CONFIG_HIDRAW is not set
540CONFIG_USB_SUPPORT=y
541CONFIG_USB_ARCH_HAS_HCD=y
542# CONFIG_USB_ARCH_HAS_OHCI is not set
543# CONFIG_USB_ARCH_HAS_EHCI is not set
544# CONFIG_USB is not set
545
546#
547# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
548#
549
550#
551# USB Gadget Support
552#
553# CONFIG_USB_GADGET is not set
554# CONFIG_MMC is not set
555# CONFIG_NEW_LEDS is not set
556# CONFIG_RTC_CLASS is not set
557
558#
559# Userspace I/O
560#
561# CONFIG_UIO is not set
562
563#
564# File systems
565#
566CONFIG_EXT2_FS=y
567# CONFIG_EXT2_FS_XATTR is not set
568# CONFIG_EXT2_FS_XIP is not set
569CONFIG_EXT3_FS=y
570CONFIG_EXT3_FS_XATTR=y
571# CONFIG_EXT3_FS_POSIX_ACL is not set
572# CONFIG_EXT3_FS_SECURITY is not set
573# CONFIG_EXT4DEV_FS is not set
574CONFIG_JBD=y
575# CONFIG_JBD_DEBUG is not set
576CONFIG_FS_MBCACHE=y
577# CONFIG_REISERFS_FS is not set
578# CONFIG_JFS_FS is not set
579# CONFIG_FS_POSIX_ACL is not set
580# CONFIG_XFS_FS is not set
581# CONFIG_GFS2_FS is not set
582# CONFIG_OCFS2_FS is not set
583CONFIG_MINIX_FS=y
584CONFIG_ROMFS_FS=y
585CONFIG_INOTIFY=y
586CONFIG_INOTIFY_USER=y
587# CONFIG_QUOTA is not set
588CONFIG_DNOTIFY=y
589# CONFIG_AUTOFS_FS is not set
590# CONFIG_AUTOFS4_FS is not set
591# CONFIG_FUSE_FS is not set
592
593#
594# CD-ROM/DVD Filesystems
595#
596# CONFIG_ISO9660_FS is not set
597# CONFIG_UDF_FS is not set
598
599#
600# DOS/FAT/NT Filesystems
601#
602# CONFIG_MSDOS_FS is not set
603# CONFIG_VFAT_FS is not set
604# CONFIG_NTFS_FS is not set
605
606#
607# Pseudo filesystems
608#
609CONFIG_PROC_FS=y
610CONFIG_PROC_KCORE=y
611CONFIG_PROC_SYSCTL=y
612CONFIG_SYSFS=y
613CONFIG_TMPFS=y
614# CONFIG_TMPFS_POSIX_ACL is not set
615CONFIG_HUGETLBFS=y
616CONFIG_HUGETLB_PAGE=y
617# CONFIG_CONFIGFS_FS is not set
618
619#
620# Miscellaneous filesystems
621#
622# CONFIG_ADFS_FS is not set
623# CONFIG_AFFS_FS is not set
624# CONFIG_HFS_FS is not set
625# CONFIG_HFSPLUS_FS is not set
626# CONFIG_BEFS_FS is not set
627# CONFIG_BFS_FS is not set
628# CONFIG_EFS_FS is not set
629# CONFIG_CRAMFS is not set
630# CONFIG_VXFS_FS is not set
631# CONFIG_HPFS_FS is not set
632# CONFIG_QNX4FS_FS is not set
633# CONFIG_SYSV_FS is not set
634# CONFIG_UFS_FS is not set
635CONFIG_NETWORK_FILESYSTEMS=y
636CONFIG_NFS_FS=y
637CONFIG_NFS_V3=y
638# CONFIG_NFS_V3_ACL is not set
639# CONFIG_NFS_V4 is not set
640# CONFIG_NFS_DIRECTIO is not set
641# CONFIG_NFSD is not set
642CONFIG_ROOT_NFS=y
643CONFIG_LOCKD=y
644CONFIG_LOCKD_V4=y
645CONFIG_NFS_COMMON=y
646CONFIG_SUNRPC=y
647# CONFIG_SUNRPC_BIND34 is not set
648# CONFIG_RPCSEC_GSS_KRB5 is not set
649# CONFIG_RPCSEC_GSS_SPKM3 is not set
650# CONFIG_SMB_FS is not set
651# CONFIG_CIFS is not set
652# CONFIG_NCP_FS is not set
653# CONFIG_CODA_FS is not set
654# CONFIG_AFS_FS is not set
655
656#
657# Partition Types
658#
659CONFIG_PARTITION_ADVANCED=y
660# CONFIG_ACORN_PARTITION is not set
661# CONFIG_OSF_PARTITION is not set
662# CONFIG_AMIGA_PARTITION is not set
663# CONFIG_ATARI_PARTITION is not set
664# CONFIG_MAC_PARTITION is not set
665CONFIG_MSDOS_PARTITION=y
666# CONFIG_BSD_DISKLABEL is not set
667# CONFIG_MINIX_SUBPARTITION is not set
668# CONFIG_SOLARIS_X86_PARTITION is not set
669# CONFIG_UNIXWARE_DISKLABEL is not set
670# CONFIG_LDM_PARTITION is not set
671# CONFIG_SGI_PARTITION is not set
672# CONFIG_ULTRIX_PARTITION is not set
673# CONFIG_SUN_PARTITION is not set
674# CONFIG_KARMA_PARTITION is not set
675# CONFIG_EFI_PARTITION is not set
676# CONFIG_SYSV68_PARTITION is not set
677# CONFIG_NLS is not set
678# CONFIG_DLM is not set
679CONFIG_INSTRUMENTATION=y
680# CONFIG_PROFILING is not set
681# CONFIG_MARKERS is not set
682
683#
684# Kernel hacking
685#
686# CONFIG_PRINTK_TIME is not set
687CONFIG_ENABLE_WARN_DEPRECATED=y
688CONFIG_ENABLE_MUST_CHECK=y
689CONFIG_MAGIC_SYSRQ=y
690# CONFIG_UNUSED_SYMBOLS is not set
691CONFIG_DEBUG_FS=y
692# CONFIG_HEADERS_CHECK is not set
693CONFIG_DEBUG_KERNEL=y
694# CONFIG_DEBUG_SHIRQ is not set
695CONFIG_DETECT_SOFTLOCKUP=y
696CONFIG_SCHED_DEBUG=y
697CONFIG_SCHEDSTATS=y
698# CONFIG_TIMER_STATS is not set
699# CONFIG_DEBUG_SLAB is not set
700# CONFIG_DEBUG_RT_MUTEXES is not set
701# CONFIG_RT_MUTEX_TESTER is not set
702# CONFIG_DEBUG_SPINLOCK is not set
703# CONFIG_DEBUG_MUTEXES is not set
704# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
705# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
706# CONFIG_DEBUG_KOBJECT is not set
707CONFIG_DEBUG_BUGVERBOSE=y
708# CONFIG_DEBUG_INFO is not set
709# CONFIG_DEBUG_VM is not set
710# CONFIG_DEBUG_LIST is not set
711# CONFIG_DEBUG_SG is not set
712CONFIG_FRAME_POINTER=y
713CONFIG_FORCED_INLINING=y
714# CONFIG_BOOT_PRINTK_DELAY is not set
715# CONFIG_FAULT_INJECTION is not set
716# CONFIG_SAMPLES is not set
717# CONFIG_EARLY_PRINTK is not set
718CONFIG_SH64_PROC_TLB=y
719CONFIG_SH64_PROC_ASIDS=y
720CONFIG_SH64_SR_WATCH=y
721# CONFIG_POOR_MANS_STRACE is not set
722# CONFIG_SH_NO_BSS_INIT is not set
723
724#
725# Security options
726#
727# CONFIG_KEYS is not set
728# CONFIG_SECURITY is not set
729# CONFIG_SECURITY_FILE_CAPABILITIES is not set
730# CONFIG_CRYPTO is not set
731
732#
733# Library routines
734#
735CONFIG_BITREVERSE=y
736# CONFIG_CRC_CCITT is not set
737# CONFIG_CRC16 is not set
738# CONFIG_CRC_ITU_T is not set
739CONFIG_CRC32=y
740# CONFIG_CRC7 is not set
741# CONFIG_LIBCRC32C is not set
742CONFIG_PLIST=y
743CONFIG_HAS_IOMEM=y
744CONFIG_HAS_IOPORT=y
745CONFIG_HAS_DMA=y
diff --git a/arch/sh64/configs/sim_defconfig b/arch/sh64/configs/sim_defconfig
deleted file mode 100644
index 18476cc522c3..000000000000
--- a/arch/sh64/configs/sim_defconfig
+++ /dev/null
@@ -1,558 +0,0 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.24-rc1
4# Fri Nov 2 14:36:08 2007
5#
6CONFIG_SUPERH=y
7CONFIG_SUPERH64=y
8CONFIG_MMU=y
9CONFIG_QUICKLIST=y
10CONFIG_RWSEM_GENERIC_SPINLOCK=y
11CONFIG_GENERIC_FIND_NEXT_BIT=y
12CONFIG_GENERIC_HWEIGHT=y
13CONFIG_GENERIC_CALIBRATE_DELAY=y
14CONFIG_GENERIC_HARDIRQS=y
15CONFIG_GENERIC_IRQ_PROBE=y
16# CONFIG_ARCH_HAS_ILOG2_U32 is not set
17# CONFIG_ARCH_HAS_ILOG2_U64 is not set
18CONFIG_ARCH_NO_VIRT_TO_BUS=y
19CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
20
21#
22# General setup
23#
24CONFIG_EXPERIMENTAL=y
25CONFIG_BROKEN_ON_SMP=y
26CONFIG_LOCK_KERNEL=y
27CONFIG_INIT_ENV_ARG_LIMIT=32
28CONFIG_LOCALVERSION=""
29CONFIG_LOCALVERSION_AUTO=y
30CONFIG_SWAP=y
31# CONFIG_SYSVIPC is not set
32# CONFIG_BSD_PROCESS_ACCT is not set
33# CONFIG_USER_NS is not set
34# CONFIG_IKCONFIG is not set
35CONFIG_LOG_BUF_SHIFT=14
36# CONFIG_CGROUPS is not set
37CONFIG_FAIR_GROUP_SCHED=y
38CONFIG_FAIR_USER_SCHED=y
39# CONFIG_FAIR_CGROUP_SCHED is not set
40CONFIG_SYSFS_DEPRECATED=y
41# CONFIG_RELAY is not set
42# CONFIG_BLK_DEV_INITRD is not set
43# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
44CONFIG_SYSCTL=y
45# CONFIG_EMBEDDED is not set
46CONFIG_UID16=y
47CONFIG_SYSCTL_SYSCALL=y
48CONFIG_KALLSYMS=y
49# CONFIG_KALLSYMS_ALL is not set
50# CONFIG_KALLSYMS_EXTRA_PASS is not set
51CONFIG_HOTPLUG=y
52CONFIG_PRINTK=y
53CONFIG_BUG=y
54CONFIG_ELF_CORE=y
55CONFIG_BASE_FULL=y
56CONFIG_FUTEX=y
57CONFIG_ANON_INODES=y
58CONFIG_EPOLL=y
59CONFIG_SIGNALFD=y
60CONFIG_EVENTFD=y
61CONFIG_SHMEM=y
62CONFIG_VM_EVENT_COUNTERS=y
63CONFIG_SLAB=y
64# CONFIG_SLUB is not set
65# CONFIG_SLOB is not set
66CONFIG_RT_MUTEXES=y
67# CONFIG_TINY_SHMEM is not set
68CONFIG_BASE_SMALL=0
69# CONFIG_MODULES is not set
70CONFIG_BLOCK=y
71# CONFIG_LBD is not set
72# CONFIG_BLK_DEV_IO_TRACE is not set
73# CONFIG_LSF is not set
74# CONFIG_BLK_DEV_BSG is not set
75
76#
77# IO Schedulers
78#
79CONFIG_IOSCHED_NOOP=y
80CONFIG_IOSCHED_AS=y
81CONFIG_IOSCHED_DEADLINE=y
82CONFIG_IOSCHED_CFQ=y
83# CONFIG_DEFAULT_AS is not set
84# CONFIG_DEFAULT_DEADLINE is not set
85CONFIG_DEFAULT_CFQ=y
86# CONFIG_DEFAULT_NOOP is not set
87CONFIG_DEFAULT_IOSCHED="cfq"
88
89#
90# System type
91#
92CONFIG_SH_SIMULATOR=y
93# CONFIG_SH_CAYMAN is not set
94# CONFIG_SH_HARP is not set
95CONFIG_CPU_SH5=y
96CONFIG_CPU_SUBTYPE_SH5_101=y
97# CONFIG_CPU_SUBTYPE_SH5_103 is not set
98CONFIG_LITTLE_ENDIAN=y
99# CONFIG_BIG_ENDIAN is not set
100CONFIG_SH_FPU=y
101# CONFIG_SH64_FPU_DENORM_FLUSH is not set
102CONFIG_SH64_PGTABLE_2_LEVEL=y
103# CONFIG_SH64_PGTABLE_3_LEVEL is not set
104CONFIG_HUGETLB_PAGE_SIZE_64K=y
105# CONFIG_HUGETLB_PAGE_SIZE_1MB is not set
106# CONFIG_HUGETLB_PAGE_SIZE_512MB is not set
107CONFIG_SH64_USER_MISALIGNED_FIXUP=y
108
109#
110# Memory options
111#
112CONFIG_CACHED_MEMORY_OFFSET=0x20000000
113CONFIG_MEMORY_START=0x80000000
114CONFIG_MEMORY_SIZE_IN_MB=128
115
116#
117# Cache options
118#
119# CONFIG_DCACHE_WRITE_BACK is not set
120# CONFIG_DCACHE_WRITE_THROUGH is not set
121CONFIG_DCACHE_DISABLED=y
122# CONFIG_ICACHE_DISABLED is not set
123CONFIG_PCIDEVICE_MEMORY_START=C0000000
124CONFIG_DEVICE_MEMORY_START=E0000000
125CONFIG_FLASH_MEMORY_START=0x00000000
126CONFIG_PCI_BLOCK_START=0x40000000
127
128#
129# CPU Subtype specific options
130#
131CONFIG_SH64_ID2815_WORKAROUND=y
132
133#
134# Misc options
135#
136# CONFIG_SH_DMA is not set
137CONFIG_PREEMPT=y
138CONFIG_SELECT_MEMORY_MODEL=y
139CONFIG_FLATMEM_MANUAL=y
140# CONFIG_DISCONTIGMEM_MANUAL is not set
141# CONFIG_SPARSEMEM_MANUAL is not set
142CONFIG_FLATMEM=y
143CONFIG_FLAT_NODE_MEM_MAP=y
144# CONFIG_SPARSEMEM_STATIC is not set
145# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
146CONFIG_SPLIT_PTLOCK_CPUS=4
147# CONFIG_RESOURCES_64BIT is not set
148CONFIG_ZONE_DMA_FLAG=0
149CONFIG_NR_QUICK=1
150
151#
152# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
153#
154# CONFIG_ARCH_SUPPORTS_MSI is not set
155# CONFIG_PCCARD is not set
156
157#
158# Executable file formats
159#
160CONFIG_BINFMT_ELF=y
161# CONFIG_BINFMT_MISC is not set
162
163#
164# Networking
165#
166# CONFIG_NET is not set
167
168#
169# Device Drivers
170#
171
172#
173# Generic Driver Options
174#
175CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
176CONFIG_STANDALONE=y
177CONFIG_PREVENT_FIRMWARE_BUILD=y
178# CONFIG_FW_LOADER is not set
179# CONFIG_DEBUG_DRIVER is not set
180# CONFIG_DEBUG_DEVRES is not set
181# CONFIG_SYS_HYPERVISOR is not set
182# CONFIG_MTD is not set
183# CONFIG_PARPORT is not set
184# CONFIG_BLK_DEV is not set
185# CONFIG_MISC_DEVICES is not set
186# CONFIG_IDE is not set
187
188#
189# SCSI device support
190#
191# CONFIG_RAID_ATTRS is not set
192CONFIG_SCSI=y
193CONFIG_SCSI_DMA=y
194# CONFIG_SCSI_TGT is not set
195# CONFIG_SCSI_NETLINK is not set
196CONFIG_SCSI_PROC_FS=y
197
198#
199# SCSI support type (disk, tape, CD-ROM)
200#
201CONFIG_BLK_DEV_SD=y
202# CONFIG_CHR_DEV_ST is not set
203# CONFIG_CHR_DEV_OSST is not set
204# CONFIG_BLK_DEV_SR is not set
205# CONFIG_CHR_DEV_SG is not set
206# CONFIG_CHR_DEV_SCH is not set
207
208#
209# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
210#
211CONFIG_SCSI_MULTI_LUN=y
212# CONFIG_SCSI_CONSTANTS is not set
213# CONFIG_SCSI_LOGGING is not set
214# CONFIG_SCSI_SCAN_ASYNC is not set
215
216#
217# SCSI Transports
218#
219CONFIG_SCSI_SPI_ATTRS=y
220# CONFIG_SCSI_FC_ATTRS is not set
221# CONFIG_SCSI_SAS_LIBSAS is not set
222# CONFIG_SCSI_SRP_ATTRS is not set
223CONFIG_SCSI_LOWLEVEL=y
224# CONFIG_SCSI_DEBUG is not set
225# CONFIG_ATA is not set
226# CONFIG_MD is not set
227# CONFIG_PHONE is not set
228
229#
230# Input device support
231#
232CONFIG_INPUT=y
233# CONFIG_INPUT_FF_MEMLESS is not set
234# CONFIG_INPUT_POLLDEV is not set
235
236#
237# Userland interfaces
238#
239CONFIG_INPUT_MOUSEDEV=y
240# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
241CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
242CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
243# CONFIG_INPUT_JOYDEV is not set
244# CONFIG_INPUT_EVDEV is not set
245# CONFIG_INPUT_EVBUG is not set
246
247#
248# Input Device Drivers
249#
250# CONFIG_INPUT_KEYBOARD is not set
251# CONFIG_INPUT_MOUSE is not set
252# CONFIG_INPUT_JOYSTICK is not set
253# CONFIG_INPUT_TABLET is not set
254# CONFIG_INPUT_TOUCHSCREEN is not set
255# CONFIG_INPUT_MISC is not set
256
257#
258# Hardware I/O ports
259#
260# CONFIG_SERIO is not set
261# CONFIG_GAMEPORT is not set
262
263#
264# Character devices
265#
266CONFIG_VT=y
267CONFIG_VT_CONSOLE=y
268CONFIG_HW_CONSOLE=y
269# CONFIG_VT_HW_CONSOLE_BINDING is not set
270# CONFIG_SERIAL_NONSTANDARD is not set
271
272#
273# Serial drivers
274#
275# CONFIG_SERIAL_8250 is not set
276
277#
278# Non-8250 serial port support
279#
280CONFIG_SERIAL_SH_SCI=y
281CONFIG_SERIAL_SH_SCI_NR_UARTS=2
282CONFIG_SERIAL_SH_SCI_CONSOLE=y
283CONFIG_SERIAL_CORE=y
284CONFIG_SERIAL_CORE_CONSOLE=y
285CONFIG_UNIX98_PTYS=y
286# CONFIG_LEGACY_PTYS is not set
287# CONFIG_IPMI_HANDLER is not set
288# CONFIG_HW_RANDOM is not set
289# CONFIG_R3964 is not set
290# CONFIG_RAW_DRIVER is not set
291# CONFIG_TCG_TPM is not set
292# CONFIG_I2C is not set
293
294#
295# SPI support
296#
297# CONFIG_SPI is not set
298# CONFIG_SPI_MASTER is not set
299# CONFIG_W1 is not set
300# CONFIG_POWER_SUPPLY is not set
301# CONFIG_HWMON is not set
302# CONFIG_WATCHDOG is not set
303
304#
305# Sonics Silicon Backplane
306#
307CONFIG_SSB_POSSIBLE=y
308# CONFIG_SSB is not set
309
310#
311# Multifunction device drivers
312#
313# CONFIG_MFD_SM501 is not set
314
315#
316# Multimedia devices
317#
318# CONFIG_VIDEO_DEV is not set
319CONFIG_DAB=y
320
321#
322# Graphics support
323#
324# CONFIG_VGASTATE is not set
325CONFIG_VIDEO_OUTPUT_CONTROL=y
326CONFIG_FB=y
327CONFIG_FIRMWARE_EDID=y
328# CONFIG_FB_DDC is not set
329# CONFIG_FB_CFB_FILLRECT is not set
330# CONFIG_FB_CFB_COPYAREA is not set
331# CONFIG_FB_CFB_IMAGEBLIT is not set
332# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
333# CONFIG_FB_SYS_FILLRECT is not set
334# CONFIG_FB_SYS_COPYAREA is not set
335# CONFIG_FB_SYS_IMAGEBLIT is not set
336# CONFIG_FB_SYS_FOPS is not set
337CONFIG_FB_DEFERRED_IO=y
338# CONFIG_FB_SVGALIB is not set
339# CONFIG_FB_MACMODES is not set
340# CONFIG_FB_BACKLIGHT is not set
341CONFIG_FB_MODE_HELPERS=y
342# CONFIG_FB_TILEBLITTING is not set
343
344#
345# Frame buffer hardware drivers
346#
347# CONFIG_FB_S1D13XXX is not set
348# CONFIG_FB_VIRTUAL is not set
349# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
350
351#
352# Display device support
353#
354# CONFIG_DISPLAY_SUPPORT is not set
355
356#
357# Console display driver support
358#
359CONFIG_DUMMY_CONSOLE=y
360CONFIG_FRAMEBUFFER_CONSOLE=y
361# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
362# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
363CONFIG_FONTS=y
364# CONFIG_FONT_8x8 is not set
365CONFIG_FONT_8x16=y
366# CONFIG_FONT_6x11 is not set
367# CONFIG_FONT_7x14 is not set
368# CONFIG_FONT_PEARL_8x8 is not set
369# CONFIG_FONT_ACORN_8x8 is not set
370# CONFIG_FONT_MINI_4x6 is not set
371# CONFIG_FONT_SUN8x16 is not set
372# CONFIG_FONT_SUN12x22 is not set
373# CONFIG_FONT_10x18 is not set
374CONFIG_LOGO=y
375# CONFIG_LOGO_LINUX_MONO is not set
376# CONFIG_LOGO_LINUX_VGA16 is not set
377# CONFIG_LOGO_LINUX_CLUT224 is not set
378# CONFIG_LOGO_SUPERH_MONO is not set
379# CONFIG_LOGO_SUPERH_VGA16 is not set
380CONFIG_LOGO_SUPERH_CLUT224=y
381
382#
383# Sound
384#
385# CONFIG_SOUND is not set
386# CONFIG_HID_SUPPORT is not set
387# CONFIG_USB_SUPPORT is not set
388# CONFIG_MMC is not set
389# CONFIG_NEW_LEDS is not set
390# CONFIG_RTC_CLASS is not set
391
392#
393# Userspace I/O
394#
395# CONFIG_UIO is not set
396
397#
398# File systems
399#
400CONFIG_EXT2_FS=y
401# CONFIG_EXT2_FS_XATTR is not set
402# CONFIG_EXT2_FS_XIP is not set
403CONFIG_EXT3_FS=y
404CONFIG_EXT3_FS_XATTR=y
405# CONFIG_EXT3_FS_POSIX_ACL is not set
406# CONFIG_EXT3_FS_SECURITY is not set
407# CONFIG_EXT4DEV_FS is not set
408CONFIG_JBD=y
409# CONFIG_JBD_DEBUG is not set
410CONFIG_FS_MBCACHE=y
411# CONFIG_REISERFS_FS is not set
412# CONFIG_JFS_FS is not set
413# CONFIG_FS_POSIX_ACL is not set
414# CONFIG_XFS_FS is not set
415# CONFIG_GFS2_FS is not set
416CONFIG_MINIX_FS=y
417CONFIG_ROMFS_FS=y
418CONFIG_INOTIFY=y
419CONFIG_INOTIFY_USER=y
420# CONFIG_QUOTA is not set
421CONFIG_DNOTIFY=y
422# CONFIG_AUTOFS_FS is not set
423# CONFIG_AUTOFS4_FS is not set
424# CONFIG_FUSE_FS is not set
425
426#
427# CD-ROM/DVD Filesystems
428#
429# CONFIG_ISO9660_FS is not set
430# CONFIG_UDF_FS is not set
431
432#
433# DOS/FAT/NT Filesystems
434#
435# CONFIG_MSDOS_FS is not set
436# CONFIG_VFAT_FS is not set
437# CONFIG_NTFS_FS is not set
438
439#
440# Pseudo filesystems
441#
442CONFIG_PROC_FS=y
443CONFIG_PROC_KCORE=y
444CONFIG_PROC_SYSCTL=y
445CONFIG_SYSFS=y
446CONFIG_TMPFS=y
447# CONFIG_TMPFS_POSIX_ACL is not set
448CONFIG_HUGETLBFS=y
449CONFIG_HUGETLB_PAGE=y
450# CONFIG_CONFIGFS_FS is not set
451
452#
453# Miscellaneous filesystems
454#
455# CONFIG_ADFS_FS is not set
456# CONFIG_AFFS_FS is not set
457# CONFIG_HFS_FS is not set
458# CONFIG_HFSPLUS_FS is not set
459# CONFIG_BEFS_FS is not set
460# CONFIG_BFS_FS is not set
461# CONFIG_EFS_FS is not set
462# CONFIG_CRAMFS is not set
463# CONFIG_VXFS_FS is not set
464# CONFIG_HPFS_FS is not set
465# CONFIG_QNX4FS_FS is not set
466# CONFIG_SYSV_FS is not set
467# CONFIG_UFS_FS is not set
468
469#
470# Partition Types
471#
472CONFIG_PARTITION_ADVANCED=y
473# CONFIG_ACORN_PARTITION is not set
474# CONFIG_OSF_PARTITION is not set
475# CONFIG_AMIGA_PARTITION is not set
476# CONFIG_ATARI_PARTITION is not set
477# CONFIG_MAC_PARTITION is not set
478CONFIG_MSDOS_PARTITION=y
479# CONFIG_BSD_DISKLABEL is not set
480# CONFIG_MINIX_SUBPARTITION is not set
481# CONFIG_SOLARIS_X86_PARTITION is not set
482# CONFIG_UNIXWARE_DISKLABEL is not set
483# CONFIG_LDM_PARTITION is not set
484# CONFIG_SGI_PARTITION is not set
485# CONFIG_ULTRIX_PARTITION is not set
486# CONFIG_SUN_PARTITION is not set
487# CONFIG_KARMA_PARTITION is not set
488# CONFIG_EFI_PARTITION is not set
489# CONFIG_SYSV68_PARTITION is not set
490# CONFIG_NLS is not set
491CONFIG_INSTRUMENTATION=y
492CONFIG_PROFILING=y
493# CONFIG_OPROFILE is not set
494# CONFIG_MARKERS is not set
495
496#
497# Kernel hacking
498#
499# CONFIG_PRINTK_TIME is not set
500CONFIG_ENABLE_WARN_DEPRECATED=y
501CONFIG_ENABLE_MUST_CHECK=y
502CONFIG_MAGIC_SYSRQ=y
503# CONFIG_UNUSED_SYMBOLS is not set
504CONFIG_DEBUG_FS=y
505# CONFIG_HEADERS_CHECK is not set
506CONFIG_DEBUG_KERNEL=y
507# CONFIG_DEBUG_SHIRQ is not set
508CONFIG_DETECT_SOFTLOCKUP=y
509CONFIG_SCHED_DEBUG=y
510CONFIG_SCHEDSTATS=y
511# CONFIG_TIMER_STATS is not set
512# CONFIG_DEBUG_SLAB is not set
513# CONFIG_DEBUG_RT_MUTEXES is not set
514# CONFIG_RT_MUTEX_TESTER is not set
515# CONFIG_DEBUG_SPINLOCK is not set
516# CONFIG_DEBUG_MUTEXES is not set
517# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
518# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
519# CONFIG_DEBUG_KOBJECT is not set
520CONFIG_DEBUG_BUGVERBOSE=y
521# CONFIG_DEBUG_INFO is not set
522# CONFIG_DEBUG_VM is not set
523# CONFIG_DEBUG_LIST is not set
524# CONFIG_DEBUG_SG is not set
525CONFIG_FRAME_POINTER=y
526CONFIG_FORCED_INLINING=y
527# CONFIG_BOOT_PRINTK_DELAY is not set
528# CONFIG_FAULT_INJECTION is not set
529# CONFIG_SAMPLES is not set
530# CONFIG_EARLY_PRINTK is not set
531CONFIG_SH64_PROC_TLB=y
532CONFIG_SH64_PROC_ASIDS=y
533CONFIG_SH64_SR_WATCH=y
534# CONFIG_POOR_MANS_STRACE is not set
535CONFIG_SH_NO_BSS_INIT=y
536
537#
538# Security options
539#
540# CONFIG_KEYS is not set
541# CONFIG_SECURITY is not set
542# CONFIG_SECURITY_FILE_CAPABILITIES is not set
543# CONFIG_CRYPTO is not set
544
545#
546# Library routines
547#
548CONFIG_BITREVERSE=y
549# CONFIG_CRC_CCITT is not set
550# CONFIG_CRC16 is not set
551# CONFIG_CRC_ITU_T is not set
552CONFIG_CRC32=y
553# CONFIG_CRC7 is not set
554# CONFIG_LIBCRC32C is not set
555CONFIG_PLIST=y
556CONFIG_HAS_IOMEM=y
557CONFIG_HAS_IOPORT=y
558CONFIG_HAS_DMA=y
diff --git a/arch/sh64/kernel/Makefile b/arch/sh64/kernel/Makefile
deleted file mode 100644
index e3467bda6167..000000000000
--- a/arch/sh64/kernel/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
1#
2# This file is subject to the terms and conditions of the GNU General Public
3# License. See the file "COPYING" in the main directory of this archive
4# for more details.
5#
6# Copyright (C) 2000, 2001 Paolo Alberelli
7# Copyright (C) 2003 Paul Mundt
8#
9# Makefile for the Linux sh64 kernel.
10#
11# Note! Dependencies are done automagically by 'make dep', which also
12# removes any old dependencies. DON'T put your own dependencies here
13# unless it's something special (ie not a .c file).
14#
15
16extra-y := head.o init_task.o vmlinux.lds
17
18obj-y := process.o signal.o entry.o traps.o irq.o irq_intc.o \
19 ptrace.o setup.o time.o sys_sh64.o semaphore.o sh_ksyms.o \
20 switchto.o syscalls.o
21
22obj-$(CONFIG_HEARTBEAT) += led.o
23obj-$(CONFIG_SH_ALPHANUMERIC) += alphanum.o
24obj-$(CONFIG_SH_DMA) += dma.o
25obj-$(CONFIG_SH_FPU) += fpu.o
26obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
27obj-$(CONFIG_KALLSYMS) += unwind.o
28obj-$(CONFIG_PCI) += pcibios.o
29obj-$(CONFIG_MODULES) += module.o
30
31ifeq ($(CONFIG_PCI),y)
32obj-$(CONFIG_CPU_SH5) += pci_sh5.o
33endif
34
35USE_STANDARD_AS_RULE := true
36
diff --git a/arch/sh64/kernel/alphanum.c b/arch/sh64/kernel/alphanum.c
deleted file mode 100644
index d1619d95fbaa..000000000000
--- a/arch/sh64/kernel/alphanum.c
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * arch/sh64/kernel/alphanum.c
3 *
4 * Copyright (C) 2002 Stuart Menefy <stuart.menefy@st.com>
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * Machine-independent functions for handling 8-digit alphanumeric display
10 * (e.g. Agilent HDSP-253x)
11 */
12#include <linux/stddef.h>
13#include <linux/sched.h>
14
15void mach_alphanum(int pos, unsigned char val);
16
17void print_seg(char *file, int line)
18{
19 int i;
20 unsigned int nibble;
21
22 for (i = 0; i < 5; i++) {
23 mach_alphanum(i, file[i]);
24 }
25
26 for (i = 0; i < 3; i++) {
27 nibble = ((line >> (i * 4)) & 0xf);
28 mach_alphanum(7 - i, nibble + ((nibble > 9) ? 55 : 48));
29 }
30}
31
32void print_seg_num(unsigned num)
33{
34 int i;
35 unsigned int nibble;
36
37 for (i = 0; i < 8; i++) {
38 nibble = ((num >> (i * 4)) & 0xf);
39
40 mach_alphanum(7 - i, nibble + ((nibble > 9) ? 55 : 48));
41 }
42}
43
diff --git a/arch/sh64/kernel/asm-offsets.c b/arch/sh64/kernel/asm-offsets.c
deleted file mode 100644
index ca76537c16c0..000000000000
--- a/arch/sh64/kernel/asm-offsets.c
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * This program is used to generate definitions needed by
3 * assembly language modules.
4 *
5 * We use the technique used in the OSF Mach kernel code:
6 * generate asm statements containing #defines,
7 * compile this file to assembler, and then extract the
8 * #defines from the assembly-language output.
9 */
10
11#include <linux/stddef.h>
12#include <linux/types.h>
13#include <linux/mm.h>
14#include <asm/thread_info.h>
15
16#define DEFINE(sym, val) \
17 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
18
19#define BLANK() asm volatile("\n->" : : )
20
21int main(void)
22{
23 /* offsets into the thread_info struct */
24 DEFINE(TI_TASK, offsetof(struct thread_info, task));
25 DEFINE(TI_EXEC_DOMAIN, offsetof(struct thread_info, exec_domain));
26 DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
27 DEFINE(TI_PRE_COUNT, offsetof(struct thread_info, preempt_count));
28 DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
29 DEFINE(TI_ADDR_LIMIT, offsetof(struct thread_info, addr_limit));
30 DEFINE(TI_RESTART_BLOCK,offsetof(struct thread_info, restart_block));
31
32 return 0;
33}
diff --git a/arch/sh64/kernel/dma.c b/arch/sh64/kernel/dma.c
deleted file mode 100644
index 32c6f0549bf1..000000000000
--- a/arch/sh64/kernel/dma.c
+++ /dev/null
@@ -1,297 +0,0 @@
1/*
2 * arch/sh64/kernel/dma.c
3 *
4 * DMA routines for the SH-5 DMAC.
5 *
6 * Copyright (C) 2003 Paul Mundt
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
10 * for more details.
11 */
12#include <linux/init.h>
13#include <linux/module.h>
14#include <linux/interrupt.h>
15#include <linux/types.h>
16#include <linux/irq.h>
17#include <linux/spinlock.h>
18#include <linux/mm.h>
19#include <asm/hardware.h>
20#include <asm/dma.h>
21#include <asm/signal.h>
22#include <asm/errno.h>
23#include <asm/io.h>
24
25typedef struct {
26 unsigned long dev_addr;
27 unsigned long mem_addr;
28
29 unsigned int mode;
30 unsigned int count;
31} dma_info_t;
32
33static dma_info_t dma_info[MAX_DMA_CHANNELS];
34static DEFINE_SPINLOCK(dma_spin_lock);
35
36/* arch/sh64/kernel/irq_intc.c */
37extern void make_intc_irq(unsigned int irq);
38
39/* DMAC Interrupts */
40#define DMA_IRQ_DMTE0 18
41#define DMA_IRQ_DERR 22
42
43#define DMAC_COMMON_BASE (dmac_base + 0x08)
44#define DMAC_SAR_BASE (dmac_base + 0x10)
45#define DMAC_DAR_BASE (dmac_base + 0x18)
46#define DMAC_COUNT_BASE (dmac_base + 0x20)
47#define DMAC_CTRL_BASE (dmac_base + 0x28)
48#define DMAC_STATUS_BASE (dmac_base + 0x30)
49
50#define DMAC_SAR(n) (DMAC_SAR_BASE + ((n) * 0x28))
51#define DMAC_DAR(n) (DMAC_DAR_BASE + ((n) * 0x28))
52#define DMAC_COUNT(n) (DMAC_COUNT_BASE + ((n) * 0x28))
53#define DMAC_CTRL(n) (DMAC_CTRL_BASE + ((n) * 0x28))
54#define DMAC_STATUS(n) (DMAC_STATUS_BASE + ((n) * 0x28))
55
56/* DMAC.COMMON Bit Definitions */
57#define DMAC_COMMON_PR 0x00000001 /* Priority */
58 /* Bits 1-2 Reserved */
59#define DMAC_COMMON_ME 0x00000008 /* Master Enable */
60#define DMAC_COMMON_NMI 0x00000010 /* NMI Flag */
61 /* Bits 5-6 Reserved */
62#define DMAC_COMMON_ER 0x00000780 /* Error Response */
63#define DMAC_COMMON_AAE 0x00007800 /* Address Alignment Error */
64 /* Bits 15-63 Reserved */
65
66/* DMAC.SAR Bit Definitions */
67#define DMAC_SAR_ADDR 0xffffffff /* Source Address */
68
69/* DMAC.DAR Bit Definitions */
70#define DMAC_DAR_ADDR 0xffffffff /* Destination Address */
71
72/* DMAC.COUNT Bit Definitions */
73#define DMAC_COUNT_CNT 0xffffffff /* Transfer Count */
74
75/* DMAC.CTRL Bit Definitions */
76#define DMAC_CTRL_TS 0x00000007 /* Transfer Size */
77#define DMAC_CTRL_SI 0x00000018 /* Source Increment */
78#define DMAC_CTRL_DI 0x00000060 /* Destination Increment */
79#define DMAC_CTRL_RS 0x00000780 /* Resource Select */
80#define DMAC_CTRL_IE 0x00000800 /* Interrupt Enable */
81#define DMAC_CTRL_TE 0x00001000 /* Transfer Enable */
82 /* Bits 15-63 Reserved */
83
84/* DMAC.STATUS Bit Definitions */
85#define DMAC_STATUS_TE 0x00000001 /* Transfer End */
86#define DMAC_STATUS_AAE 0x00000002 /* Address Alignment Error */
87 /* Bits 2-63 Reserved */
88
89static unsigned long dmac_base;
90
91void set_dma_count(unsigned int chan, unsigned int count);
92void set_dma_addr(unsigned int chan, unsigned int addr);
93
94static irqreturn_t dma_mte(int irq, void *dev_id, struct pt_regs *regs)
95{
96 unsigned int chan = irq - DMA_IRQ_DMTE0;
97 dma_info_t *info = dma_info + chan;
98 u64 status;
99
100 if (info->mode & DMA_MODE_WRITE) {
101 sh64_out64(info->mem_addr & DMAC_SAR_ADDR, DMAC_SAR(chan));
102 } else {
103 sh64_out64(info->mem_addr & DMAC_DAR_ADDR, DMAC_DAR(chan));
104 }
105
106 set_dma_count(chan, info->count);
107
108 /* Clear the TE bit */
109 status = sh64_in64(DMAC_STATUS(chan));
110 status &= ~DMAC_STATUS_TE;
111 sh64_out64(status, DMAC_STATUS(chan));
112
113 return IRQ_HANDLED;
114}
115
116static struct irqaction irq_dmte = {
117 .handler = dma_mte,
118 .flags = IRQF_DISABLED,
119 .name = "DMA MTE",
120};
121
122static irqreturn_t dma_err(int irq, void *dev_id, struct pt_regs *regs)
123{
124 u64 tmp;
125 u8 chan;
126
127 printk(KERN_NOTICE "DMAC: Got a DMA Error!\n");
128
129 tmp = sh64_in64(DMAC_COMMON_BASE);
130
131 /* Check for the type of error */
132 if ((chan = tmp & DMAC_COMMON_AAE)) {
133 /* It's an address alignment error.. */
134 printk(KERN_NOTICE "DMAC: Alignment error on channel %d, ", chan);
135
136 printk(KERN_NOTICE "SAR: 0x%08llx, DAR: 0x%08llx, COUNT: %lld\n",
137 (sh64_in64(DMAC_SAR(chan)) & DMAC_SAR_ADDR),
138 (sh64_in64(DMAC_DAR(chan)) & DMAC_DAR_ADDR),
139 (sh64_in64(DMAC_COUNT(chan)) & DMAC_COUNT_CNT));
140
141 } else if ((chan = tmp & DMAC_COMMON_ER)) {
142 /* Something else went wrong.. */
143 printk(KERN_NOTICE "DMAC: Error on channel %d\n", chan);
144 }
145
146 /* Reset the ME bit to clear the interrupt */
147 tmp |= DMAC_COMMON_ME;
148 sh64_out64(tmp, DMAC_COMMON_BASE);
149
150 return IRQ_HANDLED;
151}
152
153static struct irqaction irq_derr = {
154 .handler = dma_err,
155 .flags = IRQF_DISABLED,
156 .name = "DMA Error",
157};
158
159static inline unsigned long calc_xmit_shift(unsigned int chan)
160{
161 return sh64_in64(DMAC_CTRL(chan)) & 0x03;
162}
163
164void setup_dma(unsigned int chan, dma_info_t *info)
165{
166 unsigned int irq = DMA_IRQ_DMTE0 + chan;
167 dma_info_t *dma = dma_info + chan;
168
169 make_intc_irq(irq);
170 setup_irq(irq, &irq_dmte);
171 dma = info;
172}
173
174void enable_dma(unsigned int chan)
175{
176 u64 ctrl;
177
178 ctrl = sh64_in64(DMAC_CTRL(chan));
179 ctrl |= DMAC_CTRL_TE;
180 sh64_out64(ctrl, DMAC_CTRL(chan));
181}
182
183void disable_dma(unsigned int chan)
184{
185 u64 ctrl;
186
187 ctrl = sh64_in64(DMAC_CTRL(chan));
188 ctrl &= ~DMAC_CTRL_TE;
189 sh64_out64(ctrl, DMAC_CTRL(chan));
190}
191
192void set_dma_mode(unsigned int chan, char mode)
193{
194 dma_info_t *info = dma_info + chan;
195
196 info->mode = mode;
197
198 set_dma_addr(chan, info->mem_addr);
199 set_dma_count(chan, info->count);
200}
201
202void set_dma_addr(unsigned int chan, unsigned int addr)
203{
204 dma_info_t *info = dma_info + chan;
205 unsigned long sar, dar;
206
207 info->mem_addr = addr;
208 sar = (info->mode & DMA_MODE_WRITE) ? info->mem_addr : info->dev_addr;
209 dar = (info->mode & DMA_MODE_WRITE) ? info->dev_addr : info->mem_addr;
210
211 sh64_out64(sar & DMAC_SAR_ADDR, DMAC_SAR(chan));
212 sh64_out64(dar & DMAC_SAR_ADDR, DMAC_DAR(chan));
213}
214
215void set_dma_count(unsigned int chan, unsigned int count)
216{
217 dma_info_t *info = dma_info + chan;
218 u64 tmp;
219
220 info->count = count;
221
222 tmp = (info->count >> calc_xmit_shift(chan)) & DMAC_COUNT_CNT;
223
224 sh64_out64(tmp, DMAC_COUNT(chan));
225}
226
227unsigned long claim_dma_lock(void)
228{
229 unsigned long flags;
230
231 spin_lock_irqsave(&dma_spin_lock, flags);
232
233 return flags;
234}
235
236void release_dma_lock(unsigned long flags)
237{
238 spin_unlock_irqrestore(&dma_spin_lock, flags);
239}
240
241int get_dma_residue(unsigned int chan)
242{
243 return sh64_in64(DMAC_COUNT(chan) << calc_xmit_shift(chan));
244}
245
246int __init init_dma(void)
247{
248 struct vcr_info vcr;
249 u64 tmp;
250
251 /* Remap the DMAC */
252 dmac_base = onchip_remap(PHYS_DMAC_BLOCK, 1024, "DMAC");
253 if (!dmac_base) {
254 printk(KERN_ERR "Unable to remap DMAC\n");
255 return -ENOMEM;
256 }
257
258 /* Report DMAC.VCR Info */
259 vcr = sh64_get_vcr_info(dmac_base);
260 printk("DMAC: Module ID: 0x%04x, Module version: 0x%04x\n",
261 vcr.mod_id, vcr.mod_vers);
262
263 /* Set the ME bit */
264 tmp = sh64_in64(DMAC_COMMON_BASE);
265 tmp |= DMAC_COMMON_ME;
266 sh64_out64(tmp, DMAC_COMMON_BASE);
267
268 /* Enable the DMAC Error Interrupt */
269 make_intc_irq(DMA_IRQ_DERR);
270 setup_irq(DMA_IRQ_DERR, &irq_derr);
271
272 return 0;
273}
274
275static void __exit exit_dma(void)
276{
277 onchip_unmap(dmac_base);
278 free_irq(DMA_IRQ_DERR, 0);
279}
280
281module_init(init_dma);
282module_exit(exit_dma);
283
284MODULE_AUTHOR("Paul Mundt");
285MODULE_DESCRIPTION("DMA API for SH-5 DMAC");
286MODULE_LICENSE("GPL");
287
288EXPORT_SYMBOL(setup_dma);
289EXPORT_SYMBOL(claim_dma_lock);
290EXPORT_SYMBOL(release_dma_lock);
291EXPORT_SYMBOL(enable_dma);
292EXPORT_SYMBOL(disable_dma);
293EXPORT_SYMBOL(set_dma_mode);
294EXPORT_SYMBOL(set_dma_addr);
295EXPORT_SYMBOL(set_dma_count);
296EXPORT_SYMBOL(get_dma_residue);
297
diff --git a/arch/sh64/kernel/early_printk.c b/arch/sh64/kernel/early_printk.c
deleted file mode 100644
index 4f9131123672..000000000000
--- a/arch/sh64/kernel/early_printk.c
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 * arch/sh64/kernel/early_printk.c
3 *
4 * SH-5 Early SCIF console (cloned and hacked from sh implementation)
5 *
6 * Copyright (C) 2003, 2004 Paul Mundt <lethal@linux-sh.org>
7 * Copyright (C) 2002 M. R. Brown <mrbrown@0xd6.org>
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13#include <linux/console.h>
14#include <linux/tty.h>
15#include <linux/init.h>
16#include <asm/io.h>
17#include <asm/hardware.h>
18
19#define SCIF_BASE_ADDR 0x01030000
20#define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR
21
22/*
23 * Fixed virtual address where SCIF is mapped (should already be done
24 * in arch/sh64/kernel/head.S!).
25 */
26#define SCIF_REG 0xfa030000
27
28enum {
29 SCIF_SCSMR2 = SCIF_REG + 0x00,
30 SCIF_SCBRR2 = SCIF_REG + 0x04,
31 SCIF_SCSCR2 = SCIF_REG + 0x08,
32 SCIF_SCFTDR2 = SCIF_REG + 0x0c,
33 SCIF_SCFSR2 = SCIF_REG + 0x10,
34 SCIF_SCFRDR2 = SCIF_REG + 0x14,
35 SCIF_SCFCR2 = SCIF_REG + 0x18,
36 SCIF_SCFDR2 = SCIF_REG + 0x1c,
37 SCIF_SCSPTR2 = SCIF_REG + 0x20,
38 SCIF_SCLSR2 = SCIF_REG + 0x24,
39};
40
41static void sh_console_putc(int c)
42{
43 while (!(ctrl_inw(SCIF_SCFSR2) & 0x20))
44 cpu_relax();
45
46 ctrl_outb(c, SCIF_SCFTDR2);
47 ctrl_outw((ctrl_inw(SCIF_SCFSR2) & 0x9f), SCIF_SCFSR2);
48
49 if (c == '\n')
50 sh_console_putc('\r');
51}
52
53static void sh_console_flush(void)
54{
55 ctrl_outw((ctrl_inw(SCIF_SCFSR2) & 0xbf), SCIF_SCFSR2);
56
57 while (!(ctrl_inw(SCIF_SCFSR2) & 0x40))
58 cpu_relax();
59
60 ctrl_outw((ctrl_inw(SCIF_SCFSR2) & 0xbf), SCIF_SCFSR2);
61}
62
63static void sh_console_write(struct console *con, const char *s, unsigned count)
64{
65 while (count-- > 0)
66 sh_console_putc(*s++);
67
68 sh_console_flush();
69}
70
71static int __init sh_console_setup(struct console *con, char *options)
72{
73 con->cflag = CREAD | HUPCL | CLOCAL | B19200 | CS8;
74
75 return 0;
76}
77
78static struct console sh_console = {
79 .name = "scifcon",
80 .write = sh_console_write,
81 .setup = sh_console_setup,
82 .flags = CON_PRINTBUFFER | CON_BOOT,
83 .index = -1,
84};
85
86void __init enable_early_printk(void)
87{
88 ctrl_outb(0x2a, SCIF_SCBRR2); /* 19200bps */
89
90 ctrl_outw(0x04, SCIF_SCFCR2); /* Reset TFRST */
91 ctrl_outw(0x10, SCIF_SCFCR2); /* TTRG0=1 */
92
93 ctrl_outw(0, SCIF_SCSPTR2);
94 ctrl_outw(0x60, SCIF_SCFSR2);
95 ctrl_outw(0, SCIF_SCLSR2);
96 ctrl_outw(0x30, SCIF_SCSCR2);
97
98 register_console(&sh_console);
99}
diff --git a/arch/sh64/kernel/entry.S b/arch/sh64/kernel/entry.S
deleted file mode 100644
index 7013fcb6665c..000000000000
--- a/arch/sh64/kernel/entry.S
+++ /dev/null
@@ -1,2102 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/entry.S
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2004, 2005 Paul Mundt
10 * Copyright (C) 2003, 2004 Richard Curnow
11 *
12 */
13
14#include <linux/errno.h>
15#include <linux/sys.h>
16
17#include <asm/processor.h>
18#include <asm/registers.h>
19#include <asm/unistd.h>
20#include <asm/thread_info.h>
21#include <asm/asm-offsets.h>
22
23/*
24 * SR fields.
25 */
26#define SR_ASID_MASK 0x00ff0000
27#define SR_FD_MASK 0x00008000
28#define SR_SS 0x08000000
29#define SR_BL 0x10000000
30#define SR_MD 0x40000000
31
32/*
33 * Event code.
34 */
35#define EVENT_INTERRUPT 0
36#define EVENT_FAULT_TLB 1
37#define EVENT_FAULT_NOT_TLB 2
38#define EVENT_DEBUG 3
39
40/* EXPEVT values */
41#define RESET_CAUSE 0x20
42#define DEBUGSS_CAUSE 0x980
43
44/*
45 * Frame layout. Quad index.
46 */
47#define FRAME_T(x) FRAME_TBASE+(x*8)
48#define FRAME_R(x) FRAME_RBASE+(x*8)
49#define FRAME_S(x) FRAME_SBASE+(x*8)
50#define FSPC 0
51#define FSSR 1
52#define FSYSCALL_ID 2
53
54/* Arrange the save frame to be a multiple of 32 bytes long */
55#define FRAME_SBASE 0
56#define FRAME_RBASE (FRAME_SBASE+(3*8)) /* SYSCALL_ID - SSR - SPC */
57#define FRAME_TBASE (FRAME_RBASE+(63*8)) /* r0 - r62 */
58#define FRAME_PBASE (FRAME_TBASE+(8*8)) /* tr0 -tr7 */
59#define FRAME_SIZE (FRAME_PBASE+(2*8)) /* pad0-pad1 */
60
61#define FP_FRAME_SIZE FP_FRAME_BASE+(33*8) /* dr0 - dr31 + fpscr */
62#define FP_FRAME_BASE 0
63
64#define SAVED_R2 0*8
65#define SAVED_R3 1*8
66#define SAVED_R4 2*8
67#define SAVED_R5 3*8
68#define SAVED_R18 4*8
69#define SAVED_R6 5*8
70#define SAVED_TR0 6*8
71
72/* These are the registers saved in the TLB path that aren't saved in the first
73 level of the normal one. */
74#define TLB_SAVED_R25 7*8
75#define TLB_SAVED_TR1 8*8
76#define TLB_SAVED_TR2 9*8
77#define TLB_SAVED_TR3 10*8
78#define TLB_SAVED_TR4 11*8
79/* Save R0/R1 : PT-migrating compiler currently dishounours -ffixed-r0 and -ffixed-r1 causing
80 breakage otherwise. */
81#define TLB_SAVED_R0 12*8
82#define TLB_SAVED_R1 13*8
83
84#define CLI() \
85 getcon SR, r6; \
86 ori r6, 0xf0, r6; \
87 putcon r6, SR;
88
89#define STI() \
90 getcon SR, r6; \
91 andi r6, ~0xf0, r6; \
92 putcon r6, SR;
93
94#ifdef CONFIG_PREEMPT
95# define preempt_stop() CLI()
96#else
97# define preempt_stop()
98# define resume_kernel restore_all
99#endif
100
101 .section .data, "aw"
102
103#define FAST_TLBMISS_STACK_CACHELINES 4
104#define FAST_TLBMISS_STACK_QUADWORDS (4*FAST_TLBMISS_STACK_CACHELINES)
105
106/* Register back-up area for all exceptions */
107 .balign 32
108 /* Allow for 16 quadwords to be pushed by fast tlbmiss handling
109 * register saves etc. */
110 .fill FAST_TLBMISS_STACK_QUADWORDS, 8, 0x0
111/* This is 32 byte aligned by construction */
112/* Register back-up area for all exceptions */
113reg_save_area:
114 .quad 0
115 .quad 0
116 .quad 0
117 .quad 0
118
119 .quad 0
120 .quad 0
121 .quad 0
122 .quad 0
123
124 .quad 0
125 .quad 0
126 .quad 0
127 .quad 0
128
129 .quad 0
130 .quad 0
131
132/* Save area for RESVEC exceptions. We cannot use reg_save_area because of
133 * reentrancy. Note this area may be accessed via physical address.
134 * Align so this fits a whole single cache line, for ease of purging.
135 */
136 .balign 32,0,32
137resvec_save_area:
138 .quad 0
139 .quad 0
140 .quad 0
141 .quad 0
142 .quad 0
143 .balign 32,0,32
144
145/* Jump table of 3rd level handlers */
146trap_jtable:
147 .long do_exception_error /* 0x000 */
148 .long do_exception_error /* 0x020 */
149 .long tlb_miss_load /* 0x040 */
150 .long tlb_miss_store /* 0x060 */
151 ! ARTIFICIAL pseudo-EXPEVT setting
152 .long do_debug_interrupt /* 0x080 */
153 .long tlb_miss_load /* 0x0A0 */
154 .long tlb_miss_store /* 0x0C0 */
155 .long do_address_error_load /* 0x0E0 */
156 .long do_address_error_store /* 0x100 */
157#ifdef CONFIG_SH_FPU
158 .long do_fpu_error /* 0x120 */
159#else
160 .long do_exception_error /* 0x120 */
161#endif
162 .long do_exception_error /* 0x140 */
163 .long system_call /* 0x160 */
164 .long do_reserved_inst /* 0x180 */
165 .long do_illegal_slot_inst /* 0x1A0 */
166 .long do_NMI /* 0x1C0 */
167 .long do_exception_error /* 0x1E0 */
168 .rept 15
169 .long do_IRQ /* 0x200 - 0x3C0 */
170 .endr
171 .long do_exception_error /* 0x3E0 */
172 .rept 32
173 .long do_IRQ /* 0x400 - 0x7E0 */
174 .endr
175 .long fpu_error_or_IRQA /* 0x800 */
176 .long fpu_error_or_IRQB /* 0x820 */
177 .long do_IRQ /* 0x840 */
178 .long do_IRQ /* 0x860 */
179 .rept 6
180 .long do_exception_error /* 0x880 - 0x920 */
181 .endr
182 .long do_software_break_point /* 0x940 */
183 .long do_exception_error /* 0x960 */
184 .long do_single_step /* 0x980 */
185
186 .rept 3
187 .long do_exception_error /* 0x9A0 - 0x9E0 */
188 .endr
189 .long do_IRQ /* 0xA00 */
190 .long do_IRQ /* 0xA20 */
191 .long itlb_miss_or_IRQ /* 0xA40 */
192 .long do_IRQ /* 0xA60 */
193 .long do_IRQ /* 0xA80 */
194 .long itlb_miss_or_IRQ /* 0xAA0 */
195 .long do_exception_error /* 0xAC0 */
196 .long do_address_error_exec /* 0xAE0 */
197 .rept 8
198 .long do_exception_error /* 0xB00 - 0xBE0 */
199 .endr
200 .rept 18
201 .long do_IRQ /* 0xC00 - 0xE20 */
202 .endr
203
204 .section .text64, "ax"
205
206/*
207 * --- Exception/Interrupt/Event Handling Section
208 */
209
210/*
211 * VBR and RESVEC blocks.
212 *
213 * First level handler for VBR-based exceptions.
214 *
215 * To avoid waste of space, align to the maximum text block size.
216 * This is assumed to be at most 128 bytes or 32 instructions.
217 * DO NOT EXCEED 32 instructions on the first level handlers !
218 *
219 * Also note that RESVEC is contained within the VBR block
220 * where the room left (1KB - TEXT_SIZE) allows placing
221 * the RESVEC block (at most 512B + TEXT_SIZE).
222 *
223 * So first (and only) level handler for RESVEC-based exceptions.
224 *
225 * Where the fault/interrupt is handled (not_a_tlb_miss, tlb_miss
226 * and interrupt) we are a lot tight with register space until
227 * saving onto the stack frame, which is done in handle_exception().
228 *
229 */
230
231#define TEXT_SIZE 128
232#define BLOCK_SIZE 1664 /* Dynamic check, 13*128 */
233
234 .balign TEXT_SIZE
235LVBR_block:
236 .space 256, 0 /* Power-on class handler, */
237 /* not required here */
238not_a_tlb_miss:
239 synco /* TAKum03020 (but probably a good idea anyway.) */
240 /* Save original stack pointer into KCR1 */
241 putcon SP, KCR1
242
243 /* Save other original registers into reg_save_area */
244 movi reg_save_area, SP
245 st.q SP, SAVED_R2, r2
246 st.q SP, SAVED_R3, r3
247 st.q SP, SAVED_R4, r4
248 st.q SP, SAVED_R5, r5
249 st.q SP, SAVED_R6, r6
250 st.q SP, SAVED_R18, r18
251 gettr tr0, r3
252 st.q SP, SAVED_TR0, r3
253
254 /* Set args for Non-debug, Not a TLB miss class handler */
255 getcon EXPEVT, r2
256 movi ret_from_exception, r3
257 ori r3, 1, r3
258 movi EVENT_FAULT_NOT_TLB, r4
259 or SP, ZERO, r5
260 getcon KCR1, SP
261 pta handle_exception, tr0
262 blink tr0, ZERO
263
264 .balign 256
265 ! VBR+0x200
266 nop
267 .balign 256
268 ! VBR+0x300
269 nop
270 .balign 256
271 /*
272 * Instead of the natural .balign 1024 place RESVEC here
273 * respecting the final 1KB alignment.
274 */
275 .balign TEXT_SIZE
276 /*
277 * Instead of '.space 1024-TEXT_SIZE' place the RESVEC
278 * block making sure the final alignment is correct.
279 */
280tlb_miss:
281 synco /* TAKum03020 (but probably a good idea anyway.) */
282 putcon SP, KCR1
283 movi reg_save_area, SP
284 /* SP is guaranteed 32-byte aligned. */
285 st.q SP, TLB_SAVED_R0 , r0
286 st.q SP, TLB_SAVED_R1 , r1
287 st.q SP, SAVED_R2 , r2
288 st.q SP, SAVED_R3 , r3
289 st.q SP, SAVED_R4 , r4
290 st.q SP, SAVED_R5 , r5
291 st.q SP, SAVED_R6 , r6
292 st.q SP, SAVED_R18, r18
293
294 /* Save R25 for safety; as/ld may want to use it to achieve the call to
295 * the code in mm/tlbmiss.c */
296 st.q SP, TLB_SAVED_R25, r25
297 gettr tr0, r2
298 gettr tr1, r3
299 gettr tr2, r4
300 gettr tr3, r5
301 gettr tr4, r18
302 st.q SP, SAVED_TR0 , r2
303 st.q SP, TLB_SAVED_TR1 , r3
304 st.q SP, TLB_SAVED_TR2 , r4
305 st.q SP, TLB_SAVED_TR3 , r5
306 st.q SP, TLB_SAVED_TR4 , r18
307
308 pt do_fast_page_fault, tr0
309 getcon SSR, r2
310 getcon EXPEVT, r3
311 getcon TEA, r4
312 shlri r2, 30, r2
313 andi r2, 1, r2 /* r2 = SSR.MD */
314 blink tr0, LINK
315
316 pt fixup_to_invoke_general_handler, tr1
317
318 /* If the fast path handler fixed the fault, just drop through quickly
319 to the restore code right away to return to the excepting context.
320 */
321 beqi/u r2, 0, tr1
322
323fast_tlb_miss_restore:
324 ld.q SP, SAVED_TR0, r2
325 ld.q SP, TLB_SAVED_TR1, r3
326 ld.q SP, TLB_SAVED_TR2, r4
327
328 ld.q SP, TLB_SAVED_TR3, r5
329 ld.q SP, TLB_SAVED_TR4, r18
330
331 ptabs r2, tr0
332 ptabs r3, tr1
333 ptabs r4, tr2
334 ptabs r5, tr3
335 ptabs r18, tr4
336
337 ld.q SP, TLB_SAVED_R0, r0
338 ld.q SP, TLB_SAVED_R1, r1
339 ld.q SP, SAVED_R2, r2
340 ld.q SP, SAVED_R3, r3
341 ld.q SP, SAVED_R4, r4
342 ld.q SP, SAVED_R5, r5
343 ld.q SP, SAVED_R6, r6
344 ld.q SP, SAVED_R18, r18
345 ld.q SP, TLB_SAVED_R25, r25
346
347 getcon KCR1, SP
348 rte
349 nop /* for safety, in case the code is run on sh5-101 cut1.x */
350
351fixup_to_invoke_general_handler:
352
353 /* OK, new method. Restore stuff that's not expected to get saved into
354 the 'first-level' reg save area, then just fall through to setting
355 up the registers and calling the second-level handler. */
356
357 /* 2nd level expects r2,3,4,5,6,18,tr0 to be saved. So we must restore
358 r25,tr1-4 and save r6 to get into the right state. */
359
360 ld.q SP, TLB_SAVED_TR1, r3
361 ld.q SP, TLB_SAVED_TR2, r4
362 ld.q SP, TLB_SAVED_TR3, r5
363 ld.q SP, TLB_SAVED_TR4, r18
364 ld.q SP, TLB_SAVED_R25, r25
365
366 ld.q SP, TLB_SAVED_R0, r0
367 ld.q SP, TLB_SAVED_R1, r1
368
369 ptabs/u r3, tr1
370 ptabs/u r4, tr2
371 ptabs/u r5, tr3
372 ptabs/u r18, tr4
373
374 /* Set args for Non-debug, TLB miss class handler */
375 getcon EXPEVT, r2
376 movi ret_from_exception, r3
377 ori r3, 1, r3
378 movi EVENT_FAULT_TLB, r4
379 or SP, ZERO, r5
380 getcon KCR1, SP
381 pta handle_exception, tr0
382 blink tr0, ZERO
383
384/* NB TAKE GREAT CARE HERE TO ENSURE THAT THE INTERRUPT CODE
385 DOES END UP AT VBR+0x600 */
386 nop
387 nop
388 nop
389 nop
390 nop
391 nop
392
393 .balign 256
394 /* VBR + 0x600 */
395
396interrupt:
397 synco /* TAKum03020 (but probably a good idea anyway.) */
398 /* Save original stack pointer into KCR1 */
399 putcon SP, KCR1
400
401 /* Save other original registers into reg_save_area */
402 movi reg_save_area, SP
403 st.q SP, SAVED_R2, r2
404 st.q SP, SAVED_R3, r3
405 st.q SP, SAVED_R4, r4
406 st.q SP, SAVED_R5, r5
407 st.q SP, SAVED_R6, r6
408 st.q SP, SAVED_R18, r18
409 gettr tr0, r3
410 st.q SP, SAVED_TR0, r3
411
412 /* Set args for interrupt class handler */
413 getcon INTEVT, r2
414 movi ret_from_irq, r3
415 ori r3, 1, r3
416 movi EVENT_INTERRUPT, r4
417 or SP, ZERO, r5
418 getcon KCR1, SP
419 pta handle_exception, tr0
420 blink tr0, ZERO
421 .balign TEXT_SIZE /* let's waste the bare minimum */
422
423LVBR_block_end: /* Marker. Used for total checking */
424
425 .balign 256
426LRESVEC_block:
427 /* Panic handler. Called with MMU off. Possible causes/actions:
428 * - Reset: Jump to program start.
429 * - Single Step: Turn off Single Step & return.
430 * - Others: Call panic handler, passing PC as arg.
431 * (this may need to be extended...)
432 */
433reset_or_panic:
434 synco /* TAKum03020 (but probably a good idea anyway.) */
435 putcon SP, DCR
436 /* First save r0-1 and tr0, as we need to use these */
437 movi resvec_save_area-CONFIG_CACHED_MEMORY_OFFSET, SP
438 st.q SP, 0, r0
439 st.q SP, 8, r1
440 gettr tr0, r0
441 st.q SP, 32, r0
442
443 /* Check cause */
444 getcon EXPEVT, r0
445 movi RESET_CAUSE, r1
446 sub r1, r0, r1 /* r1=0 if reset */
447 movi _stext-CONFIG_CACHED_MEMORY_OFFSET, r0
448 ori r0, 1, r0
449 ptabs r0, tr0
450 beqi r1, 0, tr0 /* Jump to start address if reset */
451
452 getcon EXPEVT, r0
453 movi DEBUGSS_CAUSE, r1
454 sub r1, r0, r1 /* r1=0 if single step */
455 pta single_step_panic, tr0
456 beqi r1, 0, tr0 /* jump if single step */
457
458 /* Now jump to where we save the registers. */
459 movi panic_stash_regs-CONFIG_CACHED_MEMORY_OFFSET, r1
460 ptabs r1, tr0
461 blink tr0, r63
462
463single_step_panic:
464 /* We are in a handler with Single Step set. We need to resume the
465 * handler, by turning on MMU & turning off Single Step. */
466 getcon SSR, r0
467 movi SR_MMU, r1
468 or r0, r1, r0
469 movi ~SR_SS, r1
470 and r0, r1, r0
471 putcon r0, SSR
472 /* Restore EXPEVT, as the rte won't do this */
473 getcon PEXPEVT, r0
474 putcon r0, EXPEVT
475 /* Restore regs */
476 ld.q SP, 32, r0
477 ptabs r0, tr0
478 ld.q SP, 0, r0
479 ld.q SP, 8, r1
480 getcon DCR, SP
481 synco
482 rte
483
484
485 .balign 256
486debug_exception:
487 synco /* TAKum03020 (but probably a good idea anyway.) */
488 /*
489 * Single step/software_break_point first level handler.
490 * Called with MMU off, so the first thing we do is enable it
491 * by doing an rte with appropriate SSR.
492 */
493 putcon SP, DCR
494 /* Save SSR & SPC, together with R0 & R1, as we need to use 2 regs. */
495 movi resvec_save_area-CONFIG_CACHED_MEMORY_OFFSET, SP
496
497 /* With the MMU off, we are bypassing the cache, so purge any
498 * data that will be made stale by the following stores.
499 */
500 ocbp SP, 0
501 synco
502
503 st.q SP, 0, r0
504 st.q SP, 8, r1
505 getcon SPC, r0
506 st.q SP, 16, r0
507 getcon SSR, r0
508 st.q SP, 24, r0
509
510 /* Enable MMU, block exceptions, set priv mode, disable single step */
511 movi SR_MMU | SR_BL | SR_MD, r1
512 or r0, r1, r0
513 movi ~SR_SS, r1
514 and r0, r1, r0
515 putcon r0, SSR
516 /* Force control to debug_exception_2 when rte is executed */
517 movi debug_exeception_2, r0
518 ori r0, 1, r0 /* force SHmedia, just in case */
519 putcon r0, SPC
520 getcon DCR, SP
521 synco
522 rte
523debug_exeception_2:
524 /* Restore saved regs */
525 putcon SP, KCR1
526 movi resvec_save_area, SP
527 ld.q SP, 24, r0
528 putcon r0, SSR
529 ld.q SP, 16, r0
530 putcon r0, SPC
531 ld.q SP, 0, r0
532 ld.q SP, 8, r1
533
534 /* Save other original registers into reg_save_area */
535 movi reg_save_area, SP
536 st.q SP, SAVED_R2, r2
537 st.q SP, SAVED_R3, r3
538 st.q SP, SAVED_R4, r4
539 st.q SP, SAVED_R5, r5
540 st.q SP, SAVED_R6, r6
541 st.q SP, SAVED_R18, r18
542 gettr tr0, r3
543 st.q SP, SAVED_TR0, r3
544
545 /* Set args for debug class handler */
546 getcon EXPEVT, r2
547 movi ret_from_exception, r3
548 ori r3, 1, r3
549 movi EVENT_DEBUG, r4
550 or SP, ZERO, r5
551 getcon KCR1, SP
552 pta handle_exception, tr0
553 blink tr0, ZERO
554
555 .balign 256
556debug_interrupt:
557 /* !!! WE COME HERE IN REAL MODE !!! */
558 /* Hook-up debug interrupt to allow various debugging options to be
559 * hooked into its handler. */
560 /* Save original stack pointer into KCR1 */
561 synco
562 putcon SP, KCR1
563 movi resvec_save_area-CONFIG_CACHED_MEMORY_OFFSET, SP
564 ocbp SP, 0
565 ocbp SP, 32
566 synco
567
568 /* Save other original registers into reg_save_area thru real addresses */
569 st.q SP, SAVED_R2, r2
570 st.q SP, SAVED_R3, r3
571 st.q SP, SAVED_R4, r4
572 st.q SP, SAVED_R5, r5
573 st.q SP, SAVED_R6, r6
574 st.q SP, SAVED_R18, r18
575 gettr tr0, r3
576 st.q SP, SAVED_TR0, r3
577
578 /* move (spc,ssr)->(pspc,pssr). The rte will shift
579 them back again, so that they look like the originals
580 as far as the real handler code is concerned. */
581 getcon spc, r6
582 putcon r6, pspc
583 getcon ssr, r6
584 putcon r6, pssr
585
586 ! construct useful SR for handle_exception
587 movi 3, r6
588 shlli r6, 30, r6
589 getcon sr, r18
590 or r18, r6, r6
591 putcon r6, ssr
592
593 ! SSR is now the current SR with the MD and MMU bits set
594 ! i.e. the rte will switch back to priv mode and put
595 ! the mmu back on
596
597 ! construct spc
598 movi handle_exception, r18
599 ori r18, 1, r18 ! for safety (do we need this?)
600 putcon r18, spc
601
602 /* Set args for Non-debug, Not a TLB miss class handler */
603
604 ! EXPEVT==0x80 is unused, so 'steal' this value to put the
605 ! debug interrupt handler in the vectoring table
606 movi 0x80, r2
607 movi ret_from_exception, r3
608 ori r3, 1, r3
609 movi EVENT_FAULT_NOT_TLB, r4
610
611 or SP, ZERO, r5
612 movi CONFIG_CACHED_MEMORY_OFFSET, r6
613 add r6, r5, r5
614 getcon KCR1, SP
615
616 synco ! for safety
617 rte ! -> handle_exception, switch back to priv mode again
618
619LRESVEC_block_end: /* Marker. Unused. */
620
621 .balign TEXT_SIZE
622
623/*
624 * Second level handler for VBR-based exceptions. Pre-handler.
625 * In common to all stack-frame sensitive handlers.
626 *
627 * Inputs:
628 * (KCR0) Current [current task union]
629 * (KCR1) Original SP
630 * (r2) INTEVT/EXPEVT
631 * (r3) appropriate return address
632 * (r4) Event (0 = interrupt, 1 = TLB miss fault, 2 = Not TLB miss fault, 3=debug)
633 * (r5) Pointer to reg_save_area
634 * (SP) Original SP
635 *
636 * Available registers:
637 * (r6)
638 * (r18)
639 * (tr0)
640 *
641 */
642handle_exception:
643 /* Common 2nd level handler. */
644
645 /* First thing we need an appropriate stack pointer */
646 getcon SSR, r6
647 shlri r6, 30, r6
648 andi r6, 1, r6
649 pta stack_ok, tr0
650 bne r6, ZERO, tr0 /* Original stack pointer is fine */
651
652 /* Set stack pointer for user fault */
653 getcon KCR0, SP
654 movi THREAD_SIZE, r6 /* Point to the end */
655 add SP, r6, SP
656
657stack_ok:
658
659/* DEBUG : check for underflow/overflow of the kernel stack */
660 pta no_underflow, tr0
661 getcon KCR0, r6
662 movi 1024, r18
663 add r6, r18, r6
664 bge SP, r6, tr0 ! ? below 1k from bottom of stack : danger zone
665
666/* Just panic to cause a crash. */
667bad_sp:
668 ld.b r63, 0, r6
669 nop
670
671no_underflow:
672 pta bad_sp, tr0
673 getcon kcr0, r6
674 movi THREAD_SIZE, r18
675 add r18, r6, r6
676 bgt SP, r6, tr0 ! sp above the stack
677
678 /* Make some room for the BASIC frame. */
679 movi -(FRAME_SIZE), r6
680 add SP, r6, SP
681
682/* Could do this with no stalling if we had another spare register, but the
683 code below will be OK. */
684 ld.q r5, SAVED_R2, r6
685 ld.q r5, SAVED_R3, r18
686 st.q SP, FRAME_R(2), r6
687 ld.q r5, SAVED_R4, r6
688 st.q SP, FRAME_R(3), r18
689 ld.q r5, SAVED_R5, r18
690 st.q SP, FRAME_R(4), r6
691 ld.q r5, SAVED_R6, r6
692 st.q SP, FRAME_R(5), r18
693 ld.q r5, SAVED_R18, r18
694 st.q SP, FRAME_R(6), r6
695 ld.q r5, SAVED_TR0, r6
696 st.q SP, FRAME_R(18), r18
697 st.q SP, FRAME_T(0), r6
698
699 /* Keep old SP around */
700 getcon KCR1, r6
701
702 /* Save the rest of the general purpose registers */
703 st.q SP, FRAME_R(0), r0
704 st.q SP, FRAME_R(1), r1
705 st.q SP, FRAME_R(7), r7
706 st.q SP, FRAME_R(8), r8
707 st.q SP, FRAME_R(9), r9
708 st.q SP, FRAME_R(10), r10
709 st.q SP, FRAME_R(11), r11
710 st.q SP, FRAME_R(12), r12
711 st.q SP, FRAME_R(13), r13
712 st.q SP, FRAME_R(14), r14
713
714 /* SP is somewhere else */
715 st.q SP, FRAME_R(15), r6
716
717 st.q SP, FRAME_R(16), r16
718 st.q SP, FRAME_R(17), r17
719 /* r18 is saved earlier. */
720 st.q SP, FRAME_R(19), r19
721 st.q SP, FRAME_R(20), r20
722 st.q SP, FRAME_R(21), r21
723 st.q SP, FRAME_R(22), r22
724 st.q SP, FRAME_R(23), r23
725 st.q SP, FRAME_R(24), r24
726 st.q SP, FRAME_R(25), r25
727 st.q SP, FRAME_R(26), r26
728 st.q SP, FRAME_R(27), r27
729 st.q SP, FRAME_R(28), r28
730 st.q SP, FRAME_R(29), r29
731 st.q SP, FRAME_R(30), r30
732 st.q SP, FRAME_R(31), r31
733 st.q SP, FRAME_R(32), r32
734 st.q SP, FRAME_R(33), r33
735 st.q SP, FRAME_R(34), r34
736 st.q SP, FRAME_R(35), r35
737 st.q SP, FRAME_R(36), r36
738 st.q SP, FRAME_R(37), r37
739 st.q SP, FRAME_R(38), r38
740 st.q SP, FRAME_R(39), r39
741 st.q SP, FRAME_R(40), r40
742 st.q SP, FRAME_R(41), r41
743 st.q SP, FRAME_R(42), r42
744 st.q SP, FRAME_R(43), r43
745 st.q SP, FRAME_R(44), r44
746 st.q SP, FRAME_R(45), r45
747 st.q SP, FRAME_R(46), r46
748 st.q SP, FRAME_R(47), r47
749 st.q SP, FRAME_R(48), r48
750 st.q SP, FRAME_R(49), r49
751 st.q SP, FRAME_R(50), r50
752 st.q SP, FRAME_R(51), r51
753 st.q SP, FRAME_R(52), r52
754 st.q SP, FRAME_R(53), r53
755 st.q SP, FRAME_R(54), r54
756 st.q SP, FRAME_R(55), r55
757 st.q SP, FRAME_R(56), r56
758 st.q SP, FRAME_R(57), r57
759 st.q SP, FRAME_R(58), r58
760 st.q SP, FRAME_R(59), r59
761 st.q SP, FRAME_R(60), r60
762 st.q SP, FRAME_R(61), r61
763 st.q SP, FRAME_R(62), r62
764
765 /*
766 * Save the S* registers.
767 */
768 getcon SSR, r61
769 st.q SP, FRAME_S(FSSR), r61
770 getcon SPC, r62
771 st.q SP, FRAME_S(FSPC), r62
772 movi -1, r62 /* Reset syscall_nr */
773 st.q SP, FRAME_S(FSYSCALL_ID), r62
774
775 /* Save the rest of the target registers */
776 gettr tr1, r6
777 st.q SP, FRAME_T(1), r6
778 gettr tr2, r6
779 st.q SP, FRAME_T(2), r6
780 gettr tr3, r6
781 st.q SP, FRAME_T(3), r6
782 gettr tr4, r6
783 st.q SP, FRAME_T(4), r6
784 gettr tr5, r6
785 st.q SP, FRAME_T(5), r6
786 gettr tr6, r6
787 st.q SP, FRAME_T(6), r6
788 gettr tr7, r6
789 st.q SP, FRAME_T(7), r6
790
791 ! setup FP so that unwinder can wind back through nested kernel mode
792 ! exceptions
793 add SP, ZERO, r14
794
795#ifdef CONFIG_POOR_MANS_STRACE
796 /* We've pushed all the registers now, so only r2-r4 hold anything
797 * useful. Move them into callee save registers */
798 or r2, ZERO, r28
799 or r3, ZERO, r29
800 or r4, ZERO, r30
801
802 /* Preserve r2 as the event code */
803 movi evt_debug, r3
804 ori r3, 1, r3
805 ptabs r3, tr0
806
807 or SP, ZERO, r6
808 getcon TRA, r5
809 blink tr0, LINK
810
811 or r28, ZERO, r2
812 or r29, ZERO, r3
813 or r30, ZERO, r4
814#endif
815
816 /* For syscall and debug race condition, get TRA now */
817 getcon TRA, r5
818
819 /* We are in a safe position to turn SR.BL off, but set IMASK=0xf
820 * Also set FD, to catch FPU usage in the kernel.
821 *
822 * benedict.gaster@superh.com 29/07/2002
823 *
824 * On all SH5-101 revisions it is unsafe to raise the IMASK and at the
825 * same time change BL from 1->0, as any pending interrupt of a level
826 * higher than he previous value of IMASK will leak through and be
827 * taken unexpectedly.
828 *
829 * To avoid this we raise the IMASK and then issue another PUTCON to
830 * enable interrupts.
831 */
832 getcon SR, r6
833 movi SR_IMASK | SR_FD, r7
834 or r6, r7, r6
835 putcon r6, SR
836 movi SR_UNBLOCK_EXC, r7
837 and r6, r7, r6
838 putcon r6, SR
839
840
841 /* Now call the appropriate 3rd level handler */
842 or r3, ZERO, LINK
843 movi trap_jtable, r3
844 shlri r2, 3, r2
845 ldx.l r2, r3, r3
846 shlri r2, 2, r2
847 ptabs r3, tr0
848 or SP, ZERO, r3
849 blink tr0, ZERO
850
851/*
852 * Second level handler for VBR-based exceptions. Post-handlers.
853 *
854 * Post-handlers for interrupts (ret_from_irq), exceptions
855 * (ret_from_exception) and common reentrance doors (restore_all
856 * to get back to the original context, ret_from_syscall loop to
857 * check kernel exiting).
858 *
859 * ret_with_reschedule and work_notifysig are an inner lables of
860 * the ret_from_syscall loop.
861 *
862 * In common to all stack-frame sensitive handlers.
863 *
864 * Inputs:
865 * (SP) struct pt_regs *, original register's frame pointer (basic)
866 *
867 */
868 .global ret_from_irq
869ret_from_irq:
870#ifdef CONFIG_POOR_MANS_STRACE
871 pta evt_debug_ret_from_irq, tr0
872 ori SP, 0, r2
873 blink tr0, LINK
874#endif
875 ld.q SP, FRAME_S(FSSR), r6
876 shlri r6, 30, r6
877 andi r6, 1, r6
878 pta resume_kernel, tr0
879 bne r6, ZERO, tr0 /* no further checks */
880 STI()
881 pta ret_with_reschedule, tr0
882 blink tr0, ZERO /* Do not check softirqs */
883
884 .global ret_from_exception
885ret_from_exception:
886 preempt_stop()
887
888#ifdef CONFIG_POOR_MANS_STRACE
889 pta evt_debug_ret_from_exc, tr0
890 ori SP, 0, r2
891 blink tr0, LINK
892#endif
893
894 ld.q SP, FRAME_S(FSSR), r6
895 shlri r6, 30, r6
896 andi r6, 1, r6
897 pta resume_kernel, tr0
898 bne r6, ZERO, tr0 /* no further checks */
899
900 /* Check softirqs */
901
902#ifdef CONFIG_PREEMPT
903 pta ret_from_syscall, tr0
904 blink tr0, ZERO
905
906resume_kernel:
907 pta restore_all, tr0
908
909 getcon KCR0, r6
910 ld.l r6, TI_PRE_COUNT, r7
911 beq/u r7, ZERO, tr0
912
913need_resched:
914 ld.l r6, TI_FLAGS, r7
915 movi (1 << TIF_NEED_RESCHED), r8
916 and r8, r7, r8
917 bne r8, ZERO, tr0
918
919 getcon SR, r7
920 andi r7, 0xf0, r7
921 bne r7, ZERO, tr0
922
923 movi ((PREEMPT_ACTIVE >> 16) & 65535), r8
924 shori (PREEMPT_ACTIVE & 65535), r8
925 st.l r6, TI_PRE_COUNT, r8
926
927 STI()
928 movi schedule, r7
929 ori r7, 1, r7
930 ptabs r7, tr1
931 blink tr1, LINK
932
933 st.l r6, TI_PRE_COUNT, ZERO
934 CLI()
935
936 pta need_resched, tr1
937 blink tr1, ZERO
938#endif
939
940 .global ret_from_syscall
941ret_from_syscall:
942
943ret_with_reschedule:
944 getcon KCR0, r6 ! r6 contains current_thread_info
945 ld.l r6, TI_FLAGS, r7 ! r7 contains current_thread_info->flags
946
947 ! FIXME:!!!
948 ! no handling of TIF_SYSCALL_TRACE yet!!
949
950 movi _TIF_NEED_RESCHED, r8
951 and r8, r7, r8
952 pta work_resched, tr0
953 bne r8, ZERO, tr0
954
955 pta restore_all, tr1
956
957 movi (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK), r8
958 and r8, r7, r8
959 pta work_notifysig, tr0
960 bne r8, ZERO, tr0
961
962 blink tr1, ZERO
963
964work_resched:
965 pta ret_from_syscall, tr0
966 gettr tr0, LINK
967 movi schedule, r6
968 ptabs r6, tr0
969 blink tr0, ZERO /* Call schedule(), return on top */
970
971work_notifysig:
972 gettr tr1, LINK
973
974 movi do_signal, r6
975 ptabs r6, tr0
976 or SP, ZERO, r2
977 or ZERO, ZERO, r3
978 blink tr0, LINK /* Call do_signal(regs, 0), return here */
979
980restore_all:
981 /* Do prefetches */
982
983 ld.q SP, FRAME_T(0), r6
984 ld.q SP, FRAME_T(1), r7
985 ld.q SP, FRAME_T(2), r8
986 ld.q SP, FRAME_T(3), r9
987 ptabs r6, tr0
988 ptabs r7, tr1
989 ptabs r8, tr2
990 ptabs r9, tr3
991 ld.q SP, FRAME_T(4), r6
992 ld.q SP, FRAME_T(5), r7
993 ld.q SP, FRAME_T(6), r8
994 ld.q SP, FRAME_T(7), r9
995 ptabs r6, tr4
996 ptabs r7, tr5
997 ptabs r8, tr6
998 ptabs r9, tr7
999
1000 ld.q SP, FRAME_R(0), r0
1001 ld.q SP, FRAME_R(1), r1
1002 ld.q SP, FRAME_R(2), r2
1003 ld.q SP, FRAME_R(3), r3
1004 ld.q SP, FRAME_R(4), r4
1005 ld.q SP, FRAME_R(5), r5
1006 ld.q SP, FRAME_R(6), r6
1007 ld.q SP, FRAME_R(7), r7
1008 ld.q SP, FRAME_R(8), r8
1009 ld.q SP, FRAME_R(9), r9
1010 ld.q SP, FRAME_R(10), r10
1011 ld.q SP, FRAME_R(11), r11
1012 ld.q SP, FRAME_R(12), r12
1013 ld.q SP, FRAME_R(13), r13
1014 ld.q SP, FRAME_R(14), r14
1015
1016 ld.q SP, FRAME_R(16), r16
1017 ld.q SP, FRAME_R(17), r17
1018 ld.q SP, FRAME_R(18), r18
1019 ld.q SP, FRAME_R(19), r19
1020 ld.q SP, FRAME_R(20), r20
1021 ld.q SP, FRAME_R(21), r21
1022 ld.q SP, FRAME_R(22), r22
1023 ld.q SP, FRAME_R(23), r23
1024 ld.q SP, FRAME_R(24), r24
1025 ld.q SP, FRAME_R(25), r25
1026 ld.q SP, FRAME_R(26), r26
1027 ld.q SP, FRAME_R(27), r27
1028 ld.q SP, FRAME_R(28), r28
1029 ld.q SP, FRAME_R(29), r29
1030 ld.q SP, FRAME_R(30), r30
1031 ld.q SP, FRAME_R(31), r31
1032 ld.q SP, FRAME_R(32), r32
1033 ld.q SP, FRAME_R(33), r33
1034 ld.q SP, FRAME_R(34), r34
1035 ld.q SP, FRAME_R(35), r35
1036 ld.q SP, FRAME_R(36), r36
1037 ld.q SP, FRAME_R(37), r37
1038 ld.q SP, FRAME_R(38), r38
1039 ld.q SP, FRAME_R(39), r39
1040 ld.q SP, FRAME_R(40), r40
1041 ld.q SP, FRAME_R(41), r41
1042 ld.q SP, FRAME_R(42), r42
1043 ld.q SP, FRAME_R(43), r43
1044 ld.q SP, FRAME_R(44), r44
1045 ld.q SP, FRAME_R(45), r45
1046 ld.q SP, FRAME_R(46), r46
1047 ld.q SP, FRAME_R(47), r47
1048 ld.q SP, FRAME_R(48), r48
1049 ld.q SP, FRAME_R(49), r49
1050 ld.q SP, FRAME_R(50), r50
1051 ld.q SP, FRAME_R(51), r51
1052 ld.q SP, FRAME_R(52), r52
1053 ld.q SP, FRAME_R(53), r53
1054 ld.q SP, FRAME_R(54), r54
1055 ld.q SP, FRAME_R(55), r55
1056 ld.q SP, FRAME_R(56), r56
1057 ld.q SP, FRAME_R(57), r57
1058 ld.q SP, FRAME_R(58), r58
1059
1060 getcon SR, r59
1061 movi SR_BLOCK_EXC, r60
1062 or r59, r60, r59
1063 putcon r59, SR /* SR.BL = 1, keep nesting out */
1064 ld.q SP, FRAME_S(FSSR), r61
1065 ld.q SP, FRAME_S(FSPC), r62
1066 movi SR_ASID_MASK, r60
1067 and r59, r60, r59
1068 andc r61, r60, r61 /* Clear out older ASID */
1069 or r59, r61, r61 /* Retain current ASID */
1070 putcon r61, SSR
1071 putcon r62, SPC
1072
1073 /* Ignore FSYSCALL_ID */
1074
1075 ld.q SP, FRAME_R(59), r59
1076 ld.q SP, FRAME_R(60), r60
1077 ld.q SP, FRAME_R(61), r61
1078 ld.q SP, FRAME_R(62), r62
1079
1080 /* Last touch */
1081 ld.q SP, FRAME_R(15), SP
1082 rte
1083 nop
1084
1085/*
1086 * Third level handlers for VBR-based exceptions. Adapting args to
1087 * and/or deflecting to fourth level handlers.
1088 *
1089 * Fourth level handlers interface.
1090 * Most are C-coded handlers directly pointed by the trap_jtable.
1091 * (Third = Fourth level)
1092 * Inputs:
1093 * (r2) fault/interrupt code, entry number (e.g. NMI = 14,
1094 * IRL0-3 (0000) = 16, RTLBMISS = 2, SYSCALL = 11, etc ...)
1095 * (r3) struct pt_regs *, original register's frame pointer
1096 * (r4) Event (0 = interrupt, 1 = TLB miss fault, 2 = Not TLB miss fault)
1097 * (r5) TRA control register (for syscall/debug benefit only)
1098 * (LINK) return address
1099 * (SP) = r3
1100 *
1101 * Kernel TLB fault handlers will get a slightly different interface.
1102 * (r2) struct pt_regs *, original register's frame pointer
1103 * (r3) writeaccess, whether it's a store fault as opposed to load fault
1104 * (r4) execaccess, whether it's a ITLB fault as opposed to DTLB fault
1105 * (r5) Effective Address of fault
1106 * (LINK) return address
1107 * (SP) = r2
1108 *
1109 * fpu_error_or_IRQ? is a helper to deflect to the right cause.
1110 *
1111 */
1112tlb_miss_load:
1113 or SP, ZERO, r2
1114 or ZERO, ZERO, r3 /* Read */
1115 or ZERO, ZERO, r4 /* Data */
1116 getcon TEA, r5
1117 pta call_do_page_fault, tr0
1118 beq ZERO, ZERO, tr0
1119
1120tlb_miss_store:
1121 or SP, ZERO, r2
1122 movi 1, r3 /* Write */
1123 or ZERO, ZERO, r4 /* Data */
1124 getcon TEA, r5
1125 pta call_do_page_fault, tr0
1126 beq ZERO, ZERO, tr0
1127
1128itlb_miss_or_IRQ:
1129 pta its_IRQ, tr0
1130 beqi/u r4, EVENT_INTERRUPT, tr0
1131 or SP, ZERO, r2
1132 or ZERO, ZERO, r3 /* Read */
1133 movi 1, r4 /* Text */
1134 getcon TEA, r5
1135 /* Fall through */
1136
1137call_do_page_fault:
1138 movi do_page_fault, r6
1139 ptabs r6, tr0
1140 blink tr0, ZERO
1141
1142fpu_error_or_IRQA:
1143 pta its_IRQ, tr0
1144 beqi/l r4, EVENT_INTERRUPT, tr0
1145#ifdef CONFIG_SH_FPU
1146 movi do_fpu_state_restore, r6
1147#else
1148 movi do_exception_error, r6
1149#endif
1150 ptabs r6, tr0
1151 blink tr0, ZERO
1152
1153fpu_error_or_IRQB:
1154 pta its_IRQ, tr0
1155 beqi/l r4, EVENT_INTERRUPT, tr0
1156#ifdef CONFIG_SH_FPU
1157 movi do_fpu_state_restore, r6
1158#else
1159 movi do_exception_error, r6
1160#endif
1161 ptabs r6, tr0
1162 blink tr0, ZERO
1163
1164its_IRQ:
1165 movi do_IRQ, r6
1166 ptabs r6, tr0
1167 blink tr0, ZERO
1168
1169/*
1170 * system_call/unknown_trap third level handler:
1171 *
1172 * Inputs:
1173 * (r2) fault/interrupt code, entry number (TRAP = 11)
1174 * (r3) struct pt_regs *, original register's frame pointer
1175 * (r4) Not used. Event (0=interrupt, 1=TLB miss fault, 2=Not TLB miss fault)
1176 * (r5) TRA Control Reg (0x00xyzzzz: x=1 SYSCALL, y = #args, z=nr)
1177 * (SP) = r3
1178 * (LINK) return address: ret_from_exception
1179 * (*r3) Syscall parms: SC#, arg0, arg1, ..., arg5 in order (Saved r2/r7)
1180 *
1181 * Outputs:
1182 * (*r3) Syscall reply (Saved r2)
1183 * (LINK) In case of syscall only it can be scrapped.
1184 * Common second level post handler will be ret_from_syscall.
1185 * Common (non-trace) exit point to that is syscall_ret (saving
1186 * result to r2). Common bad exit point is syscall_bad (returning
1187 * ENOSYS then saved to r2).
1188 *
1189 */
1190
1191unknown_trap:
1192 /* Unknown Trap or User Trace */
1193 movi do_unknown_trapa, r6
1194 ptabs r6, tr0
1195 ld.q r3, FRAME_R(9), r2 /* r2 = #arg << 16 | syscall # */
1196 andi r2, 0x1ff, r2 /* r2 = syscall # */
1197 blink tr0, LINK
1198
1199 pta syscall_ret, tr0
1200 blink tr0, ZERO
1201
1202 /* New syscall implementation*/
1203system_call:
1204 pta unknown_trap, tr0
1205 or r5, ZERO, r4 /* TRA (=r5) -> r4 */
1206 shlri r4, 20, r4
1207 bnei r4, 1, tr0 /* unknown_trap if not 0x1yzzzz */
1208
1209 /* It's a system call */
1210 st.q r3, FRAME_S(FSYSCALL_ID), r5 /* ID (0x1yzzzz) -> stack */
1211 andi r5, 0x1ff, r5 /* syscall # -> r5 */
1212
1213 STI()
1214
1215 pta syscall_allowed, tr0
1216 movi NR_syscalls - 1, r4 /* Last valid */
1217 bgeu/l r4, r5, tr0
1218
1219syscall_bad:
1220 /* Return ENOSYS ! */
1221 movi -(ENOSYS), r2 /* Fall-through */
1222
1223 .global syscall_ret
1224syscall_ret:
1225 st.q SP, FRAME_R(9), r2 /* Expecting SP back to BASIC frame */
1226
1227#ifdef CONFIG_POOR_MANS_STRACE
1228 /* nothing useful in registers at this point */
1229
1230 movi evt_debug2, r5
1231 ori r5, 1, r5
1232 ptabs r5, tr0
1233 ld.q SP, FRAME_R(9), r2
1234 or SP, ZERO, r3
1235 blink tr0, LINK
1236#endif
1237
1238 ld.q SP, FRAME_S(FSPC), r2
1239 addi r2, 4, r2 /* Move PC, being pre-execution event */
1240 st.q SP, FRAME_S(FSPC), r2
1241 pta ret_from_syscall, tr0
1242 blink tr0, ZERO
1243
1244
1245/* A different return path for ret_from_fork, because we now need
1246 * to call schedule_tail with the later kernels. Because prev is
1247 * loaded into r2 by switch_to() means we can just call it straight away
1248 */
1249
1250.global ret_from_fork
1251ret_from_fork:
1252
1253 movi schedule_tail,r5
1254 ori r5, 1, r5
1255 ptabs r5, tr0
1256 blink tr0, LINK
1257
1258#ifdef CONFIG_POOR_MANS_STRACE
1259 /* nothing useful in registers at this point */
1260
1261 movi evt_debug2, r5
1262 ori r5, 1, r5
1263 ptabs r5, tr0
1264 ld.q SP, FRAME_R(9), r2
1265 or SP, ZERO, r3
1266 blink tr0, LINK
1267#endif
1268
1269 ld.q SP, FRAME_S(FSPC), r2
1270 addi r2, 4, r2 /* Move PC, being pre-execution event */
1271 st.q SP, FRAME_S(FSPC), r2
1272 pta ret_from_syscall, tr0
1273 blink tr0, ZERO
1274
1275
1276
1277syscall_allowed:
1278 /* Use LINK to deflect the exit point, default is syscall_ret */
1279 pta syscall_ret, tr0
1280 gettr tr0, LINK
1281 pta syscall_notrace, tr0
1282
1283 getcon KCR0, r2
1284 ld.l r2, TI_FLAGS, r4
1285 movi (1 << TIF_SYSCALL_TRACE), r6
1286 and r6, r4, r6
1287 beq/l r6, ZERO, tr0
1288
1289 /* Trace it by calling syscall_trace before and after */
1290 movi syscall_trace, r4
1291 ptabs r4, tr0
1292 blink tr0, LINK
1293 /* Reload syscall number as r5 is trashed by syscall_trace */
1294 ld.q SP, FRAME_S(FSYSCALL_ID), r5
1295 andi r5, 0x1ff, r5
1296
1297 pta syscall_ret_trace, tr0
1298 gettr tr0, LINK
1299
1300syscall_notrace:
1301 /* Now point to the appropriate 4th level syscall handler */
1302 movi sys_call_table, r4
1303 shlli r5, 2, r5
1304 ldx.l r4, r5, r5
1305 ptabs r5, tr0
1306
1307 /* Prepare original args */
1308 ld.q SP, FRAME_R(2), r2
1309 ld.q SP, FRAME_R(3), r3
1310 ld.q SP, FRAME_R(4), r4
1311 ld.q SP, FRAME_R(5), r5
1312 ld.q SP, FRAME_R(6), r6
1313 ld.q SP, FRAME_R(7), r7
1314
1315 /* And now the trick for those syscalls requiring regs * ! */
1316 or SP, ZERO, r8
1317
1318 /* Call it */
1319 blink tr0, ZERO /* LINK is already properly set */
1320
1321syscall_ret_trace:
1322 /* We get back here only if under trace */
1323 st.q SP, FRAME_R(9), r2 /* Save return value */
1324
1325 movi syscall_trace, LINK
1326 ptabs LINK, tr0
1327 blink tr0, LINK
1328
1329 /* This needs to be done after any syscall tracing */
1330 ld.q SP, FRAME_S(FSPC), r2
1331 addi r2, 4, r2 /* Move PC, being pre-execution event */
1332 st.q SP, FRAME_S(FSPC), r2
1333
1334 pta ret_from_syscall, tr0
1335 blink tr0, ZERO /* Resume normal return sequence */
1336
1337/*
1338 * --- Switch to running under a particular ASID and return the previous ASID value
1339 * --- The caller is assumed to have done a cli before calling this.
1340 *
1341 * Input r2 : new ASID
1342 * Output r2 : old ASID
1343 */
1344
1345 .global switch_and_save_asid
1346switch_and_save_asid:
1347 getcon sr, r0
1348 movi 255, r4
1349 shlli r4, 16, r4 /* r4 = mask to select ASID */
1350 and r0, r4, r3 /* r3 = shifted old ASID */
1351 andi r2, 255, r2 /* mask down new ASID */
1352 shlli r2, 16, r2 /* align new ASID against SR.ASID */
1353 andc r0, r4, r0 /* efface old ASID from SR */
1354 or r0, r2, r0 /* insert the new ASID */
1355 putcon r0, ssr
1356 movi 1f, r0
1357 putcon r0, spc
1358 rte
1359 nop
13601:
1361 ptabs LINK, tr0
1362 shlri r3, 16, r2 /* r2 = old ASID */
1363 blink tr0, r63
1364
1365 .global route_to_panic_handler
1366route_to_panic_handler:
1367 /* Switch to real mode, goto panic_handler, don't return. Useful for
1368 last-chance debugging, e.g. if no output wants to go to the console.
1369 */
1370
1371 movi panic_handler - CONFIG_CACHED_MEMORY_OFFSET, r1
1372 ptabs r1, tr0
1373 pta 1f, tr1
1374 gettr tr1, r0
1375 putcon r0, spc
1376 getcon sr, r0
1377 movi 1, r1
1378 shlli r1, 31, r1
1379 andc r0, r1, r0
1380 putcon r0, ssr
1381 rte
1382 nop
13831: /* Now in real mode */
1384 blink tr0, r63
1385 nop
1386
1387 .global peek_real_address_q
1388peek_real_address_q:
1389 /* Two args:
1390 r2 : real mode address to peek
1391 r2(out) : result quadword
1392
1393 This is provided as a cheapskate way of manipulating device
1394 registers for debugging (to avoid the need to onchip_remap the debug
1395 module, and to avoid the need to onchip_remap the watchpoint
1396 controller in a way that identity maps sufficient bits to avoid the
1397 SH5-101 cut2 silicon defect).
1398
1399 This code is not performance critical
1400 */
1401
1402 add.l r2, r63, r2 /* sign extend address */
1403 getcon sr, r0 /* r0 = saved original SR */
1404 movi 1, r1
1405 shlli r1, 28, r1
1406 or r0, r1, r1 /* r0 with block bit set */
1407 putcon r1, sr /* now in critical section */
1408 movi 1, r36
1409 shlli r36, 31, r36
1410 andc r1, r36, r1 /* turn sr.mmu off in real mode section */
1411
1412 putcon r1, ssr
1413 movi .peek0 - CONFIG_CACHED_MEMORY_OFFSET, r36 /* real mode target address */
1414 movi 1f, r37 /* virtual mode return addr */
1415 putcon r36, spc
1416
1417 synco
1418 rte
1419 nop
1420
1421.peek0: /* come here in real mode, don't touch caches!!
1422 still in critical section (sr.bl==1) */
1423 putcon r0, ssr
1424 putcon r37, spc
1425 /* Here's the actual peek. If the address is bad, all bets are now off
1426 * what will happen (handlers invoked in real-mode = bad news) */
1427 ld.q r2, 0, r2
1428 synco
1429 rte /* Back to virtual mode */
1430 nop
1431
14321:
1433 ptabs LINK, tr0
1434 blink tr0, r63
1435
1436 .global poke_real_address_q
1437poke_real_address_q:
1438 /* Two args:
1439 r2 : real mode address to poke
1440 r3 : quadword value to write.
1441
1442 This is provided as a cheapskate way of manipulating device
1443 registers for debugging (to avoid the need to onchip_remap the debug
1444 module, and to avoid the need to onchip_remap the watchpoint
1445 controller in a way that identity maps sufficient bits to avoid the
1446 SH5-101 cut2 silicon defect).
1447
1448 This code is not performance critical
1449 */
1450
1451 add.l r2, r63, r2 /* sign extend address */
1452 getcon sr, r0 /* r0 = saved original SR */
1453 movi 1, r1
1454 shlli r1, 28, r1
1455 or r0, r1, r1 /* r0 with block bit set */
1456 putcon r1, sr /* now in critical section */
1457 movi 1, r36
1458 shlli r36, 31, r36
1459 andc r1, r36, r1 /* turn sr.mmu off in real mode section */
1460
1461 putcon r1, ssr
1462 movi .poke0-CONFIG_CACHED_MEMORY_OFFSET, r36 /* real mode target address */
1463 movi 1f, r37 /* virtual mode return addr */
1464 putcon r36, spc
1465
1466 synco
1467 rte
1468 nop
1469
1470.poke0: /* come here in real mode, don't touch caches!!
1471 still in critical section (sr.bl==1) */
1472 putcon r0, ssr
1473 putcon r37, spc
1474 /* Here's the actual poke. If the address is bad, all bets are now off
1475 * what will happen (handlers invoked in real-mode = bad news) */
1476 st.q r2, 0, r3
1477 synco
1478 rte /* Back to virtual mode */
1479 nop
1480
14811:
1482 ptabs LINK, tr0
1483 blink tr0, r63
1484
1485/*
1486 * --- User Access Handling Section
1487 */
1488
1489/*
1490 * User Access support. It all moved to non inlined Assembler
1491 * functions in here.
1492 *
1493 * __kernel_size_t __copy_user(void *__to, const void *__from,
1494 * __kernel_size_t __n)
1495 *
1496 * Inputs:
1497 * (r2) target address
1498 * (r3) source address
1499 * (r4) size in bytes
1500 *
1501 * Ouputs:
1502 * (*r2) target data
1503 * (r2) non-copied bytes
1504 *
1505 * If a fault occurs on the user pointer, bail out early and return the
1506 * number of bytes not copied in r2.
1507 * Strategy : for large blocks, call a real memcpy function which can
1508 * move >1 byte at a time using unaligned ld/st instructions, and can
1509 * manipulate the cache using prefetch + alloco to improve the speed
1510 * further. If a fault occurs in that function, just revert to the
1511 * byte-by-byte approach used for small blocks; this is rare so the
1512 * performance hit for that case does not matter.
1513 *
1514 * For small blocks it's not worth the overhead of setting up and calling
1515 * the memcpy routine; do the copy a byte at a time.
1516 *
1517 */
1518 .global __copy_user
1519__copy_user:
1520 pta __copy_user_byte_by_byte, tr1
1521 movi 16, r0 ! this value is a best guess, should tune it by benchmarking
1522 bge/u r0, r4, tr1
1523 pta copy_user_memcpy, tr0
1524 addi SP, -32, SP
1525 /* Save arguments in case we have to fix-up unhandled page fault */
1526 st.q SP, 0, r2
1527 st.q SP, 8, r3
1528 st.q SP, 16, r4
1529 st.q SP, 24, r35 ! r35 is callee-save
1530 /* Save LINK in a register to reduce RTS time later (otherwise
1531 ld SP,*,LINK;ptabs LINK;trn;blink trn,r63 becomes a critical path) */
1532 ori LINK, 0, r35
1533 blink tr0, LINK
1534
1535 /* Copy completed normally if we get back here */
1536 ptabs r35, tr0
1537 ld.q SP, 24, r35
1538 /* don't restore r2-r4, pointless */
1539 /* set result=r2 to zero as the copy must have succeeded. */
1540 or r63, r63, r2
1541 addi SP, 32, SP
1542 blink tr0, r63 ! RTS
1543
1544 .global __copy_user_fixup
1545__copy_user_fixup:
1546 /* Restore stack frame */
1547 ori r35, 0, LINK
1548 ld.q SP, 24, r35
1549 ld.q SP, 16, r4
1550 ld.q SP, 8, r3
1551 ld.q SP, 0, r2
1552 addi SP, 32, SP
1553 /* Fall through to original code, in the 'same' state we entered with */
1554
1555/* The slow byte-by-byte method is used if the fast copy traps due to a bad
1556 user address. In that rare case, the speed drop can be tolerated. */
1557__copy_user_byte_by_byte:
1558 pta ___copy_user_exit, tr1
1559 pta ___copy_user1, tr0
1560 beq/u r4, r63, tr1 /* early exit for zero length copy */
1561 sub r2, r3, r0
1562 addi r0, -1, r0
1563
1564___copy_user1:
1565 ld.b r3, 0, r5 /* Fault address 1 */
1566
1567 /* Could rewrite this to use just 1 add, but the second comes 'free'
1568 due to load latency */
1569 addi r3, 1, r3
1570 addi r4, -1, r4 /* No real fixup required */
1571___copy_user2:
1572 stx.b r3, r0, r5 /* Fault address 2 */
1573 bne r4, ZERO, tr0
1574
1575___copy_user_exit:
1576 or r4, ZERO, r2
1577 ptabs LINK, tr0
1578 blink tr0, ZERO
1579
1580/*
1581 * __kernel_size_t __clear_user(void *addr, __kernel_size_t size)
1582 *
1583 * Inputs:
1584 * (r2) target address
1585 * (r3) size in bytes
1586 *
1587 * Ouputs:
1588 * (*r2) zero-ed target data
1589 * (r2) non-zero-ed bytes
1590 */
1591 .global __clear_user
1592__clear_user:
1593 pta ___clear_user_exit, tr1
1594 pta ___clear_user1, tr0
1595 beq/u r3, r63, tr1
1596
1597___clear_user1:
1598 st.b r2, 0, ZERO /* Fault address */
1599 addi r2, 1, r2
1600 addi r3, -1, r3 /* No real fixup required */
1601 bne r3, ZERO, tr0
1602
1603___clear_user_exit:
1604 or r3, ZERO, r2
1605 ptabs LINK, tr0
1606 blink tr0, ZERO
1607
1608
1609/*
1610 * int __strncpy_from_user(unsigned long __dest, unsigned long __src,
1611 * int __count)
1612 *
1613 * Inputs:
1614 * (r2) target address
1615 * (r3) source address
1616 * (r4) maximum size in bytes
1617 *
1618 * Ouputs:
1619 * (*r2) copied data
1620 * (r2) -EFAULT (in case of faulting)
1621 * copied data (otherwise)
1622 */
1623 .global __strncpy_from_user
1624__strncpy_from_user:
1625 pta ___strncpy_from_user1, tr0
1626 pta ___strncpy_from_user_done, tr1
1627 or r4, ZERO, r5 /* r5 = original count */
1628 beq/u r4, r63, tr1 /* early exit if r4==0 */
1629 movi -(EFAULT), r6 /* r6 = reply, no real fixup */
1630 or ZERO, ZERO, r7 /* r7 = data, clear top byte of data */
1631
1632___strncpy_from_user1:
1633 ld.b r3, 0, r7 /* Fault address: only in reading */
1634 st.b r2, 0, r7
1635 addi r2, 1, r2
1636 addi r3, 1, r3
1637 beq/u ZERO, r7, tr1
1638 addi r4, -1, r4 /* return real number of copied bytes */
1639 bne/l ZERO, r4, tr0
1640
1641___strncpy_from_user_done:
1642 sub r5, r4, r6 /* If done, return copied */
1643
1644___strncpy_from_user_exit:
1645 or r6, ZERO, r2
1646 ptabs LINK, tr0
1647 blink tr0, ZERO
1648
1649/*
1650 * extern long __strnlen_user(const char *__s, long __n)
1651 *
1652 * Inputs:
1653 * (r2) source address
1654 * (r3) source size in bytes
1655 *
1656 * Ouputs:
1657 * (r2) -EFAULT (in case of faulting)
1658 * string length (otherwise)
1659 */
1660 .global __strnlen_user
1661__strnlen_user:
1662 pta ___strnlen_user_set_reply, tr0
1663 pta ___strnlen_user1, tr1
1664 or ZERO, ZERO, r5 /* r5 = counter */
1665 movi -(EFAULT), r6 /* r6 = reply, no real fixup */
1666 or ZERO, ZERO, r7 /* r7 = data, clear top byte of data */
1667 beq r3, ZERO, tr0
1668
1669___strnlen_user1:
1670 ldx.b r2, r5, r7 /* Fault address: only in reading */
1671 addi r3, -1, r3 /* No real fixup */
1672 addi r5, 1, r5
1673 beq r3, ZERO, tr0
1674 bne r7, ZERO, tr1
1675! The line below used to be active. This meant led to a junk byte lying between each pair
1676! of entries in the argv & envp structures in memory. Whilst the program saw the right data
1677! via the argv and envp arguments to main, it meant the 'flat' representation visible through
1678! /proc/$pid/cmdline was corrupt, causing trouble with ps, for example.
1679! addi r5, 1, r5 /* Include '\0' */
1680
1681___strnlen_user_set_reply:
1682 or r5, ZERO, r6 /* If done, return counter */
1683
1684___strnlen_user_exit:
1685 or r6, ZERO, r2
1686 ptabs LINK, tr0
1687 blink tr0, ZERO
1688
1689/*
1690 * extern long __get_user_asm_?(void *val, long addr)
1691 *
1692 * Inputs:
1693 * (r2) dest address
1694 * (r3) source address (in User Space)
1695 *
1696 * Ouputs:
1697 * (r2) -EFAULT (faulting)
1698 * 0 (not faulting)
1699 */
1700 .global __get_user_asm_b
1701__get_user_asm_b:
1702 or r2, ZERO, r4
1703 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1704
1705___get_user_asm_b1:
1706 ld.b r3, 0, r5 /* r5 = data */
1707 st.b r4, 0, r5
1708 or ZERO, ZERO, r2
1709
1710___get_user_asm_b_exit:
1711 ptabs LINK, tr0
1712 blink tr0, ZERO
1713
1714
1715 .global __get_user_asm_w
1716__get_user_asm_w:
1717 or r2, ZERO, r4
1718 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1719
1720___get_user_asm_w1:
1721 ld.w r3, 0, r5 /* r5 = data */
1722 st.w r4, 0, r5
1723 or ZERO, ZERO, r2
1724
1725___get_user_asm_w_exit:
1726 ptabs LINK, tr0
1727 blink tr0, ZERO
1728
1729
1730 .global __get_user_asm_l
1731__get_user_asm_l:
1732 or r2, ZERO, r4
1733 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1734
1735___get_user_asm_l1:
1736 ld.l r3, 0, r5 /* r5 = data */
1737 st.l r4, 0, r5
1738 or ZERO, ZERO, r2
1739
1740___get_user_asm_l_exit:
1741 ptabs LINK, tr0
1742 blink tr0, ZERO
1743
1744
1745 .global __get_user_asm_q
1746__get_user_asm_q:
1747 or r2, ZERO, r4
1748 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1749
1750___get_user_asm_q1:
1751 ld.q r3, 0, r5 /* r5 = data */
1752 st.q r4, 0, r5
1753 or ZERO, ZERO, r2
1754
1755___get_user_asm_q_exit:
1756 ptabs LINK, tr0
1757 blink tr0, ZERO
1758
1759/*
1760 * extern long __put_user_asm_?(void *pval, long addr)
1761 *
1762 * Inputs:
1763 * (r2) kernel pointer to value
1764 * (r3) dest address (in User Space)
1765 *
1766 * Ouputs:
1767 * (r2) -EFAULT (faulting)
1768 * 0 (not faulting)
1769 */
1770 .global __put_user_asm_b
1771__put_user_asm_b:
1772 ld.b r2, 0, r4 /* r4 = data */
1773 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1774
1775___put_user_asm_b1:
1776 st.b r3, 0, r4
1777 or ZERO, ZERO, r2
1778
1779___put_user_asm_b_exit:
1780 ptabs LINK, tr0
1781 blink tr0, ZERO
1782
1783
1784 .global __put_user_asm_w
1785__put_user_asm_w:
1786 ld.w r2, 0, r4 /* r4 = data */
1787 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1788
1789___put_user_asm_w1:
1790 st.w r3, 0, r4
1791 or ZERO, ZERO, r2
1792
1793___put_user_asm_w_exit:
1794 ptabs LINK, tr0
1795 blink tr0, ZERO
1796
1797
1798 .global __put_user_asm_l
1799__put_user_asm_l:
1800 ld.l r2, 0, r4 /* r4 = data */
1801 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1802
1803___put_user_asm_l1:
1804 st.l r3, 0, r4
1805 or ZERO, ZERO, r2
1806
1807___put_user_asm_l_exit:
1808 ptabs LINK, tr0
1809 blink tr0, ZERO
1810
1811
1812 .global __put_user_asm_q
1813__put_user_asm_q:
1814 ld.q r2, 0, r4 /* r4 = data */
1815 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1816
1817___put_user_asm_q1:
1818 st.q r3, 0, r4
1819 or ZERO, ZERO, r2
1820
1821___put_user_asm_q_exit:
1822 ptabs LINK, tr0
1823 blink tr0, ZERO
1824
1825panic_stash_regs:
1826 /* The idea is : when we get an unhandled panic, we dump the registers
1827 to a known memory location, the just sit in a tight loop.
1828 This allows the human to look at the memory region through the GDB
1829 session (assuming the debug module's SHwy initiator isn't locked up
1830 or anything), to hopefully analyze the cause of the panic. */
1831
1832 /* On entry, former r15 (SP) is in DCR
1833 former r0 is at resvec_saved_area + 0
1834 former r1 is at resvec_saved_area + 8
1835 former tr0 is at resvec_saved_area + 32
1836 DCR is the only register whose value is lost altogether.
1837 */
1838
1839 movi 0xffffffff80000000, r0 ! phy of dump area
1840 ld.q SP, 0x000, r1 ! former r0
1841 st.q r0, 0x000, r1
1842 ld.q SP, 0x008, r1 ! former r1
1843 st.q r0, 0x008, r1
1844 st.q r0, 0x010, r2
1845 st.q r0, 0x018, r3
1846 st.q r0, 0x020, r4
1847 st.q r0, 0x028, r5
1848 st.q r0, 0x030, r6
1849 st.q r0, 0x038, r7
1850 st.q r0, 0x040, r8
1851 st.q r0, 0x048, r9
1852 st.q r0, 0x050, r10
1853 st.q r0, 0x058, r11
1854 st.q r0, 0x060, r12
1855 st.q r0, 0x068, r13
1856 st.q r0, 0x070, r14
1857 getcon dcr, r14
1858 st.q r0, 0x078, r14
1859 st.q r0, 0x080, r16
1860 st.q r0, 0x088, r17
1861 st.q r0, 0x090, r18
1862 st.q r0, 0x098, r19
1863 st.q r0, 0x0a0, r20
1864 st.q r0, 0x0a8, r21
1865 st.q r0, 0x0b0, r22
1866 st.q r0, 0x0b8, r23
1867 st.q r0, 0x0c0, r24
1868 st.q r0, 0x0c8, r25
1869 st.q r0, 0x0d0, r26
1870 st.q r0, 0x0d8, r27
1871 st.q r0, 0x0e0, r28
1872 st.q r0, 0x0e8, r29
1873 st.q r0, 0x0f0, r30
1874 st.q r0, 0x0f8, r31
1875 st.q r0, 0x100, r32
1876 st.q r0, 0x108, r33
1877 st.q r0, 0x110, r34
1878 st.q r0, 0x118, r35
1879 st.q r0, 0x120, r36
1880 st.q r0, 0x128, r37
1881 st.q r0, 0x130, r38
1882 st.q r0, 0x138, r39
1883 st.q r0, 0x140, r40
1884 st.q r0, 0x148, r41
1885 st.q r0, 0x150, r42
1886 st.q r0, 0x158, r43
1887 st.q r0, 0x160, r44
1888 st.q r0, 0x168, r45
1889 st.q r0, 0x170, r46
1890 st.q r0, 0x178, r47
1891 st.q r0, 0x180, r48
1892 st.q r0, 0x188, r49
1893 st.q r0, 0x190, r50
1894 st.q r0, 0x198, r51
1895 st.q r0, 0x1a0, r52
1896 st.q r0, 0x1a8, r53
1897 st.q r0, 0x1b0, r54
1898 st.q r0, 0x1b8, r55
1899 st.q r0, 0x1c0, r56
1900 st.q r0, 0x1c8, r57
1901 st.q r0, 0x1d0, r58
1902 st.q r0, 0x1d8, r59
1903 st.q r0, 0x1e0, r60
1904 st.q r0, 0x1e8, r61
1905 st.q r0, 0x1f0, r62
1906 st.q r0, 0x1f8, r63 ! bogus, but for consistency's sake...
1907
1908 ld.q SP, 0x020, r1 ! former tr0
1909 st.q r0, 0x200, r1
1910 gettr tr1, r1
1911 st.q r0, 0x208, r1
1912 gettr tr2, r1
1913 st.q r0, 0x210, r1
1914 gettr tr3, r1
1915 st.q r0, 0x218, r1
1916 gettr tr4, r1
1917 st.q r0, 0x220, r1
1918 gettr tr5, r1
1919 st.q r0, 0x228, r1
1920 gettr tr6, r1
1921 st.q r0, 0x230, r1
1922 gettr tr7, r1
1923 st.q r0, 0x238, r1
1924
1925 getcon sr, r1
1926 getcon ssr, r2
1927 getcon pssr, r3
1928 getcon spc, r4
1929 getcon pspc, r5
1930 getcon intevt, r6
1931 getcon expevt, r7
1932 getcon pexpevt, r8
1933 getcon tra, r9
1934 getcon tea, r10
1935 getcon kcr0, r11
1936 getcon kcr1, r12
1937 getcon vbr, r13
1938 getcon resvec, r14
1939
1940 st.q r0, 0x240, r1
1941 st.q r0, 0x248, r2
1942 st.q r0, 0x250, r3
1943 st.q r0, 0x258, r4
1944 st.q r0, 0x260, r5
1945 st.q r0, 0x268, r6
1946 st.q r0, 0x270, r7
1947 st.q r0, 0x278, r8
1948 st.q r0, 0x280, r9
1949 st.q r0, 0x288, r10
1950 st.q r0, 0x290, r11
1951 st.q r0, 0x298, r12
1952 st.q r0, 0x2a0, r13
1953 st.q r0, 0x2a8, r14
1954
1955 getcon SPC,r2
1956 getcon SSR,r3
1957 getcon EXPEVT,r4
1958 /* Prepare to jump to C - physical address */
1959 movi panic_handler-CONFIG_CACHED_MEMORY_OFFSET, r1
1960 ori r1, 1, r1
1961 ptabs r1, tr0
1962 getcon DCR, SP
1963 blink tr0, ZERO
1964 nop
1965 nop
1966 nop
1967 nop
1968
1969
1970
1971
1972/*
1973 * --- Signal Handling Section
1974 */
1975
1976/*
1977 * extern long long _sa_default_rt_restorer
1978 * extern long long _sa_default_restorer
1979 *
1980 * or, better,
1981 *
1982 * extern void _sa_default_rt_restorer(void)
1983 * extern void _sa_default_restorer(void)
1984 *
1985 * Code prototypes to do a sys_rt_sigreturn() or sys_sysreturn()
1986 * from user space. Copied into user space by signal management.
1987 * Both must be quad aligned and 2 quad long (4 instructions).
1988 *
1989 */
1990 .balign 8
1991 .global sa_default_rt_restorer
1992sa_default_rt_restorer:
1993 movi 0x10, r9
1994 shori __NR_rt_sigreturn, r9
1995 trapa r9
1996 nop
1997
1998 .balign 8
1999 .global sa_default_restorer
2000sa_default_restorer:
2001 movi 0x10, r9
2002 shori __NR_sigreturn, r9
2003 trapa r9
2004 nop
2005
2006/*
2007 * --- __ex_table Section
2008 */
2009
2010/*
2011 * User Access Exception Table.
2012 */
2013 .section __ex_table, "a"
2014
2015 .global asm_uaccess_start /* Just a marker */
2016asm_uaccess_start:
2017
2018 .long ___copy_user1, ___copy_user_exit
2019 .long ___copy_user2, ___copy_user_exit
2020 .long ___clear_user1, ___clear_user_exit
2021 .long ___strncpy_from_user1, ___strncpy_from_user_exit
2022 .long ___strnlen_user1, ___strnlen_user_exit
2023 .long ___get_user_asm_b1, ___get_user_asm_b_exit
2024 .long ___get_user_asm_w1, ___get_user_asm_w_exit
2025 .long ___get_user_asm_l1, ___get_user_asm_l_exit
2026 .long ___get_user_asm_q1, ___get_user_asm_q_exit
2027 .long ___put_user_asm_b1, ___put_user_asm_b_exit
2028 .long ___put_user_asm_w1, ___put_user_asm_w_exit
2029 .long ___put_user_asm_l1, ___put_user_asm_l_exit
2030 .long ___put_user_asm_q1, ___put_user_asm_q_exit
2031
2032 .global asm_uaccess_end /* Just a marker */
2033asm_uaccess_end:
2034
2035
2036
2037
2038/*
2039 * --- .text.init Section
2040 */
2041
2042 .section .text.init, "ax"
2043
2044/*
2045 * void trap_init (void)
2046 *
2047 */
2048 .global trap_init
2049trap_init:
2050 addi SP, -24, SP /* Room to save r28/r29/r30 */
2051 st.q SP, 0, r28
2052 st.q SP, 8, r29
2053 st.q SP, 16, r30
2054
2055 /* Set VBR and RESVEC */
2056 movi LVBR_block, r19
2057 andi r19, -4, r19 /* reset MMUOFF + reserved */
2058 /* For RESVEC exceptions we force the MMU off, which means we need the
2059 physical address. */
2060 movi LRESVEC_block-CONFIG_CACHED_MEMORY_OFFSET, r20
2061 andi r20, -4, r20 /* reset reserved */
2062 ori r20, 1, r20 /* set MMUOFF */
2063 putcon r19, VBR
2064 putcon r20, RESVEC
2065
2066 /* Sanity check */
2067 movi LVBR_block_end, r21
2068 andi r21, -4, r21
2069 movi BLOCK_SIZE, r29 /* r29 = expected size */
2070 or r19, ZERO, r30
2071 add r19, r29, r19
2072
2073 /*
2074 * Ugly, but better loop forever now than crash afterwards.
2075 * We should print a message, but if we touch LVBR or
2076 * LRESVEC blocks we should not be surprised if we get stuck
2077 * in trap_init().
2078 */
2079 pta trap_init_loop, tr1
2080 gettr tr1, r28 /* r28 = trap_init_loop */
2081 sub r21, r30, r30 /* r30 = actual size */
2082
2083 /*
2084 * VBR/RESVEC handlers overlap by being bigger than
2085 * allowed. Very bad. Just loop forever.
2086 * (r28) panic/loop address
2087 * (r29) expected size
2088 * (r30) actual size
2089 */
2090trap_init_loop:
2091 bne r19, r21, tr1
2092
2093 /* Now that exception vectors are set up reset SR.BL */
2094 getcon SR, r22
2095 movi SR_UNBLOCK_EXC, r23
2096 and r22, r23, r22
2097 putcon r22, SR
2098
2099 addi SP, 24, SP
2100 ptabs LINK, tr0
2101 blink tr0, ZERO
2102
diff --git a/arch/sh64/kernel/fpu.c b/arch/sh64/kernel/fpu.c
deleted file mode 100644
index 8ad4ed6a6c9b..000000000000
--- a/arch/sh64/kernel/fpu.c
+++ /dev/null
@@ -1,170 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/fpu.c
7 *
8 * Copyright (C) 2001 Manuela Cirronis, Paolo Alberelli
9 * Copyright (C) 2002 STMicroelectronics Limited
10 * Author : Stuart Menefy
11 *
12 * Started from SH4 version:
13 * Copyright (C) 1999, 2000 Kaz Kojima & Niibe Yutaka
14 *
15 */
16
17#include <linux/sched.h>
18#include <linux/signal.h>
19#include <asm/processor.h>
20#include <asm/user.h>
21#include <asm/io.h>
22
23/*
24 * Initially load the FPU with signalling NANS. This bit pattern
25 * has the property that no matter whether considered as single or as
26 * double precision, it still represents a signalling NAN.
27 */
28#define sNAN64 0xFFFFFFFFFFFFFFFFULL
29#define sNAN32 0xFFFFFFFFUL
30
31static union sh_fpu_union init_fpuregs = {
32 .hard = {
33 .fp_regs = { [0 ... 63] = sNAN32 },
34 .fpscr = FPSCR_INIT
35 }
36};
37
38inline void fpsave(struct sh_fpu_hard_struct *fpregs)
39{
40 asm volatile("fst.p %0, (0*8), fp0\n\t"
41 "fst.p %0, (1*8), fp2\n\t"
42 "fst.p %0, (2*8), fp4\n\t"
43 "fst.p %0, (3*8), fp6\n\t"
44 "fst.p %0, (4*8), fp8\n\t"
45 "fst.p %0, (5*8), fp10\n\t"
46 "fst.p %0, (6*8), fp12\n\t"
47 "fst.p %0, (7*8), fp14\n\t"
48 "fst.p %0, (8*8), fp16\n\t"
49 "fst.p %0, (9*8), fp18\n\t"
50 "fst.p %0, (10*8), fp20\n\t"
51 "fst.p %0, (11*8), fp22\n\t"
52 "fst.p %0, (12*8), fp24\n\t"
53 "fst.p %0, (13*8), fp26\n\t"
54 "fst.p %0, (14*8), fp28\n\t"
55 "fst.p %0, (15*8), fp30\n\t"
56 "fst.p %0, (16*8), fp32\n\t"
57 "fst.p %0, (17*8), fp34\n\t"
58 "fst.p %0, (18*8), fp36\n\t"
59 "fst.p %0, (19*8), fp38\n\t"
60 "fst.p %0, (20*8), fp40\n\t"
61 "fst.p %0, (21*8), fp42\n\t"
62 "fst.p %0, (22*8), fp44\n\t"
63 "fst.p %0, (23*8), fp46\n\t"
64 "fst.p %0, (24*8), fp48\n\t"
65 "fst.p %0, (25*8), fp50\n\t"
66 "fst.p %0, (26*8), fp52\n\t"
67 "fst.p %0, (27*8), fp54\n\t"
68 "fst.p %0, (28*8), fp56\n\t"
69 "fst.p %0, (29*8), fp58\n\t"
70 "fst.p %0, (30*8), fp60\n\t"
71 "fst.p %0, (31*8), fp62\n\t"
72
73 "fgetscr fr63\n\t"
74 "fst.s %0, (32*8), fr63\n\t"
75 : /* no output */
76 : "r" (fpregs)
77 : "memory");
78}
79
80
81static inline void
82fpload(struct sh_fpu_hard_struct *fpregs)
83{
84 asm volatile("fld.p %0, (0*8), fp0\n\t"
85 "fld.p %0, (1*8), fp2\n\t"
86 "fld.p %0, (2*8), fp4\n\t"
87 "fld.p %0, (3*8), fp6\n\t"
88 "fld.p %0, (4*8), fp8\n\t"
89 "fld.p %0, (5*8), fp10\n\t"
90 "fld.p %0, (6*8), fp12\n\t"
91 "fld.p %0, (7*8), fp14\n\t"
92 "fld.p %0, (8*8), fp16\n\t"
93 "fld.p %0, (9*8), fp18\n\t"
94 "fld.p %0, (10*8), fp20\n\t"
95 "fld.p %0, (11*8), fp22\n\t"
96 "fld.p %0, (12*8), fp24\n\t"
97 "fld.p %0, (13*8), fp26\n\t"
98 "fld.p %0, (14*8), fp28\n\t"
99 "fld.p %0, (15*8), fp30\n\t"
100 "fld.p %0, (16*8), fp32\n\t"
101 "fld.p %0, (17*8), fp34\n\t"
102 "fld.p %0, (18*8), fp36\n\t"
103 "fld.p %0, (19*8), fp38\n\t"
104 "fld.p %0, (20*8), fp40\n\t"
105 "fld.p %0, (21*8), fp42\n\t"
106 "fld.p %0, (22*8), fp44\n\t"
107 "fld.p %0, (23*8), fp46\n\t"
108 "fld.p %0, (24*8), fp48\n\t"
109 "fld.p %0, (25*8), fp50\n\t"
110 "fld.p %0, (26*8), fp52\n\t"
111 "fld.p %0, (27*8), fp54\n\t"
112 "fld.p %0, (28*8), fp56\n\t"
113 "fld.p %0, (29*8), fp58\n\t"
114 "fld.p %0, (30*8), fp60\n\t"
115
116 "fld.s %0, (32*8), fr63\n\t"
117 "fputscr fr63\n\t"
118
119 "fld.p %0, (31*8), fp62\n\t"
120 : /* no output */
121 : "r" (fpregs) );
122}
123
124void fpinit(struct sh_fpu_hard_struct *fpregs)
125{
126 *fpregs = init_fpuregs.hard;
127}
128
129asmlinkage void
130do_fpu_error(unsigned long ex, struct pt_regs *regs)
131{
132 struct task_struct *tsk = current;
133
134 regs->pc += 4;
135
136 tsk->thread.trap_no = 11;
137 tsk->thread.error_code = 0;
138 force_sig(SIGFPE, tsk);
139}
140
141
142asmlinkage void
143do_fpu_state_restore(unsigned long ex, struct pt_regs *regs)
144{
145 void die(const char *str, struct pt_regs *regs, long err);
146
147 if (! user_mode(regs))
148 die("FPU used in kernel", regs, ex);
149
150 regs->sr &= ~SR_FD;
151
152 if (last_task_used_math == current)
153 return;
154
155 grab_fpu();
156 if (last_task_used_math != NULL) {
157 /* Other processes fpu state, save away */
158 fpsave(&last_task_used_math->thread.fpu.hard);
159 }
160 last_task_used_math = current;
161 if (used_math()) {
162 fpload(&current->thread.fpu.hard);
163 } else {
164 /* First time FPU user. */
165 fpload(&init_fpuregs.hard);
166 set_used_math();
167 }
168 release_fpu();
169}
170
diff --git a/arch/sh64/kernel/head.S b/arch/sh64/kernel/head.S
deleted file mode 100644
index 186406d3ad9c..000000000000
--- a/arch/sh64/kernel/head.S
+++ /dev/null
@@ -1,372 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/head.S
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003, 2004 Paul Mundt
10 *
11 *
12 * benedict.gaster@superh.com: 2nd May 2002
13 * Moved definition of empty_zero_page to its own section allowing
14 * it to be placed at an absolute address known at load time.
15 *
16 * lethal@linux-sh.org: 9th May 2003
17 * Kill off GLOBAL_NAME() usage.
18 *
19 * lethal@linux-sh.org: 8th May 2004
20 * Add early SCIF console DTLB mapping.
21 */
22
23
24#include <asm/page.h>
25#include <asm/mmu_context.h>
26#include <asm/cache.h>
27#include <asm/tlb.h>
28#include <asm/processor.h>
29#include <asm/registers.h>
30#include <asm/thread_info.h>
31
32/*
33 * MMU defines: TLB boundaries.
34 */
35
36#define MMUIR_FIRST ITLB_FIXED
37#define MMUIR_END ITLB_LAST_VAR_UNRESTRICTED+TLB_STEP
38#define MMUIR_STEP TLB_STEP
39
40#define MMUDR_FIRST DTLB_FIXED
41#define MMUDR_END DTLB_LAST_VAR_UNRESTRICTED+TLB_STEP
42#define MMUDR_STEP TLB_STEP
43
44/* Safety check : CONFIG_CACHED_MEMORY_OFFSET has to be a multiple of 512Mb */
45#if (CONFIG_CACHED_MEMORY_OFFSET & ((1UL<<29)-1))
46#error "CONFIG_CACHED_MEMORY_OFFSET must be a multiple of 512Mb"
47#endif
48
49/*
50 * MMU defines: Fixed TLBs.
51 */
52/* Deal safely with the case where the base of RAM is not 512Mb aligned */
53
54#define ALIGN_512M_MASK (0xffffffffe0000000)
55#define ALIGNED_EFFECTIVE ((CONFIG_CACHED_MEMORY_OFFSET + CONFIG_MEMORY_START) & ALIGN_512M_MASK)
56#define ALIGNED_PHYSICAL (CONFIG_MEMORY_START & ALIGN_512M_MASK)
57
58#define MMUIR_TEXT_H (0x0000000000000003 | ALIGNED_EFFECTIVE)
59 /* Enabled, Shared, ASID 0, Eff. Add. 0xA0000000 */
60
61#define MMUIR_TEXT_L (0x000000000000009a | ALIGNED_PHYSICAL)
62 /* 512 Mb, Cacheable, Write-back, execute, Not User, Ph. Add. */
63
64#define MMUDR_CACHED_H 0x0000000000000003 | ALIGNED_EFFECTIVE
65 /* Enabled, Shared, ASID 0, Eff. Add. 0xA0000000 */
66#define MMUDR_CACHED_L 0x000000000000015a | ALIGNED_PHYSICAL
67 /* 512 Mb, Cacheable, Write-back, read/write, Not User, Ph. Add. */
68
69#ifdef CONFIG_ICACHE_DISABLED
70#define ICCR0_INIT_VAL ICCR0_OFF /* ICACHE off */
71#else
72#define ICCR0_INIT_VAL ICCR0_ON | ICCR0_ICI /* ICE + ICI */
73#endif
74#define ICCR1_INIT_VAL ICCR1_NOLOCK /* No locking */
75
76#if defined (CONFIG_DCACHE_DISABLED)
77#define OCCR0_INIT_VAL OCCR0_OFF /* D-cache: off */
78#elif defined (CONFIG_DCACHE_WRITE_THROUGH)
79#define OCCR0_INIT_VAL OCCR0_ON | OCCR0_OCI | OCCR0_WT /* D-cache: on, */
80 /* WT, invalidate */
81#elif defined (CONFIG_DCACHE_WRITE_BACK)
82#define OCCR0_INIT_VAL OCCR0_ON | OCCR0_OCI | OCCR0_WB /* D-cache: on, */
83 /* WB, invalidate */
84#else
85#error preprocessor flag CONFIG_DCACHE_... not recognized!
86#endif
87
88#define OCCR1_INIT_VAL OCCR1_NOLOCK /* No locking */
89
90 .section .empty_zero_page, "aw"
91 .global empty_zero_page
92
93empty_zero_page:
94 .long 1 /* MOUNT_ROOT_RDONLY */
95 .long 0 /* RAMDISK_FLAGS */
96 .long 0x0200 /* ORIG_ROOT_DEV */
97 .long 1 /* LOADER_TYPE */
98 .long 0x00800000 /* INITRD_START */
99 .long 0x00800000 /* INITRD_SIZE */
100 .long 0
101
102 .text
103 .balign 4096,0,4096
104
105 .section .data, "aw"
106 .balign PAGE_SIZE
107
108 .section .data, "aw"
109 .balign PAGE_SIZE
110
111 .global swapper_pg_dir
112swapper_pg_dir:
113 .space PAGE_SIZE, 0
114
115 .global empty_bad_page
116empty_bad_page:
117 .space PAGE_SIZE, 0
118
119 .global empty_bad_pte_table
120empty_bad_pte_table:
121 .space PAGE_SIZE, 0
122
123 .global fpu_in_use
124fpu_in_use: .quad 0
125
126
127 .section .text.head, "ax"
128 .balign L1_CACHE_BYTES
129/*
130 * Condition at the entry of __stext:
131 * . Reset state:
132 * . SR.FD = 1 (FPU disabled)
133 * . SR.BL = 1 (Exceptions disabled)
134 * . SR.MD = 1 (Privileged Mode)
135 * . SR.MMU = 0 (MMU Disabled)
136 * . SR.CD = 0 (CTC User Visible)
137 * . SR.IMASK = Undefined (Interrupt Mask)
138 *
139 * Operations supposed to be performed by __stext:
140 * . prevent speculative fetch onto device memory while MMU is off
141 * . reflect as much as possible SH5 ABI (r15, r26, r27, r18)
142 * . first, save CPU state and set it to something harmless
143 * . any CPU detection and/or endianness settings (?)
144 * . initialize EMI/LMI (but not TMU/RTC/INTC/SCIF): TBD
145 * . set initial TLB entries for cached and uncached regions
146 * (no fine granularity paging)
147 * . set initial cache state
148 * . enable MMU and caches
149 * . set CPU to a consistent state
150 * . registers (including stack pointer and current/KCR0)
151 * . NOT expecting to set Exception handling nor VBR/RESVEC/DCR
152 * at this stage. This is all to later Linux initialization steps.
153 * . initialize FPU
154 * . clear BSS
155 * . jump into start_kernel()
156 * . be prepared to hopeless start_kernel() returns.
157 *
158 */
159 .global _stext
160_stext:
161 /*
162 * Prevent speculative fetch on device memory due to
163 * uninitialized target registers.
164 */
165 ptabs/u ZERO, tr0
166 ptabs/u ZERO, tr1
167 ptabs/u ZERO, tr2
168 ptabs/u ZERO, tr3
169 ptabs/u ZERO, tr4
170 ptabs/u ZERO, tr5
171 ptabs/u ZERO, tr6
172 ptabs/u ZERO, tr7
173 synci
174
175 /*
176 * Read/Set CPU state. After this block:
177 * r29 = Initial SR
178 */
179 getcon SR, r29
180 movi SR_HARMLESS, r20
181 putcon r20, SR
182
183 /*
184 * Initialize EMI/LMI. To Be Done.
185 */
186
187 /*
188 * CPU detection and/or endianness settings (?). To Be Done.
189 * Pure PIC code here, please ! Just save state into r30.
190 * After this block:
191 * r30 = CPU type/Platform Endianness
192 */
193
194 /*
195 * Set initial TLB entries for cached and uncached regions.
196 * Note: PTA/BLINK is PIC code, PTABS/BLINK isn't !
197 */
198 /* Clear ITLBs */
199 pta clear_ITLB, tr1
200 movi MMUIR_FIRST, r21
201 movi MMUIR_END, r22
202clear_ITLB:
203 putcfg r21, 0, ZERO /* Clear MMUIR[n].PTEH.V */
204 addi r21, MMUIR_STEP, r21
205 bne r21, r22, tr1
206
207 /* Clear DTLBs */
208 pta clear_DTLB, tr1
209 movi MMUDR_FIRST, r21
210 movi MMUDR_END, r22
211clear_DTLB:
212 putcfg r21, 0, ZERO /* Clear MMUDR[n].PTEH.V */
213 addi r21, MMUDR_STEP, r21
214 bne r21, r22, tr1
215
216 /* Map one big (512Mb) page for ITLB */
217 movi MMUIR_FIRST, r21
218 movi MMUIR_TEXT_L, r22 /* PTEL first */
219 add.l r22, r63, r22 /* Sign extend */
220 putcfg r21, 1, r22 /* Set MMUIR[0].PTEL */
221 movi MMUIR_TEXT_H, r22 /* PTEH last */
222 add.l r22, r63, r22 /* Sign extend */
223 putcfg r21, 0, r22 /* Set MMUIR[0].PTEH */
224
225 /* Map one big CACHED (512Mb) page for DTLB */
226 movi MMUDR_FIRST, r21
227 movi MMUDR_CACHED_L, r22 /* PTEL first */
228 add.l r22, r63, r22 /* Sign extend */
229 putcfg r21, 1, r22 /* Set MMUDR[0].PTEL */
230 movi MMUDR_CACHED_H, r22 /* PTEH last */
231 add.l r22, r63, r22 /* Sign extend */
232 putcfg r21, 0, r22 /* Set MMUDR[0].PTEH */
233
234#ifdef CONFIG_EARLY_PRINTK
235 /*
236 * Setup a DTLB translation for SCIF phys.
237 */
238 addi r21, MMUDR_STEP, r21
239 movi 0x0a03, r22 /* SCIF phys */
240 shori 0x0148, r22
241 putcfg r21, 1, r22 /* PTEL first */
242 movi 0xfa03, r22 /* 0xfa030000, fixed SCIF virt */
243 shori 0x0003, r22
244 putcfg r21, 0, r22 /* PTEH last */
245#endif
246
247 /*
248 * Set cache behaviours.
249 */
250 /* ICache */
251 movi ICCR_BASE, r21
252 movi ICCR0_INIT_VAL, r22
253 movi ICCR1_INIT_VAL, r23
254 putcfg r21, ICCR_REG0, r22
255 putcfg r21, ICCR_REG1, r23
256
257 /* OCache */
258 movi OCCR_BASE, r21
259 movi OCCR0_INIT_VAL, r22
260 movi OCCR1_INIT_VAL, r23
261 putcfg r21, OCCR_REG0, r22
262 putcfg r21, OCCR_REG1, r23
263
264
265 /*
266 * Enable Caches and MMU. Do the first non-PIC jump.
267 * Now head.S global variables, constants and externs
268 * can be used.
269 */
270 getcon SR, r21
271 movi SR_ENABLE_MMU, r22
272 or r21, r22, r21
273 putcon r21, SSR
274 movi hyperspace, r22
275 ori r22, 1, r22 /* Make it SHmedia, not required but..*/
276 putcon r22, SPC
277 synco
278 rte /* And now go into the hyperspace ... */
279hyperspace: /* ... that's the next instruction ! */
280
281 /*
282 * Set CPU to a consistent state.
283 * r31 = FPU support flag
284 * tr0/tr7 in use. Others give a chance to loop somewhere safe
285 */
286 movi start_kernel, r32
287 ori r32, 1, r32
288
289 ptabs r32, tr0 /* r32 = _start_kernel address */
290 pta/u hopeless, tr1
291 pta/u hopeless, tr2
292 pta/u hopeless, tr3
293 pta/u hopeless, tr4
294 pta/u hopeless, tr5
295 pta/u hopeless, tr6
296 pta/u hopeless, tr7
297 gettr tr1, r28 /* r28 = hopeless address */
298
299 /* Set initial stack pointer */
300 movi init_thread_union, SP
301 putcon SP, KCR0 /* Set current to init_task */
302 movi THREAD_SIZE, r22 /* Point to the end */
303 add SP, r22, SP
304
305 /*
306 * Initialize FPU.
307 * Keep FPU flag in r31. After this block:
308 * r31 = FPU flag
309 */
310 movi fpu_in_use, r31 /* Temporary */
311
312#ifdef CONFIG_SH_FPU
313 getcon SR, r21
314 movi SR_ENABLE_FPU, r22
315 and r21, r22, r22
316 putcon r22, SR /* Try to enable */
317 getcon SR, r22
318 xor r21, r22, r21
319 shlri r21, 15, r21 /* Supposedly 0/1 */
320 st.q r31, 0 , r21 /* Set fpu_in_use */
321#else
322 movi 0, r21
323 st.q r31, 0 , r21 /* Set fpu_in_use */
324#endif
325 or r21, ZERO, r31 /* Set FPU flag at last */
326
327#ifndef CONFIG_SH_NO_BSS_INIT
328/* Don't clear BSS if running on slow platforms such as an RTL simulation,
329 remote memory via SHdebug link, etc. For these the memory can be guaranteed
330 to be all zero on boot anyway. */
331 /*
332 * Clear bss
333 */
334 pta clear_quad, tr1
335 movi __bss_start, r22
336 movi _end, r23
337clear_quad:
338 st.q r22, 0, ZERO
339 addi r22, 8, r22
340 bne r22, r23, tr1 /* Both quad aligned, see vmlinux.lds.S */
341#endif
342 pta/u hopeless, tr1
343
344 /* Say bye to head.S but be prepared to wrongly get back ... */
345 blink tr0, LINK
346
347 /* If we ever get back here through LINK/tr1-tr7 */
348 pta/u hopeless, tr7
349
350hopeless:
351 /*
352 * Something's badly wrong here. Loop endlessly,
353 * there's nothing more we can do about it.
354 *
355 * Note on hopeless: it can be jumped into invariably
356 * before or after jumping into hyperspace. The only
357 * requirement is to be PIC called (PTA) before and
358 * any way (PTA/PTABS) after. According to Virtual
359 * to Physical mapping a simulator/emulator can easily
360 * tell where we came here from just looking at hopeless
361 * (PC) address.
362 *
363 * For debugging purposes:
364 * (r28) hopeless/loop address
365 * (r29) Original SR
366 * (r30) CPU type/Platform endianness
367 * (r31) FPU Support
368 * (r32) _start_kernel address
369 */
370 blink tr7, ZERO
371
372
diff --git a/arch/sh64/kernel/init_task.c b/arch/sh64/kernel/init_task.c
deleted file mode 100644
index deee8bfd3270..000000000000
--- a/arch/sh64/kernel/init_task.c
+++ /dev/null
@@ -1,46 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/init_task.c
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003 Paul Mundt
10 *
11 */
12#include <linux/rwsem.h>
13#include <linux/mm.h>
14#include <linux/sched.h>
15#include <linux/init_task.h>
16#include <linux/mqueue.h>
17#include <linux/fs.h>
18#include <asm/uaccess.h>
19#include <asm/pgtable.h>
20
21static struct fs_struct init_fs = INIT_FS;
22static struct files_struct init_files = INIT_FILES;
23static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
24static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
25struct mm_struct init_mm = INIT_MM(init_mm);
26
27struct pt_regs fake_swapper_regs;
28
29/*
30 * Initial thread structure.
31 *
32 * We need to make sure that this is THREAD_SIZE-byte aligned due
33 * to the way process stacks are handled. This is done by having a
34 * special "init_task" linker map entry..
35 */
36union thread_union init_thread_union
37 __attribute__((__section__(".data.init_task"))) =
38 { INIT_THREAD_INFO(init_task) };
39
40/*
41 * Initial task structure.
42 *
43 * All other task structs will be allocated on slabs in fork.c
44 */
45struct task_struct init_task = INIT_TASK(init_task);
46
diff --git a/arch/sh64/kernel/irq.c b/arch/sh64/kernel/irq.c
deleted file mode 100644
index 9412b7166700..000000000000
--- a/arch/sh64/kernel/irq.c
+++ /dev/null
@@ -1,115 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/irq.c
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003 Paul Mundt
10 *
11 */
12
13/*
14 * IRQs are in fact implemented a bit like signal handlers for the kernel.
15 * Naturally it's not a 1:1 relation, but there are similarities.
16 */
17
18#include <linux/errno.h>
19#include <linux/kernel_stat.h>
20#include <linux/signal.h>
21#include <linux/rwsem.h>
22#include <linux/sched.h>
23#include <linux/ioport.h>
24#include <linux/interrupt.h>
25#include <linux/timex.h>
26#include <linux/slab.h>
27#include <linux/random.h>
28#include <linux/smp.h>
29#include <linux/init.h>
30#include <linux/seq_file.h>
31#include <linux/bitops.h>
32#include <asm/system.h>
33#include <asm/io.h>
34#include <asm/smp.h>
35#include <asm/pgalloc.h>
36#include <asm/delay.h>
37#include <asm/irq.h>
38#include <linux/irq.h>
39
40void ack_bad_irq(unsigned int irq)
41{
42 printk("unexpected IRQ trap at irq %02x\n", irq);
43}
44
45#if defined(CONFIG_PROC_FS)
46int show_interrupts(struct seq_file *p, void *v)
47{
48 int i = *(loff_t *) v, j;
49 struct irqaction * action;
50 unsigned long flags;
51
52 if (i == 0) {
53 seq_puts(p, " ");
54 for_each_online_cpu(j)
55 seq_printf(p, "CPU%d ",j);
56 seq_putc(p, '\n');
57 }
58
59 if (i < NR_IRQS) {
60 spin_lock_irqsave(&irq_desc[i].lock, flags);
61 action = irq_desc[i].action;
62 if (!action)
63 goto unlock;
64 seq_printf(p, "%3d: ",i);
65 seq_printf(p, "%10u ", kstat_irqs(i));
66 seq_printf(p, " %14s", irq_desc[i].chip->typename);
67 seq_printf(p, " %s", action->name);
68
69 for (action=action->next; action; action = action->next)
70 seq_printf(p, ", %s", action->name);
71 seq_putc(p, '\n');
72unlock:
73 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
74 }
75 return 0;
76}
77#endif
78
79/*
80 * do_NMI handles all Non-Maskable Interrupts.
81 */
82asmlinkage void do_NMI(unsigned long vector_num, struct pt_regs * regs)
83{
84 if (regs->sr & 0x40000000)
85 printk("unexpected NMI trap in system mode\n");
86 else
87 printk("unexpected NMI trap in user mode\n");
88
89 /* No statistics */
90}
91
92/*
93 * do_IRQ handles all normal device IRQ's.
94 */
95asmlinkage int do_IRQ(unsigned long vector_num, struct pt_regs * regs)
96{
97 struct pt_regs *old_regs = set_irq_regs(regs);
98 int irq;
99
100 irq_enter();
101
102 irq = irq_demux(vector_num);
103
104 if (irq >= 0) {
105 __do_IRQ(irq);
106 } else {
107 printk("unexpected IRQ trap at vector %03lx\n", vector_num);
108 }
109
110 irq_exit();
111
112 set_irq_regs(old_regs);
113 return 1;
114}
115
diff --git a/arch/sh64/kernel/irq_intc.c b/arch/sh64/kernel/irq_intc.c
deleted file mode 100644
index 3b63a93198f2..000000000000
--- a/arch/sh64/kernel/irq_intc.c
+++ /dev/null
@@ -1,272 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/irq_intc.c
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003 Paul Mundt
10 *
11 * Interrupt Controller support for SH5 INTC.
12 * Per-interrupt selective. IRLM=0 (Fixed priority) is not
13 * supported being useless without a cascaded interrupt
14 * controller.
15 *
16 */
17
18#include <linux/init.h>
19#include <linux/interrupt.h>
20#include <linux/irq.h>
21#include <linux/kernel.h>
22#include <linux/stddef.h>
23#include <linux/bitops.h> /* this includes also <asm/registers.h */
24 /* which is required to remap register */
25 /* names used into __asm__ blocks... */
26
27#include <asm/hardware.h>
28#include <asm/platform.h>
29#include <asm/page.h>
30#include <asm/io.h>
31#include <asm/irq.h>
32
33/*
34 * Maybe the generic Peripheral block could move to a more
35 * generic include file. INTC Block will be defined here
36 * and only here to make INTC self-contained in a single
37 * file.
38 */
39#define INTC_BLOCK_OFFSET 0x01000000
40
41/* Base */
42#define INTC_BASE PHYS_PERIPHERAL_BLOCK + \
43 INTC_BLOCK_OFFSET
44
45/* Address */
46#define INTC_ICR_SET (intc_virt + 0x0)
47#define INTC_ICR_CLEAR (intc_virt + 0x8)
48#define INTC_INTPRI_0 (intc_virt + 0x10)
49#define INTC_INTSRC_0 (intc_virt + 0x50)
50#define INTC_INTSRC_1 (intc_virt + 0x58)
51#define INTC_INTREQ_0 (intc_virt + 0x60)
52#define INTC_INTREQ_1 (intc_virt + 0x68)
53#define INTC_INTENB_0 (intc_virt + 0x70)
54#define INTC_INTENB_1 (intc_virt + 0x78)
55#define INTC_INTDSB_0 (intc_virt + 0x80)
56#define INTC_INTDSB_1 (intc_virt + 0x88)
57
58#define INTC_ICR_IRLM 0x1
59#define INTC_INTPRI_PREGS 8 /* 8 Priority Registers */
60#define INTC_INTPRI_PPREG 8 /* 8 Priorities per Register */
61
62
63/*
64 * Mapper between the vector ordinal and the IRQ number
65 * passed to kernel/device drivers.
66 */
67int intc_evt_to_irq[(0xE20/0x20)+1] = {
68 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x000 - 0x0E0 */
69 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x100 - 0x1E0 */
70 0, 0, 0, 0, 0, 1, 0, 0, /* 0x200 - 0x2E0 */
71 2, 0, 0, 3, 0, 0, 0, -1, /* 0x300 - 0x3E0 */
72 32, 33, 34, 35, 36, 37, 38, -1, /* 0x400 - 0x4E0 */
73 -1, -1, -1, 63, -1, -1, -1, -1, /* 0x500 - 0x5E0 */
74 -1, -1, 18, 19, 20, 21, 22, -1, /* 0x600 - 0x6E0 */
75 39, 40, 41, 42, -1, -1, -1, -1, /* 0x700 - 0x7E0 */
76 4, 5, 6, 7, -1, -1, -1, -1, /* 0x800 - 0x8E0 */
77 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x900 - 0x9E0 */
78 12, 13, 14, 15, 16, 17, -1, -1, /* 0xA00 - 0xAE0 */
79 -1, -1, -1, -1, -1, -1, -1, -1, /* 0xB00 - 0xBE0 */
80 -1, -1, -1, -1, -1, -1, -1, -1, /* 0xC00 - 0xCE0 */
81 -1, -1, -1, -1, -1, -1, -1, -1, /* 0xD00 - 0xDE0 */
82 -1, -1 /* 0xE00 - 0xE20 */
83};
84
85/*
86 * Opposite mapper.
87 */
88static int IRQ_to_vectorN[NR_INTC_IRQS] = {
89 0x12, 0x15, 0x18, 0x1B, 0x40, 0x41, 0x42, 0x43, /* 0- 7 */
90 -1, -1, -1, -1, 0x50, 0x51, 0x52, 0x53, /* 8-15 */
91 0x54, 0x55, 0x32, 0x33, 0x34, 0x35, 0x36, -1, /* 16-23 */
92 -1, -1, -1, -1, -1, -1, -1, -1, /* 24-31 */
93 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x38, /* 32-39 */
94 0x39, 0x3A, 0x3B, -1, -1, -1, -1, -1, /* 40-47 */
95 -1, -1, -1, -1, -1, -1, -1, -1, /* 48-55 */
96 -1, -1, -1, -1, -1, -1, -1, 0x2B, /* 56-63 */
97
98};
99
100static unsigned long intc_virt;
101
102static unsigned int startup_intc_irq(unsigned int irq);
103static void shutdown_intc_irq(unsigned int irq);
104static void enable_intc_irq(unsigned int irq);
105static void disable_intc_irq(unsigned int irq);
106static void mask_and_ack_intc(unsigned int);
107static void end_intc_irq(unsigned int irq);
108
109static struct hw_interrupt_type intc_irq_type = {
110 .typename = "INTC",
111 .startup = startup_intc_irq,
112 .shutdown = shutdown_intc_irq,
113 .enable = enable_intc_irq,
114 .disable = disable_intc_irq,
115 .ack = mask_and_ack_intc,
116 .end = end_intc_irq
117};
118
119static int irlm; /* IRL mode */
120
121static unsigned int startup_intc_irq(unsigned int irq)
122{
123 enable_intc_irq(irq);
124 return 0; /* never anything pending */
125}
126
127static void shutdown_intc_irq(unsigned int irq)
128{
129 disable_intc_irq(irq);
130}
131
132static void enable_intc_irq(unsigned int irq)
133{
134 unsigned long reg;
135 unsigned long bitmask;
136
137 if ((irq <= IRQ_IRL3) && (irlm == NO_PRIORITY))
138 printk("Trying to use straight IRL0-3 with an encoding platform.\n");
139
140 if (irq < 32) {
141 reg = INTC_INTENB_0;
142 bitmask = 1 << irq;
143 } else {
144 reg = INTC_INTENB_1;
145 bitmask = 1 << (irq - 32);
146 }
147
148 ctrl_outl(bitmask, reg);
149}
150
151static void disable_intc_irq(unsigned int irq)
152{
153 unsigned long reg;
154 unsigned long bitmask;
155
156 if (irq < 32) {
157 reg = INTC_INTDSB_0;
158 bitmask = 1 << irq;
159 } else {
160 reg = INTC_INTDSB_1;
161 bitmask = 1 << (irq - 32);
162 }
163
164 ctrl_outl(bitmask, reg);
165}
166
167static void mask_and_ack_intc(unsigned int irq)
168{
169 disable_intc_irq(irq);
170}
171
172static void end_intc_irq(unsigned int irq)
173{
174 enable_intc_irq(irq);
175}
176
177/* For future use, if we ever support IRLM=0) */
178void make_intc_irq(unsigned int irq)
179{
180 disable_irq_nosync(irq);
181 irq_desc[irq].chip = &intc_irq_type;
182 disable_intc_irq(irq);
183}
184
185#if defined(CONFIG_PROC_FS) && defined(CONFIG_SYSCTL)
186int intc_irq_describe(char* p, int irq)
187{
188 if (irq < NR_INTC_IRQS)
189 return sprintf(p, "(0x%3x)", IRQ_to_vectorN[irq]*0x20);
190 else
191 return 0;
192}
193#endif
194
195void __init init_IRQ(void)
196{
197 unsigned long long __dummy0, __dummy1=~0x00000000100000f0;
198 unsigned long reg;
199 unsigned long data;
200 int i;
201
202 intc_virt = onchip_remap(INTC_BASE, 1024, "INTC");
203 if (!intc_virt) {
204 panic("Unable to remap INTC\n");
205 }
206
207
208 /* Set default: per-line enable/disable, priority driven ack/eoi */
209 for (i = 0; i < NR_INTC_IRQS; i++) {
210 if (platform_int_priority[i] != NO_PRIORITY) {
211 irq_desc[i].chip = &intc_irq_type;
212 }
213 }
214
215
216 /* Disable all interrupts and set all priorities to 0 to avoid trouble */
217 ctrl_outl(-1, INTC_INTDSB_0);
218 ctrl_outl(-1, INTC_INTDSB_1);
219
220 for (reg = INTC_INTPRI_0, i = 0; i < INTC_INTPRI_PREGS; i++, reg += 8)
221 ctrl_outl( NO_PRIORITY, reg);
222
223
224 /* Set IRLM */
225 /* If all the priorities are set to 'no priority', then
226 * assume we are using encoded mode.
227 */
228 irlm = platform_int_priority[IRQ_IRL0] + platform_int_priority[IRQ_IRL1] + \
229 platform_int_priority[IRQ_IRL2] + platform_int_priority[IRQ_IRL3];
230
231 if (irlm == NO_PRIORITY) {
232 /* IRLM = 0 */
233 reg = INTC_ICR_CLEAR;
234 i = IRQ_INTA;
235 printk("Trying to use encoded IRL0-3. IRLs unsupported.\n");
236 } else {
237 /* IRLM = 1 */
238 reg = INTC_ICR_SET;
239 i = IRQ_IRL0;
240 }
241 ctrl_outl(INTC_ICR_IRLM, reg);
242
243 /* Set interrupt priorities according to platform description */
244 for (data = 0, reg = INTC_INTPRI_0; i < NR_INTC_IRQS; i++) {
245 data |= platform_int_priority[i] << ((i % INTC_INTPRI_PPREG) * 4);
246 if ((i % INTC_INTPRI_PPREG) == (INTC_INTPRI_PPREG - 1)) {
247 /* Upon the 7th, set Priority Register */
248 ctrl_outl(data, reg);
249 data = 0;
250 reg += 8;
251 }
252 }
253
254#ifdef CONFIG_SH_CAYMAN
255 {
256 extern void init_cayman_irq(void);
257
258 init_cayman_irq();
259 }
260#endif
261
262 /*
263 * And now let interrupts come in.
264 * sti() is not enough, we need to
265 * lower priority, too.
266 */
267 __asm__ __volatile__("getcon " __SR ", %0\n\t"
268 "and %0, %1, %0\n\t"
269 "putcon %0, " __SR "\n\t"
270 : "=&r" (__dummy0)
271 : "r" (__dummy1));
272}
diff --git a/arch/sh64/kernel/led.c b/arch/sh64/kernel/led.c
deleted file mode 100644
index e35d3f667fb4..000000000000
--- a/arch/sh64/kernel/led.c
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2 * arch/sh64/kernel/led.c
3 *
4 * Copyright (C) 2002 Stuart Menefy <stuart.menefy@st.com>
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * Flash the LEDs
10 */
11#include <linux/stddef.h>
12#include <linux/sched.h>
13
14void mach_led(int pos, int val);
15
16/* acts like an actual heart beat -- ie thump-thump-pause... */
17void heartbeat(void)
18{
19 static unsigned int cnt = 0, period = 0, dist = 0;
20
21 if (cnt == 0 || cnt == dist) {
22 mach_led(-1, 1);
23 } else if (cnt == 7 || cnt == dist + 7) {
24 mach_led(-1, 0);
25 }
26
27 if (++cnt > period) {
28 cnt = 0;
29
30 /*
31 * The hyperbolic function below modifies the heartbeat period
32 * length in dependency of the current (5min) load. It goes
33 * through the points f(0)=126, f(1)=86, f(5)=51, f(inf)->30.
34 */
35 period = ((672 << FSHIFT) / (5 * avenrun[0] +
36 (7 << FSHIFT))) + 30;
37 dist = period / 4;
38 }
39}
40
diff --git a/arch/sh64/kernel/module.c b/arch/sh64/kernel/module.c
deleted file mode 100644
index 2598f6b88b44..000000000000
--- a/arch/sh64/kernel/module.c
+++ /dev/null
@@ -1,161 +0,0 @@
1/* Kernel module help for sh64.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
17 Copyright 2004 SuperH (UK) Ltd
18 Author: Richard Curnow
19
20 Based on the sh version, and on code from the sh64-specific parts of
21 modutils, originally written by Richard Curnow and Ben Gaster.
22
23*/
24#include <linux/moduleloader.h>
25#include <linux/elf.h>
26#include <linux/vmalloc.h>
27#include <linux/fs.h>
28#include <linux/string.h>
29#include <linux/kernel.h>
30
31#if 0
32#define DEBUGP printk
33#else
34#define DEBUGP(fmt...)
35#endif
36
37void *module_alloc(unsigned long size)
38{
39 if (size == 0)
40 return NULL;
41 return vmalloc(size);
42}
43
44
45/* Free memory returned from module_alloc */
46void module_free(struct module *mod, void *module_region)
47{
48 vfree(module_region);
49 /* FIXME: If module_region == mod->init_region, trim exception
50 table entries. */
51}
52
53/* We don't need anything special. */
54int module_frob_arch_sections(Elf_Ehdr *hdr,
55 Elf_Shdr *sechdrs,
56 char *secstrings,
57 struct module *mod)
58{
59 return 0;
60}
61
62int apply_relocate_add(Elf32_Shdr *sechdrs,
63 const char *strtab,
64 unsigned int symindex,
65 unsigned int relsec,
66 struct module *me)
67{
68 unsigned int i;
69 Elf32_Rela *rel = (void *)sechdrs[relsec].sh_addr;
70 Elf32_Sym *sym;
71 Elf32_Addr relocation;
72 uint32_t *location;
73 int align;
74 int is_shmedia;
75
76 DEBUGP("Applying relocate section %u to %u\n", relsec,
77 sechdrs[relsec].sh_info);
78 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
79 /* This is where to make the change */
80 location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
81 + rel[i].r_offset;
82 /* This is the symbol it is referring to. Note that all
83 undefined symbols have been resolved. */
84 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
85 + ELF32_R_SYM(rel[i].r_info);
86 relocation = sym->st_value + rel[i].r_addend;
87 align = (int)location & 3;
88
89 /* For text addresses, bit2 of the st_other field indicates
90 * whether the symbol is SHmedia (1) or SHcompact (0). If
91 * SHmedia, the LSB of the symbol needs to be asserted
92 * for the CPU to be in SHmedia mode when it starts executing
93 * the branch target. */
94 is_shmedia = (sym->st_other & 4) ? 1 : 0;
95 if (is_shmedia) {
96 relocation |= 1;
97 }
98
99 switch (ELF32_R_TYPE(rel[i].r_info)) {
100 case R_SH_DIR32:
101 DEBUGP("R_SH_DIR32 @%08lx = %08lx\n", (unsigned long) location, (unsigned long) relocation);
102 *location += relocation;
103 break;
104 case R_SH_REL32:
105 DEBUGP("R_SH_REL32 @%08lx = %08lx\n", (unsigned long) location, (unsigned long) relocation);
106 relocation -= (Elf32_Addr) location;
107 *location += relocation;
108 break;
109 case R_SH_IMM_LOW16:
110 DEBUGP("R_SH_IMM_LOW16 @%08lx = %08lx\n", (unsigned long) location, (unsigned long) relocation);
111 *location = (*location & ~0x3fffc00) |
112 ((relocation & 0xffff) << 10);
113 break;
114 case R_SH_IMM_MEDLOW16:
115 DEBUGP("R_SH_IMM_MEDLOW16 @%08lx = %08lx\n", (unsigned long) location, (unsigned long) relocation);
116 *location = (*location & ~0x3fffc00) |
117 (((relocation >> 16) & 0xffff) << 10);
118 break;
119 case R_SH_IMM_LOW16_PCREL:
120 DEBUGP("R_SH_IMM_LOW16_PCREL @%08lx = %08lx\n", (unsigned long) location, (unsigned long) relocation);
121 relocation -= (Elf32_Addr) location;
122 *location = (*location & ~0x3fffc00) |
123 ((relocation & 0xffff) << 10);
124 break;
125 case R_SH_IMM_MEDLOW16_PCREL:
126 DEBUGP("R_SH_IMM_MEDLOW16_PCREL @%08lx = %08lx\n", (unsigned long) location, (unsigned long) relocation);
127 relocation -= (Elf32_Addr) location;
128 *location = (*location & ~0x3fffc00) |
129 (((relocation >> 16) & 0xffff) << 10);
130 break;
131 default:
132 printk(KERN_ERR "module %s: Unknown relocation: %u\n",
133 me->name, ELF32_R_TYPE(rel[i].r_info));
134 return -ENOEXEC;
135 }
136 }
137 return 0;
138}
139
140int apply_relocate(Elf32_Shdr *sechdrs,
141 const char *strtab,
142 unsigned int symindex,
143 unsigned int relsec,
144 struct module *me)
145{
146 printk(KERN_ERR "module %s: REL RELOCATION unsupported\n",
147 me->name);
148 return -ENOEXEC;
149}
150
151int module_finalize(const Elf_Ehdr *hdr,
152 const Elf_Shdr *sechdrs,
153 struct module *me)
154{
155 return 0;
156}
157
158void module_arch_cleanup(struct module *mod)
159{
160}
161
diff --git a/arch/sh64/kernel/pci_sh5.c b/arch/sh64/kernel/pci_sh5.c
deleted file mode 100644
index b4d9534d2b0e..000000000000
--- a/arch/sh64/kernel/pci_sh5.c
+++ /dev/null
@@ -1,536 +0,0 @@
1/*
2 * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
3 * Copyright (C) 2003, 2004 Paul Mundt
4 * Copyright (C) 2004 Richard Curnow
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * Support functions for the SH5 PCI hardware.
10 */
11
12#include <linux/kernel.h>
13#include <linux/rwsem.h>
14#include <linux/smp.h>
15#include <linux/interrupt.h>
16#include <linux/init.h>
17#include <linux/errno.h>
18#include <linux/pci.h>
19#include <linux/delay.h>
20#include <linux/types.h>
21#include <asm/pci.h>
22#include <linux/irq.h>
23
24#include <asm/io.h>
25#include <asm/hardware.h>
26#include "pci_sh5.h"
27
28static unsigned long pcicr_virt;
29unsigned long pciio_virt;
30
31static void __init pci_fixup_ide_bases(struct pci_dev *d)
32{
33 int i;
34
35 /*
36 * PCI IDE controllers use non-standard I/O port decoding, respect it.
37 */
38 if ((d->class >> 8) != PCI_CLASS_STORAGE_IDE)
39 return;
40 printk("PCI: IDE base address fixup for %s\n", pci_name(d));
41 for(i=0; i<4; i++) {
42 struct resource *r = &d->resource[i];
43 if ((r->start & ~0x80) == 0x374) {
44 r->start |= 2;
45 r->end = r->start;
46 }
47 }
48}
49DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_ide_bases);
50
51char * __devinit pcibios_setup(char *str)
52{
53 return str;
54}
55
56/* Rounds a number UP to the nearest power of two. Used for
57 * sizing the PCI window.
58 */
59static u32 __init r2p2(u32 num)
60{
61 int i = 31;
62 u32 tmp = num;
63
64 if (num == 0)
65 return 0;
66
67 do {
68 if (tmp & (1 << 31))
69 break;
70 i--;
71 tmp <<= 1;
72 } while (i >= 0);
73
74 tmp = 1 << i;
75 /* If the original number isn't a power of 2, round it up */
76 if (tmp != num)
77 tmp <<= 1;
78
79 return tmp;
80}
81
82extern unsigned long long memory_start, memory_end;
83
84int __init sh5pci_init(unsigned memStart, unsigned memSize)
85{
86 u32 lsr0;
87 u32 uval;
88
89 pcicr_virt = onchip_remap(SH5PCI_ICR_BASE, 1024, "PCICR");
90 if (!pcicr_virt) {
91 panic("Unable to remap PCICR\n");
92 }
93
94 pciio_virt = onchip_remap(SH5PCI_IO_BASE, 0x10000, "PCIIO");
95 if (!pciio_virt) {
96 panic("Unable to remap PCIIO\n");
97 }
98
99 pr_debug("Register base addres is 0x%08lx\n", pcicr_virt);
100
101 /* Clear snoop registers */
102 SH5PCI_WRITE(CSCR0, 0);
103 SH5PCI_WRITE(CSCR1, 0);
104
105 pr_debug("Wrote to reg\n");
106
107 /* Switch off interrupts */
108 SH5PCI_WRITE(INTM, 0);
109 SH5PCI_WRITE(AINTM, 0);
110 SH5PCI_WRITE(PINTM, 0);
111
112 /* Set bus active, take it out of reset */
113 uval = SH5PCI_READ(CR);
114
115 /* Set command Register */
116 SH5PCI_WRITE(CR, uval | CR_LOCK_MASK | CR_CFINT| CR_FTO | CR_PFE | CR_PFCS | CR_BMAM);
117
118 uval=SH5PCI_READ(CR);
119 pr_debug("CR is actually 0x%08x\n",uval);
120
121 /* Allow it to be a master */
122 /* NB - WE DISABLE I/O ACCESS to stop overlap */
123 /* set WAIT bit to enable stepping, an attempt to improve stability */
124 SH5PCI_WRITE_SHORT(CSR_CMD,
125 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_WAIT);
126
127 /*
128 ** Set translation mapping memory in order to convert the address
129 ** used for the main bus, to the PCI internal address.
130 */
131 SH5PCI_WRITE(MBR,0x40000000);
132
133 /* Always set the max size 512M */
134 SH5PCI_WRITE(MBMR, PCISH5_MEM_SIZCONV(512*1024*1024));
135
136 /*
137 ** I/O addresses are mapped at internal PCI specific address
138 ** as is described into the configuration bridge table.
139 ** These are changed to 0, to allow cards that have legacy
140 ** io such as vga to function correctly. We set the SH5 IOBAR to
141 ** 256K, which is a bit big as we can only have 64K of address space
142 */
143
144 SH5PCI_WRITE(IOBR,0x0);
145
146 pr_debug("PCI:Writing 0x%08x to IOBR\n",0);
147
148 /* Set up a 256K window. Totally pointless waste of address space */
149 SH5PCI_WRITE(IOBMR,0);
150 pr_debug("PCI:Writing 0x%08x to IOBMR\n",0);
151
152 /* The SH5 has a HUGE 256K I/O region, which breaks the PCI spec. Ideally,
153 * we would want to map the I/O region somewhere, but it is so big this is not
154 * that easy!
155 */
156 SH5PCI_WRITE(CSR_IBAR0,~0);
157 /* Set memory size value */
158 memSize = memory_end - memory_start;
159
160 /* Now we set up the mbars so the PCI bus can see the memory of the machine */
161 if (memSize < (1024 * 1024)) {
162 printk(KERN_ERR "PCISH5: Ridiculous memory size of 0x%x?\n", memSize);
163 return -EINVAL;
164 }
165
166 /* Set LSR 0 */
167 lsr0 = (memSize > (512 * 1024 * 1024)) ? 0x1ff00001 : ((r2p2(memSize) - 0x100000) | 0x1);
168 SH5PCI_WRITE(LSR0, lsr0);
169
170 pr_debug("PCI:Writing 0x%08x to LSR0\n",lsr0);
171
172 /* Set MBAR 0 */
173 SH5PCI_WRITE(CSR_MBAR0, memory_start);
174 SH5PCI_WRITE(LAR0, memory_start);
175
176 SH5PCI_WRITE(CSR_MBAR1,0);
177 SH5PCI_WRITE(LAR1,0);
178 SH5PCI_WRITE(LSR1,0);
179
180 pr_debug("PCI:Writing 0x%08llx to CSR_MBAR0\n",memory_start);
181 pr_debug("PCI:Writing 0x%08llx to LAR0\n",memory_start);
182
183 /* Enable the PCI interrupts on the device */
184 SH5PCI_WRITE(INTM, ~0);
185 SH5PCI_WRITE(AINTM, ~0);
186 SH5PCI_WRITE(PINTM, ~0);
187
188 pr_debug("Switching on all error interrupts\n");
189
190 return(0);
191}
192
193static int sh5pci_read(struct pci_bus *bus, unsigned int devfn, int where,
194 int size, u32 *val)
195{
196 SH5PCI_WRITE(PAR, CONFIG_CMD(bus, devfn, where));
197
198 switch (size) {
199 case 1:
200 *val = (u8)SH5PCI_READ_BYTE(PDR + (where & 3));
201 break;
202 case 2:
203 *val = (u16)SH5PCI_READ_SHORT(PDR + (where & 2));
204 break;
205 case 4:
206 *val = SH5PCI_READ(PDR);
207 break;
208 }
209
210 return PCIBIOS_SUCCESSFUL;
211}
212
213static int sh5pci_write(struct pci_bus *bus, unsigned int devfn, int where,
214 int size, u32 val)
215{
216 SH5PCI_WRITE(PAR, CONFIG_CMD(bus, devfn, where));
217
218 switch (size) {
219 case 1:
220 SH5PCI_WRITE_BYTE(PDR + (where & 3), (u8)val);
221 break;
222 case 2:
223 SH5PCI_WRITE_SHORT(PDR + (where & 2), (u16)val);
224 break;
225 case 4:
226 SH5PCI_WRITE(PDR, val);
227 break;
228 }
229
230 return PCIBIOS_SUCCESSFUL;
231}
232
233static struct pci_ops pci_config_ops = {
234 .read = sh5pci_read,
235 .write = sh5pci_write,
236};
237
238/* Everything hangs off this */
239static struct pci_bus *pci_root_bus;
240
241
242static u8 __init no_swizzle(struct pci_dev *dev, u8 * pin)
243{
244 pr_debug("swizzle for dev %d on bus %d slot %d pin is %d\n",
245 dev->devfn,dev->bus->number, PCI_SLOT(dev->devfn),*pin);
246 return PCI_SLOT(dev->devfn);
247}
248
249static inline u8 bridge_swizzle(u8 pin, u8 slot)
250{
251 return (((pin-1) + slot) % 4) + 1;
252}
253
254u8 __init common_swizzle(struct pci_dev *dev, u8 *pinp)
255{
256 if (dev->bus->number != 0) {
257 u8 pin = *pinp;
258 do {
259 pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn));
260 /* Move up the chain of bridges. */
261 dev = dev->bus->self;
262 } while (dev->bus->self);
263 *pinp = pin;
264
265 /* The slot is the slot of the last bridge. */
266 }
267
268 return PCI_SLOT(dev->devfn);
269}
270
271/* This needs to be shunted out of here into the board specific bit */
272
273static int __init map_cayman_irq(struct pci_dev *dev, u8 slot, u8 pin)
274{
275 int result = -1;
276
277 /* The complication here is that the PCI IRQ lines from the Cayman's 2
278 5V slots get into the CPU via a different path from the IRQ lines
279 from the 3 3.3V slots. Thus, we have to detect whether the card's
280 interrupts go via the 5V or 3.3V path, i.e. the 'bridge swizzling'
281 at the point where we cross from 5V to 3.3V is not the normal case.
282
283 The added complication is that we don't know that the 5V slots are
284 always bus 2, because a card containing a PCI-PCI bridge may be
285 plugged into a 3.3V slot, and this changes the bus numbering.
286
287 Also, the Cayman has an intermediate PCI bus that goes a custom
288 expansion board header (and to the secondary bridge). This bus has
289 never been used in practice.
290
291 The 1ary onboard PCI-PCI bridge is device 3 on bus 0
292 The 2ary onboard PCI-PCI bridge is device 0 on the 2ary bus of the 1ary bridge.
293 */
294
295 struct slot_pin {
296 int slot;
297 int pin;
298 } path[4];
299 int i=0;
300
301 while (dev->bus->number > 0) {
302
303 slot = path[i].slot = PCI_SLOT(dev->devfn);
304 pin = path[i].pin = bridge_swizzle(pin, slot);
305 dev = dev->bus->self;
306 i++;
307 if (i > 3) panic("PCI path to root bus too long!\n");
308 }
309
310 slot = PCI_SLOT(dev->devfn);
311 /* This is the slot on bus 0 through which the device is eventually
312 reachable. */
313
314 /* Now work back up. */
315 if ((slot < 3) || (i == 0)) {
316 /* Bus 0 (incl. PCI-PCI bridge itself) : perform the final
317 swizzle now. */
318 result = IRQ_INTA + bridge_swizzle(pin, slot) - 1;
319 } else {
320 i--;
321 slot = path[i].slot;
322 pin = path[i].pin;
323 if (slot > 0) {
324 panic("PCI expansion bus device found - not handled!\n");
325 } else {
326 if (i > 0) {
327 /* 5V slots */
328 i--;
329 slot = path[i].slot;
330 pin = path[i].pin;
331 /* 'pin' was swizzled earlier wrt slot, don't do it again. */
332 result = IRQ_P2INTA + (pin - 1);
333 } else {
334 /* IRQ for 2ary PCI-PCI bridge : unused */
335 result = -1;
336 }
337 }
338 }
339
340 return result;
341}
342
343static irqreturn_t pcish5_err_irq(int irq, void *dev_id)
344{
345 struct pt_regs *regs = get_irq_regs();
346 unsigned pci_int, pci_air, pci_cir, pci_aint;
347
348 pci_int = SH5PCI_READ(INT);
349 pci_cir = SH5PCI_READ(CIR);
350 pci_air = SH5PCI_READ(AIR);
351
352 if (pci_int) {
353 printk("PCI INTERRUPT (at %08llx)!\n", regs->pc);
354 printk("PCI INT -> 0x%x\n", pci_int & 0xffff);
355 printk("PCI AIR -> 0x%x\n", pci_air);
356 printk("PCI CIR -> 0x%x\n", pci_cir);
357 SH5PCI_WRITE(INT, ~0);
358 }
359
360 pci_aint = SH5PCI_READ(AINT);
361 if (pci_aint) {
362 printk("PCI ARB INTERRUPT!\n");
363 printk("PCI AINT -> 0x%x\n", pci_aint);
364 printk("PCI AIR -> 0x%x\n", pci_air);
365 printk("PCI CIR -> 0x%x\n", pci_cir);
366 SH5PCI_WRITE(AINT, ~0);
367 }
368
369 return IRQ_HANDLED;
370}
371
372static irqreturn_t pcish5_serr_irq(int irq, void *dev_id)
373{
374 printk("SERR IRQ\n");
375
376 return IRQ_NONE;
377}
378
379static void __init
380pcibios_size_bridge(struct pci_bus *bus, struct resource *ior,
381 struct resource *memr)
382{
383 struct resource io_res, mem_res;
384 struct pci_dev *dev;
385 struct pci_dev *bridge = bus->self;
386 struct list_head *ln;
387
388 if (!bridge)
389 return; /* host bridge, nothing to do */
390
391 /* set reasonable default locations for pcibios_align_resource */
392 io_res.start = PCIBIOS_MIN_IO;
393 mem_res.start = PCIBIOS_MIN_MEM;
394
395 io_res.end = io_res.start;
396 mem_res.end = mem_res.start;
397
398 /* Collect information about how our direct children are layed out. */
399 for (ln=bus->devices.next; ln != &bus->devices; ln=ln->next) {
400 int i;
401 dev = pci_dev_b(ln);
402
403 /* Skip bridges for now */
404 if (dev->class >> 8 == PCI_CLASS_BRIDGE_PCI)
405 continue;
406
407 for (i = 0; i < PCI_NUM_RESOURCES; i++) {
408 struct resource res;
409 unsigned long size;
410
411 memcpy(&res, &dev->resource[i], sizeof(res));
412 size = res.end - res.start + 1;
413
414 if (res.flags & IORESOURCE_IO) {
415 res.start = io_res.end;
416 pcibios_align_resource(dev, &res, size, 0);
417 io_res.end = res.start + size;
418 } else if (res.flags & IORESOURCE_MEM) {
419 res.start = mem_res.end;
420 pcibios_align_resource(dev, &res, size, 0);
421 mem_res.end = res.start + size;
422 }
423 }
424 }
425
426 /* And for all of the subordinate busses. */
427 for (ln=bus->children.next; ln != &bus->children; ln=ln->next)
428 pcibios_size_bridge(pci_bus_b(ln), &io_res, &mem_res);
429
430 /* turn the ending locations into sizes (subtract start) */
431 io_res.end -= io_res.start;
432 mem_res.end -= mem_res.start;
433
434 /* Align the sizes up by bridge rules */
435 io_res.end = ALIGN(io_res.end, 4*1024) - 1;
436 mem_res.end = ALIGN(mem_res.end, 1*1024*1024) - 1;
437
438 /* Adjust the bridge's allocation requirements */
439 bridge->resource[0].end = bridge->resource[0].start + io_res.end;
440 bridge->resource[1].end = bridge->resource[1].start + mem_res.end;
441
442 bridge->resource[PCI_BRIDGE_RESOURCES].end =
443 bridge->resource[PCI_BRIDGE_RESOURCES].start + io_res.end;
444 bridge->resource[PCI_BRIDGE_RESOURCES+1].end =
445 bridge->resource[PCI_BRIDGE_RESOURCES+1].start + mem_res.end;
446
447 /* adjust parent's resource requirements */
448 if (ior) {
449 ior->end = ALIGN(ior->end, 4*1024);
450 ior->end += io_res.end;
451 }
452
453 if (memr) {
454 memr->end = ALIGN(memr->end, 1*1024*1024);
455 memr->end += mem_res.end;
456 }
457}
458
459static void __init pcibios_size_bridges(void)
460{
461 struct resource io_res, mem_res;
462
463 memset(&io_res, 0, sizeof(io_res));
464 memset(&mem_res, 0, sizeof(mem_res));
465
466 pcibios_size_bridge(pci_root_bus, &io_res, &mem_res);
467}
468
469static int __init pcibios_init(void)
470{
471 if (request_irq(IRQ_ERR, pcish5_err_irq,
472 IRQF_DISABLED, "PCI Error",NULL) < 0) {
473 printk(KERN_ERR "PCISH5: Cannot hook PCI_PERR interrupt\n");
474 return -EINVAL;
475 }
476
477 if (request_irq(IRQ_SERR, pcish5_serr_irq,
478 IRQF_DISABLED, "PCI SERR interrupt", NULL) < 0) {
479 printk(KERN_ERR "PCISH5: Cannot hook PCI_SERR interrupt\n");
480 return -EINVAL;
481 }
482
483 /* The pci subsystem needs to know where memory is and how much
484 * of it there is. I've simply made these globals. A better mechanism
485 * is probably needed.
486 */
487 sh5pci_init(__pa(memory_start),
488 __pa(memory_end) - __pa(memory_start));
489
490 pci_root_bus = pci_scan_bus(0, &pci_config_ops, NULL);
491 pcibios_size_bridges();
492 pci_assign_unassigned_resources();
493 pci_fixup_irqs(no_swizzle, map_cayman_irq);
494
495 return 0;
496}
497
498subsys_initcall(pcibios_init);
499
500void __devinit pcibios_fixup_bus(struct pci_bus *bus)
501{
502 struct pci_dev *dev = bus->self;
503 int i;
504
505#if 1
506 if(dev) {
507 for(i=0; i<3; i++) {
508 bus->resource[i] =
509 &dev->resource[PCI_BRIDGE_RESOURCES+i];
510 bus->resource[i]->name = bus->name;
511 }
512 bus->resource[0]->flags |= IORESOURCE_IO;
513 bus->resource[1]->flags |= IORESOURCE_MEM;
514
515 /* For now, propagate host limits to the bus;
516 * we'll adjust them later. */
517
518#if 1
519 bus->resource[0]->end = 64*1024 - 1 ;
520 bus->resource[1]->end = PCIBIOS_MIN_MEM+(256*1024*1024)-1;
521 bus->resource[0]->start = PCIBIOS_MIN_IO;
522 bus->resource[1]->start = PCIBIOS_MIN_MEM;
523#else
524 bus->resource[0]->end = 0;
525 bus->resource[1]->end = 0;
526 bus->resource[0]->start =0;
527 bus->resource[1]->start = 0;
528#endif
529 /* Turn off downstream PF memory address range by default */
530 bus->resource[2]->start = 1024*1024;
531 bus->resource[2]->end = bus->resource[2]->start - 1;
532 }
533#endif
534
535}
536
diff --git a/arch/sh64/kernel/pci_sh5.h b/arch/sh64/kernel/pci_sh5.h
deleted file mode 100644
index c71159dd04b9..000000000000
--- a/arch/sh64/kernel/pci_sh5.h
+++ /dev/null
@@ -1,107 +0,0 @@
1/*
2 * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
3 *
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 * Definitions for the SH5 PCI hardware.
8 */
9
10/* Product ID */
11#define PCISH5_PID 0x350d
12
13/* vendor ID */
14#define PCISH5_VID 0x1054
15
16/* Configuration types */
17#define ST_TYPE0 0x00 /* Configuration cycle type 0 */
18#define ST_TYPE1 0x01 /* Configuration cycle type 1 */
19
20/* VCR data */
21#define PCISH5_VCR_STATUS 0x00
22#define PCISH5_VCR_VERSION 0x08
23
24/*
25** ICR register offsets and bits
26*/
27#define PCISH5_ICR_CR 0x100 /* PCI control register values */
28#define CR_PBAM (1<<12)
29#define CR_PFCS (1<<11)
30#define CR_FTO (1<<10)
31#define CR_PFE (1<<9)
32#define CR_TBS (1<<8)
33#define CR_SPUE (1<<7)
34#define CR_BMAM (1<<6)
35#define CR_HOST (1<<5)
36#define CR_CLKEN (1<<4)
37#define CR_SOCS (1<<3)
38#define CR_IOCS (1<<2)
39#define CR_RSTCTL (1<<1)
40#define CR_CFINT (1<<0)
41#define CR_LOCK_MASK 0xa5000000
42
43#define PCISH5_ICR_INT 0x114 /* Interrupt registert values */
44#define INT_MADIM (1<<2)
45
46#define PCISH5_ICR_LSR0 0X104 /* Local space register values */
47#define PCISH5_ICR_LSR1 0X108 /* Local space register values */
48#define PCISH5_ICR_LAR0 0x10c /* Local address register values */
49#define PCISH5_ICR_LAR1 0x110 /* Local address register values */
50#define PCISH5_ICR_INTM 0x118 /* Interrupt mask register values */
51#define PCISH5_ICR_AIR 0x11c /* Interrupt error address information register values */
52#define PCISH5_ICR_CIR 0x120 /* Interrupt error command information register values */
53#define PCISH5_ICR_AINT 0x130 /* Interrupt error arbiter interrupt register values */
54#define PCISH5_ICR_AINTM 0x134 /* Interrupt error arbiter interrupt mask register values */
55#define PCISH5_ICR_BMIR 0x138 /* Interrupt error info register of bus master values */
56#define PCISH5_ICR_PAR 0x1c0 /* Pio address register values */
57#define PCISH5_ICR_MBR 0x1c4 /* Memory space bank register values */
58#define PCISH5_ICR_IOBR 0x1c8 /* I/O space bank register values */
59#define PCISH5_ICR_PINT 0x1cc /* power management interrupt register values */
60#define PCISH5_ICR_PINTM 0x1d0 /* power management interrupt mask register values */
61#define PCISH5_ICR_MBMR 0x1d8 /* memory space bank mask register values */
62#define PCISH5_ICR_IOBMR 0x1dc /* I/O space bank mask register values */
63#define PCISH5_ICR_CSCR0 0x210 /* PCI cache snoop control register 0 */
64#define PCISH5_ICR_CSCR1 0x214 /* PCI cache snoop control register 1 */
65#define PCISH5_ICR_PDR 0x220 /* Pio data register values */
66
67/* These are configs space registers */
68#define PCISH5_ICR_CSR_VID 0x000 /* Vendor id */
69#define PCISH5_ICR_CSR_DID 0x002 /* Device id */
70#define PCISH5_ICR_CSR_CMD 0x004 /* Command register */
71#define PCISH5_ICR_CSR_STATUS 0x006 /* Stautus */
72#define PCISH5_ICR_CSR_IBAR0 0x010 /* I/O base address register */
73#define PCISH5_ICR_CSR_MBAR0 0x014 /* First Memory base address register */
74#define PCISH5_ICR_CSR_MBAR1 0x018 /* Second Memory base address register */
75
76
77
78/* Base address of registers */
79#define SH5PCI_ICR_BASE (PHYS_PCI_BLOCK + 0x00040000)
80#define SH5PCI_IO_BASE (PHYS_PCI_BLOCK + 0x00800000)
81/* #define SH5PCI_VCR_BASE (P2SEG_PCICB_BLOCK + P2SEG) */
82
83/* Register selection macro */
84#define PCISH5_ICR_REG(x) ( pcicr_virt + (PCISH5_ICR_##x))
85/* #define PCISH5_VCR_REG(x) ( SH5PCI_VCR_BASE (PCISH5_VCR_##x)) */
86
87/* Write I/O functions */
88#define SH5PCI_WRITE(reg,val) ctrl_outl((u32)(val),PCISH5_ICR_REG(reg))
89#define SH5PCI_WRITE_SHORT(reg,val) ctrl_outw((u16)(val),PCISH5_ICR_REG(reg))
90#define SH5PCI_WRITE_BYTE(reg,val) ctrl_outb((u8)(val),PCISH5_ICR_REG(reg))
91
92/* Read I/O functions */
93#define SH5PCI_READ(reg) ctrl_inl(PCISH5_ICR_REG(reg))
94#define SH5PCI_READ_SHORT(reg) ctrl_inw(PCISH5_ICR_REG(reg))
95#define SH5PCI_READ_BYTE(reg) ctrl_inb(PCISH5_ICR_REG(reg))
96
97/* Set PCI config bits */
98#define SET_CONFIG_BITS(bus,devfn,where) ((((bus) << 16) | ((devfn) << 8) | ((where) & ~3)) | 0x80000000)
99
100/* Set PCI command register */
101#define CONFIG_CMD(bus, devfn, where) SET_CONFIG_BITS(bus->number,devfn,where)
102
103/* Size converters */
104#define PCISH5_MEM_SIZCONV(x) (((x / 0x40000) - 1) << 18)
105#define PCISH5_IO_SIZCONV(x) (((x / 0x40000) - 1) << 18)
106
107
diff --git a/arch/sh64/kernel/pcibios.c b/arch/sh64/kernel/pcibios.c
deleted file mode 100644
index 945920bc24db..000000000000
--- a/arch/sh64/kernel/pcibios.c
+++ /dev/null
@@ -1,168 +0,0 @@
1/*
2 * $Id: pcibios.c,v 1.1 2001/08/24 12:38:19 dwmw2 Exp $
3 *
4 * arch/sh/kernel/pcibios.c
5 *
6 * Copyright (C) 2002 STMicroelectronics Limited
7 * Author : David J. McKay
8 *
9 * Copyright (C) 2004 Richard Curnow, SuperH UK Limited
10 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
14 * This is GPL'd.
15 *
16 * Provided here are generic versions of:
17 * pcibios_update_resource()
18 * pcibios_align_resource()
19 * pcibios_enable_device()
20 * pcibios_set_master()
21 * pcibios_update_irq()
22 *
23 * These functions are collected here to reduce duplication of common
24 * code amongst the many platform-specific PCI support code files.
25 *
26 * Platform-specific files are expected to provide:
27 * pcibios_fixup_bus()
28 * pcibios_init()
29 * pcibios_setup()
30 * pcibios_fixup_pbus_ranges()
31 */
32
33#include <linux/kernel.h>
34#include <linux/pci.h>
35#include <linux/init.h>
36
37void
38pcibios_update_resource(struct pci_dev *dev, struct resource *root,
39 struct resource *res, int resource)
40{
41 u32 new, check;
42 int reg;
43
44 new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
45 if (resource < 6) {
46 reg = PCI_BASE_ADDRESS_0 + 4*resource;
47 } else if (resource == PCI_ROM_RESOURCE) {
48 res->flags |= IORESOURCE_ROM_ENABLE;
49 new |= PCI_ROM_ADDRESS_ENABLE;
50 reg = dev->rom_base_reg;
51 } else {
52 /* Somebody might have asked allocation of a non-standard resource */
53 return;
54 }
55
56 pci_write_config_dword(dev, reg, new);
57 pci_read_config_dword(dev, reg, &check);
58 if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
59 printk(KERN_ERR "PCI: Error while updating region "
60 "%s/%d (%08x != %08x)\n", pci_name(dev), resource,
61 new, check);
62 }
63}
64
65/*
66 * We need to avoid collisions with `mirrored' VGA ports
67 * and other strange ISA hardware, so we always want the
68 * addresses to be allocated in the 0x000-0x0ff region
69 * modulo 0x400.
70 */
71void pcibios_align_resource(void *data, struct resource *res,
72 resource_size_t size, resource_size_t align)
73{
74 if (res->flags & IORESOURCE_IO) {
75 resource_size_t start = res->start;
76
77 if (start & 0x300) {
78 start = (start + 0x3ff) & ~0x3ff;
79 res->start = start;
80 }
81 }
82}
83
84static void pcibios_enable_bridge(struct pci_dev *dev)
85{
86 struct pci_bus *bus = dev->subordinate;
87 u16 cmd, old_cmd;
88
89 pci_read_config_word(dev, PCI_COMMAND, &cmd);
90 old_cmd = cmd;
91
92 if (bus->resource[0]->flags & IORESOURCE_IO) {
93 cmd |= PCI_COMMAND_IO;
94 }
95 if ((bus->resource[1]->flags & IORESOURCE_MEM) ||
96 (bus->resource[2]->flags & IORESOURCE_PREFETCH)) {
97 cmd |= PCI_COMMAND_MEMORY;
98 }
99
100 if (cmd != old_cmd) {
101 pci_write_config_word(dev, PCI_COMMAND, cmd);
102 }
103
104 printk("PCI bridge %s, command register -> %04x\n",
105 pci_name(dev), cmd);
106
107}
108
109
110
111int pcibios_enable_device(struct pci_dev *dev, int mask)
112{
113 u16 cmd, old_cmd;
114 int idx;
115 struct resource *r;
116
117 if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
118 pcibios_enable_bridge(dev);
119 }
120
121 pci_read_config_word(dev, PCI_COMMAND, &cmd);
122 old_cmd = cmd;
123 for(idx=0; idx<6; idx++) {
124 if (!(mask & (1 << idx)))
125 continue;
126 r = &dev->resource[idx];
127 if (!r->start && r->end) {
128 printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev));
129 return -EINVAL;
130 }
131 if (r->flags & IORESOURCE_IO)
132 cmd |= PCI_COMMAND_IO;
133 if (r->flags & IORESOURCE_MEM)
134 cmd |= PCI_COMMAND_MEMORY;
135 }
136 if (dev->resource[PCI_ROM_RESOURCE].start)
137 cmd |= PCI_COMMAND_MEMORY;
138 if (cmd != old_cmd) {
139 printk(KERN_INFO "PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd);
140 pci_write_config_word(dev, PCI_COMMAND, cmd);
141 }
142 return 0;
143}
144
145/*
146 * If we set up a device for bus mastering, we need to check and set
147 * the latency timer as it may not be properly set.
148 */
149unsigned int pcibios_max_latency = 255;
150
151void pcibios_set_master(struct pci_dev *dev)
152{
153 u8 lat;
154 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
155 if (lat < 16)
156 lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
157 else if (lat > pcibios_max_latency)
158 lat = pcibios_max_latency;
159 else
160 return;
161 printk(KERN_INFO "PCI: Setting latency timer of device %s to %d\n", pci_name(dev), lat);
162 pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
163}
164
165void __init pcibios_update_irq(struct pci_dev *dev, int irq)
166{
167 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
168}
diff --git a/arch/sh64/kernel/process.c b/arch/sh64/kernel/process.c
deleted file mode 100644
index 0761af4d2a42..000000000000
--- a/arch/sh64/kernel/process.c
+++ /dev/null
@@ -1,691 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/process.c
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003 Paul Mundt
10 * Copyright (C) 2003, 2004 Richard Curnow
11 *
12 * Started from SH3/4 version:
13 * Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima
14 *
15 * In turn started from i386 version:
16 * Copyright (C) 1995 Linus Torvalds
17 *
18 */
19
20/*
21 * This file handles the architecture-dependent parts of process handling..
22 */
23#include <linux/mm.h>
24#include <linux/fs.h>
25#include <linux/ptrace.h>
26#include <linux/reboot.h>
27#include <linux/init.h>
28#include <linux/module.h>
29#include <linux/proc_fs.h>
30#include <asm/uaccess.h>
31#include <asm/pgtable.h>
32
33struct task_struct *last_task_used_math = NULL;
34
35static int hlt_counter = 1;
36
37#define HARD_IDLE_TIMEOUT (HZ / 3)
38
39void disable_hlt(void)
40{
41 hlt_counter++;
42}
43
44void enable_hlt(void)
45{
46 hlt_counter--;
47}
48
49static int __init nohlt_setup(char *__unused)
50{
51 hlt_counter = 1;
52 return 1;
53}
54
55static int __init hlt_setup(char *__unused)
56{
57 hlt_counter = 0;
58 return 1;
59}
60
61__setup("nohlt", nohlt_setup);
62__setup("hlt", hlt_setup);
63
64static inline void hlt(void)
65{
66 __asm__ __volatile__ ("sleep" : : : "memory");
67}
68
69/*
70 * The idle loop on a uniprocessor SH..
71 */
72void cpu_idle(void)
73{
74 /* endless idle loop with no priority at all */
75 while (1) {
76 if (hlt_counter) {
77 while (!need_resched())
78 cpu_relax();
79 } else {
80 local_irq_disable();
81 while (!need_resched()) {
82 local_irq_enable();
83 hlt();
84 local_irq_disable();
85 }
86 local_irq_enable();
87 }
88 preempt_enable_no_resched();
89 schedule();
90 preempt_disable();
91 }
92
93}
94
95void machine_restart(char * __unused)
96{
97 extern void phys_stext(void);
98
99 phys_stext();
100}
101
102void machine_halt(void)
103{
104 for (;;);
105}
106
107void machine_power_off(void)
108{
109 extern void enter_deep_standby(void);
110
111 enter_deep_standby();
112}
113
114void (*pm_power_off)(void) = machine_power_off;
115EXPORT_SYMBOL(pm_power_off);
116
117void show_regs(struct pt_regs * regs)
118{
119 unsigned long long ah, al, bh, bl, ch, cl;
120
121 printk("\n");
122
123 ah = (regs->pc) >> 32;
124 al = (regs->pc) & 0xffffffff;
125 bh = (regs->regs[18]) >> 32;
126 bl = (regs->regs[18]) & 0xffffffff;
127 ch = (regs->regs[15]) >> 32;
128 cl = (regs->regs[15]) & 0xffffffff;
129 printk("PC : %08Lx%08Lx LINK: %08Lx%08Lx SP : %08Lx%08Lx\n",
130 ah, al, bh, bl, ch, cl);
131
132 ah = (regs->sr) >> 32;
133 al = (regs->sr) & 0xffffffff;
134 asm volatile ("getcon " __TEA ", %0" : "=r" (bh));
135 asm volatile ("getcon " __TEA ", %0" : "=r" (bl));
136 bh = (bh) >> 32;
137 bl = (bl) & 0xffffffff;
138 asm volatile ("getcon " __KCR0 ", %0" : "=r" (ch));
139 asm volatile ("getcon " __KCR0 ", %0" : "=r" (cl));
140 ch = (ch) >> 32;
141 cl = (cl) & 0xffffffff;
142 printk("SR : %08Lx%08Lx TEA : %08Lx%08Lx KCR0: %08Lx%08Lx\n",
143 ah, al, bh, bl, ch, cl);
144
145 ah = (regs->regs[0]) >> 32;
146 al = (regs->regs[0]) & 0xffffffff;
147 bh = (regs->regs[1]) >> 32;
148 bl = (regs->regs[1]) & 0xffffffff;
149 ch = (regs->regs[2]) >> 32;
150 cl = (regs->regs[2]) & 0xffffffff;
151 printk("R0 : %08Lx%08Lx R1 : %08Lx%08Lx R2 : %08Lx%08Lx\n",
152 ah, al, bh, bl, ch, cl);
153
154 ah = (regs->regs[3]) >> 32;
155 al = (regs->regs[3]) & 0xffffffff;
156 bh = (regs->regs[4]) >> 32;
157 bl = (regs->regs[4]) & 0xffffffff;
158 ch = (regs->regs[5]) >> 32;
159 cl = (regs->regs[5]) & 0xffffffff;
160 printk("R3 : %08Lx%08Lx R4 : %08Lx%08Lx R5 : %08Lx%08Lx\n",
161 ah, al, bh, bl, ch, cl);
162
163 ah = (regs->regs[6]) >> 32;
164 al = (regs->regs[6]) & 0xffffffff;
165 bh = (regs->regs[7]) >> 32;
166 bl = (regs->regs[7]) & 0xffffffff;
167 ch = (regs->regs[8]) >> 32;
168 cl = (regs->regs[8]) & 0xffffffff;
169 printk("R6 : %08Lx%08Lx R7 : %08Lx%08Lx R8 : %08Lx%08Lx\n",
170 ah, al, bh, bl, ch, cl);
171
172 ah = (regs->regs[9]) >> 32;
173 al = (regs->regs[9]) & 0xffffffff;
174 bh = (regs->regs[10]) >> 32;
175 bl = (regs->regs[10]) & 0xffffffff;
176 ch = (regs->regs[11]) >> 32;
177 cl = (regs->regs[11]) & 0xffffffff;
178 printk("R9 : %08Lx%08Lx R10 : %08Lx%08Lx R11 : %08Lx%08Lx\n",
179 ah, al, bh, bl, ch, cl);
180
181 ah = (regs->regs[12]) >> 32;
182 al = (regs->regs[12]) & 0xffffffff;
183 bh = (regs->regs[13]) >> 32;
184 bl = (regs->regs[13]) & 0xffffffff;
185 ch = (regs->regs[14]) >> 32;
186 cl = (regs->regs[14]) & 0xffffffff;
187 printk("R12 : %08Lx%08Lx R13 : %08Lx%08Lx R14 : %08Lx%08Lx\n",
188 ah, al, bh, bl, ch, cl);
189
190 ah = (regs->regs[16]) >> 32;
191 al = (regs->regs[16]) & 0xffffffff;
192 bh = (regs->regs[17]) >> 32;
193 bl = (regs->regs[17]) & 0xffffffff;
194 ch = (regs->regs[19]) >> 32;
195 cl = (regs->regs[19]) & 0xffffffff;
196 printk("R16 : %08Lx%08Lx R17 : %08Lx%08Lx R19 : %08Lx%08Lx\n",
197 ah, al, bh, bl, ch, cl);
198
199 ah = (regs->regs[20]) >> 32;
200 al = (regs->regs[20]) & 0xffffffff;
201 bh = (regs->regs[21]) >> 32;
202 bl = (regs->regs[21]) & 0xffffffff;
203 ch = (regs->regs[22]) >> 32;
204 cl = (regs->regs[22]) & 0xffffffff;
205 printk("R20 : %08Lx%08Lx R21 : %08Lx%08Lx R22 : %08Lx%08Lx\n",
206 ah, al, bh, bl, ch, cl);
207
208 ah = (regs->regs[23]) >> 32;
209 al = (regs->regs[23]) & 0xffffffff;
210 bh = (regs->regs[24]) >> 32;
211 bl = (regs->regs[24]) & 0xffffffff;
212 ch = (regs->regs[25]) >> 32;
213 cl = (regs->regs[25]) & 0xffffffff;
214 printk("R23 : %08Lx%08Lx R24 : %08Lx%08Lx R25 : %08Lx%08Lx\n",
215 ah, al, bh, bl, ch, cl);
216
217 ah = (regs->regs[26]) >> 32;
218 al = (regs->regs[26]) & 0xffffffff;
219 bh = (regs->regs[27]) >> 32;
220 bl = (regs->regs[27]) & 0xffffffff;
221 ch = (regs->regs[28]) >> 32;
222 cl = (regs->regs[28]) & 0xffffffff;
223 printk("R26 : %08Lx%08Lx R27 : %08Lx%08Lx R28 : %08Lx%08Lx\n",
224 ah, al, bh, bl, ch, cl);
225
226 ah = (regs->regs[29]) >> 32;
227 al = (regs->regs[29]) & 0xffffffff;
228 bh = (regs->regs[30]) >> 32;
229 bl = (regs->regs[30]) & 0xffffffff;
230 ch = (regs->regs[31]) >> 32;
231 cl = (regs->regs[31]) & 0xffffffff;
232 printk("R29 : %08Lx%08Lx R30 : %08Lx%08Lx R31 : %08Lx%08Lx\n",
233 ah, al, bh, bl, ch, cl);
234
235 ah = (regs->regs[32]) >> 32;
236 al = (regs->regs[32]) & 0xffffffff;
237 bh = (regs->regs[33]) >> 32;
238 bl = (regs->regs[33]) & 0xffffffff;
239 ch = (regs->regs[34]) >> 32;
240 cl = (regs->regs[34]) & 0xffffffff;
241 printk("R32 : %08Lx%08Lx R33 : %08Lx%08Lx R34 : %08Lx%08Lx\n",
242 ah, al, bh, bl, ch, cl);
243
244 ah = (regs->regs[35]) >> 32;
245 al = (regs->regs[35]) & 0xffffffff;
246 bh = (regs->regs[36]) >> 32;
247 bl = (regs->regs[36]) & 0xffffffff;
248 ch = (regs->regs[37]) >> 32;
249 cl = (regs->regs[37]) & 0xffffffff;
250 printk("R35 : %08Lx%08Lx R36 : %08Lx%08Lx R37 : %08Lx%08Lx\n",
251 ah, al, bh, bl, ch, cl);
252
253 ah = (regs->regs[38]) >> 32;
254 al = (regs->regs[38]) & 0xffffffff;
255 bh = (regs->regs[39]) >> 32;
256 bl = (regs->regs[39]) & 0xffffffff;
257 ch = (regs->regs[40]) >> 32;
258 cl = (regs->regs[40]) & 0xffffffff;
259 printk("R38 : %08Lx%08Lx R39 : %08Lx%08Lx R40 : %08Lx%08Lx\n",
260 ah, al, bh, bl, ch, cl);
261
262 ah = (regs->regs[41]) >> 32;
263 al = (regs->regs[41]) & 0xffffffff;
264 bh = (regs->regs[42]) >> 32;
265 bl = (regs->regs[42]) & 0xffffffff;
266 ch = (regs->regs[43]) >> 32;
267 cl = (regs->regs[43]) & 0xffffffff;
268 printk("R41 : %08Lx%08Lx R42 : %08Lx%08Lx R43 : %08Lx%08Lx\n",
269 ah, al, bh, bl, ch, cl);
270
271 ah = (regs->regs[44]) >> 32;
272 al = (regs->regs[44]) & 0xffffffff;
273 bh = (regs->regs[45]) >> 32;
274 bl = (regs->regs[45]) & 0xffffffff;
275 ch = (regs->regs[46]) >> 32;
276 cl = (regs->regs[46]) & 0xffffffff;
277 printk("R44 : %08Lx%08Lx R45 : %08Lx%08Lx R46 : %08Lx%08Lx\n",
278 ah, al, bh, bl, ch, cl);
279
280 ah = (regs->regs[47]) >> 32;
281 al = (regs->regs[47]) & 0xffffffff;
282 bh = (regs->regs[48]) >> 32;
283 bl = (regs->regs[48]) & 0xffffffff;
284 ch = (regs->regs[49]) >> 32;
285 cl = (regs->regs[49]) & 0xffffffff;
286 printk("R47 : %08Lx%08Lx R48 : %08Lx%08Lx R49 : %08Lx%08Lx\n",
287 ah, al, bh, bl, ch, cl);
288
289 ah = (regs->regs[50]) >> 32;
290 al = (regs->regs[50]) & 0xffffffff;
291 bh = (regs->regs[51]) >> 32;
292 bl = (regs->regs[51]) & 0xffffffff;
293 ch = (regs->regs[52]) >> 32;
294 cl = (regs->regs[52]) & 0xffffffff;
295 printk("R50 : %08Lx%08Lx R51 : %08Lx%08Lx R52 : %08Lx%08Lx\n",
296 ah, al, bh, bl, ch, cl);
297
298 ah = (regs->regs[53]) >> 32;
299 al = (regs->regs[53]) & 0xffffffff;
300 bh = (regs->regs[54]) >> 32;
301 bl = (regs->regs[54]) & 0xffffffff;
302 ch = (regs->regs[55]) >> 32;
303 cl = (regs->regs[55]) & 0xffffffff;
304 printk("R53 : %08Lx%08Lx R54 : %08Lx%08Lx R55 : %08Lx%08Lx\n",
305 ah, al, bh, bl, ch, cl);
306
307 ah = (regs->regs[56]) >> 32;
308 al = (regs->regs[56]) & 0xffffffff;
309 bh = (regs->regs[57]) >> 32;
310 bl = (regs->regs[57]) & 0xffffffff;
311 ch = (regs->regs[58]) >> 32;
312 cl = (regs->regs[58]) & 0xffffffff;
313 printk("R56 : %08Lx%08Lx R57 : %08Lx%08Lx R58 : %08Lx%08Lx\n",
314 ah, al, bh, bl, ch, cl);
315
316 ah = (regs->regs[59]) >> 32;
317 al = (regs->regs[59]) & 0xffffffff;
318 bh = (regs->regs[60]) >> 32;
319 bl = (regs->regs[60]) & 0xffffffff;
320 ch = (regs->regs[61]) >> 32;
321 cl = (regs->regs[61]) & 0xffffffff;
322 printk("R59 : %08Lx%08Lx R60 : %08Lx%08Lx R61 : %08Lx%08Lx\n",
323 ah, al, bh, bl, ch, cl);
324
325 ah = (regs->regs[62]) >> 32;
326 al = (regs->regs[62]) & 0xffffffff;
327 bh = (regs->tregs[0]) >> 32;
328 bl = (regs->tregs[0]) & 0xffffffff;
329 ch = (regs->tregs[1]) >> 32;
330 cl = (regs->tregs[1]) & 0xffffffff;
331 printk("R62 : %08Lx%08Lx T0 : %08Lx%08Lx T1 : %08Lx%08Lx\n",
332 ah, al, bh, bl, ch, cl);
333
334 ah = (regs->tregs[2]) >> 32;
335 al = (regs->tregs[2]) & 0xffffffff;
336 bh = (regs->tregs[3]) >> 32;
337 bl = (regs->tregs[3]) & 0xffffffff;
338 ch = (regs->tregs[4]) >> 32;
339 cl = (regs->tregs[4]) & 0xffffffff;
340 printk("T2 : %08Lx%08Lx T3 : %08Lx%08Lx T4 : %08Lx%08Lx\n",
341 ah, al, bh, bl, ch, cl);
342
343 ah = (regs->tregs[5]) >> 32;
344 al = (regs->tregs[5]) & 0xffffffff;
345 bh = (regs->tregs[6]) >> 32;
346 bl = (regs->tregs[6]) & 0xffffffff;
347 ch = (regs->tregs[7]) >> 32;
348 cl = (regs->tregs[7]) & 0xffffffff;
349 printk("T5 : %08Lx%08Lx T6 : %08Lx%08Lx T7 : %08Lx%08Lx\n",
350 ah, al, bh, bl, ch, cl);
351
352 /*
353 * If we're in kernel mode, dump the stack too..
354 */
355 if (!user_mode(regs)) {
356 void show_stack(struct task_struct *tsk, unsigned long *sp);
357 unsigned long sp = regs->regs[15] & 0xffffffff;
358 struct task_struct *tsk = get_current();
359
360 tsk->thread.kregs = regs;
361
362 show_stack(tsk, (unsigned long *)sp);
363 }
364}
365
366struct task_struct * alloc_task_struct(void)
367{
368 /* Get task descriptor pages */
369 return (struct task_struct *)
370 __get_free_pages(GFP_KERNEL, get_order(THREAD_SIZE));
371}
372
373void free_task_struct(struct task_struct *p)
374{
375 free_pages((unsigned long) p, get_order(THREAD_SIZE));
376}
377
378/*
379 * Create a kernel thread
380 */
381ATTRIB_NORET void kernel_thread_helper(void *arg, int (*fn)(void *))
382{
383 do_exit(fn(arg));
384}
385
386/*
387 * This is the mechanism for creating a new kernel thread.
388 *
389 * NOTE! Only a kernel-only process(ie the swapper or direct descendants
390 * who haven't done an "execve()") should use this: it will work within
391 * a system call from a "real" process, but the process memory space will
392 * not be freed until both the parent and the child have exited.
393 */
394int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
395{
396 struct pt_regs regs;
397
398 memset(&regs, 0, sizeof(regs));
399 regs.regs[2] = (unsigned long)arg;
400 regs.regs[3] = (unsigned long)fn;
401
402 regs.pc = (unsigned long)kernel_thread_helper;
403 regs.sr = (1 << 30);
404
405 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
406 &regs, 0, NULL, NULL);
407}
408
409/*
410 * Free current thread data structures etc..
411 */
412void exit_thread(void)
413{
414 /* See arch/sparc/kernel/process.c for the precedent for doing this -- RPC.
415
416 The SH-5 FPU save/restore approach relies on last_task_used_math
417 pointing to a live task_struct. When another task tries to use the
418 FPU for the 1st time, the FPUDIS trap handling (see
419 arch/sh64/kernel/fpu.c) will save the existing FPU state to the
420 FP regs field within last_task_used_math before re-loading the new
421 task's FPU state (or initialising it if the FPU has been used
422 before). So if last_task_used_math is stale, and its page has already been
423 re-allocated for another use, the consequences are rather grim. Unless we
424 null it here, there is no other path through which it would get safely
425 nulled. */
426
427#ifdef CONFIG_SH_FPU
428 if (last_task_used_math == current) {
429 last_task_used_math = NULL;
430 }
431#endif
432}
433
434void flush_thread(void)
435{
436
437 /* Called by fs/exec.c (flush_old_exec) to remove traces of a
438 * previously running executable. */
439#ifdef CONFIG_SH_FPU
440 if (last_task_used_math == current) {
441 last_task_used_math = NULL;
442 }
443 /* Force FPU state to be reinitialised after exec */
444 clear_used_math();
445#endif
446
447 /* if we are a kernel thread, about to change to user thread,
448 * update kreg
449 */
450 if(current->thread.kregs==&fake_swapper_regs) {
451 current->thread.kregs =
452 ((struct pt_regs *)(THREAD_SIZE + (unsigned long) current) - 1);
453 current->thread.uregs = current->thread.kregs;
454 }
455}
456
457void release_thread(struct task_struct *dead_task)
458{
459 /* do nothing */
460}
461
462/* Fill in the fpu structure for a core dump.. */
463int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
464{
465#ifdef CONFIG_SH_FPU
466 int fpvalid;
467 struct task_struct *tsk = current;
468
469 fpvalid = !!tsk_used_math(tsk);
470 if (fpvalid) {
471 if (current == last_task_used_math) {
472 grab_fpu();
473 fpsave(&tsk->thread.fpu.hard);
474 release_fpu();
475 last_task_used_math = 0;
476 regs->sr |= SR_FD;
477 }
478
479 memcpy(fpu, &tsk->thread.fpu.hard, sizeof(*fpu));
480 }
481
482 return fpvalid;
483#else
484 return 0; /* Task didn't use the fpu at all. */
485#endif
486}
487
488asmlinkage void ret_from_fork(void);
489
490int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
491 unsigned long unused,
492 struct task_struct *p, struct pt_regs *regs)
493{
494 struct pt_regs *childregs;
495 unsigned long long se; /* Sign extension */
496
497#ifdef CONFIG_SH_FPU
498 if(last_task_used_math == current) {
499 grab_fpu();
500 fpsave(&current->thread.fpu.hard);
501 release_fpu();
502 last_task_used_math = NULL;
503 regs->sr |= SR_FD;
504 }
505#endif
506 /* Copy from sh version */
507 childregs = (struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1;
508
509 *childregs = *regs;
510
511 if (user_mode(regs)) {
512 childregs->regs[15] = usp;
513 p->thread.uregs = childregs;
514 } else {
515 childregs->regs[15] = (unsigned long)task_stack_page(p) + THREAD_SIZE;
516 }
517
518 childregs->regs[9] = 0; /* Set return value for child */
519 childregs->sr |= SR_FD; /* Invalidate FPU flag */
520
521 p->thread.sp = (unsigned long) childregs;
522 p->thread.pc = (unsigned long) ret_from_fork;
523
524 /*
525 * Sign extend the edited stack.
526 * Note that thread.pc and thread.pc will stay
527 * 32-bit wide and context switch must take care
528 * of NEFF sign extension.
529 */
530
531 se = childregs->regs[15];
532 se = (se & NEFF_SIGN) ? (se | NEFF_MASK) : se;
533 childregs->regs[15] = se;
534
535 return 0;
536}
537
538asmlinkage int sys_fork(unsigned long r2, unsigned long r3,
539 unsigned long r4, unsigned long r5,
540 unsigned long r6, unsigned long r7,
541 struct pt_regs *pregs)
542{
543 return do_fork(SIGCHLD, pregs->regs[15], pregs, 0, 0, 0);
544}
545
546asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
547 unsigned long r4, unsigned long r5,
548 unsigned long r6, unsigned long r7,
549 struct pt_regs *pregs)
550{
551 if (!newsp)
552 newsp = pregs->regs[15];
553 return do_fork(clone_flags, newsp, pregs, 0, 0, 0);
554}
555
556/*
557 * This is trivial, and on the face of it looks like it
558 * could equally well be done in user mode.
559 *
560 * Not so, for quite unobvious reasons - register pressure.
561 * In user mode vfork() cannot have a stack frame, and if
562 * done by calling the "clone()" system call directly, you
563 * do not have enough call-clobbered registers to hold all
564 * the information you need.
565 */
566asmlinkage int sys_vfork(unsigned long r2, unsigned long r3,
567 unsigned long r4, unsigned long r5,
568 unsigned long r6, unsigned long r7,
569 struct pt_regs *pregs)
570{
571 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, pregs->regs[15], pregs, 0, 0, 0);
572}
573
574/*
575 * sys_execve() executes a new program.
576 */
577asmlinkage int sys_execve(char *ufilename, char **uargv,
578 char **uenvp, unsigned long r5,
579 unsigned long r6, unsigned long r7,
580 struct pt_regs *pregs)
581{
582 int error;
583 char *filename;
584
585 lock_kernel();
586 filename = getname((char __user *)ufilename);
587 error = PTR_ERR(filename);
588 if (IS_ERR(filename))
589 goto out;
590
591 error = do_execve(filename,
592 (char __user * __user *)uargv,
593 (char __user * __user *)uenvp,
594 pregs);
595 if (error == 0) {
596 task_lock(current);
597 current->ptrace &= ~PT_DTRACE;
598 task_unlock(current);
599 }
600 putname(filename);
601out:
602 unlock_kernel();
603 return error;
604}
605
606/*
607 * These bracket the sleeping functions..
608 */
609extern void interruptible_sleep_on(wait_queue_head_t *q);
610
611#define mid_sched ((unsigned long) interruptible_sleep_on)
612
613static int in_sh64_switch_to(unsigned long pc)
614{
615 extern char __sh64_switch_to_end;
616 /* For a sleeping task, the PC is somewhere in the middle of the function,
617 so we don't have to worry about masking the LSB off */
618 return (pc >= (unsigned long) sh64_switch_to) &&
619 (pc < (unsigned long) &__sh64_switch_to_end);
620}
621
622unsigned long get_wchan(struct task_struct *p)
623{
624 unsigned long schedule_fp;
625 unsigned long sh64_switch_to_fp;
626 unsigned long schedule_caller_pc;
627 unsigned long pc;
628
629 if (!p || p == current || p->state == TASK_RUNNING)
630 return 0;
631
632 /*
633 * The same comment as on the Alpha applies here, too ...
634 */
635 pc = thread_saved_pc(p);
636
637#ifdef CONFIG_FRAME_POINTER
638 if (in_sh64_switch_to(pc)) {
639 sh64_switch_to_fp = (long) p->thread.sp;
640 /* r14 is saved at offset 4 in the sh64_switch_to frame */
641 schedule_fp = *(unsigned long *) (long)(sh64_switch_to_fp + 4);
642
643 /* and the caller of 'schedule' is (currently!) saved at offset 24
644 in the frame of schedule (from disasm) */
645 schedule_caller_pc = *(unsigned long *) (long)(schedule_fp + 24);
646 return schedule_caller_pc;
647 }
648#endif
649 return pc;
650}
651
652/* Provide a /proc/asids file that lists out the
653 ASIDs currently associated with the processes. (If the DM.PC register is
654 examined through the debug link, this shows ASID + PC. To make use of this,
655 the PID->ASID relationship needs to be known. This is primarily for
656 debugging.)
657 */
658
659#if defined(CONFIG_SH64_PROC_ASIDS)
660static int
661asids_proc_info(char *buf, char **start, off_t fpos, int length, int *eof, void *data)
662{
663 int len=0;
664 struct task_struct *p;
665 read_lock(&tasklist_lock);
666 for_each_process(p) {
667 int pid = p->pid;
668 struct mm_struct *mm;
669 if (!pid) continue;
670 mm = p->mm;
671 if (mm) {
672 unsigned long asid, context;
673 context = mm->context;
674 asid = (context & 0xff);
675 len += sprintf(buf+len, "%5d : %02lx\n", pid, asid);
676 } else {
677 len += sprintf(buf+len, "%5d : (none)\n", pid);
678 }
679 }
680 read_unlock(&tasklist_lock);
681 *eof = 1;
682 return len;
683}
684
685static int __init register_proc_asids(void)
686{
687 create_proc_read_entry("asids", 0, NULL, asids_proc_info, NULL);
688 return 0;
689}
690__initcall(register_proc_asids);
691#endif
diff --git a/arch/sh64/kernel/ptrace.c b/arch/sh64/kernel/ptrace.c
deleted file mode 100644
index 8a2d339cf760..000000000000
--- a/arch/sh64/kernel/ptrace.c
+++ /dev/null
@@ -1,332 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/ptrace.c
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003 Paul Mundt
10 *
11 * Started from SH3/4 version:
12 * SuperH version: Copyright (C) 1999, 2000 Kaz Kojima & Niibe Yutaka
13 *
14 * Original x86 implementation:
15 * By Ross Biro 1/23/92
16 * edited by Linus Torvalds
17 *
18 */
19
20#include <linux/kernel.h>
21#include <linux/rwsem.h>
22#include <linux/sched.h>
23#include <linux/mm.h>
24#include <linux/smp.h>
25#include <linux/smp_lock.h>
26#include <linux/errno.h>
27#include <linux/ptrace.h>
28#include <linux/user.h>
29#include <linux/signal.h>
30#include <linux/syscalls.h>
31
32#include <asm/io.h>
33#include <asm/uaccess.h>
34#include <asm/pgtable.h>
35#include <asm/system.h>
36#include <asm/processor.h>
37#include <asm/mmu_context.h>
38
39/* This mask defines the bits of the SR which the user is not allowed to
40 change, which are everything except S, Q, M, PR, SZ, FR. */
41#define SR_MASK (0xffff8cfd)
42
43/*
44 * does not yet catch signals sent when the child dies.
45 * in exit.c or in signal.c.
46 */
47
48/*
49 * This routine will get a word from the user area in the process kernel stack.
50 */
51static inline int get_stack_long(struct task_struct *task, int offset)
52{
53 unsigned char *stack;
54
55 stack = (unsigned char *)(task->thread.uregs);
56 stack += offset;
57 return (*((int *)stack));
58}
59
60static inline unsigned long
61get_fpu_long(struct task_struct *task, unsigned long addr)
62{
63 unsigned long tmp;
64 struct pt_regs *regs;
65 regs = (struct pt_regs*)((unsigned char *)task + THREAD_SIZE) - 1;
66
67 if (!tsk_used_math(task)) {
68 if (addr == offsetof(struct user_fpu_struct, fpscr)) {
69 tmp = FPSCR_INIT;
70 } else {
71 tmp = 0xffffffffUL; /* matches initial value in fpu.c */
72 }
73 return tmp;
74 }
75
76 if (last_task_used_math == task) {
77 grab_fpu();
78 fpsave(&task->thread.fpu.hard);
79 release_fpu();
80 last_task_used_math = 0;
81 regs->sr |= SR_FD;
82 }
83
84 tmp = ((long *)&task->thread.fpu)[addr / sizeof(unsigned long)];
85 return tmp;
86}
87
88/*
89 * This routine will put a word into the user area in the process kernel stack.
90 */
91static inline int put_stack_long(struct task_struct *task, int offset,
92 unsigned long data)
93{
94 unsigned char *stack;
95
96 stack = (unsigned char *)(task->thread.uregs);
97 stack += offset;
98 *(unsigned long *) stack = data;
99 return 0;
100}
101
102static inline int
103put_fpu_long(struct task_struct *task, unsigned long addr, unsigned long data)
104{
105 struct pt_regs *regs;
106
107 regs = (struct pt_regs*)((unsigned char *)task + THREAD_SIZE) - 1;
108
109 if (!tsk_used_math(task)) {
110 fpinit(&task->thread.fpu.hard);
111 set_stopped_child_used_math(task);
112 } else if (last_task_used_math == task) {
113 grab_fpu();
114 fpsave(&task->thread.fpu.hard);
115 release_fpu();
116 last_task_used_math = 0;
117 regs->sr |= SR_FD;
118 }
119
120 ((long *)&task->thread.fpu)[addr / sizeof(unsigned long)] = data;
121 return 0;
122}
123
124
125long arch_ptrace(struct task_struct *child, long request, long addr, long data)
126{
127 int ret;
128
129 switch (request) {
130 /* when I and D space are separate, these will need to be fixed. */
131 case PTRACE_PEEKTEXT: /* read word at location addr. */
132 case PTRACE_PEEKDATA:
133 ret = generic_ptrace_peekdata(child, addr, data);
134 break;
135
136 /* read the word at location addr in the USER area. */
137 case PTRACE_PEEKUSR: {
138 unsigned long tmp;
139
140 ret = -EIO;
141 if ((addr & 3) || addr < 0)
142 break;
143
144 if (addr < sizeof(struct pt_regs))
145 tmp = get_stack_long(child, addr);
146 else if ((addr >= offsetof(struct user, fpu)) &&
147 (addr < offsetof(struct user, u_fpvalid))) {
148 tmp = get_fpu_long(child, addr - offsetof(struct user, fpu));
149 } else if (addr == offsetof(struct user, u_fpvalid)) {
150 tmp = !!tsk_used_math(child);
151 } else {
152 break;
153 }
154 ret = put_user(tmp, (unsigned long *)data);
155 break;
156 }
157
158 /* when I and D space are separate, this will have to be fixed. */
159 case PTRACE_POKETEXT: /* write the word at location addr. */
160 case PTRACE_POKEDATA:
161 ret = generic_ptrace_pokedata(child, addr, data);
162 break;
163
164 case PTRACE_POKEUSR:
165 /* write the word at location addr in the USER area. We must
166 disallow any changes to certain SR bits or u_fpvalid, since
167 this could crash the kernel or result in a security
168 loophole. */
169 ret = -EIO;
170 if ((addr & 3) || addr < 0)
171 break;
172
173 if (addr < sizeof(struct pt_regs)) {
174 /* Ignore change of top 32 bits of SR */
175 if (addr == offsetof (struct pt_regs, sr)+4)
176 {
177 ret = 0;
178 break;
179 }
180 /* If lower 32 bits of SR, ignore non-user bits */
181 if (addr == offsetof (struct pt_regs, sr))
182 {
183 long cursr = get_stack_long(child, addr);
184 data &= ~(SR_MASK);
185 data |= (cursr & SR_MASK);
186 }
187 ret = put_stack_long(child, addr, data);
188 }
189 else if ((addr >= offsetof(struct user, fpu)) &&
190 (addr < offsetof(struct user, u_fpvalid))) {
191 ret = put_fpu_long(child, addr - offsetof(struct user, fpu), data);
192 }
193 break;
194
195 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
196 case PTRACE_CONT: { /* restart after signal. */
197 ret = -EIO;
198 if (!valid_signal(data))
199 break;
200 if (request == PTRACE_SYSCALL)
201 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
202 else
203 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
204 child->exit_code = data;
205 wake_up_process(child);
206 ret = 0;
207 break;
208 }
209
210/*
211 * make the child exit. Best I can do is send it a sigkill.
212 * perhaps it should be put in the status that it wants to
213 * exit.
214 */
215 case PTRACE_KILL: {
216 ret = 0;
217 if (child->exit_state == EXIT_ZOMBIE) /* already dead */
218 break;
219 child->exit_code = SIGKILL;
220 wake_up_process(child);
221 break;
222 }
223
224 case PTRACE_SINGLESTEP: { /* set the trap flag. */
225 struct pt_regs *regs;
226
227 ret = -EIO;
228 if (!valid_signal(data))
229 break;
230 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
231 if ((child->ptrace & PT_DTRACE) == 0) {
232 /* Spurious delayed TF traps may occur */
233 child->ptrace |= PT_DTRACE;
234 }
235
236 regs = child->thread.uregs;
237
238 regs->sr |= SR_SSTEP; /* auto-resetting upon exception */
239
240 child->exit_code = data;
241 /* give it a chance to run. */
242 wake_up_process(child);
243 ret = 0;
244 break;
245 }
246
247 default:
248 ret = ptrace_request(child, request, addr, data);
249 break;
250 }
251 return ret;
252}
253
254asmlinkage int sh64_ptrace(long request, long pid, long addr, long data)
255{
256 extern void poke_real_address_q(unsigned long long addr, unsigned long long data);
257#define WPC_DBRMODE 0x0d104008
258 static int first_call = 1;
259
260 lock_kernel();
261 if (first_call) {
262 /* Set WPC.DBRMODE to 0. This makes all debug events get
263 * delivered through RESVEC, i.e. into the handlers in entry.S.
264 * (If the kernel was downloaded using a remote gdb, WPC.DBRMODE
265 * would normally be left set to 1, which makes debug events get
266 * delivered through DBRVEC, i.e. into the remote gdb's
267 * handlers. This prevents ptrace getting them, and confuses
268 * the remote gdb.) */
269 printk("DBRMODE set to 0 to permit native debugging\n");
270 poke_real_address_q(WPC_DBRMODE, 0);
271 first_call = 0;
272 }
273 unlock_kernel();
274
275 return sys_ptrace(request, pid, addr, data);
276}
277
278asmlinkage void syscall_trace(void)
279{
280 struct task_struct *tsk = current;
281
282 if (!test_thread_flag(TIF_SYSCALL_TRACE))
283 return;
284 if (!(tsk->ptrace & PT_PTRACED))
285 return;
286
287 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
288 ? 0x80 : 0));
289 /*
290 * this isn't the same as continuing with a signal, but it will do
291 * for normal use. strace only continues with a signal if the
292 * stopping signal is not SIGTRAP. -brl
293 */
294 if (tsk->exit_code) {
295 send_sig(tsk->exit_code, tsk, 1);
296 tsk->exit_code = 0;
297 }
298}
299
300/* Called with interrupts disabled */
301asmlinkage void do_single_step(unsigned long long vec, struct pt_regs *regs)
302{
303 /* This is called after a single step exception (DEBUGSS).
304 There is no need to change the PC, as it is a post-execution
305 exception, as entry.S does not do anything to the PC for DEBUGSS.
306 We need to clear the Single Step setting in SR to avoid
307 continually stepping. */
308 local_irq_enable();
309 regs->sr &= ~SR_SSTEP;
310 force_sig(SIGTRAP, current);
311}
312
313/* Called with interrupts disabled */
314asmlinkage void do_software_break_point(unsigned long long vec,
315 struct pt_regs *regs)
316{
317 /* We need to forward step the PC, to counteract the backstep done
318 in signal.c. */
319 local_irq_enable();
320 force_sig(SIGTRAP, current);
321 regs->pc += 4;
322}
323
324/*
325 * Called by kernel/ptrace.c when detaching..
326 *
327 * Make sure single step bits etc are not set.
328 */
329void ptrace_disable(struct task_struct *child)
330{
331 /* nothing to do.. */
332}
diff --git a/arch/sh64/kernel/semaphore.c b/arch/sh64/kernel/semaphore.c
deleted file mode 100644
index 72c16533436e..000000000000
--- a/arch/sh64/kernel/semaphore.c
+++ /dev/null
@@ -1,140 +0,0 @@
1/*
2 * Just taken from alpha implementation.
3 * This can't work well, perhaps.
4 */
5/*
6 * Generic semaphore code. Buyer beware. Do your own
7 * specific changes in <asm/semaphore-helper.h>
8 */
9
10#include <linux/errno.h>
11#include <linux/rwsem.h>
12#include <linux/sched.h>
13#include <linux/wait.h>
14#include <linux/init.h>
15#include <asm/semaphore.h>
16#include <asm/semaphore-helper.h>
17
18spinlock_t semaphore_wake_lock;
19
20/*
21 * Semaphores are implemented using a two-way counter:
22 * The "count" variable is decremented for each process
23 * that tries to sleep, while the "waking" variable is
24 * incremented when the "up()" code goes to wake up waiting
25 * processes.
26 *
27 * Notably, the inline "up()" and "down()" functions can
28 * efficiently test if they need to do any extra work (up
29 * needs to do something only if count was negative before
30 * the increment operation.
31 *
32 * waking_non_zero() (from asm/semaphore.h) must execute
33 * atomically.
34 *
35 * When __up() is called, the count was negative before
36 * incrementing it, and we need to wake up somebody.
37 *
38 * This routine adds one to the count of processes that need to
39 * wake up and exit. ALL waiting processes actually wake up but
40 * only the one that gets to the "waking" field first will gate
41 * through and acquire the semaphore. The others will go back
42 * to sleep.
43 *
44 * Note that these functions are only called when there is
45 * contention on the lock, and as such all this is the
46 * "non-critical" part of the whole semaphore business. The
47 * critical part is the inline stuff in <asm/semaphore.h>
48 * where we want to avoid any extra jumps and calls.
49 */
50void __up(struct semaphore *sem)
51{
52 wake_one_more(sem);
53 wake_up(&sem->wait);
54}
55
56/*
57 * Perform the "down" function. Return zero for semaphore acquired,
58 * return negative for signalled out of the function.
59 *
60 * If called from __down, the return is ignored and the wait loop is
61 * not interruptible. This means that a task waiting on a semaphore
62 * using "down()" cannot be killed until someone does an "up()" on
63 * the semaphore.
64 *
65 * If called from __down_interruptible, the return value gets checked
66 * upon return. If the return value is negative then the task continues
67 * with the negative value in the return register (it can be tested by
68 * the caller).
69 *
70 * Either form may be used in conjunction with "up()".
71 *
72 */
73
74#define DOWN_VAR \
75 struct task_struct *tsk = current; \
76 wait_queue_t wait; \
77 init_waitqueue_entry(&wait, tsk);
78
79#define DOWN_HEAD(task_state) \
80 \
81 \
82 tsk->state = (task_state); \
83 add_wait_queue(&sem->wait, &wait); \
84 \
85 /* \
86 * Ok, we're set up. sem->count is known to be less than zero \
87 * so we must wait. \
88 * \
89 * We can let go the lock for purposes of waiting. \
90 * We re-acquire it after awaking so as to protect \
91 * all semaphore operations. \
92 * \
93 * If "up()" is called before we call waking_non_zero() then \
94 * we will catch it right away. If it is called later then \
95 * we will have to go through a wakeup cycle to catch it. \
96 * \
97 * Multiple waiters contend for the semaphore lock to see \
98 * who gets to gate through and who has to wait some more. \
99 */ \
100 for (;;) {
101
102#define DOWN_TAIL(task_state) \
103 tsk->state = (task_state); \
104 } \
105 tsk->state = TASK_RUNNING; \
106 remove_wait_queue(&sem->wait, &wait);
107
108void __sched __down(struct semaphore * sem)
109{
110 DOWN_VAR
111 DOWN_HEAD(TASK_UNINTERRUPTIBLE)
112 if (waking_non_zero(sem))
113 break;
114 schedule();
115 DOWN_TAIL(TASK_UNINTERRUPTIBLE)
116}
117
118int __sched __down_interruptible(struct semaphore * sem)
119{
120 int ret = 0;
121 DOWN_VAR
122 DOWN_HEAD(TASK_INTERRUPTIBLE)
123
124 ret = waking_non_zero_interruptible(sem, tsk);
125 if (ret)
126 {
127 if (ret == 1)
128 /* ret != 0 only if we get interrupted -arca */
129 ret = 0;
130 break;
131 }
132 schedule();
133 DOWN_TAIL(TASK_INTERRUPTIBLE)
134 return ret;
135}
136
137int __down_trylock(struct semaphore * sem)
138{
139 return waking_non_zero_trylock(sem);
140}
diff --git a/arch/sh64/kernel/setup.c b/arch/sh64/kernel/setup.c
deleted file mode 100644
index 2b7264c0c6f7..000000000000
--- a/arch/sh64/kernel/setup.c
+++ /dev/null
@@ -1,379 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/setup.c
7 *
8 * sh64 Arch Support
9 *
10 * This file handles the architecture-dependent parts of initialization
11 *
12 * Copyright (C) 2000, 2001 Paolo Alberelli
13 * Copyright (C) 2003, 2004 Paul Mundt
14 *
15 * benedict.gaster@superh.com: 2nd May 2002
16 * Modified to use the empty_zero_page to pass command line arguments.
17 *
18 * benedict.gaster@superh.com: 3rd May 2002
19 * Added support for ramdisk, removing statically linked romfs at the same time.
20 *
21 * lethal@linux-sh.org: 15th May 2003
22 * Added generic procfs cpuinfo reporting. Make boards just export their name.
23 *
24 * lethal@linux-sh.org: 25th May 2003
25 * Added generic get_cpu_subtype() for subtype reporting from cpu_data->type.
26 *
27 */
28#include <linux/errno.h>
29#include <linux/rwsem.h>
30#include <linux/sched.h>
31#include <linux/kernel.h>
32#include <linux/mm.h>
33#include <linux/stddef.h>
34#include <linux/unistd.h>
35#include <linux/ptrace.h>
36#include <linux/slab.h>
37#include <linux/user.h>
38#include <linux/a.out.h>
39#include <linux/screen_info.h>
40#include <linux/ioport.h>
41#include <linux/delay.h>
42#include <linux/init.h>
43#include <linux/seq_file.h>
44#include <linux/blkdev.h>
45#include <linux/bootmem.h>
46#include <linux/console.h>
47#include <linux/root_dev.h>
48#include <linux/cpu.h>
49#include <linux/initrd.h>
50#include <linux/pfn.h>
51#include <asm/processor.h>
52#include <asm/page.h>
53#include <asm/pgtable.h>
54#include <asm/platform.h>
55#include <asm/uaccess.h>
56#include <asm/system.h>
57#include <asm/io.h>
58#include <asm/sections.h>
59#include <asm/setup.h>
60#include <asm/smp.h>
61
62struct screen_info screen_info;
63
64#ifdef CONFIG_BLK_DEV_RAM
65extern int rd_doload; /* 1 = load ramdisk, 0 = don't load */
66extern int rd_prompt; /* 1 = prompt for ramdisk, 0 = don't prompt */
67extern int rd_image_start; /* starting block # of image */
68#endif
69
70extern int root_mountflags;
71extern char *get_system_type(void);
72extern void platform_setup(void);
73extern void platform_monitor(void);
74extern void platform_reserve(void);
75extern int sh64_cache_init(void);
76extern int sh64_tlb_init(void);
77
78#define RAMDISK_IMAGE_START_MASK 0x07FF
79#define RAMDISK_PROMPT_FLAG 0x8000
80#define RAMDISK_LOAD_FLAG 0x4000
81
82static char __initdata command_line[COMMAND_LINE_SIZE] = { 0, };
83unsigned long long memory_start = CONFIG_MEMORY_START;
84unsigned long long memory_end = CONFIG_MEMORY_START + (CONFIG_MEMORY_SIZE_IN_MB * 1024 * 1024);
85
86struct sh_cpuinfo boot_cpu_data;
87
88static inline void parse_mem_cmdline (char ** cmdline_p)
89{
90 char c = ' ', *to = command_line, *from = COMMAND_LINE;
91 int len = 0;
92
93 /* Save unparsed command line copy for /proc/cmdline */
94 memcpy(boot_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
95 boot_command_line[COMMAND_LINE_SIZE-1] = '\0';
96
97 for (;;) {
98 /*
99 * "mem=XXX[kKmM]" defines a size of memory.
100 */
101 if (c == ' ' && !memcmp(from, "mem=", 4)) {
102 if (to != command_line)
103 to--;
104 {
105 unsigned long mem_size;
106
107 mem_size = memparse(from+4, &from);
108 memory_end = memory_start + mem_size;
109 }
110 }
111 c = *(from++);
112 if (!c)
113 break;
114 if (COMMAND_LINE_SIZE <= ++len)
115 break;
116 *(to++) = c;
117 }
118 *to = '\0';
119
120 *cmdline_p = command_line;
121}
122
123static void __init sh64_cpu_type_detect(void)
124{
125 extern unsigned long long peek_real_address_q(unsigned long long addr);
126 unsigned long long cir;
127 /* Do peeks in real mode to avoid having to set up a mapping for the
128 WPC registers. On SH5-101 cut2, such a mapping would be exposed to
129 an address translation erratum which would make it hard to set up
130 correctly. */
131 cir = peek_real_address_q(0x0d000008);
132
133 if ((cir & 0xffff) == 0x5103) {
134 boot_cpu_data.type = CPU_SH5_103;
135 } else if (((cir >> 32) & 0xffff) == 0x51e2) {
136 /* CPU.VCR aliased at CIR address on SH5-101 */
137 boot_cpu_data.type = CPU_SH5_101;
138 } else {
139 boot_cpu_data.type = CPU_SH_NONE;
140 }
141}
142
143void __init setup_arch(char **cmdline_p)
144{
145 unsigned long bootmap_size, i;
146 unsigned long first_pfn, start_pfn, last_pfn, pages;
147
148#ifdef CONFIG_EARLY_PRINTK
149 extern void enable_early_printk(void);
150
151 /*
152 * Setup Early SCIF console
153 */
154 enable_early_printk();
155#endif
156
157 /*
158 * Setup TLB mappings
159 */
160 sh64_tlb_init();
161
162 /*
163 * Caches are already initialized by the time we get here, so we just
164 * fill in cpu_data info for the caches.
165 */
166 sh64_cache_init();
167
168 platform_setup();
169 platform_monitor();
170
171 sh64_cpu_type_detect();
172
173 ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
174
175#ifdef CONFIG_BLK_DEV_RAM
176 rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
177 rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
178 rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
179#endif
180
181 if (!MOUNT_ROOT_RDONLY)
182 root_mountflags &= ~MS_RDONLY;
183 init_mm.start_code = (unsigned long) _text;
184 init_mm.end_code = (unsigned long) _etext;
185 init_mm.end_data = (unsigned long) _edata;
186 init_mm.brk = (unsigned long) _end;
187
188 code_resource.start = __pa(_text);
189 code_resource.end = __pa(_etext)-1;
190 data_resource.start = __pa(_etext);
191 data_resource.end = __pa(_edata)-1;
192
193 parse_mem_cmdline(cmdline_p);
194
195 /*
196 * Find the lowest and highest page frame numbers we have available
197 */
198 first_pfn = PFN_DOWN(memory_start);
199 last_pfn = PFN_DOWN(memory_end);
200 pages = last_pfn - first_pfn;
201
202 /*
203 * Partially used pages are not usable - thus
204 * we are rounding upwards:
205 */
206 start_pfn = PFN_UP(__pa(_end));
207
208 /*
209 * Find a proper area for the bootmem bitmap. After this
210 * bootstrap step all allocations (until the page allocator
211 * is intact) must be done via bootmem_alloc().
212 */
213 bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
214 first_pfn,
215 last_pfn);
216 /*
217 * Round it up.
218 */
219 bootmap_size = PFN_PHYS(PFN_UP(bootmap_size));
220
221 /*
222 * Register fully available RAM pages with the bootmem allocator.
223 */
224 free_bootmem_node(NODE_DATA(0), PFN_PHYS(first_pfn), PFN_PHYS(pages));
225
226 /*
227 * Reserve all kernel sections + bootmem bitmap + a guard page.
228 */
229 reserve_bootmem_node(NODE_DATA(0), PFN_PHYS(first_pfn),
230 (PFN_PHYS(start_pfn) + bootmap_size + PAGE_SIZE) - PFN_PHYS(first_pfn));
231
232 /*
233 * Reserve platform dependent sections
234 */
235 platform_reserve();
236
237#ifdef CONFIG_BLK_DEV_INITRD
238 if (LOADER_TYPE && INITRD_START) {
239 if (INITRD_START + INITRD_SIZE <= (PFN_PHYS(last_pfn))) {
240 reserve_bootmem_node(NODE_DATA(0), INITRD_START + __MEMORY_START, INITRD_SIZE);
241
242 initrd_start = (long) INITRD_START + PAGE_OFFSET + __MEMORY_START;
243 initrd_end = initrd_start + INITRD_SIZE;
244 } else {
245 printk("initrd extends beyond end of memory "
246 "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
247 (long) INITRD_START + INITRD_SIZE,
248 PFN_PHYS(last_pfn));
249 initrd_start = 0;
250 }
251 }
252#endif
253
254 /*
255 * Claim all RAM, ROM, and I/O resources.
256 */
257
258 /* Kernel RAM */
259 request_resource(&iomem_resource, &code_resource);
260 request_resource(&iomem_resource, &data_resource);
261
262 /* Other KRAM space */
263 for (i = 0; i < STANDARD_KRAM_RESOURCES - 2; i++)
264 request_resource(&iomem_resource,
265 &platform_parms.kram_res_p[i]);
266
267 /* XRAM space */
268 for (i = 0; i < STANDARD_XRAM_RESOURCES; i++)
269 request_resource(&iomem_resource,
270 &platform_parms.xram_res_p[i]);
271
272 /* ROM space */
273 for (i = 0; i < STANDARD_ROM_RESOURCES; i++)
274 request_resource(&iomem_resource,
275 &platform_parms.rom_res_p[i]);
276
277 /* I/O space */
278 for (i = 0; i < STANDARD_IO_RESOURCES; i++)
279 request_resource(&ioport_resource,
280 &platform_parms.io_res_p[i]);
281
282
283#ifdef CONFIG_VT
284#if defined(CONFIG_VGA_CONSOLE)
285 conswitchp = &vga_con;
286#elif defined(CONFIG_DUMMY_CONSOLE)
287 conswitchp = &dummy_con;
288#endif
289#endif
290
291 printk("Hardware FPU: %s\n", fpu_in_use ? "enabled" : "disabled");
292
293 paging_init();
294}
295
296void __xchg_called_with_bad_pointer(void)
297{
298 printk(KERN_EMERG "xchg() called with bad pointer !\n");
299}
300
301static struct cpu cpu[1];
302
303static int __init topology_init(void)
304{
305 return register_cpu(cpu, 0);
306}
307
308subsys_initcall(topology_init);
309
310/*
311 * Get CPU information
312 */
313static const char *cpu_name[] = {
314 [CPU_SH5_101] = "SH5-101",
315 [CPU_SH5_103] = "SH5-103",
316 [CPU_SH_NONE] = "Unknown",
317};
318
319const char *get_cpu_subtype(void)
320{
321 return cpu_name[boot_cpu_data.type];
322}
323
324#ifdef CONFIG_PROC_FS
325static int show_cpuinfo(struct seq_file *m,void *v)
326{
327 unsigned int cpu = smp_processor_id();
328
329 if (!cpu)
330 seq_printf(m, "machine\t\t: %s\n", get_system_type());
331
332 seq_printf(m, "processor\t: %d\n", cpu);
333 seq_printf(m, "cpu family\t: SH-5\n");
334 seq_printf(m, "cpu type\t: %s\n", get_cpu_subtype());
335
336 seq_printf(m, "icache size\t: %dK-bytes\n",
337 (boot_cpu_data.icache.ways *
338 boot_cpu_data.icache.sets *
339 boot_cpu_data.icache.linesz) >> 10);
340 seq_printf(m, "dcache size\t: %dK-bytes\n",
341 (boot_cpu_data.dcache.ways *
342 boot_cpu_data.dcache.sets *
343 boot_cpu_data.dcache.linesz) >> 10);
344 seq_printf(m, "itlb entries\t: %d\n", boot_cpu_data.itlb.entries);
345 seq_printf(m, "dtlb entries\t: %d\n", boot_cpu_data.dtlb.entries);
346
347#define PRINT_CLOCK(name, value) \
348 seq_printf(m, name " clock\t: %d.%02dMHz\n", \
349 ((value) / 1000000), ((value) % 1000000)/10000)
350
351 PRINT_CLOCK("cpu", boot_cpu_data.cpu_clock);
352 PRINT_CLOCK("bus", boot_cpu_data.bus_clock);
353 PRINT_CLOCK("module", boot_cpu_data.module_clock);
354
355 seq_printf(m, "bogomips\t: %lu.%02lu\n\n",
356 (loops_per_jiffy*HZ+2500)/500000,
357 ((loops_per_jiffy*HZ+2500)/5000) % 100);
358
359 return 0;
360}
361
362static void *c_start(struct seq_file *m, loff_t *pos)
363{
364 return (void*)(*pos == 0);
365}
366static void *c_next(struct seq_file *m, void *v, loff_t *pos)
367{
368 return NULL;
369}
370static void c_stop(struct seq_file *m, void *v)
371{
372}
373struct seq_operations cpuinfo_op = {
374 .start = c_start,
375 .next = c_next,
376 .stop = c_stop,
377 .show = show_cpuinfo,
378};
379#endif /* CONFIG_PROC_FS */
diff --git a/arch/sh64/kernel/sh_ksyms.c b/arch/sh64/kernel/sh_ksyms.c
deleted file mode 100644
index b1705acc8e64..000000000000
--- a/arch/sh64/kernel/sh_ksyms.c
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/sh_ksyms.c
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 *
10 */
11
12#include <linux/rwsem.h>
13#include <linux/module.h>
14#include <linux/smp.h>
15#include <linux/user.h>
16#include <linux/elfcore.h>
17#include <linux/sched.h>
18#include <linux/in6.h>
19#include <linux/interrupt.h>
20#include <linux/screen_info.h>
21
22#include <asm/semaphore.h>
23#include <asm/processor.h>
24#include <asm/uaccess.h>
25#include <asm/checksum.h>
26#include <asm/io.h>
27#include <asm/delay.h>
28#include <asm/irq.h>
29
30extern int dump_fpu(struct pt_regs *, elf_fpregset_t *);
31
32/* platform dependent support */
33EXPORT_SYMBOL(dump_fpu);
34EXPORT_SYMBOL(kernel_thread);
35
36/* Networking helper routines. */
37EXPORT_SYMBOL(csum_partial_copy_nocheck);
38
39#ifdef CONFIG_VT
40EXPORT_SYMBOL(screen_info);
41#endif
42
43EXPORT_SYMBOL(__down);
44EXPORT_SYMBOL(__down_trylock);
45EXPORT_SYMBOL(__up);
46EXPORT_SYMBOL(__put_user_asm_l);
47EXPORT_SYMBOL(__get_user_asm_l);
48EXPORT_SYMBOL(__copy_user);
49EXPORT_SYMBOL(memcpy);
50EXPORT_SYMBOL(udelay);
51EXPORT_SYMBOL(__udelay);
52EXPORT_SYMBOL(ndelay);
53EXPORT_SYMBOL(__ndelay);
54EXPORT_SYMBOL(flush_dcache_page);
55EXPORT_SYMBOL(sh64_page_clear);
56
57/* Ugh. These come in from libgcc.a at link time. */
58#define DECLARE_EXPORT(name) extern void name(void);EXPORT_SYMBOL(name)
59
60DECLARE_EXPORT(__sdivsi3);
61DECLARE_EXPORT(__muldi3);
62DECLARE_EXPORT(__udivsi3);
diff --git a/arch/sh64/kernel/signal.c b/arch/sh64/kernel/signal.c
deleted file mode 100644
index 79fc48cf54c6..000000000000
--- a/arch/sh64/kernel/signal.c
+++ /dev/null
@@ -1,750 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/signal.c
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003 Paul Mundt
10 * Copyright (C) 2004 Richard Curnow
11 *
12 * Started from sh version.
13 *
14 */
15#include <linux/rwsem.h>
16#include <linux/sched.h>
17#include <linux/mm.h>
18#include <linux/smp.h>
19#include <linux/kernel.h>
20#include <linux/signal.h>
21#include <linux/errno.h>
22#include <linux/wait.h>
23#include <linux/personality.h>
24#include <linux/freezer.h>
25#include <linux/ptrace.h>
26#include <linux/unistd.h>
27#include <linux/stddef.h>
28#include <asm/ucontext.h>
29#include <asm/uaccess.h>
30#include <asm/pgtable.h>
31
32
33#define REG_RET 9
34#define REG_ARG1 2
35#define REG_ARG2 3
36#define REG_ARG3 4
37#define REG_SP 15
38#define REG_PR 18
39#define REF_REG_RET regs->regs[REG_RET]
40#define REF_REG_SP regs->regs[REG_SP]
41#define DEREF_REG_PR regs->regs[REG_PR]
42
43#define DEBUG_SIG 0
44
45#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
46
47asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset);
48
49/*
50 * Atomically swap in the new signal mask, and wait for a signal.
51 */
52
53asmlinkage int
54sys_sigsuspend(old_sigset_t mask,
55 unsigned long r3, unsigned long r4, unsigned long r5,
56 unsigned long r6, unsigned long r7,
57 struct pt_regs * regs)
58{
59 sigset_t saveset;
60
61 mask &= _BLOCKABLE;
62 spin_lock_irq(&current->sighand->siglock);
63 saveset = current->blocked;
64 siginitset(&current->blocked, mask);
65 recalc_sigpending();
66 spin_unlock_irq(&current->sighand->siglock);
67
68 REF_REG_RET = -EINTR;
69 while (1) {
70 current->state = TASK_INTERRUPTIBLE;
71 schedule();
72 regs->pc += 4; /* because sys_sigreturn decrements the pc */
73 if (do_signal(regs, &saveset)) {
74 /* pc now points at signal handler. Need to decrement
75 it because entry.S will increment it. */
76 regs->pc -= 4;
77 return -EINTR;
78 }
79 }
80}
81
82asmlinkage int
83sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize,
84 unsigned long r4, unsigned long r5, unsigned long r6,
85 unsigned long r7,
86 struct pt_regs * regs)
87{
88 sigset_t saveset, newset;
89
90 /* XXX: Don't preclude handling different sized sigset_t's. */
91 if (sigsetsize != sizeof(sigset_t))
92 return -EINVAL;
93
94 if (copy_from_user(&newset, unewset, sizeof(newset)))
95 return -EFAULT;
96 sigdelsetmask(&newset, ~_BLOCKABLE);
97 spin_lock_irq(&current->sighand->siglock);
98 saveset = current->blocked;
99 current->blocked = newset;
100 recalc_sigpending();
101 spin_unlock_irq(&current->sighand->siglock);
102
103 REF_REG_RET = -EINTR;
104 while (1) {
105 current->state = TASK_INTERRUPTIBLE;
106 schedule();
107 regs->pc += 4; /* because sys_sigreturn decrements the pc */
108 if (do_signal(regs, &saveset)) {
109 /* pc now points at signal handler. Need to decrement
110 it because entry.S will increment it. */
111 regs->pc -= 4;
112 return -EINTR;
113 }
114 }
115}
116
117asmlinkage int
118sys_sigaction(int sig, const struct old_sigaction __user *act,
119 struct old_sigaction __user *oact)
120{
121 struct k_sigaction new_ka, old_ka;
122 int ret;
123
124 if (act) {
125 old_sigset_t mask;
126 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
127 __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
128 __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
129 return -EFAULT;
130 __get_user(new_ka.sa.sa_flags, &act->sa_flags);
131 __get_user(mask, &act->sa_mask);
132 siginitset(&new_ka.sa.sa_mask, mask);
133 }
134
135 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
136
137 if (!ret && oact) {
138 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
139 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
140 __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
141 return -EFAULT;
142 __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
143 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
144 }
145
146 return ret;
147}
148
149asmlinkage int
150sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
151 unsigned long r4, unsigned long r5, unsigned long r6,
152 unsigned long r7,
153 struct pt_regs * regs)
154{
155 return do_sigaltstack(uss, uoss, REF_REG_SP);
156}
157
158
159/*
160 * Do a signal return; undo the signal stack.
161 */
162
163struct sigframe
164{
165 struct sigcontext sc;
166 unsigned long extramask[_NSIG_WORDS-1];
167 long long retcode[2];
168};
169
170struct rt_sigframe
171{
172 struct siginfo __user *pinfo;
173 void *puc;
174 struct siginfo info;
175 struct ucontext uc;
176 long long retcode[2];
177};
178
179#ifdef CONFIG_SH_FPU
180static inline int
181restore_sigcontext_fpu(struct pt_regs *regs, struct sigcontext __user *sc)
182{
183 int err = 0;
184 int fpvalid;
185
186 err |= __get_user (fpvalid, &sc->sc_fpvalid);
187 conditional_used_math(fpvalid);
188 if (! fpvalid)
189 return err;
190
191 if (current == last_task_used_math) {
192 last_task_used_math = NULL;
193 regs->sr |= SR_FD;
194 }
195
196 err |= __copy_from_user(&current->thread.fpu.hard, &sc->sc_fpregs[0],
197 (sizeof(long long) * 32) + (sizeof(int) * 1));
198
199 return err;
200}
201
202static inline int
203setup_sigcontext_fpu(struct pt_regs *regs, struct sigcontext __user *sc)
204{
205 int err = 0;
206 int fpvalid;
207
208 fpvalid = !!used_math();
209 err |= __put_user(fpvalid, &sc->sc_fpvalid);
210 if (! fpvalid)
211 return err;
212
213 if (current == last_task_used_math) {
214 grab_fpu();
215 fpsave(&current->thread.fpu.hard);
216 release_fpu();
217 last_task_used_math = NULL;
218 regs->sr |= SR_FD;
219 }
220
221 err |= __copy_to_user(&sc->sc_fpregs[0], &current->thread.fpu.hard,
222 (sizeof(long long) * 32) + (sizeof(int) * 1));
223 clear_used_math();
224
225 return err;
226}
227#else
228static inline int
229restore_sigcontext_fpu(struct pt_regs *regs, struct sigcontext __user *sc)
230{}
231static inline int
232setup_sigcontext_fpu(struct pt_regs *regs, struct sigcontext __user *sc)
233{}
234#endif
235
236static int
237restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, long long *r2_p)
238{
239 unsigned int err = 0;
240 unsigned long long current_sr, new_sr;
241#define SR_MASK 0xffff8cfd
242
243#define COPY(x) err |= __get_user(regs->x, &sc->sc_##x)
244
245 COPY(regs[0]); COPY(regs[1]); COPY(regs[2]); COPY(regs[3]);
246 COPY(regs[4]); COPY(regs[5]); COPY(regs[6]); COPY(regs[7]);
247 COPY(regs[8]); COPY(regs[9]); COPY(regs[10]); COPY(regs[11]);
248 COPY(regs[12]); COPY(regs[13]); COPY(regs[14]); COPY(regs[15]);
249 COPY(regs[16]); COPY(regs[17]); COPY(regs[18]); COPY(regs[19]);
250 COPY(regs[20]); COPY(regs[21]); COPY(regs[22]); COPY(regs[23]);
251 COPY(regs[24]); COPY(regs[25]); COPY(regs[26]); COPY(regs[27]);
252 COPY(regs[28]); COPY(regs[29]); COPY(regs[30]); COPY(regs[31]);
253 COPY(regs[32]); COPY(regs[33]); COPY(regs[34]); COPY(regs[35]);
254 COPY(regs[36]); COPY(regs[37]); COPY(regs[38]); COPY(regs[39]);
255 COPY(regs[40]); COPY(regs[41]); COPY(regs[42]); COPY(regs[43]);
256 COPY(regs[44]); COPY(regs[45]); COPY(regs[46]); COPY(regs[47]);
257 COPY(regs[48]); COPY(regs[49]); COPY(regs[50]); COPY(regs[51]);
258 COPY(regs[52]); COPY(regs[53]); COPY(regs[54]); COPY(regs[55]);
259 COPY(regs[56]); COPY(regs[57]); COPY(regs[58]); COPY(regs[59]);
260 COPY(regs[60]); COPY(regs[61]); COPY(regs[62]);
261 COPY(tregs[0]); COPY(tregs[1]); COPY(tregs[2]); COPY(tregs[3]);
262 COPY(tregs[4]); COPY(tregs[5]); COPY(tregs[6]); COPY(tregs[7]);
263
264 /* Prevent the signal handler manipulating SR in a way that can
265 crash the kernel. i.e. only allow S, Q, M, PR, SZ, FR to be
266 modified */
267 current_sr = regs->sr;
268 err |= __get_user(new_sr, &sc->sc_sr);
269 regs->sr &= SR_MASK;
270 regs->sr |= (new_sr & ~SR_MASK);
271
272 COPY(pc);
273
274#undef COPY
275
276 /* Must do this last in case it sets regs->sr.fd (i.e. after rest of sr
277 * has been restored above.) */
278 err |= restore_sigcontext_fpu(regs, sc);
279
280 regs->syscall_nr = -1; /* disable syscall checks */
281 err |= __get_user(*r2_p, &sc->sc_regs[REG_RET]);
282 return err;
283}
284
285asmlinkage int sys_sigreturn(unsigned long r2, unsigned long r3,
286 unsigned long r4, unsigned long r5,
287 unsigned long r6, unsigned long r7,
288 struct pt_regs * regs)
289{
290 struct sigframe __user *frame = (struct sigframe __user *) (long) REF_REG_SP;
291 sigset_t set;
292 long long ret;
293
294 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
295 goto badframe;
296
297 if (__get_user(set.sig[0], &frame->sc.oldmask)
298 || (_NSIG_WORDS > 1
299 && __copy_from_user(&set.sig[1], &frame->extramask,
300 sizeof(frame->extramask))))
301 goto badframe;
302
303 sigdelsetmask(&set, ~_BLOCKABLE);
304
305 spin_lock_irq(&current->sighand->siglock);
306 current->blocked = set;
307 recalc_sigpending();
308 spin_unlock_irq(&current->sighand->siglock);
309
310 if (restore_sigcontext(regs, &frame->sc, &ret))
311 goto badframe;
312 regs->pc -= 4;
313
314 return (int) ret;
315
316badframe:
317 force_sig(SIGSEGV, current);
318 return 0;
319}
320
321asmlinkage int sys_rt_sigreturn(unsigned long r2, unsigned long r3,
322 unsigned long r4, unsigned long r5,
323 unsigned long r6, unsigned long r7,
324 struct pt_regs * regs)
325{
326 struct rt_sigframe __user *frame = (struct rt_sigframe __user *) (long) REF_REG_SP;
327 sigset_t set;
328 stack_t __user st;
329 long long ret;
330
331 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
332 goto badframe;
333
334 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
335 goto badframe;
336
337 sigdelsetmask(&set, ~_BLOCKABLE);
338 spin_lock_irq(&current->sighand->siglock);
339 current->blocked = set;
340 recalc_sigpending();
341 spin_unlock_irq(&current->sighand->siglock);
342
343 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ret))
344 goto badframe;
345 regs->pc -= 4;
346
347 if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st)))
348 goto badframe;
349 /* It is more difficult to avoid calling this function than to
350 call it and ignore errors. */
351 do_sigaltstack(&st, NULL, REF_REG_SP);
352
353 return (int) ret;
354
355badframe:
356 force_sig(SIGSEGV, current);
357 return 0;
358}
359
360/*
361 * Set up a signal frame.
362 */
363
364static int
365setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
366 unsigned long mask)
367{
368 int err = 0;
369
370 /* Do this first, otherwise is this sets sr->fd, that value isn't preserved. */
371 err |= setup_sigcontext_fpu(regs, sc);
372
373#define COPY(x) err |= __put_user(regs->x, &sc->sc_##x)
374
375 COPY(regs[0]); COPY(regs[1]); COPY(regs[2]); COPY(regs[3]);
376 COPY(regs[4]); COPY(regs[5]); COPY(regs[6]); COPY(regs[7]);
377 COPY(regs[8]); COPY(regs[9]); COPY(regs[10]); COPY(regs[11]);
378 COPY(regs[12]); COPY(regs[13]); COPY(regs[14]); COPY(regs[15]);
379 COPY(regs[16]); COPY(regs[17]); COPY(regs[18]); COPY(regs[19]);
380 COPY(regs[20]); COPY(regs[21]); COPY(regs[22]); COPY(regs[23]);
381 COPY(regs[24]); COPY(regs[25]); COPY(regs[26]); COPY(regs[27]);
382 COPY(regs[28]); COPY(regs[29]); COPY(regs[30]); COPY(regs[31]);
383 COPY(regs[32]); COPY(regs[33]); COPY(regs[34]); COPY(regs[35]);
384 COPY(regs[36]); COPY(regs[37]); COPY(regs[38]); COPY(regs[39]);
385 COPY(regs[40]); COPY(regs[41]); COPY(regs[42]); COPY(regs[43]);
386 COPY(regs[44]); COPY(regs[45]); COPY(regs[46]); COPY(regs[47]);
387 COPY(regs[48]); COPY(regs[49]); COPY(regs[50]); COPY(regs[51]);
388 COPY(regs[52]); COPY(regs[53]); COPY(regs[54]); COPY(regs[55]);
389 COPY(regs[56]); COPY(regs[57]); COPY(regs[58]); COPY(regs[59]);
390 COPY(regs[60]); COPY(regs[61]); COPY(regs[62]);
391 COPY(tregs[0]); COPY(tregs[1]); COPY(tregs[2]); COPY(tregs[3]);
392 COPY(tregs[4]); COPY(tregs[5]); COPY(tregs[6]); COPY(tregs[7]);
393 COPY(sr); COPY(pc);
394
395#undef COPY
396
397 err |= __put_user(mask, &sc->oldmask);
398
399 return err;
400}
401
402/*
403 * Determine which stack to use..
404 */
405static inline void __user *
406get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size)
407{
408 if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! sas_ss_flags(sp))
409 sp = current->sas_ss_sp + current->sas_ss_size;
410
411 return (void __user *)((sp - frame_size) & -8ul);
412}
413
414void sa_default_restorer(void); /* See comments below */
415void sa_default_rt_restorer(void); /* See comments below */
416
417static void setup_frame(int sig, struct k_sigaction *ka,
418 sigset_t *set, struct pt_regs *regs)
419{
420 struct sigframe __user *frame;
421 int err = 0;
422 int signal;
423
424 frame = get_sigframe(ka, regs->regs[REG_SP], sizeof(*frame));
425
426 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
427 goto give_sigsegv;
428
429 signal = current_thread_info()->exec_domain
430 && current_thread_info()->exec_domain->signal_invmap
431 && sig < 32
432 ? current_thread_info()->exec_domain->signal_invmap[sig]
433 : sig;
434
435 err |= setup_sigcontext(&frame->sc, regs, set->sig[0]);
436
437 /* Give up earlier as i386, in case */
438 if (err)
439 goto give_sigsegv;
440
441 if (_NSIG_WORDS > 1) {
442 err |= __copy_to_user(frame->extramask, &set->sig[1],
443 sizeof(frame->extramask)); }
444
445 /* Give up earlier as i386, in case */
446 if (err)
447 goto give_sigsegv;
448
449 /* Set up to return from userspace. If provided, use a stub
450 already in userspace. */
451 if (ka->sa.sa_flags & SA_RESTORER) {
452 DEREF_REG_PR = (unsigned long) ka->sa.sa_restorer | 0x1;
453
454 /*
455 * On SH5 all edited pointers are subject to NEFF
456 */
457 DEREF_REG_PR = (DEREF_REG_PR & NEFF_SIGN) ?
458 (DEREF_REG_PR | NEFF_MASK) : DEREF_REG_PR;
459 } else {
460 /*
461 * Different approach on SH5.
462 * . Endianness independent asm code gets placed in entry.S .
463 * This is limited to four ASM instructions corresponding
464 * to two long longs in size.
465 * . err checking is done on the else branch only
466 * . flush_icache_range() is called upon __put_user() only
467 * . all edited pointers are subject to NEFF
468 * . being code, linker turns ShMedia bit on, always
469 * dereference index -1.
470 */
471 DEREF_REG_PR = (unsigned long) frame->retcode | 0x01;
472 DEREF_REG_PR = (DEREF_REG_PR & NEFF_SIGN) ?
473 (DEREF_REG_PR | NEFF_MASK) : DEREF_REG_PR;
474
475 if (__copy_to_user(frame->retcode,
476 (unsigned long long)sa_default_restorer & (~1), 16) != 0)
477 goto give_sigsegv;
478
479 /* Cohere the trampoline with the I-cache. */
480 flush_cache_sigtramp(DEREF_REG_PR-1, DEREF_REG_PR-1+16);
481 }
482
483 /*
484 * Set up registers for signal handler.
485 * All edited pointers are subject to NEFF.
486 */
487 regs->regs[REG_SP] = (unsigned long) frame;
488 regs->regs[REG_SP] = (regs->regs[REG_SP] & NEFF_SIGN) ?
489 (regs->regs[REG_SP] | NEFF_MASK) : regs->regs[REG_SP];
490 regs->regs[REG_ARG1] = signal; /* Arg for signal handler */
491
492 /* FIXME:
493 The glibc profiling support for SH-5 needs to be passed a sigcontext
494 so it can retrieve the PC. At some point during 2003 the glibc
495 support was changed to receive the sigcontext through the 2nd
496 argument, but there are still versions of libc.so in use that use
497 the 3rd argument. Until libc.so is stabilised, pass the sigcontext
498 through both 2nd and 3rd arguments.
499 */
500
501 regs->regs[REG_ARG2] = (unsigned long long)(unsigned long)(signed long)&frame->sc;
502 regs->regs[REG_ARG3] = (unsigned long long)(unsigned long)(signed long)&frame->sc;
503
504 regs->pc = (unsigned long) ka->sa.sa_handler;
505 regs->pc = (regs->pc & NEFF_SIGN) ? (regs->pc | NEFF_MASK) : regs->pc;
506
507 set_fs(USER_DS);
508
509#if DEBUG_SIG
510 /* Broken %016Lx */
511 printk("SIG deliver (#%d,%s:%d): sp=%p pc=%08Lx%08Lx link=%08Lx%08Lx\n",
512 signal,
513 current->comm, current->pid, frame,
514 regs->pc >> 32, regs->pc & 0xffffffff,
515 DEREF_REG_PR >> 32, DEREF_REG_PR & 0xffffffff);
516#endif
517
518 return;
519
520give_sigsegv:
521 force_sigsegv(sig, current);
522}
523
524static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
525 sigset_t *set, struct pt_regs *regs)
526{
527 struct rt_sigframe __user *frame;
528 int err = 0;
529 int signal;
530
531 frame = get_sigframe(ka, regs->regs[REG_SP], sizeof(*frame));
532
533 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
534 goto give_sigsegv;
535
536 signal = current_thread_info()->exec_domain
537 && current_thread_info()->exec_domain->signal_invmap
538 && sig < 32
539 ? current_thread_info()->exec_domain->signal_invmap[sig]
540 : sig;
541
542 err |= __put_user(&frame->info, &frame->pinfo);
543 err |= __put_user(&frame->uc, &frame->puc);
544 err |= copy_siginfo_to_user(&frame->info, info);
545
546 /* Give up earlier as i386, in case */
547 if (err)
548 goto give_sigsegv;
549
550 /* Create the ucontext. */
551 err |= __put_user(0, &frame->uc.uc_flags);
552 err |= __put_user(0, &frame->uc.uc_link);
553 err |= __put_user((void *)current->sas_ss_sp,
554 &frame->uc.uc_stack.ss_sp);
555 err |= __put_user(sas_ss_flags(regs->regs[REG_SP]),
556 &frame->uc.uc_stack.ss_flags);
557 err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
558 err |= setup_sigcontext(&frame->uc.uc_mcontext,
559 regs, set->sig[0]);
560 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
561
562 /* Give up earlier as i386, in case */
563 if (err)
564 goto give_sigsegv;
565
566 /* Set up to return from userspace. If provided, use a stub
567 already in userspace. */
568 if (ka->sa.sa_flags & SA_RESTORER) {
569 DEREF_REG_PR = (unsigned long) ka->sa.sa_restorer | 0x1;
570
571 /*
572 * On SH5 all edited pointers are subject to NEFF
573 */
574 DEREF_REG_PR = (DEREF_REG_PR & NEFF_SIGN) ?
575 (DEREF_REG_PR | NEFF_MASK) : DEREF_REG_PR;
576 } else {
577 /*
578 * Different approach on SH5.
579 * . Endianness independent asm code gets placed in entry.S .
580 * This is limited to four ASM instructions corresponding
581 * to two long longs in size.
582 * . err checking is done on the else branch only
583 * . flush_icache_range() is called upon __put_user() only
584 * . all edited pointers are subject to NEFF
585 * . being code, linker turns ShMedia bit on, always
586 * dereference index -1.
587 */
588
589 DEREF_REG_PR = (unsigned long) frame->retcode | 0x01;
590 DEREF_REG_PR = (DEREF_REG_PR & NEFF_SIGN) ?
591 (DEREF_REG_PR | NEFF_MASK) : DEREF_REG_PR;
592
593 if (__copy_to_user(frame->retcode,
594 (unsigned long long)sa_default_rt_restorer & (~1), 16) != 0)
595 goto give_sigsegv;
596
597 flush_icache_range(DEREF_REG_PR-1, DEREF_REG_PR-1+15);
598 }
599
600 /*
601 * Set up registers for signal handler.
602 * All edited pointers are subject to NEFF.
603 */
604 regs->regs[REG_SP] = (unsigned long) frame;
605 regs->regs[REG_SP] = (regs->regs[REG_SP] & NEFF_SIGN) ?
606 (regs->regs[REG_SP] | NEFF_MASK) : regs->regs[REG_SP];
607 regs->regs[REG_ARG1] = signal; /* Arg for signal handler */
608 regs->regs[REG_ARG2] = (unsigned long long)(unsigned long)(signed long)&frame->info;
609 regs->regs[REG_ARG3] = (unsigned long long)(unsigned long)(signed long)&frame->uc.uc_mcontext;
610 regs->pc = (unsigned long) ka->sa.sa_handler;
611 regs->pc = (regs->pc & NEFF_SIGN) ? (regs->pc | NEFF_MASK) : regs->pc;
612
613 set_fs(USER_DS);
614
615#if DEBUG_SIG
616 /* Broken %016Lx */
617 printk("SIG deliver (#%d,%s:%d): sp=%p pc=%08Lx%08Lx link=%08Lx%08Lx\n",
618 signal,
619 current->comm, current->pid, frame,
620 regs->pc >> 32, regs->pc & 0xffffffff,
621 DEREF_REG_PR >> 32, DEREF_REG_PR & 0xffffffff);
622#endif
623
624 return;
625
626give_sigsegv:
627 force_sigsegv(sig, current);
628}
629
630/*
631 * OK, we're invoking a handler
632 */
633
634static void
635handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
636 sigset_t *oldset, struct pt_regs * regs)
637{
638 /* Are we from a system call? */
639 if (regs->syscall_nr >= 0) {
640 /* If so, check system call restarting.. */
641 switch (regs->regs[REG_RET]) {
642 case -ERESTART_RESTARTBLOCK:
643 case -ERESTARTNOHAND:
644 regs->regs[REG_RET] = -EINTR;
645 break;
646
647 case -ERESTARTSYS:
648 if (!(ka->sa.sa_flags & SA_RESTART)) {
649 regs->regs[REG_RET] = -EINTR;
650 break;
651 }
652 /* fallthrough */
653 case -ERESTARTNOINTR:
654 /* Decode syscall # */
655 regs->regs[REG_RET] = regs->syscall_nr;
656 regs->pc -= 4;
657 }
658 }
659
660 /* Set up the stack frame */
661 if (ka->sa.sa_flags & SA_SIGINFO)
662 setup_rt_frame(sig, ka, info, oldset, regs);
663 else
664 setup_frame(sig, ka, oldset, regs);
665
666 spin_lock_irq(&current->sighand->siglock);
667 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
668 if (!(ka->sa.sa_flags & SA_NODEFER))
669 sigaddset(&current->blocked,sig);
670 recalc_sigpending();
671 spin_unlock_irq(&current->sighand->siglock);
672}
673
674/*
675 * Note that 'init' is a special process: it doesn't get signals it doesn't
676 * want to handle. Thus you cannot kill init even with a SIGKILL even by
677 * mistake.
678 *
679 * Note that we go through the signals twice: once to check the signals that
680 * the kernel can handle, and then we build all the user-level signal handling
681 * stack-frames in one go after that.
682 */
683int do_signal(struct pt_regs *regs, sigset_t *oldset)
684{
685 siginfo_t info;
686 int signr;
687 struct k_sigaction ka;
688
689 /*
690 * We want the common case to go fast, which
691 * is why we may in certain cases get here from
692 * kernel mode. Just return without doing anything
693 * if so.
694 */
695 if (!user_mode(regs))
696 return 1;
697
698 if (try_to_freeze())
699 goto no_signal;
700
701 if (test_thread_flag(TIF_RESTORE_SIGMASK))
702 oldset = &current->saved_sigmask;
703 else if (!oldset)
704 oldset = &current->blocked;
705
706 signr = get_signal_to_deliver(&info, &ka, regs, 0);
707
708 if (signr > 0) {
709 /* Whee! Actually deliver the signal. */
710 handle_signal(signr, &info, &ka, oldset, regs);
711
712 /*
713 * If a signal was successfully delivered, the saved sigmask
714 * is in its frame, and we can clear the TIF_RESTORE_SIGMASK
715 * flag.
716 */
717 if (test_thread_flag(TIF_RESTORE_SIGMASK))
718 clear_thread_flag(TIF_RESTORE_SIGMASK);
719
720 return 1;
721 }
722
723no_signal:
724 /* Did we come from a system call? */
725 if (regs->syscall_nr >= 0) {
726 /* Restart the system call - no handlers present */
727 switch (regs->regs[REG_RET]) {
728 case -ERESTARTNOHAND:
729 case -ERESTARTSYS:
730 case -ERESTARTNOINTR:
731 /* Decode Syscall # */
732 regs->regs[REG_RET] = regs->syscall_nr;
733 regs->pc -= 4;
734 break;
735
736 case -ERESTART_RESTARTBLOCK:
737 regs->regs[REG_RET] = __NR_restart_syscall;
738 regs->pc -= 4;
739 break;
740 }
741 }
742
743 /* No signal to deliver -- put the saved sigmask back */
744 if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
745 clear_thread_flag(TIF_RESTORE_SIGMASK);
746 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
747 }
748
749 return 0;
750}
diff --git a/arch/sh64/kernel/switchto.S b/arch/sh64/kernel/switchto.S
deleted file mode 100644
index 45b2d90eed7d..000000000000
--- a/arch/sh64/kernel/switchto.S
+++ /dev/null
@@ -1,198 +0,0 @@
1/*
2 * arch/sh64/kernel/switchto.S
3 *
4 * sh64 context switch
5 *
6 * Copyright (C) 2004 Richard Curnow
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
10 * for more details.
11*/
12
13 .section .text..SHmedia32,"ax"
14 .little
15
16 .balign 32
17
18 .type sh64_switch_to,@function
19 .global sh64_switch_to
20 .global __sh64_switch_to_end
21sh64_switch_to:
22
23/* Incoming args
24 r2 - prev
25 r3 - &prev->thread
26 r4 - next
27 r5 - &next->thread
28
29 Outgoing results
30 r2 - last (=prev) : this just stays in r2 throughout
31
32 Want to create a full (struct pt_regs) on the stack to allow backtracing
33 functions to work. However, we only need to populate the callee-save
34 register slots in this structure; since we're a function our ancestors must
35 have themselves preserved all caller saved state in the stack. This saves
36 some wasted effort since we won't need to look at the values.
37
38 In particular, all caller-save registers are immediately available for
39 scratch use.
40
41*/
42
43#define FRAME_SIZE (76*8 + 8)
44
45 movi FRAME_SIZE, r0
46 sub.l r15, r0, r15
47 ! Do normal-style register save to support backtrace
48
49 st.l r15, 0, r18 ! save link reg
50 st.l r15, 4, r14 ! save fp
51 add.l r15, r63, r14 ! setup frame pointer
52
53 ! hopefully this looks normal to the backtrace now.
54
55 addi.l r15, 8, r1 ! base of pt_regs
56 addi.l r1, 24, r0 ! base of pt_regs.regs
57 addi.l r0, (63*8), r8 ! base of pt_regs.trregs
58
59 /* Note : to be fixed?
60 struct pt_regs is really designed for holding the state on entry
61 to an exception, i.e. pc,sr,regs etc. However, for the context
62 switch state, some of this is not required. But the unwinder takes
63 struct pt_regs * as an arg so we have to build this structure
64 to allow unwinding switched tasks in show_state() */
65
66 st.q r0, ( 9*8), r9
67 st.q r0, (10*8), r10
68 st.q r0, (11*8), r11
69 st.q r0, (12*8), r12
70 st.q r0, (13*8), r13
71 st.q r0, (14*8), r14 ! for unwind, want to look as though we took a trap at
72 ! the point where the process is left in suspended animation, i.e. current
73 ! fp here, not the saved one.
74 st.q r0, (16*8), r16
75
76 st.q r0, (24*8), r24
77 st.q r0, (25*8), r25
78 st.q r0, (26*8), r26
79 st.q r0, (27*8), r27
80 st.q r0, (28*8), r28
81 st.q r0, (29*8), r29
82 st.q r0, (30*8), r30
83 st.q r0, (31*8), r31
84 st.q r0, (32*8), r32
85 st.q r0, (33*8), r33
86 st.q r0, (34*8), r34
87 st.q r0, (35*8), r35
88
89 st.q r0, (44*8), r44
90 st.q r0, (45*8), r45
91 st.q r0, (46*8), r46
92 st.q r0, (47*8), r47
93 st.q r0, (48*8), r48
94 st.q r0, (49*8), r49
95 st.q r0, (50*8), r50
96 st.q r0, (51*8), r51
97 st.q r0, (52*8), r52
98 st.q r0, (53*8), r53
99 st.q r0, (54*8), r54
100 st.q r0, (55*8), r55
101 st.q r0, (56*8), r56
102 st.q r0, (57*8), r57
103 st.q r0, (58*8), r58
104 st.q r0, (59*8), r59
105
106 ! do this early as pta->gettr has no pipeline forwarding (=> 5 cycle latency)
107 ! Use a local label to avoid creating a symbol that will confuse the !
108 ! backtrace
109 pta .Lsave_pc, tr0
110
111 gettr tr5, r45
112 gettr tr6, r46
113 gettr tr7, r47
114 st.q r8, (5*8), r45
115 st.q r8, (6*8), r46
116 st.q r8, (7*8), r47
117
118 ! Now switch context
119 gettr tr0, r9
120 st.l r3, 0, r15 ! prev->thread.sp
121 st.l r3, 8, r1 ! prev->thread.kregs
122 st.l r3, 4, r9 ! prev->thread.pc
123 st.q r1, 0, r9 ! save prev->thread.pc into pt_regs->pc
124
125 ! Load PC for next task (init value or save_pc later)
126 ld.l r5, 4, r18 ! next->thread.pc
127 ! Switch stacks
128 ld.l r5, 0, r15 ! next->thread.sp
129 ptabs r18, tr0
130
131 ! Update current
132 ld.l r4, 4, r9 ! next->thread_info (2nd element of next task_struct)
133 putcon r9, kcr0 ! current = next->thread_info
134
135 ! go to save_pc for a reschedule, or the initial thread.pc for a new process
136 blink tr0, r63
137
138 ! Restore (when we come back to a previously saved task)
139.Lsave_pc:
140 addi.l r15, 32, r0 ! r0 = next's regs
141 addi.l r0, (63*8), r8 ! r8 = next's tr_regs
142
143 ld.q r8, (5*8), r45
144 ld.q r8, (6*8), r46
145 ld.q r8, (7*8), r47
146 ptabs r45, tr5
147 ptabs r46, tr6
148 ptabs r47, tr7
149
150 ld.q r0, ( 9*8), r9
151 ld.q r0, (10*8), r10
152 ld.q r0, (11*8), r11
153 ld.q r0, (12*8), r12
154 ld.q r0, (13*8), r13
155 ld.q r0, (14*8), r14
156 ld.q r0, (16*8), r16
157
158 ld.q r0, (24*8), r24
159 ld.q r0, (25*8), r25
160 ld.q r0, (26*8), r26
161 ld.q r0, (27*8), r27
162 ld.q r0, (28*8), r28
163 ld.q r0, (29*8), r29
164 ld.q r0, (30*8), r30
165 ld.q r0, (31*8), r31
166 ld.q r0, (32*8), r32
167 ld.q r0, (33*8), r33
168 ld.q r0, (34*8), r34
169 ld.q r0, (35*8), r35
170
171 ld.q r0, (44*8), r44
172 ld.q r0, (45*8), r45
173 ld.q r0, (46*8), r46
174 ld.q r0, (47*8), r47
175 ld.q r0, (48*8), r48
176 ld.q r0, (49*8), r49
177 ld.q r0, (50*8), r50
178 ld.q r0, (51*8), r51
179 ld.q r0, (52*8), r52
180 ld.q r0, (53*8), r53
181 ld.q r0, (54*8), r54
182 ld.q r0, (55*8), r55
183 ld.q r0, (56*8), r56
184 ld.q r0, (57*8), r57
185 ld.q r0, (58*8), r58
186 ld.q r0, (59*8), r59
187
188 ! epilogue
189 ld.l r15, 0, r18
190 ld.l r15, 4, r14
191 ptabs r18, tr0
192 movi FRAME_SIZE, r0
193 add r15, r0, r15
194 blink tr0, r63
195__sh64_switch_to_end:
196.LFE1:
197 .size sh64_switch_to,.LFE1-sh64_switch_to
198
diff --git a/arch/sh64/kernel/sys_sh64.c b/arch/sh64/kernel/sys_sh64.c
deleted file mode 100644
index de0a303ba26f..000000000000
--- a/arch/sh64/kernel/sys_sh64.c
+++ /dev/null
@@ -1,304 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/sys_sh64.c
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 *
10 * This file contains various random system calls that
11 * have a non-standard calling sequence on the Linux/SH5
12 * platform.
13 *
14 * Mostly taken from i386 version.
15 *
16 */
17
18#include <linux/errno.h>
19#include <linux/rwsem.h>
20#include <linux/sched.h>
21#include <linux/mm.h>
22#include <linux/fs.h>
23#include <linux/smp.h>
24#include <linux/sem.h>
25#include <linux/msg.h>
26#include <linux/shm.h>
27#include <linux/stat.h>
28#include <linux/mman.h>
29#include <linux/file.h>
30#include <linux/utsname.h>
31#include <linux/syscalls.h>
32#include <linux/ipc.h>
33#include <asm/uaccess.h>
34#include <asm/ptrace.h>
35#include <asm/unistd.h>
36
37#define REG_3 3
38
39/*
40 * sys_pipe() is the normal C calling standard for creating
41 * a pipe. It's not the way Unix traditionally does this, though.
42 */
43#ifdef NEW_PIPE_IMPLEMENTATION
44asmlinkage int sys_pipe(unsigned long * fildes,
45 unsigned long dummy_r3,
46 unsigned long dummy_r4,
47 unsigned long dummy_r5,
48 unsigned long dummy_r6,
49 unsigned long dummy_r7,
50 struct pt_regs * regs) /* r8 = pt_regs forced by entry.S */
51{
52 int fd[2];
53 int ret;
54
55 ret = do_pipe(fd);
56 if (ret == 0)
57 /*
58 ***********************************************************************
59 * To avoid the copy_to_user we prefer to break the ABIs convention, *
60 * packing the valid pair of file IDs into a single register (r3); *
61 * while r2 is the return code as defined by the sh5-ABIs. *
62 * BE CAREFUL: pipe stub, into glibc, must be aware of this solution *
63 ***********************************************************************
64
65#ifdef __LITTLE_ENDIAN__
66 regs->regs[REG_3] = (((unsigned long long) fd[1]) << 32) | ((unsigned long long) fd[0]);
67#else
68 regs->regs[REG_3] = (((unsigned long long) fd[0]) << 32) | ((unsigned long long) fd[1]);
69#endif
70
71 */
72 /* although not very clever this is endianess independent */
73 regs->regs[REG_3] = (unsigned long long) *((unsigned long long *) fd);
74
75 return ret;
76}
77
78#else
79asmlinkage int sys_pipe(unsigned long * fildes)
80{
81 int fd[2];
82 int error;
83
84 error = do_pipe(fd);
85 if (!error) {
86 if (copy_to_user(fildes, fd, 2*sizeof(int)))
87 error = -EFAULT;
88 }
89 return error;
90}
91
92#endif
93
94/*
95 * To avoid cache alias, we map the shard page with same color.
96 */
97#define COLOUR_ALIGN(addr) (((addr)+SHMLBA-1)&~(SHMLBA-1))
98
99unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
100 unsigned long len, unsigned long pgoff, unsigned long flags)
101{
102 struct vm_area_struct *vma;
103
104 if (flags & MAP_FIXED) {
105 /* We do not accept a shared mapping if it would violate
106 * cache aliasing constraints.
107 */
108 if ((flags & MAP_SHARED) && (addr & (SHMLBA - 1)))
109 return -EINVAL;
110 return addr;
111 }
112
113 if (len > TASK_SIZE)
114 return -ENOMEM;
115 if (!addr)
116 addr = TASK_UNMAPPED_BASE;
117
118 if (flags & MAP_PRIVATE)
119 addr = PAGE_ALIGN(addr);
120 else
121 addr = COLOUR_ALIGN(addr);
122
123 for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) {
124 /* At this point: (!vma || addr < vma->vm_end). */
125 if (TASK_SIZE - len < addr)
126 return -ENOMEM;
127 if (!vma || addr + len <= vma->vm_start)
128 return addr;
129 addr = vma->vm_end;
130 if (!(flags & MAP_PRIVATE))
131 addr = COLOUR_ALIGN(addr);
132 }
133}
134
135/* common code for old and new mmaps */
136static inline long do_mmap2(
137 unsigned long addr, unsigned long len,
138 unsigned long prot, unsigned long flags,
139 unsigned long fd, unsigned long pgoff)
140{
141 int error = -EBADF;
142 struct file * file = NULL;
143
144 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
145 if (!(flags & MAP_ANONYMOUS)) {
146 file = fget(fd);
147 if (!file)
148 goto out;
149 }
150
151 down_write(&current->mm->mmap_sem);
152 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
153 up_write(&current->mm->mmap_sem);
154
155 if (file)
156 fput(file);
157out:
158 return error;
159}
160
161asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
162 unsigned long prot, unsigned long flags,
163 unsigned long fd, unsigned long pgoff)
164{
165 return do_mmap2(addr, len, prot, flags, fd, pgoff);
166}
167
168asmlinkage int old_mmap(unsigned long addr, unsigned long len,
169 unsigned long prot, unsigned long flags,
170 int fd, unsigned long off)
171{
172 if (off & ~PAGE_MASK)
173 return -EINVAL;
174 return do_mmap2(addr, len, prot, flags, fd, off>>PAGE_SHIFT);
175}
176
177/*
178 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
179 *
180 * This is really horribly ugly.
181 */
182asmlinkage int sys_ipc(uint call, int first, int second,
183 int third, void __user *ptr, long fifth)
184{
185 int version, ret;
186
187 version = call >> 16; /* hack for backward compatibility */
188 call &= 0xffff;
189
190 if (call <= SEMCTL)
191 switch (call) {
192 case SEMOP:
193 return sys_semtimedop(first, (struct sembuf __user *)ptr,
194 second, NULL);
195 case SEMTIMEDOP:
196 return sys_semtimedop(first, (struct sembuf __user *)ptr,
197 second,
198 (const struct timespec __user *)fifth);
199 case SEMGET:
200 return sys_semget (first, second, third);
201 case SEMCTL: {
202 union semun fourth;
203 if (!ptr)
204 return -EINVAL;
205 if (get_user(fourth.__pad, (void * __user *) ptr))
206 return -EFAULT;
207 return sys_semctl (first, second, third, fourth);
208 }
209 default:
210 return -EINVAL;
211 }
212
213 if (call <= MSGCTL)
214 switch (call) {
215 case MSGSND:
216 return sys_msgsnd (first, (struct msgbuf __user *) ptr,
217 second, third);
218 case MSGRCV:
219 switch (version) {
220 case 0: {
221 struct ipc_kludge tmp;
222 if (!ptr)
223 return -EINVAL;
224
225 if (copy_from_user(&tmp,
226 (struct ipc_kludge __user *) ptr,
227 sizeof (tmp)))
228 return -EFAULT;
229 return sys_msgrcv (first, tmp.msgp, second,
230 tmp.msgtyp, third);
231 }
232 default:
233 return sys_msgrcv (first,
234 (struct msgbuf __user *) ptr,
235 second, fifth, third);
236 }
237 case MSGGET:
238 return sys_msgget ((key_t) first, second);
239 case MSGCTL:
240 return sys_msgctl (first, second,
241 (struct msqid_ds __user *) ptr);
242 default:
243 return -EINVAL;
244 }
245 if (call <= SHMCTL)
246 switch (call) {
247 case SHMAT:
248 switch (version) {
249 default: {
250 ulong raddr;
251 ret = do_shmat (first, (char __user *) ptr,
252 second, &raddr);
253 if (ret)
254 return ret;
255 return put_user (raddr, (ulong __user *) third);
256 }
257 case 1: /* iBCS2 emulator entry point */
258 if (!segment_eq(get_fs(), get_ds()))
259 return -EINVAL;
260 return do_shmat (first, (char __user *) ptr,
261 second, (ulong *) third);
262 }
263 case SHMDT:
264 return sys_shmdt ((char __user *)ptr);
265 case SHMGET:
266 return sys_shmget (first, second, third);
267 case SHMCTL:
268 return sys_shmctl (first, second,
269 (struct shmid_ds __user *) ptr);
270 default:
271 return -EINVAL;
272 }
273
274 return -EINVAL;
275}
276
277asmlinkage int sys_uname(struct old_utsname * name)
278{
279 int err;
280 if (!name)
281 return -EFAULT;
282 down_read(&uts_sem);
283 err = copy_to_user(name, utsname(), sizeof (*name));
284 up_read(&uts_sem);
285 return err?-EFAULT:0;
286}
287
288/*
289 * Do a system call from kernel instead of calling sys_execve so we
290 * end up with proper pt_regs.
291 */
292int kernel_execve(const char *filename, char *const argv[], char *const envp[])
293{
294 register unsigned long __sc0 __asm__ ("r9") = ((0x13 << 16) | __NR_execve);
295 register unsigned long __sc2 __asm__ ("r2") = (unsigned long) filename;
296 register unsigned long __sc3 __asm__ ("r3") = (unsigned long) argv;
297 register unsigned long __sc4 __asm__ ("r4") = (unsigned long) envp;
298 __asm__ __volatile__ ("trapa %1 !\t\t\t execve(%2,%3,%4)"
299 : "=r" (__sc0)
300 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) );
301 __asm__ __volatile__ ("!dummy %0 %1 %2 %3"
302 : : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) : "memory");
303 return __sc0;
304}
diff --git a/arch/sh64/kernel/syscalls.S b/arch/sh64/kernel/syscalls.S
deleted file mode 100644
index abb94c05d07a..000000000000
--- a/arch/sh64/kernel/syscalls.S
+++ /dev/null
@@ -1,381 +0,0 @@
1/*
2 * arch/sh64/kernel/syscalls.S
3 *
4 * Copyright (C) 2000, 2001 Paolo Alberelli
5 * Copyright (C) 2004 - 2007 Paul Mundt
6 * Copyright (C) 2003, 2004 Richard Curnow
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
10 * for more details.
11 */
12
13#include <linux/sys.h>
14
15 .section .data, "aw"
16 .balign 32
17
18/*
19 * System calls jump table
20 */
21 .globl sys_call_table
22sys_call_table:
23 .long sys_restart_syscall /* 0 - old "setup()" system call */
24 .long sys_exit
25 .long sys_fork
26 .long sys_read
27 .long sys_write
28 .long sys_open /* 5 */
29 .long sys_close
30 .long sys_waitpid
31 .long sys_creat
32 .long sys_link
33 .long sys_unlink /* 10 */
34 .long sys_execve
35 .long sys_chdir
36 .long sys_time
37 .long sys_mknod
38 .long sys_chmod /* 15 */
39 .long sys_lchown16
40 .long sys_ni_syscall /* old break syscall holder */
41 .long sys_stat
42 .long sys_lseek
43 .long sys_getpid /* 20 */
44 .long sys_mount
45 .long sys_oldumount
46 .long sys_setuid16
47 .long sys_getuid16
48 .long sys_stime /* 25 */
49 .long sh64_ptrace
50 .long sys_alarm
51 .long sys_fstat
52 .long sys_pause
53 .long sys_utime /* 30 */
54 .long sys_ni_syscall /* old stty syscall holder */
55 .long sys_ni_syscall /* old gtty syscall holder */
56 .long sys_access
57 .long sys_nice
58 .long sys_ni_syscall /* 35 */ /* old ftime syscall holder */
59 .long sys_sync
60 .long sys_kill
61 .long sys_rename
62 .long sys_mkdir
63 .long sys_rmdir /* 40 */
64 .long sys_dup
65 .long sys_pipe
66 .long sys_times
67 .long sys_ni_syscall /* old prof syscall holder */
68 .long sys_brk /* 45 */
69 .long sys_setgid16
70 .long sys_getgid16
71 .long sys_signal
72 .long sys_geteuid16
73 .long sys_getegid16 /* 50 */
74 .long sys_acct
75 .long sys_umount /* recycled never used phys( */
76 .long sys_ni_syscall /* old lock syscall holder */
77 .long sys_ioctl
78 .long sys_fcntl /* 55 */
79 .long sys_ni_syscall /* old mpx syscall holder */
80 .long sys_setpgid
81 .long sys_ni_syscall /* old ulimit syscall holder */
82 .long sys_ni_syscall /* sys_olduname */
83 .long sys_umask /* 60 */
84 .long sys_chroot
85 .long sys_ustat
86 .long sys_dup2
87 .long sys_getppid
88 .long sys_getpgrp /* 65 */
89 .long sys_setsid
90 .long sys_sigaction
91 .long sys_sgetmask
92 .long sys_ssetmask
93 .long sys_setreuid16 /* 70 */
94 .long sys_setregid16
95 .long sys_sigsuspend
96 .long sys_sigpending
97 .long sys_sethostname
98 .long sys_setrlimit /* 75 */
99 .long sys_old_getrlimit
100 .long sys_getrusage
101 .long sys_gettimeofday
102 .long sys_settimeofday
103 .long sys_getgroups16 /* 80 */
104 .long sys_setgroups16
105 .long sys_ni_syscall /* sys_oldselect */
106 .long sys_symlink
107 .long sys_lstat
108 .long sys_readlink /* 85 */
109 .long sys_uselib
110 .long sys_swapon
111 .long sys_reboot
112 .long old_readdir
113 .long old_mmap /* 90 */
114 .long sys_munmap
115 .long sys_truncate
116 .long sys_ftruncate
117 .long sys_fchmod
118 .long sys_fchown16 /* 95 */
119 .long sys_getpriority
120 .long sys_setpriority
121 .long sys_ni_syscall /* old profil syscall holder */
122 .long sys_statfs
123 .long sys_fstatfs /* 100 */
124 .long sys_ni_syscall /* ioperm */
125 .long sys_socketcall /* Obsolete implementation of socket syscall */
126 .long sys_syslog
127 .long sys_setitimer
128 .long sys_getitimer /* 105 */
129 .long sys_newstat
130 .long sys_newlstat
131 .long sys_newfstat
132 .long sys_uname
133 .long sys_ni_syscall /* 110 */ /* iopl */
134 .long sys_vhangup
135 .long sys_ni_syscall /* idle */
136 .long sys_ni_syscall /* vm86old */
137 .long sys_wait4
138 .long sys_swapoff /* 115 */
139 .long sys_sysinfo
140 .long sys_ipc /* Obsolete ipc syscall implementation */
141 .long sys_fsync
142 .long sys_sigreturn
143 .long sys_clone /* 120 */
144 .long sys_setdomainname
145 .long sys_newuname
146 .long sys_ni_syscall /* sys_modify_ldt */
147 .long sys_adjtimex
148 .long sys_mprotect /* 125 */
149 .long sys_sigprocmask
150 .long sys_ni_syscall /* old "create_module" */
151 .long sys_init_module
152 .long sys_delete_module
153 .long sys_ni_syscall /* 130: old "get_kernel_syms" */
154 .long sys_quotactl
155 .long sys_getpgid
156 .long sys_fchdir
157 .long sys_bdflush
158 .long sys_sysfs /* 135 */
159 .long sys_personality
160 .long sys_ni_syscall /* for afs_syscall */
161 .long sys_setfsuid16
162 .long sys_setfsgid16
163 .long sys_llseek /* 140 */
164 .long sys_getdents
165 .long sys_select
166 .long sys_flock
167 .long sys_msync
168 .long sys_readv /* 145 */
169 .long sys_writev
170 .long sys_getsid
171 .long sys_fdatasync
172 .long sys_sysctl
173 .long sys_mlock /* 150 */
174 .long sys_munlock
175 .long sys_mlockall
176 .long sys_munlockall
177 .long sys_sched_setparam
178 .long sys_sched_getparam /* 155 */
179 .long sys_sched_setscheduler
180 .long sys_sched_getscheduler
181 .long sys_sched_yield
182 .long sys_sched_get_priority_max
183 .long sys_sched_get_priority_min /* 160 */
184 .long sys_sched_rr_get_interval
185 .long sys_nanosleep
186 .long sys_mremap
187 .long sys_setresuid16
188 .long sys_getresuid16 /* 165 */
189 .long sys_ni_syscall /* vm86 */
190 .long sys_ni_syscall /* old "query_module" */
191 .long sys_poll
192 .long sys_nfsservctl
193 .long sys_setresgid16 /* 170 */
194 .long sys_getresgid16
195 .long sys_prctl
196 .long sys_rt_sigreturn
197 .long sys_rt_sigaction
198 .long sys_rt_sigprocmask /* 175 */
199 .long sys_rt_sigpending
200 .long sys_rt_sigtimedwait
201 .long sys_rt_sigqueueinfo
202 .long sys_rt_sigsuspend
203 .long sys_pread64 /* 180 */
204 .long sys_pwrite64
205 .long sys_chown16
206 .long sys_getcwd
207 .long sys_capget
208 .long sys_capset /* 185 */
209 .long sys_sigaltstack
210 .long sys_sendfile
211 .long sys_ni_syscall /* streams1 */
212 .long sys_ni_syscall /* streams2 */
213 .long sys_vfork /* 190 */
214 .long sys_getrlimit
215 .long sys_mmap2
216 .long sys_truncate64
217 .long sys_ftruncate64
218 .long sys_stat64 /* 195 */
219 .long sys_lstat64
220 .long sys_fstat64
221 .long sys_lchown
222 .long sys_getuid
223 .long sys_getgid /* 200 */
224 .long sys_geteuid
225 .long sys_getegid
226 .long sys_setreuid
227 .long sys_setregid
228 .long sys_getgroups /* 205 */
229 .long sys_setgroups
230 .long sys_fchown
231 .long sys_setresuid
232 .long sys_getresuid
233 .long sys_setresgid /* 210 */
234 .long sys_getresgid
235 .long sys_chown
236 .long sys_setuid
237 .long sys_setgid
238 .long sys_setfsuid /* 215 */
239 .long sys_setfsgid
240 .long sys_pivot_root
241 .long sys_mincore
242 .long sys_madvise
243 /* Broken-out socket family (maintain backwards compatibility in syscall
244 numbering with 2.4) */
245 .long sys_socket /* 220 */
246 .long sys_bind
247 .long sys_connect
248 .long sys_listen
249 .long sys_accept
250 .long sys_getsockname /* 225 */
251 .long sys_getpeername
252 .long sys_socketpair
253 .long sys_send
254 .long sys_sendto
255 .long sys_recv /* 230*/
256 .long sys_recvfrom
257 .long sys_shutdown
258 .long sys_setsockopt
259 .long sys_getsockopt
260 .long sys_sendmsg /* 235 */
261 .long sys_recvmsg
262 /* Broken-out IPC family (maintain backwards compatibility in syscall
263 numbering with 2.4) */
264 .long sys_semop
265 .long sys_semget
266 .long sys_semctl
267 .long sys_msgsnd /* 240 */
268 .long sys_msgrcv
269 .long sys_msgget
270 .long sys_msgctl
271 .long sys_shmat
272 .long sys_shmdt /* 245 */
273 .long sys_shmget
274 .long sys_shmctl
275 /* Rest of syscalls listed in 2.4 i386 unistd.h */
276 .long sys_getdents64
277 .long sys_fcntl64
278 .long sys_ni_syscall /* 250 reserved for TUX */
279 .long sys_ni_syscall /* Reserved for Security */
280 .long sys_gettid
281 .long sys_readahead
282 .long sys_setxattr
283 .long sys_lsetxattr /* 255 */
284 .long sys_fsetxattr
285 .long sys_getxattr
286 .long sys_lgetxattr
287 .long sys_fgetxattr
288 .long sys_listxattr /* 260 */
289 .long sys_llistxattr
290 .long sys_flistxattr
291 .long sys_removexattr
292 .long sys_lremovexattr
293 .long sys_fremovexattr /* 265 */
294 .long sys_tkill
295 .long sys_sendfile64
296 .long sys_futex
297 .long sys_sched_setaffinity
298 .long sys_sched_getaffinity /* 270 */
299 .long sys_ni_syscall
300 .long sys_ni_syscall
301 .long sys_io_setup
302 .long sys_io_destroy
303 .long sys_io_getevents /* 275 */
304 .long sys_io_submit
305 .long sys_io_cancel
306 .long sys_fadvise64
307 .long sys_ni_syscall
308 .long sys_exit_group /* 280 */
309 /* Rest of new 2.6 syscalls */
310 .long sys_lookup_dcookie
311 .long sys_epoll_create
312 .long sys_epoll_ctl
313 .long sys_epoll_wait
314 .long sys_remap_file_pages /* 285 */
315 .long sys_set_tid_address
316 .long sys_timer_create
317 .long sys_timer_settime
318 .long sys_timer_gettime
319 .long sys_timer_getoverrun /* 290 */
320 .long sys_timer_delete
321 .long sys_clock_settime
322 .long sys_clock_gettime
323 .long sys_clock_getres
324 .long sys_clock_nanosleep /* 295 */
325 .long sys_statfs64
326 .long sys_fstatfs64
327 .long sys_tgkill
328 .long sys_utimes
329 .long sys_fadvise64_64 /* 300 */
330 .long sys_ni_syscall /* Reserved for vserver */
331 .long sys_ni_syscall /* Reserved for mbind */
332 .long sys_ni_syscall /* get_mempolicy */
333 .long sys_ni_syscall /* set_mempolicy */
334 .long sys_mq_open /* 305 */
335 .long sys_mq_unlink
336 .long sys_mq_timedsend
337 .long sys_mq_timedreceive
338 .long sys_mq_notify
339 .long sys_mq_getsetattr /* 310 */
340 .long sys_ni_syscall /* Reserved for kexec */
341 .long sys_waitid
342 .long sys_add_key
343 .long sys_request_key
344 .long sys_keyctl /* 315 */
345 .long sys_ioprio_set
346 .long sys_ioprio_get
347 .long sys_inotify_init
348 .long sys_inotify_add_watch
349 .long sys_inotify_rm_watch /* 320 */
350 .long sys_ni_syscall
351 .long sys_migrate_pages
352 .long sys_openat
353 .long sys_mkdirat
354 .long sys_mknodat /* 325 */
355 .long sys_fchownat
356 .long sys_futimesat
357 .long sys_fstatat64
358 .long sys_unlinkat
359 .long sys_renameat /* 330 */
360 .long sys_linkat
361 .long sys_symlinkat
362 .long sys_readlinkat
363 .long sys_fchmodat
364 .long sys_faccessat /* 335 */
365 .long sys_pselect6
366 .long sys_ppoll
367 .long sys_unshare
368 .long sys_set_robust_list
369 .long sys_get_robust_list /* 340 */
370 .long sys_splice
371 .long sys_sync_file_range
372 .long sys_tee
373 .long sys_vmsplice
374 .long sys_move_pages /* 345 */
375 .long sys_getcpu
376 .long sys_epoll_pwait
377 .long sys_utimensat
378 .long sys_signalfd
379 .long sys_timerfd /* 350 */
380 .long sys_eventfd
381 .long sys_fallocate
diff --git a/arch/sh64/kernel/time.c b/arch/sh64/kernel/time.c
deleted file mode 100644
index 06f3c179e345..000000000000
--- a/arch/sh64/kernel/time.c
+++ /dev/null
@@ -1,593 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/time.c
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003, 2004 Paul Mundt
10 * Copyright (C) 2003 Richard Curnow
11 *
12 * Original TMU/RTC code taken from sh version.
13 * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka
14 * Some code taken from i386 version.
15 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
16 */
17
18#include <linux/errno.h>
19#include <linux/rwsem.h>
20#include <linux/sched.h>
21#include <linux/kernel.h>
22#include <linux/param.h>
23#include <linux/string.h>
24#include <linux/mm.h>
25#include <linux/interrupt.h>
26#include <linux/time.h>
27#include <linux/delay.h>
28#include <linux/init.h>
29#include <linux/profile.h>
30#include <linux/smp.h>
31#include <linux/module.h>
32#include <linux/bcd.h>
33
34#include <asm/registers.h> /* required by inline __asm__ stmt. */
35
36#include <asm/processor.h>
37#include <asm/uaccess.h>
38#include <asm/io.h>
39#include <asm/irq.h>
40#include <asm/delay.h>
41
42#include <linux/timex.h>
43#include <linux/irq.h>
44#include <asm/hardware.h>
45
46#define TMU_TOCR_INIT 0x00
47#define TMU0_TCR_INIT 0x0020
48#define TMU_TSTR_INIT 1
49#define TMU_TSTR_OFF 0
50
51/* RCR1 Bits */
52#define RCR1_CF 0x80 /* Carry Flag */
53#define RCR1_CIE 0x10 /* Carry Interrupt Enable */
54#define RCR1_AIE 0x08 /* Alarm Interrupt Enable */
55#define RCR1_AF 0x01 /* Alarm Flag */
56
57/* RCR2 Bits */
58#define RCR2_PEF 0x80 /* PEriodic interrupt Flag */
59#define RCR2_PESMASK 0x70 /* Periodic interrupt Set */
60#define RCR2_RTCEN 0x08 /* ENable RTC */
61#define RCR2_ADJ 0x04 /* ADJustment (30-second) */
62#define RCR2_RESET 0x02 /* Reset bit */
63#define RCR2_START 0x01 /* Start bit */
64
65/* Clock, Power and Reset Controller */
66#define CPRC_BLOCK_OFF 0x01010000
67#define CPRC_BASE PHYS_PERIPHERAL_BLOCK + CPRC_BLOCK_OFF
68
69#define FRQCR (cprc_base+0x0)
70#define WTCSR (cprc_base+0x0018)
71#define STBCR (cprc_base+0x0030)
72
73/* Time Management Unit */
74#define TMU_BLOCK_OFF 0x01020000
75#define TMU_BASE PHYS_PERIPHERAL_BLOCK + TMU_BLOCK_OFF
76#define TMU0_BASE tmu_base + 0x8 + (0xc * 0x0)
77#define TMU1_BASE tmu_base + 0x8 + (0xc * 0x1)
78#define TMU2_BASE tmu_base + 0x8 + (0xc * 0x2)
79
80#define TMU_TOCR tmu_base+0x0 /* Byte access */
81#define TMU_TSTR tmu_base+0x4 /* Byte access */
82
83#define TMU0_TCOR TMU0_BASE+0x0 /* Long access */
84#define TMU0_TCNT TMU0_BASE+0x4 /* Long access */
85#define TMU0_TCR TMU0_BASE+0x8 /* Word access */
86
87/* Real Time Clock */
88#define RTC_BLOCK_OFF 0x01040000
89#define RTC_BASE PHYS_PERIPHERAL_BLOCK + RTC_BLOCK_OFF
90
91#define R64CNT rtc_base+0x00
92#define RSECCNT rtc_base+0x04
93#define RMINCNT rtc_base+0x08
94#define RHRCNT rtc_base+0x0c
95#define RWKCNT rtc_base+0x10
96#define RDAYCNT rtc_base+0x14
97#define RMONCNT rtc_base+0x18
98#define RYRCNT rtc_base+0x1c /* 16bit */
99#define RSECAR rtc_base+0x20
100#define RMINAR rtc_base+0x24
101#define RHRAR rtc_base+0x28
102#define RWKAR rtc_base+0x2c
103#define RDAYAR rtc_base+0x30
104#define RMONAR rtc_base+0x34
105#define RCR1 rtc_base+0x38
106#define RCR2 rtc_base+0x3c
107
108#define TICK_SIZE (tick_nsec / 1000)
109
110static unsigned long tmu_base, rtc_base;
111unsigned long cprc_base;
112
113/* Variables to allow interpolation of time of day to resolution better than a
114 * jiffy. */
115
116/* This is effectively protected by xtime_lock */
117static unsigned long ctc_last_interrupt;
118static unsigned long long usecs_per_jiffy = 1000000/HZ; /* Approximation */
119
120#define CTC_JIFFY_SCALE_SHIFT 40
121
122/* 2**CTC_JIFFY_SCALE_SHIFT / ctc_ticks_per_jiffy */
123static unsigned long long scaled_recip_ctc_ticks_per_jiffy;
124
125/* Estimate number of microseconds that have elapsed since the last timer tick,
126 by scaling the delta that has occurred in the CTC register.
127
128 WARNING WARNING WARNING : This algorithm relies on the CTC decrementing at
129 the CPU clock rate. If the CPU sleeps, the CTC stops counting. Bear this
130 in mind if enabling SLEEP_WORKS in process.c. In that case, this algorithm
131 probably needs to use TMU.TCNT0 instead. This will work even if the CPU is
132 sleeping, though will be coarser.
133
134 FIXME : What if usecs_per_tick is moving around too much, e.g. if an adjtime
135 is running or if the freq or tick arguments of adjtimex are modified after
136 we have calibrated the scaling factor? This will result in either a jump at
137 the end of a tick period, or a wrap backwards at the start of the next one,
138 if the application is reading the time of day often enough. I think we
139 ought to do better than this. For this reason, usecs_per_jiffy is left
140 separated out in the calculation below. This allows some future hook into
141 the adjtime-related stuff in kernel/timer.c to remove this hazard.
142
143*/
144
145static unsigned long usecs_since_tick(void)
146{
147 unsigned long long current_ctc;
148 long ctc_ticks_since_interrupt;
149 unsigned long long ull_ctc_ticks_since_interrupt;
150 unsigned long result;
151
152 unsigned long long mul1_out;
153 unsigned long long mul1_out_high;
154 unsigned long long mul2_out_low, mul2_out_high;
155
156 /* Read CTC register */
157 asm ("getcon cr62, %0" : "=r" (current_ctc));
158 /* Note, the CTC counts down on each CPU clock, not up.
159 Note(2), use long type to get correct wraparound arithmetic when
160 the counter crosses zero. */
161 ctc_ticks_since_interrupt = (long) ctc_last_interrupt - (long) current_ctc;
162 ull_ctc_ticks_since_interrupt = (unsigned long long) ctc_ticks_since_interrupt;
163
164 /* Inline assembly to do 32x32x32->64 multiplier */
165 asm volatile ("mulu.l %1, %2, %0" :
166 "=r" (mul1_out) :
167 "r" (ull_ctc_ticks_since_interrupt), "r" (usecs_per_jiffy));
168
169 mul1_out_high = mul1_out >> 32;
170
171 asm volatile ("mulu.l %1, %2, %0" :
172 "=r" (mul2_out_low) :
173 "r" (mul1_out), "r" (scaled_recip_ctc_ticks_per_jiffy));
174
175#if 1
176 asm volatile ("mulu.l %1, %2, %0" :
177 "=r" (mul2_out_high) :
178 "r" (mul1_out_high), "r" (scaled_recip_ctc_ticks_per_jiffy));
179#endif
180
181 result = (unsigned long) (((mul2_out_high << 32) + mul2_out_low) >> CTC_JIFFY_SCALE_SHIFT);
182
183 return result;
184}
185
186void do_gettimeofday(struct timeval *tv)
187{
188 unsigned long flags;
189 unsigned long seq;
190 unsigned long usec, sec;
191
192 do {
193 seq = read_seqbegin_irqsave(&xtime_lock, flags);
194 usec = usecs_since_tick();
195 sec = xtime.tv_sec;
196 usec += xtime.tv_nsec / 1000;
197 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
198
199 while (usec >= 1000000) {
200 usec -= 1000000;
201 sec++;
202 }
203
204 tv->tv_sec = sec;
205 tv->tv_usec = usec;
206}
207
208int do_settimeofday(struct timespec *tv)
209{
210 time_t wtm_sec, sec = tv->tv_sec;
211 long wtm_nsec, nsec = tv->tv_nsec;
212
213 if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
214 return -EINVAL;
215
216 write_seqlock_irq(&xtime_lock);
217 /*
218 * This is revolting. We need to set "xtime" correctly. However, the
219 * value in this location is the value at the most recent update of
220 * wall time. Discover what correction gettimeofday() would have
221 * made, and then undo it!
222 */
223 nsec -= 1000 * usecs_since_tick();
224
225 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
226 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
227
228 set_normalized_timespec(&xtime, sec, nsec);
229 set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec);
230
231 ntp_clear();
232 write_sequnlock_irq(&xtime_lock);
233 clock_was_set();
234
235 return 0;
236}
237EXPORT_SYMBOL(do_settimeofday);
238
239static int set_rtc_time(unsigned long nowtime)
240{
241 int retval = 0;
242 int real_seconds, real_minutes, cmos_minutes;
243
244 ctrl_outb(RCR2_RESET, RCR2); /* Reset pre-scaler & stop RTC */
245
246 cmos_minutes = ctrl_inb(RMINCNT);
247 BCD_TO_BIN(cmos_minutes);
248
249 /*
250 * since we're only adjusting minutes and seconds,
251 * don't interfere with hour overflow. This avoids
252 * messing with unknown time zones but requires your
253 * RTC not to be off by more than 15 minutes
254 */
255 real_seconds = nowtime % 60;
256 real_minutes = nowtime / 60;
257 if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
258 real_minutes += 30; /* correct for half hour time zone */
259 real_minutes %= 60;
260
261 if (abs(real_minutes - cmos_minutes) < 30) {
262 BIN_TO_BCD(real_seconds);
263 BIN_TO_BCD(real_minutes);
264 ctrl_outb(real_seconds, RSECCNT);
265 ctrl_outb(real_minutes, RMINCNT);
266 } else {
267 printk(KERN_WARNING
268 "set_rtc_time: can't update from %d to %d\n",
269 cmos_minutes, real_minutes);
270 retval = -1;
271 }
272
273 ctrl_outb(RCR2_RTCEN|RCR2_START, RCR2); /* Start RTC */
274
275 return retval;
276}
277
278/* last time the RTC clock got updated */
279static long last_rtc_update = 0;
280
281/*
282 * timer_interrupt() needs to keep up the real-time clock,
283 * as well as call the "do_timer()" routine every clocktick
284 */
285static inline void do_timer_interrupt(void)
286{
287 unsigned long long current_ctc;
288 asm ("getcon cr62, %0" : "=r" (current_ctc));
289 ctc_last_interrupt = (unsigned long) current_ctc;
290
291 do_timer(1);
292#ifndef CONFIG_SMP
293 update_process_times(user_mode(get_irq_regs()));
294#endif
295 if (current->pid)
296 profile_tick(CPU_PROFILING);
297
298#ifdef CONFIG_HEARTBEAT
299 {
300 extern void heartbeat(void);
301
302 heartbeat();
303 }
304#endif
305
306 /*
307 * If we have an externally synchronized Linux clock, then update
308 * RTC clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
309 * called as close as possible to 500 ms before the new second starts.
310 */
311 if (ntp_synced() &&
312 xtime.tv_sec > last_rtc_update + 660 &&
313 (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 &&
314 (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) {
315 if (set_rtc_time(xtime.tv_sec) == 0)
316 last_rtc_update = xtime.tv_sec;
317 else
318 last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
319 }
320}
321
322/*
323 * This is the same as the above, except we _also_ save the current
324 * Time Stamp Counter value at the time of the timer interrupt, so that
325 * we later on can estimate the time of day more exactly.
326 */
327static irqreturn_t timer_interrupt(int irq, void *dev_id)
328{
329 unsigned long timer_status;
330
331 /* Clear UNF bit */
332 timer_status = ctrl_inw(TMU0_TCR);
333 timer_status &= ~0x100;
334 ctrl_outw(timer_status, TMU0_TCR);
335
336 /*
337 * Here we are in the timer irq handler. We just have irqs locally
338 * disabled but we don't know if the timer_bh is running on the other
339 * CPU. We need to avoid to SMP race with it. NOTE: we don' t need
340 * the irq version of write_lock because as just said we have irq
341 * locally disabled. -arca
342 */
343 write_lock(&xtime_lock);
344 do_timer_interrupt();
345 write_unlock(&xtime_lock);
346
347 return IRQ_HANDLED;
348}
349
350static unsigned long get_rtc_time(void)
351{
352 unsigned int sec, min, hr, wk, day, mon, yr, yr100;
353
354 again:
355 do {
356 ctrl_outb(0, RCR1); /* Clear CF-bit */
357 sec = ctrl_inb(RSECCNT);
358 min = ctrl_inb(RMINCNT);
359 hr = ctrl_inb(RHRCNT);
360 wk = ctrl_inb(RWKCNT);
361 day = ctrl_inb(RDAYCNT);
362 mon = ctrl_inb(RMONCNT);
363 yr = ctrl_inw(RYRCNT);
364 yr100 = (yr >> 8);
365 yr &= 0xff;
366 } while ((ctrl_inb(RCR1) & RCR1_CF) != 0);
367
368 BCD_TO_BIN(yr100);
369 BCD_TO_BIN(yr);
370 BCD_TO_BIN(mon);
371 BCD_TO_BIN(day);
372 BCD_TO_BIN(hr);
373 BCD_TO_BIN(min);
374 BCD_TO_BIN(sec);
375
376 if (yr > 99 || mon < 1 || mon > 12 || day > 31 || day < 1 ||
377 hr > 23 || min > 59 || sec > 59) {
378 printk(KERN_ERR
379 "SH RTC: invalid value, resetting to 1 Jan 2000\n");
380 ctrl_outb(RCR2_RESET, RCR2); /* Reset & Stop */
381 ctrl_outb(0, RSECCNT);
382 ctrl_outb(0, RMINCNT);
383 ctrl_outb(0, RHRCNT);
384 ctrl_outb(6, RWKCNT);
385 ctrl_outb(1, RDAYCNT);
386 ctrl_outb(1, RMONCNT);
387 ctrl_outw(0x2000, RYRCNT);
388 ctrl_outb(RCR2_RTCEN|RCR2_START, RCR2); /* Start */
389 goto again;
390 }
391
392 return mktime(yr100 * 100 + yr, mon, day, hr, min, sec);
393}
394
395static __init unsigned int get_cpu_hz(void)
396{
397 unsigned int count;
398 unsigned long __dummy;
399 unsigned long ctc_val_init, ctc_val;
400
401 /*
402 ** Regardless the toolchain, force the compiler to use the
403 ** arbitrary register r3 as a clock tick counter.
404 ** NOTE: r3 must be in accordance with sh64_rtc_interrupt()
405 */
406 register unsigned long long __rtc_irq_flag __asm__ ("r3");
407
408 local_irq_enable();
409 do {} while (ctrl_inb(R64CNT) != 0);
410 ctrl_outb(RCR1_CIE, RCR1); /* Enable carry interrupt */
411
412 /*
413 * r3 is arbitrary. CDC does not support "=z".
414 */
415 ctc_val_init = 0xffffffff;
416 ctc_val = ctc_val_init;
417
418 asm volatile("gettr tr0, %1\n\t"
419 "putcon %0, " __CTC "\n\t"
420 "and %2, r63, %2\n\t"
421 "pta $+4, tr0\n\t"
422 "beq/l %2, r63, tr0\n\t"
423 "ptabs %1, tr0\n\t"
424 "getcon " __CTC ", %0\n\t"
425 : "=r"(ctc_val), "=r" (__dummy), "=r" (__rtc_irq_flag)
426 : "0" (0));
427 local_irq_disable();
428 /*
429 * SH-3:
430 * CPU clock = 4 stages * loop
431 * tst rm,rm if id ex
432 * bt/s 1b if id ex
433 * add #1,rd if id ex
434 * (if) pipe line stole
435 * tst rm,rm if id ex
436 * ....
437 *
438 *
439 * SH-4:
440 * CPU clock = 6 stages * loop
441 * I don't know why.
442 * ....
443 *
444 * SH-5:
445 * Use CTC register to count. This approach returns the right value
446 * even if the I-cache is disabled (e.g. whilst debugging.)
447 *
448 */
449
450 count = ctc_val_init - ctc_val; /* CTC counts down */
451
452#if defined (CONFIG_SH_SIMULATOR)
453 /*
454 * Let's pretend we are a 5MHz SH-5 to avoid a too
455 * little timer interval. Also to keep delay
456 * calibration within a reasonable time.
457 */
458 return 5000000;
459#else
460 /*
461 * This really is count by the number of clock cycles
462 * by the ratio between a complete R64CNT
463 * wrap-around (128) and CUI interrupt being raised (64).
464 */
465 return count*2;
466#endif
467}
468
469static irqreturn_t sh64_rtc_interrupt(int irq, void *dev_id)
470{
471 struct pt_regs *regs = get_irq_regs();
472
473 ctrl_outb(0, RCR1); /* Disable Carry Interrupts */
474 regs->regs[3] = 1; /* Using r3 */
475
476 return IRQ_HANDLED;
477}
478
479static struct irqaction irq0 = {
480 .handler = timer_interrupt,
481 .flags = IRQF_DISABLED,
482 .mask = CPU_MASK_NONE,
483 .name = "timer",
484};
485static struct irqaction irq1 = {
486 .handler = sh64_rtc_interrupt,
487 .flags = IRQF_DISABLED,
488 .mask = CPU_MASK_NONE,
489 .name = "rtc",
490};
491
492void __init time_init(void)
493{
494 unsigned int cpu_clock, master_clock, bus_clock, module_clock;
495 unsigned long interval;
496 unsigned long frqcr, ifc, pfc;
497 static int ifc_table[] = { 2, 4, 6, 8, 10, 12, 16, 24 };
498#define bfc_table ifc_table /* Same */
499#define pfc_table ifc_table /* Same */
500
501 tmu_base = onchip_remap(TMU_BASE, 1024, "TMU");
502 if (!tmu_base) {
503 panic("Unable to remap TMU\n");
504 }
505
506 rtc_base = onchip_remap(RTC_BASE, 1024, "RTC");
507 if (!rtc_base) {
508 panic("Unable to remap RTC\n");
509 }
510
511 cprc_base = onchip_remap(CPRC_BASE, 1024, "CPRC");
512 if (!cprc_base) {
513 panic("Unable to remap CPRC\n");
514 }
515
516 xtime.tv_sec = get_rtc_time();
517 xtime.tv_nsec = 0;
518
519 setup_irq(TIMER_IRQ, &irq0);
520 setup_irq(RTC_IRQ, &irq1);
521
522 /* Check how fast it is.. */
523 cpu_clock = get_cpu_hz();
524
525 /* Note careful order of operations to maintain reasonable precision and avoid overflow. */
526 scaled_recip_ctc_ticks_per_jiffy = ((1ULL << CTC_JIFFY_SCALE_SHIFT) / (unsigned long long)(cpu_clock / HZ));
527
528 disable_irq(RTC_IRQ);
529
530 printk("CPU clock: %d.%02dMHz\n",
531 (cpu_clock / 1000000), (cpu_clock % 1000000)/10000);
532 {
533 unsigned short bfc;
534 frqcr = ctrl_inl(FRQCR);
535 ifc = ifc_table[(frqcr>> 6) & 0x0007];
536 bfc = bfc_table[(frqcr>> 3) & 0x0007];
537 pfc = pfc_table[(frqcr>> 12) & 0x0007];
538 master_clock = cpu_clock * ifc;
539 bus_clock = master_clock/bfc;
540 }
541
542 printk("Bus clock: %d.%02dMHz\n",
543 (bus_clock/1000000), (bus_clock % 1000000)/10000);
544 module_clock = master_clock/pfc;
545 printk("Module clock: %d.%02dMHz\n",
546 (module_clock/1000000), (module_clock % 1000000)/10000);
547 interval = (module_clock/(HZ*4));
548
549 printk("Interval = %ld\n", interval);
550
551 current_cpu_data.cpu_clock = cpu_clock;
552 current_cpu_data.master_clock = master_clock;
553 current_cpu_data.bus_clock = bus_clock;
554 current_cpu_data.module_clock = module_clock;
555
556 /* Start TMU0 */
557 ctrl_outb(TMU_TSTR_OFF, TMU_TSTR);
558 ctrl_outb(TMU_TOCR_INIT, TMU_TOCR);
559 ctrl_outw(TMU0_TCR_INIT, TMU0_TCR);
560 ctrl_outl(interval, TMU0_TCOR);
561 ctrl_outl(interval, TMU0_TCNT);
562 ctrl_outb(TMU_TSTR_INIT, TMU_TSTR);
563}
564
565void enter_deep_standby(void)
566{
567 /* Disable watchdog timer */
568 ctrl_outl(0xa5000000, WTCSR);
569 /* Configure deep standby on sleep */
570 ctrl_outl(0x03, STBCR);
571
572#ifdef CONFIG_SH_ALPHANUMERIC
573 {
574 extern void mach_alphanum(int position, unsigned char value);
575 extern void mach_alphanum_brightness(int setting);
576 char halted[] = "Halted. ";
577 int i;
578 mach_alphanum_brightness(6); /* dimmest setting above off */
579 for (i=0; i<8; i++) {
580 mach_alphanum(i, halted[i]);
581 }
582 asm __volatile__ ("synco");
583 }
584#endif
585
586 asm __volatile__ ("sleep");
587 asm __volatile__ ("synci");
588 asm __volatile__ ("nop");
589 asm __volatile__ ("nop");
590 asm __volatile__ ("nop");
591 asm __volatile__ ("nop");
592 panic("Unexpected wakeup!\n");
593}
diff --git a/arch/sh64/kernel/traps.c b/arch/sh64/kernel/traps.c
deleted file mode 100644
index f32df3831f45..000000000000
--- a/arch/sh64/kernel/traps.c
+++ /dev/null
@@ -1,982 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/traps.c
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003, 2004 Paul Mundt
10 * Copyright (C) 2003, 2004 Richard Curnow
11 *
12 */
13
14/*
15 * 'Traps.c' handles hardware traps and faults after we have saved some
16 * state in 'entry.S'.
17 */
18#include <linux/sched.h>
19#include <linux/kernel.h>
20#include <linux/string.h>
21#include <linux/errno.h>
22#include <linux/ptrace.h>
23#include <linux/timer.h>
24#include <linux/mm.h>
25#include <linux/smp.h>
26#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/spinlock.h>
29#include <linux/kallsyms.h>
30#include <linux/interrupt.h>
31#include <linux/sysctl.h>
32#include <linux/module.h>
33#include <asm/system.h>
34#include <asm/uaccess.h>
35#include <asm/io.h>
36#include <asm/atomic.h>
37#include <asm/processor.h>
38#include <asm/pgtable.h>
39
40#undef DEBUG_EXCEPTION
41#ifdef DEBUG_EXCEPTION
42/* implemented in ../lib/dbg.c */
43extern void show_excp_regs(char *fname, int trapnr, int signr,
44 struct pt_regs *regs);
45#else
46#define show_excp_regs(a, b, c, d)
47#endif
48
49static void do_unhandled_exception(int trapnr, int signr, char *str, char *fn_name,
50 unsigned long error_code, struct pt_regs *regs, struct task_struct *tsk);
51
52#define DO_ERROR(trapnr, signr, str, name, tsk) \
53asmlinkage void do_##name(unsigned long error_code, struct pt_regs *regs) \
54{ \
55 do_unhandled_exception(trapnr, signr, str, __stringify(name), error_code, regs, current); \
56}
57
58spinlock_t die_lock;
59
60void die(const char * str, struct pt_regs * regs, long err)
61{
62 console_verbose();
63 spin_lock_irq(&die_lock);
64 printk("%s: %lx\n", str, (err & 0xffffff));
65 show_regs(regs);
66 spin_unlock_irq(&die_lock);
67 do_exit(SIGSEGV);
68}
69
70static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
71{
72 if (!user_mode(regs))
73 die(str, regs, err);
74}
75
76static void die_if_no_fixup(const char * str, struct pt_regs * regs, long err)
77{
78 if (!user_mode(regs)) {
79 const struct exception_table_entry *fixup;
80 fixup = search_exception_tables(regs->pc);
81 if (fixup) {
82 regs->pc = fixup->fixup;
83 return;
84 }
85 die(str, regs, err);
86 }
87}
88
89DO_ERROR(13, SIGILL, "illegal slot instruction", illegal_slot_inst, current)
90DO_ERROR(87, SIGSEGV, "address error (exec)", address_error_exec, current)
91
92
93/* Implement misaligned load/store handling for kernel (and optionally for user
94 mode too). Limitation : only SHmedia mode code is handled - there is no
95 handling at all for misaligned accesses occurring in SHcompact code yet. */
96
97static int misaligned_fixup(struct pt_regs *regs);
98
99asmlinkage void do_address_error_load(unsigned long error_code, struct pt_regs *regs)
100{
101 if (misaligned_fixup(regs) < 0) {
102 do_unhandled_exception(7, SIGSEGV, "address error(load)",
103 "do_address_error_load",
104 error_code, regs, current);
105 }
106 return;
107}
108
109asmlinkage void do_address_error_store(unsigned long error_code, struct pt_regs *regs)
110{
111 if (misaligned_fixup(regs) < 0) {
112 do_unhandled_exception(8, SIGSEGV, "address error(store)",
113 "do_address_error_store",
114 error_code, regs, current);
115 }
116 return;
117}
118
119#if defined(CONFIG_SH64_ID2815_WORKAROUND)
120
121#define OPCODE_INVALID 0
122#define OPCODE_USER_VALID 1
123#define OPCODE_PRIV_VALID 2
124
125/* getcon/putcon - requires checking which control register is referenced. */
126#define OPCODE_CTRL_REG 3
127
128/* Table of valid opcodes for SHmedia mode.
129 Form a 10-bit value by concatenating the major/minor opcodes i.e.
130 opcode[31:26,20:16]. The 6 MSBs of this value index into the following
131 array. The 4 LSBs select the bit-pair in the entry (bits 1:0 correspond to
132 LSBs==4'b0000 etc). */
133static unsigned long shmedia_opcode_table[64] = {
134 0x55554044,0x54445055,0x15141514,0x14541414,0x00000000,0x10001000,0x01110055,0x04050015,
135 0x00000444,0xc0000000,0x44545515,0x40405555,0x55550015,0x10005555,0x55555505,0x04050000,
136 0x00000555,0x00000404,0x00040445,0x15151414,0x00000000,0x00000000,0x00000000,0x00000000,
137 0x00000055,0x40404444,0x00000404,0xc0009495,0x00000000,0x00000000,0x00000000,0x00000000,
138 0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
139 0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
140 0x80005050,0x04005055,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
141 0x81055554,0x00000404,0x55555555,0x55555555,0x00000000,0x00000000,0x00000000,0x00000000
142};
143
144void do_reserved_inst(unsigned long error_code, struct pt_regs *regs)
145{
146 /* Workaround SH5-101 cut2 silicon defect #2815 :
147 in some situations, inter-mode branches from SHcompact -> SHmedia
148 which should take ITLBMISS or EXECPROT exceptions at the target
149 falsely take RESINST at the target instead. */
150
151 unsigned long opcode = 0x6ff4fff0; /* guaranteed reserved opcode */
152 unsigned long pc, aligned_pc;
153 int get_user_error;
154 int trapnr = 12;
155 int signr = SIGILL;
156 char *exception_name = "reserved_instruction";
157
158 pc = regs->pc;
159 if ((pc & 3) == 1) {
160 /* SHmedia : check for defect. This requires executable vmas
161 to be readable too. */
162 aligned_pc = pc & ~3;
163 if (!access_ok(VERIFY_READ, aligned_pc, sizeof(unsigned long))) {
164 get_user_error = -EFAULT;
165 } else {
166 get_user_error = __get_user(opcode, (unsigned long *)aligned_pc);
167 }
168 if (get_user_error >= 0) {
169 unsigned long index, shift;
170 unsigned long major, minor, combined;
171 unsigned long reserved_field;
172 reserved_field = opcode & 0xf; /* These bits are currently reserved as zero in all valid opcodes */
173 major = (opcode >> 26) & 0x3f;
174 minor = (opcode >> 16) & 0xf;
175 combined = (major << 4) | minor;
176 index = major;
177 shift = minor << 1;
178 if (reserved_field == 0) {
179 int opcode_state = (shmedia_opcode_table[index] >> shift) & 0x3;
180 switch (opcode_state) {
181 case OPCODE_INVALID:
182 /* Trap. */
183 break;
184 case OPCODE_USER_VALID:
185 /* Restart the instruction : the branch to the instruction will now be from an RTE
186 not from SHcompact so the silicon defect won't be triggered. */
187 return;
188 case OPCODE_PRIV_VALID:
189 if (!user_mode(regs)) {
190 /* Should only ever get here if a module has
191 SHcompact code inside it. If so, the same fix up is needed. */
192 return; /* same reason */
193 }
194 /* Otherwise, user mode trying to execute a privileged instruction -
195 fall through to trap. */
196 break;
197 case OPCODE_CTRL_REG:
198 /* If in privileged mode, return as above. */
199 if (!user_mode(regs)) return;
200 /* In user mode ... */
201 if (combined == 0x9f) { /* GETCON */
202 unsigned long regno = (opcode >> 20) & 0x3f;
203 if (regno >= 62) {
204 return;
205 }
206 /* Otherwise, reserved or privileged control register, => trap */
207 } else if (combined == 0x1bf) { /* PUTCON */
208 unsigned long regno = (opcode >> 4) & 0x3f;
209 if (regno >= 62) {
210 return;
211 }
212 /* Otherwise, reserved or privileged control register, => trap */
213 } else {
214 /* Trap */
215 }
216 break;
217 default:
218 /* Fall through to trap. */
219 break;
220 }
221 }
222 /* fall through to normal resinst processing */
223 } else {
224 /* Error trying to read opcode. This typically means a
225 real fault, not a RESINST any more. So change the
226 codes. */
227 trapnr = 87;
228 exception_name = "address error (exec)";
229 signr = SIGSEGV;
230 }
231 }
232
233 do_unhandled_exception(trapnr, signr, exception_name, "do_reserved_inst", error_code, regs, current);
234}
235
236#else /* CONFIG_SH64_ID2815_WORKAROUND */
237
238/* If the workaround isn't needed, this is just a straightforward reserved
239 instruction */
240DO_ERROR(12, SIGILL, "reserved instruction", reserved_inst, current)
241
242#endif /* CONFIG_SH64_ID2815_WORKAROUND */
243
244/* Called with interrupts disabled */
245asmlinkage void do_exception_error(unsigned long ex, struct pt_regs *regs)
246{
247 PLS();
248 show_excp_regs(__FUNCTION__, -1, -1, regs);
249 die_if_kernel("exception", regs, ex);
250}
251
252int do_unknown_trapa(unsigned long scId, struct pt_regs *regs)
253{
254 /* Syscall debug */
255 printk("System call ID error: [0x1#args:8 #syscall:16 0x%lx]\n", scId);
256
257 die_if_kernel("unknown trapa", regs, scId);
258
259 return -ENOSYS;
260}
261
262void show_stack(struct task_struct *tsk, unsigned long *sp)
263{
264#ifdef CONFIG_KALLSYMS
265 extern void sh64_unwind(struct pt_regs *regs);
266 struct pt_regs *regs;
267
268 regs = tsk ? tsk->thread.kregs : NULL;
269
270 sh64_unwind(regs);
271#else
272 printk(KERN_ERR "Can't backtrace on sh64 without CONFIG_KALLSYMS\n");
273#endif
274}
275
276void show_task(unsigned long *sp)
277{
278 show_stack(NULL, sp);
279}
280
281void dump_stack(void)
282{
283 show_task(NULL);
284}
285/* Needed by any user of WARN_ON in view of the defn in include/asm-sh/bug.h */
286EXPORT_SYMBOL(dump_stack);
287
288static void do_unhandled_exception(int trapnr, int signr, char *str, char *fn_name,
289 unsigned long error_code, struct pt_regs *regs, struct task_struct *tsk)
290{
291 show_excp_regs(fn_name, trapnr, signr, regs);
292 tsk->thread.error_code = error_code;
293 tsk->thread.trap_no = trapnr;
294
295 if (user_mode(regs))
296 force_sig(signr, tsk);
297
298 die_if_no_fixup(str, regs, error_code);
299}
300
301static int read_opcode(unsigned long long pc, unsigned long *result_opcode, int from_user_mode)
302{
303 int get_user_error;
304 unsigned long aligned_pc;
305 unsigned long opcode;
306
307 if ((pc & 3) == 1) {
308 /* SHmedia */
309 aligned_pc = pc & ~3;
310 if (from_user_mode) {
311 if (!access_ok(VERIFY_READ, aligned_pc, sizeof(unsigned long))) {
312 get_user_error = -EFAULT;
313 } else {
314 get_user_error = __get_user(opcode, (unsigned long *)aligned_pc);
315 *result_opcode = opcode;
316 }
317 return get_user_error;
318 } else {
319 /* If the fault was in the kernel, we can either read
320 * this directly, or if not, we fault.
321 */
322 *result_opcode = *(unsigned long *) aligned_pc;
323 return 0;
324 }
325 } else if ((pc & 1) == 0) {
326 /* SHcompact */
327 /* TODO : provide handling for this. We don't really support
328 user-mode SHcompact yet, and for a kernel fault, this would
329 have to come from a module built for SHcompact. */
330 return -EFAULT;
331 } else {
332 /* misaligned */
333 return -EFAULT;
334 }
335}
336
337static int address_is_sign_extended(__u64 a)
338{
339 __u64 b;
340#if (NEFF == 32)
341 b = (__u64)(__s64)(__s32)(a & 0xffffffffUL);
342 return (b == a) ? 1 : 0;
343#else
344#error "Sign extend check only works for NEFF==32"
345#endif
346}
347
348static int generate_and_check_address(struct pt_regs *regs,
349 __u32 opcode,
350 int displacement_not_indexed,
351 int width_shift,
352 __u64 *address)
353{
354 /* return -1 for fault, 0 for OK */
355
356 __u64 base_address, addr;
357 int basereg;
358
359 basereg = (opcode >> 20) & 0x3f;
360 base_address = regs->regs[basereg];
361 if (displacement_not_indexed) {
362 __s64 displacement;
363 displacement = (opcode >> 10) & 0x3ff;
364 displacement = ((displacement << 54) >> 54); /* sign extend */
365 addr = (__u64)((__s64)base_address + (displacement << width_shift));
366 } else {
367 __u64 offset;
368 int offsetreg;
369 offsetreg = (opcode >> 10) & 0x3f;
370 offset = regs->regs[offsetreg];
371 addr = base_address + offset;
372 }
373
374 /* Check sign extended */
375 if (!address_is_sign_extended(addr)) {
376 return -1;
377 }
378
379#if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
380 /* Check accessible. For misaligned access in the kernel, assume the
381 address is always accessible (and if not, just fault when the
382 load/store gets done.) */
383 if (user_mode(regs)) {
384 if (addr >= TASK_SIZE) {
385 return -1;
386 }
387 /* Do access_ok check later - it depends on whether it's a load or a store. */
388 }
389#endif
390
391 *address = addr;
392 return 0;
393}
394
395/* Default value as for sh */
396#if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
397static int user_mode_unaligned_fixup_count = 10;
398static int user_mode_unaligned_fixup_enable = 1;
399#endif
400
401static int kernel_mode_unaligned_fixup_count = 32;
402
403static void misaligned_kernel_word_load(__u64 address, int do_sign_extend, __u64 *result)
404{
405 unsigned short x;
406 unsigned char *p, *q;
407 p = (unsigned char *) (int) address;
408 q = (unsigned char *) &x;
409 q[0] = p[0];
410 q[1] = p[1];
411
412 if (do_sign_extend) {
413 *result = (__u64)(__s64) *(short *) &x;
414 } else {
415 *result = (__u64) x;
416 }
417}
418
419static void misaligned_kernel_word_store(__u64 address, __u64 value)
420{
421 unsigned short x;
422 unsigned char *p, *q;
423 p = (unsigned char *) (int) address;
424 q = (unsigned char *) &x;
425
426 x = (__u16) value;
427 p[0] = q[0];
428 p[1] = q[1];
429}
430
431static int misaligned_load(struct pt_regs *regs,
432 __u32 opcode,
433 int displacement_not_indexed,
434 int width_shift,
435 int do_sign_extend)
436{
437 /* Return -1 for a fault, 0 for OK */
438 int error;
439 int destreg;
440 __u64 address;
441
442 error = generate_and_check_address(regs, opcode,
443 displacement_not_indexed, width_shift, &address);
444 if (error < 0) {
445 return error;
446 }
447
448 destreg = (opcode >> 4) & 0x3f;
449#if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
450 if (user_mode(regs)) {
451 __u64 buffer;
452
453 if (!access_ok(VERIFY_READ, (unsigned long) address, 1UL<<width_shift)) {
454 return -1;
455 }
456
457 if (__copy_user(&buffer, (const void *)(int)address, (1 << width_shift)) > 0) {
458 return -1; /* fault */
459 }
460 switch (width_shift) {
461 case 1:
462 if (do_sign_extend) {
463 regs->regs[destreg] = (__u64)(__s64) *(__s16 *) &buffer;
464 } else {
465 regs->regs[destreg] = (__u64) *(__u16 *) &buffer;
466 }
467 break;
468 case 2:
469 regs->regs[destreg] = (__u64)(__s64) *(__s32 *) &buffer;
470 break;
471 case 3:
472 regs->regs[destreg] = buffer;
473 break;
474 default:
475 printk("Unexpected width_shift %d in misaligned_load, PC=%08lx\n",
476 width_shift, (unsigned long) regs->pc);
477 break;
478 }
479 } else
480#endif
481 {
482 /* kernel mode - we can take short cuts since if we fault, it's a genuine bug */
483 __u64 lo, hi;
484
485 switch (width_shift) {
486 case 1:
487 misaligned_kernel_word_load(address, do_sign_extend, &regs->regs[destreg]);
488 break;
489 case 2:
490 asm ("ldlo.l %1, 0, %0" : "=r" (lo) : "r" (address));
491 asm ("ldhi.l %1, 3, %0" : "=r" (hi) : "r" (address));
492 regs->regs[destreg] = lo | hi;
493 break;
494 case 3:
495 asm ("ldlo.q %1, 0, %0" : "=r" (lo) : "r" (address));
496 asm ("ldhi.q %1, 7, %0" : "=r" (hi) : "r" (address));
497 regs->regs[destreg] = lo | hi;
498 break;
499
500 default:
501 printk("Unexpected width_shift %d in misaligned_load, PC=%08lx\n",
502 width_shift, (unsigned long) regs->pc);
503 break;
504 }
505 }
506
507 return 0;
508
509}
510
511static int misaligned_store(struct pt_regs *regs,
512 __u32 opcode,
513 int displacement_not_indexed,
514 int width_shift)
515{
516 /* Return -1 for a fault, 0 for OK */
517 int error;
518 int srcreg;
519 __u64 address;
520
521 error = generate_and_check_address(regs, opcode,
522 displacement_not_indexed, width_shift, &address);
523 if (error < 0) {
524 return error;
525 }
526
527 srcreg = (opcode >> 4) & 0x3f;
528#if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
529 if (user_mode(regs)) {
530 __u64 buffer;
531
532 if (!access_ok(VERIFY_WRITE, (unsigned long) address, 1UL<<width_shift)) {
533 return -1;
534 }
535
536 switch (width_shift) {
537 case 1:
538 *(__u16 *) &buffer = (__u16) regs->regs[srcreg];
539 break;
540 case 2:
541 *(__u32 *) &buffer = (__u32) regs->regs[srcreg];
542 break;
543 case 3:
544 buffer = regs->regs[srcreg];
545 break;
546 default:
547 printk("Unexpected width_shift %d in misaligned_store, PC=%08lx\n",
548 width_shift, (unsigned long) regs->pc);
549 break;
550 }
551
552 if (__copy_user((void *)(int)address, &buffer, (1 << width_shift)) > 0) {
553 return -1; /* fault */
554 }
555 } else
556#endif
557 {
558 /* kernel mode - we can take short cuts since if we fault, it's a genuine bug */
559 __u64 val = regs->regs[srcreg];
560
561 switch (width_shift) {
562 case 1:
563 misaligned_kernel_word_store(address, val);
564 break;
565 case 2:
566 asm ("stlo.l %1, 0, %0" : : "r" (val), "r" (address));
567 asm ("sthi.l %1, 3, %0" : : "r" (val), "r" (address));
568 break;
569 case 3:
570 asm ("stlo.q %1, 0, %0" : : "r" (val), "r" (address));
571 asm ("sthi.q %1, 7, %0" : : "r" (val), "r" (address));
572 break;
573
574 default:
575 printk("Unexpected width_shift %d in misaligned_store, PC=%08lx\n",
576 width_shift, (unsigned long) regs->pc);
577 break;
578 }
579 }
580
581 return 0;
582
583}
584
585#if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
586/* Never need to fix up misaligned FPU accesses within the kernel since that's a real
587 error. */
588static int misaligned_fpu_load(struct pt_regs *regs,
589 __u32 opcode,
590 int displacement_not_indexed,
591 int width_shift,
592 int do_paired_load)
593{
594 /* Return -1 for a fault, 0 for OK */
595 int error;
596 int destreg;
597 __u64 address;
598
599 error = generate_and_check_address(regs, opcode,
600 displacement_not_indexed, width_shift, &address);
601 if (error < 0) {
602 return error;
603 }
604
605 destreg = (opcode >> 4) & 0x3f;
606 if (user_mode(regs)) {
607 __u64 buffer;
608 __u32 buflo, bufhi;
609
610 if (!access_ok(VERIFY_READ, (unsigned long) address, 1UL<<width_shift)) {
611 return -1;
612 }
613
614 if (__copy_user(&buffer, (const void *)(int)address, (1 << width_shift)) > 0) {
615 return -1; /* fault */
616 }
617 /* 'current' may be the current owner of the FPU state, so
618 context switch the registers into memory so they can be
619 indexed by register number. */
620 if (last_task_used_math == current) {
621 grab_fpu();
622 fpsave(&current->thread.fpu.hard);
623 release_fpu();
624 last_task_used_math = NULL;
625 regs->sr |= SR_FD;
626 }
627
628 buflo = *(__u32*) &buffer;
629 bufhi = *(1 + (__u32*) &buffer);
630
631 switch (width_shift) {
632 case 2:
633 current->thread.fpu.hard.fp_regs[destreg] = buflo;
634 break;
635 case 3:
636 if (do_paired_load) {
637 current->thread.fpu.hard.fp_regs[destreg] = buflo;
638 current->thread.fpu.hard.fp_regs[destreg+1] = bufhi;
639 } else {
640#if defined(CONFIG_LITTLE_ENDIAN)
641 current->thread.fpu.hard.fp_regs[destreg] = bufhi;
642 current->thread.fpu.hard.fp_regs[destreg+1] = buflo;
643#else
644 current->thread.fpu.hard.fp_regs[destreg] = buflo;
645 current->thread.fpu.hard.fp_regs[destreg+1] = bufhi;
646#endif
647 }
648 break;
649 default:
650 printk("Unexpected width_shift %d in misaligned_fpu_load, PC=%08lx\n",
651 width_shift, (unsigned long) regs->pc);
652 break;
653 }
654 return 0;
655 } else {
656 die ("Misaligned FPU load inside kernel", regs, 0);
657 return -1;
658 }
659
660
661}
662
663static int misaligned_fpu_store(struct pt_regs *regs,
664 __u32 opcode,
665 int displacement_not_indexed,
666 int width_shift,
667 int do_paired_load)
668{
669 /* Return -1 for a fault, 0 for OK */
670 int error;
671 int srcreg;
672 __u64 address;
673
674 error = generate_and_check_address(regs, opcode,
675 displacement_not_indexed, width_shift, &address);
676 if (error < 0) {
677 return error;
678 }
679
680 srcreg = (opcode >> 4) & 0x3f;
681 if (user_mode(regs)) {
682 __u64 buffer;
683 /* Initialise these to NaNs. */
684 __u32 buflo=0xffffffffUL, bufhi=0xffffffffUL;
685
686 if (!access_ok(VERIFY_WRITE, (unsigned long) address, 1UL<<width_shift)) {
687 return -1;
688 }
689
690 /* 'current' may be the current owner of the FPU state, so
691 context switch the registers into memory so they can be
692 indexed by register number. */
693 if (last_task_used_math == current) {
694 grab_fpu();
695 fpsave(&current->thread.fpu.hard);
696 release_fpu();
697 last_task_used_math = NULL;
698 regs->sr |= SR_FD;
699 }
700
701 switch (width_shift) {
702 case 2:
703 buflo = current->thread.fpu.hard.fp_regs[srcreg];
704 break;
705 case 3:
706 if (do_paired_load) {
707 buflo = current->thread.fpu.hard.fp_regs[srcreg];
708 bufhi = current->thread.fpu.hard.fp_regs[srcreg+1];
709 } else {
710#if defined(CONFIG_LITTLE_ENDIAN)
711 bufhi = current->thread.fpu.hard.fp_regs[srcreg];
712 buflo = current->thread.fpu.hard.fp_regs[srcreg+1];
713#else
714 buflo = current->thread.fpu.hard.fp_regs[srcreg];
715 bufhi = current->thread.fpu.hard.fp_regs[srcreg+1];
716#endif
717 }
718 break;
719 default:
720 printk("Unexpected width_shift %d in misaligned_fpu_store, PC=%08lx\n",
721 width_shift, (unsigned long) regs->pc);
722 break;
723 }
724
725 *(__u32*) &buffer = buflo;
726 *(1 + (__u32*) &buffer) = bufhi;
727 if (__copy_user((void *)(int)address, &buffer, (1 << width_shift)) > 0) {
728 return -1; /* fault */
729 }
730 return 0;
731 } else {
732 die ("Misaligned FPU load inside kernel", regs, 0);
733 return -1;
734 }
735}
736#endif
737
738static int misaligned_fixup(struct pt_regs *regs)
739{
740 unsigned long opcode;
741 int error;
742 int major, minor;
743
744#if !defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
745 /* Never fixup user mode misaligned accesses without this option enabled. */
746 return -1;
747#else
748 if (!user_mode_unaligned_fixup_enable) return -1;
749#endif
750
751 error = read_opcode(regs->pc, &opcode, user_mode(regs));
752 if (error < 0) {
753 return error;
754 }
755 major = (opcode >> 26) & 0x3f;
756 minor = (opcode >> 16) & 0xf;
757
758#if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
759 if (user_mode(regs) && (user_mode_unaligned_fixup_count > 0)) {
760 --user_mode_unaligned_fixup_count;
761 /* Only do 'count' worth of these reports, to remove a potential DoS against syslog */
762 printk("Fixing up unaligned userspace access in \"%s\" pid=%d pc=0x%08x ins=0x%08lx\n",
763 current->comm, task_pid_nr(current), (__u32)regs->pc, opcode);
764 } else
765#endif
766 if (!user_mode(regs) && (kernel_mode_unaligned_fixup_count > 0)) {
767 --kernel_mode_unaligned_fixup_count;
768 if (in_interrupt()) {
769 printk("Fixing up unaligned kernelspace access in interrupt pc=0x%08x ins=0x%08lx\n",
770 (__u32)regs->pc, opcode);
771 } else {
772 printk("Fixing up unaligned kernelspace access in \"%s\" pid=%d pc=0x%08x ins=0x%08lx\n",
773 current->comm, task_pid_nr(current), (__u32)regs->pc, opcode);
774 }
775 }
776
777
778 switch (major) {
779 case (0x84>>2): /* LD.W */
780 error = misaligned_load(regs, opcode, 1, 1, 1);
781 break;
782 case (0xb0>>2): /* LD.UW */
783 error = misaligned_load(regs, opcode, 1, 1, 0);
784 break;
785 case (0x88>>2): /* LD.L */
786 error = misaligned_load(regs, opcode, 1, 2, 1);
787 break;
788 case (0x8c>>2): /* LD.Q */
789 error = misaligned_load(regs, opcode, 1, 3, 0);
790 break;
791
792 case (0xa4>>2): /* ST.W */
793 error = misaligned_store(regs, opcode, 1, 1);
794 break;
795 case (0xa8>>2): /* ST.L */
796 error = misaligned_store(regs, opcode, 1, 2);
797 break;
798 case (0xac>>2): /* ST.Q */
799 error = misaligned_store(regs, opcode, 1, 3);
800 break;
801
802 case (0x40>>2): /* indexed loads */
803 switch (minor) {
804 case 0x1: /* LDX.W */
805 error = misaligned_load(regs, opcode, 0, 1, 1);
806 break;
807 case 0x5: /* LDX.UW */
808 error = misaligned_load(regs, opcode, 0, 1, 0);
809 break;
810 case 0x2: /* LDX.L */
811 error = misaligned_load(regs, opcode, 0, 2, 1);
812 break;
813 case 0x3: /* LDX.Q */
814 error = misaligned_load(regs, opcode, 0, 3, 0);
815 break;
816 default:
817 error = -1;
818 break;
819 }
820 break;
821
822 case (0x60>>2): /* indexed stores */
823 switch (minor) {
824 case 0x1: /* STX.W */
825 error = misaligned_store(regs, opcode, 0, 1);
826 break;
827 case 0x2: /* STX.L */
828 error = misaligned_store(regs, opcode, 0, 2);
829 break;
830 case 0x3: /* STX.Q */
831 error = misaligned_store(regs, opcode, 0, 3);
832 break;
833 default:
834 error = -1;
835 break;
836 }
837 break;
838
839#if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
840 case (0x94>>2): /* FLD.S */
841 error = misaligned_fpu_load(regs, opcode, 1, 2, 0);
842 break;
843 case (0x98>>2): /* FLD.P */
844 error = misaligned_fpu_load(regs, opcode, 1, 3, 1);
845 break;
846 case (0x9c>>2): /* FLD.D */
847 error = misaligned_fpu_load(regs, opcode, 1, 3, 0);
848 break;
849 case (0x1c>>2): /* floating indexed loads */
850 switch (minor) {
851 case 0x8: /* FLDX.S */
852 error = misaligned_fpu_load(regs, opcode, 0, 2, 0);
853 break;
854 case 0xd: /* FLDX.P */
855 error = misaligned_fpu_load(regs, opcode, 0, 3, 1);
856 break;
857 case 0x9: /* FLDX.D */
858 error = misaligned_fpu_load(regs, opcode, 0, 3, 0);
859 break;
860 default:
861 error = -1;
862 break;
863 }
864 break;
865 case (0xb4>>2): /* FLD.S */
866 error = misaligned_fpu_store(regs, opcode, 1, 2, 0);
867 break;
868 case (0xb8>>2): /* FLD.P */
869 error = misaligned_fpu_store(regs, opcode, 1, 3, 1);
870 break;
871 case (0xbc>>2): /* FLD.D */
872 error = misaligned_fpu_store(regs, opcode, 1, 3, 0);
873 break;
874 case (0x3c>>2): /* floating indexed stores */
875 switch (minor) {
876 case 0x8: /* FSTX.S */
877 error = misaligned_fpu_store(regs, opcode, 0, 2, 0);
878 break;
879 case 0xd: /* FSTX.P */
880 error = misaligned_fpu_store(regs, opcode, 0, 3, 1);
881 break;
882 case 0x9: /* FSTX.D */
883 error = misaligned_fpu_store(regs, opcode, 0, 3, 0);
884 break;
885 default:
886 error = -1;
887 break;
888 }
889 break;
890#endif
891
892 default:
893 /* Fault */
894 error = -1;
895 break;
896 }
897
898 if (error < 0) {
899 return error;
900 } else {
901 regs->pc += 4; /* Skip the instruction that's just been emulated */
902 return 0;
903 }
904
905}
906
907static ctl_table unaligned_table[] = {
908 {
909 .ctl_name = CTL_UNNUMBERED,
910 .procname = "kernel_reports",
911 .data = &kernel_mode_unaligned_fixup_count,
912 .maxlen = sizeof(int),
913 .mode = 0644,
914 .proc_handler = &proc_dointvec
915 },
916#if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
917 {
918 .ctl_name = CTL_UNNUMBERED,
919 .procname = "user_reports",
920 .data = &user_mode_unaligned_fixup_count,
921 .maxlen = sizeof(int),
922 .mode = 0644,
923 .proc_handler = &proc_dointvec
924 },
925 {
926 .ctl_name = CTL_UNNUMBERED,
927 .procname = "user_enable",
928 .data = &user_mode_unaligned_fixup_enable,
929 .maxlen = sizeof(int),
930 .mode = 0644,
931 .proc_handler = &proc_dointvec},
932#endif
933 {}
934};
935
936static ctl_table unaligned_root[] = {
937 {
938 .ctl_name = CTL_UNNUMBERED,
939 .procname = "unaligned_fixup",
940 .mode = 0555,
941 unaligned_table
942 },
943 {}
944};
945
946static ctl_table sh64_root[] = {
947 {
948 .ctl_name = CTL_UNNUMBERED,
949 .procname = "sh64",
950 .mode = 0555,
951 .child = unaligned_root
952 },
953 {}
954};
955static struct ctl_table_header *sysctl_header;
956static int __init init_sysctl(void)
957{
958 sysctl_header = register_sysctl_table(sh64_root);
959 return 0;
960}
961
962__initcall(init_sysctl);
963
964
965asmlinkage void do_debug_interrupt(unsigned long code, struct pt_regs *regs)
966{
967 u64 peek_real_address_q(u64 addr);
968 u64 poke_real_address_q(u64 addr, u64 val);
969 unsigned long long DM_EXP_CAUSE_PHY = 0x0c100010;
970 unsigned long long exp_cause;
971 /* It's not worth ioremapping the debug module registers for the amount
972 of access we make to them - just go direct to their physical
973 addresses. */
974 exp_cause = peek_real_address_q(DM_EXP_CAUSE_PHY);
975 if (exp_cause & ~4) {
976 printk("DM.EXP_CAUSE had unexpected bits set (=%08lx)\n",
977 (unsigned long)(exp_cause & 0xffffffff));
978 }
979 show_state();
980 /* Clear all DEBUGINT causes */
981 poke_real_address_q(DM_EXP_CAUSE_PHY, 0x0);
982}
diff --git a/arch/sh64/kernel/unwind.c b/arch/sh64/kernel/unwind.c
deleted file mode 100644
index 1214c78e3584..000000000000
--- a/arch/sh64/kernel/unwind.c
+++ /dev/null
@@ -1,326 +0,0 @@
1/*
2 * arch/sh64/kernel/unwind.c
3 *
4 * Copyright (C) 2004 Paul Mundt
5 * Copyright (C) 2004 Richard Curnow
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#include <linux/kallsyms.h>
12#include <linux/kernel.h>
13#include <linux/types.h>
14#include <linux/errno.h>
15#include <asm/page.h>
16#include <asm/ptrace.h>
17#include <asm/processor.h>
18#include <asm/io.h>
19
20static u8 regcache[63];
21
22/*
23 * Finding the previous stack frame isn't horribly straightforward as it is
24 * on some other platforms. In the sh64 case, we don't have "linked" stack
25 * frames, so we need to do a bit of work to determine the previous frame,
26 * and in turn, the previous r14/r18 pair.
27 *
28 * There are generally a few cases which determine where we can find out
29 * the r14/r18 values. In the general case, this can be determined by poking
30 * around the prologue of the symbol PC is in (note that we absolutely must
31 * have frame pointer support as well as the kernel symbol table mapped,
32 * otherwise we can't even get this far).
33 *
34 * In other cases, such as the interrupt/exception path, we can poke around
35 * the sp/fp.
36 *
37 * Notably, this entire approach is somewhat error prone, and in the event
38 * that the previous frame cannot be determined, that's all we can do.
39 * Either way, this still leaves us with a more correct backtrace then what
40 * we would be able to come up with by walking the stack (which is garbage
41 * for anything beyond the first frame).
42 * -- PFM.
43 */
44static int lookup_prev_stack_frame(unsigned long fp, unsigned long pc,
45 unsigned long *pprev_fp, unsigned long *pprev_pc,
46 struct pt_regs *regs)
47{
48 const char *sym;
49 char namebuf[128];
50 unsigned long offset;
51 unsigned long prologue = 0;
52 unsigned long fp_displacement = 0;
53 unsigned long fp_prev = 0;
54 unsigned long offset_r14 = 0, offset_r18 = 0;
55 int i, found_prologue_end = 0;
56
57 sym = kallsyms_lookup(pc, NULL, &offset, NULL, namebuf);
58 if (!sym)
59 return -EINVAL;
60
61 prologue = pc - offset;
62 if (!prologue)
63 return -EINVAL;
64
65 /* Validate fp, to avoid risk of dereferencing a bad pointer later.
66 Assume 128Mb since that's the amount of RAM on a Cayman. Modify
67 when there is an SH-5 board with more. */
68 if ((fp < (unsigned long) phys_to_virt(__MEMORY_START)) ||
69 (fp >= (unsigned long)(phys_to_virt(__MEMORY_START)) + 128*1024*1024) ||
70 ((fp & 7) != 0)) {
71 return -EINVAL;
72 }
73
74 /*
75 * Depth to walk, depth is completely arbitrary.
76 */
77 for (i = 0; i < 100; i++, prologue += sizeof(unsigned long)) {
78 unsigned long op;
79 u8 major, minor;
80 u8 src, dest, disp;
81
82 op = *(unsigned long *)prologue;
83
84 major = (op >> 26) & 0x3f;
85 src = (op >> 20) & 0x3f;
86 minor = (op >> 16) & 0xf;
87 disp = (op >> 10) & 0x3f;
88 dest = (op >> 4) & 0x3f;
89
90 /*
91 * Stack frame creation happens in a number of ways.. in the
92 * general case when the stack frame is less than 511 bytes,
93 * it's generally created by an addi or addi.l:
94 *
95 * addi/addi.l r15, -FRAME_SIZE, r15
96 *
97 * in the event that the frame size is bigger than this, it's
98 * typically created using a movi/sub pair as follows:
99 *
100 * movi FRAME_SIZE, rX
101 * sub r15, rX, r15
102 */
103
104 switch (major) {
105 case (0x00 >> 2):
106 switch (minor) {
107 case 0x8: /* add.l */
108 case 0x9: /* add */
109 /* Look for r15, r63, r14 */
110 if (src == 15 && disp == 63 && dest == 14)
111 found_prologue_end = 1;
112
113 break;
114 case 0xa: /* sub.l */
115 case 0xb: /* sub */
116 if (src != 15 || dest != 15)
117 continue;
118
119 fp_displacement -= regcache[disp];
120 fp_prev = fp - fp_displacement;
121 break;
122 }
123 break;
124 case (0xa8 >> 2): /* st.l */
125 if (src != 15)
126 continue;
127
128 switch (dest) {
129 case 14:
130 if (offset_r14 || fp_displacement == 0)
131 continue;
132
133 offset_r14 = (u64)(((((s64)op >> 10) & 0x3ff) << 54) >> 54);
134 offset_r14 *= sizeof(unsigned long);
135 offset_r14 += fp_displacement;
136 break;
137 case 18:
138 if (offset_r18 || fp_displacement == 0)
139 continue;
140
141 offset_r18 = (u64)(((((s64)op >> 10) & 0x3ff) << 54) >> 54);
142 offset_r18 *= sizeof(unsigned long);
143 offset_r18 += fp_displacement;
144 break;
145 }
146
147 break;
148 case (0xcc >> 2): /* movi */
149 if (dest >= 63) {
150 printk(KERN_NOTICE "%s: Invalid dest reg %d "
151 "specified in movi handler. Failed "
152 "opcode was 0x%lx: ", __FUNCTION__,
153 dest, op);
154
155 continue;
156 }
157
158 /* Sign extend */
159 regcache[dest] =
160 ((((s64)(u64)op >> 10) & 0xffff) << 54) >> 54;
161 break;
162 case (0xd0 >> 2): /* addi */
163 case (0xd4 >> 2): /* addi.l */
164 /* Look for r15, -FRAME_SIZE, r15 */
165 if (src != 15 || dest != 15)
166 continue;
167
168 /* Sign extended frame size.. */
169 fp_displacement +=
170 (u64)(((((s64)op >> 10) & 0x3ff) << 54) >> 54);
171 fp_prev = fp - fp_displacement;
172 break;
173 }
174
175 if (found_prologue_end && offset_r14 && (offset_r18 || *pprev_pc) && fp_prev)
176 break;
177 }
178
179 if (offset_r14 == 0 || fp_prev == 0) {
180 if (!offset_r14)
181 pr_debug("Unable to find r14 offset\n");
182 if (!fp_prev)
183 pr_debug("Unable to find previous fp\n");
184
185 return -EINVAL;
186 }
187
188 /* For innermost leaf function, there might not be a offset_r18 */
189 if (!*pprev_pc && (offset_r18 == 0))
190 return -EINVAL;
191
192 *pprev_fp = *(unsigned long *)(fp_prev + offset_r14);
193
194 if (offset_r18)
195 *pprev_pc = *(unsigned long *)(fp_prev + offset_r18);
196
197 *pprev_pc &= ~1;
198
199 return 0;
200}
201
202/* Don't put this on the stack since we'll want to call sh64_unwind
203 * when we're close to underflowing the stack anyway. */
204static struct pt_regs here_regs;
205
206extern const char syscall_ret;
207extern const char ret_from_syscall;
208extern const char ret_from_exception;
209extern const char ret_from_irq;
210
211static void sh64_unwind_inner(struct pt_regs *regs);
212
213static void unwind_nested (unsigned long pc, unsigned long fp)
214{
215 if ((fp >= __MEMORY_START) &&
216 ((fp & 7) == 0)) {
217 sh64_unwind_inner((struct pt_regs *) fp);
218 }
219}
220
221static void sh64_unwind_inner(struct pt_regs *regs)
222{
223 unsigned long pc, fp;
224 int ofs = 0;
225 int first_pass;
226
227 pc = regs->pc & ~1;
228 fp = regs->regs[14];
229
230 first_pass = 1;
231 for (;;) {
232 int cond;
233 unsigned long next_fp, next_pc;
234
235 if (pc == ((unsigned long) &syscall_ret & ~1)) {
236 printk("SYSCALL\n");
237 unwind_nested(pc,fp);
238 return;
239 }
240
241 if (pc == ((unsigned long) &ret_from_syscall & ~1)) {
242 printk("SYSCALL (PREEMPTED)\n");
243 unwind_nested(pc,fp);
244 return;
245 }
246
247 /* In this case, the PC is discovered by lookup_prev_stack_frame but
248 it has 4 taken off it to look like the 'caller' */
249 if (pc == ((unsigned long) &ret_from_exception & ~1)) {
250 printk("EXCEPTION\n");
251 unwind_nested(pc,fp);
252 return;
253 }
254
255 if (pc == ((unsigned long) &ret_from_irq & ~1)) {
256 printk("IRQ\n");
257 unwind_nested(pc,fp);
258 return;
259 }
260
261 cond = ((pc >= __MEMORY_START) && (fp >= __MEMORY_START) &&
262 ((pc & 3) == 0) && ((fp & 7) == 0));
263
264 pc -= ofs;
265
266 printk("[<%08lx>] ", pc);
267 print_symbol("%s\n", pc);
268
269 if (first_pass) {
270 /* If the innermost frame is a leaf function, it's
271 * possible that r18 is never saved out to the stack.
272 */
273 next_pc = regs->regs[18];
274 } else {
275 next_pc = 0;
276 }
277
278 if (lookup_prev_stack_frame(fp, pc, &next_fp, &next_pc, regs) == 0) {
279 ofs = sizeof(unsigned long);
280 pc = next_pc & ~1;
281 fp = next_fp;
282 } else {
283 printk("Unable to lookup previous stack frame\n");
284 break;
285 }
286 first_pass = 0;
287 }
288
289 printk("\n");
290
291}
292
293void sh64_unwind(struct pt_regs *regs)
294{
295 if (!regs) {
296 /*
297 * Fetch current regs if we have no other saved state to back
298 * trace from.
299 */
300 regs = &here_regs;
301
302 __asm__ __volatile__ ("ori r14, 0, %0" : "=r" (regs->regs[14]));
303 __asm__ __volatile__ ("ori r15, 0, %0" : "=r" (regs->regs[15]));
304 __asm__ __volatile__ ("ori r18, 0, %0" : "=r" (regs->regs[18]));
305
306 __asm__ __volatile__ ("gettr tr0, %0" : "=r" (regs->tregs[0]));
307 __asm__ __volatile__ ("gettr tr1, %0" : "=r" (regs->tregs[1]));
308 __asm__ __volatile__ ("gettr tr2, %0" : "=r" (regs->tregs[2]));
309 __asm__ __volatile__ ("gettr tr3, %0" : "=r" (regs->tregs[3]));
310 __asm__ __volatile__ ("gettr tr4, %0" : "=r" (regs->tregs[4]));
311 __asm__ __volatile__ ("gettr tr5, %0" : "=r" (regs->tregs[5]));
312 __asm__ __volatile__ ("gettr tr6, %0" : "=r" (regs->tregs[6]));
313 __asm__ __volatile__ ("gettr tr7, %0" : "=r" (regs->tregs[7]));
314
315 __asm__ __volatile__ (
316 "pta 0f, tr0\n\t"
317 "blink tr0, %0\n\t"
318 "0: nop"
319 : "=r" (regs->pc)
320 );
321 }
322
323 printk("\nCall Trace:\n");
324 sh64_unwind_inner(regs);
325}
326
diff --git a/arch/sh64/kernel/vmlinux.lds.S b/arch/sh64/kernel/vmlinux.lds.S
deleted file mode 100644
index f533a064da5f..000000000000
--- a/arch/sh64/kernel/vmlinux.lds.S
+++ /dev/null
@@ -1,140 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh5/vmlinux.lds.S
7 *
8 * ld script to make ST50 Linux kernel
9 *
10 * Copyright (C) 2000, 2001 Paolo Alberelli
11 *
12 * benedict.gaster@superh.com: 2nd May 2002
13 * Add definition of empty_zero_page to be the first page of kernel image.
14 *
15 * benedict.gaster@superh.com: 3rd May 2002
16 * Added support for ramdisk, removing statically linked romfs at the same time.
17 *
18 * lethal@linux-sh.org: 9th May 2003
19 * Kill off GLOBAL_NAME() usage and other CDC-isms.
20 *
21 * lethal@linux-sh.org: 19th May 2003
22 * Remove support for ancient toolchains.
23 */
24
25#include <asm/page.h>
26#include <asm/cache.h>
27#include <asm/processor.h>
28#include <asm/thread_info.h>
29
30#define LOAD_OFFSET CONFIG_CACHED_MEMORY_OFFSET
31#include <asm-generic/vmlinux.lds.h>
32
33OUTPUT_ARCH(sh:sh5)
34
35#define C_PHYS(x) AT (ADDR(x) - LOAD_OFFSET)
36
37ENTRY(__start)
38SECTIONS
39{
40 . = CONFIG_CACHED_MEMORY_OFFSET + CONFIG_MEMORY_START + PAGE_SIZE;
41 _text = .; /* Text and read-only data */
42 text = .; /* Text and read-only data */
43
44 .empty_zero_page : C_PHYS(.empty_zero_page) {
45 *(.empty_zero_page)
46 } = 0
47
48 .text : C_PHYS(.text) {
49 *(.text.head)
50 TEXT_TEXT
51 *(.text64)
52 *(.text..SHmedia32)
53 SCHED_TEXT
54 LOCK_TEXT
55 *(.fixup)
56 *(.gnu.warning)
57#ifdef CONFIG_LITTLE_ENDIAN
58 } = 0x6ff0fff0
59#else
60 } = 0xf0fff06f
61#endif
62
63 /* We likely want __ex_table to be Cache Line aligned */
64 . = ALIGN(L1_CACHE_BYTES); /* Exception table */
65 __start___ex_table = .;
66 __ex_table : C_PHYS(__ex_table) { *(__ex_table) }
67 __stop___ex_table = .;
68
69 _etext = .; /* End of text section */
70
71 NOTES
72
73 RODATA
74
75 .data : C_PHYS(.data) { /* Data */
76 DATA_DATA
77 CONSTRUCTORS
78 }
79
80 . = ALIGN(PAGE_SIZE);
81 .data.page_aligned : C_PHYS(.data.page_aligned) { *(.data.page_aligned) }
82
83 PERCPU(PAGE_SIZE)
84
85 . = ALIGN(L1_CACHE_BYTES);
86 .data.cacheline_aligned : C_PHYS(.data.cacheline_aligned) { *(.data.cacheline_aligned) }
87
88 _edata = .; /* End of data section */
89
90 . = ALIGN(THREAD_SIZE); /* init_task: structure size aligned */
91 .data.init_task : C_PHYS(.data.init_task) { *(.data.init_task) }
92
93 . = ALIGN(PAGE_SIZE); /* Init code and data */
94 __init_begin = .;
95 _sinittext = .;
96 .init.text : C_PHYS(.init.text) { *(.init.text) }
97 _einittext = .;
98 .init.data : C_PHYS(.init.data) { *(.init.data) }
99 . = ALIGN(L1_CACHE_BYTES); /* Better if Cache Line aligned */
100 __setup_start = .;
101 .init.setup : C_PHYS(.init.setup) { *(.init.setup) }
102 __setup_end = .;
103 __initcall_start = .;
104 .initcall.init : C_PHYS(.initcall.init) {
105 INITCALLS
106 }
107 __initcall_end = .;
108 __con_initcall_start = .;
109 .con_initcall.init : C_PHYS(.con_initcall.init) { *(.con_initcall.init) }
110 __con_initcall_end = .;
111 SECURITY_INIT
112
113#ifdef CONFIG_BLK_DEV_INITRD
114 __initramfs_start = .;
115 .init.ramfs : C_PHYS(.init.ramfs) { *(.init.ramfs) }
116 __initramfs_end = .;
117#endif
118
119 . = ALIGN(PAGE_SIZE);
120 __init_end = .;
121
122 /* Align to the biggest single data representation, head and tail */
123 . = ALIGN(8);
124 __bss_start = .; /* BSS */
125 .bss : C_PHYS(.bss) {
126 *(.bss)
127 }
128 . = ALIGN(8);
129 _end = . ;
130
131 /* Sections to be discarded */
132 /DISCARD/ : {
133 *(.exit.text)
134 *(.exit.data)
135 *(.exitcall.exit)
136 }
137
138 STABS_DEBUG
139 DWARF_DEBUG
140}
diff --git a/arch/sh64/lib/.gitignore b/arch/sh64/lib/.gitignore
deleted file mode 100644
index 3508c2cb23c4..000000000000
--- a/arch/sh64/lib/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
1syscalltab.h
diff --git a/arch/sh64/lib/Makefile b/arch/sh64/lib/Makefile
deleted file mode 100644
index 6a4cc3f9c0b1..000000000000
--- a/arch/sh64/lib/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
1#
2# This file is subject to the terms and conditions of the GNU General Public
3# License. See the file "COPYING" in the main directory of this archive
4# for more details.
5#
6# Copyright (C) 2000, 2001 Paolo Alberelli
7# Coprygith (C) 2003 Paul Mundt
8#
9# Makefile for the SH-5 specific library files..
10#
11# Note! Dependencies are done automagically by 'make dep', which also
12# removes any old dependencies. DON'T put your own dependencies here
13# unless it's something special (ie not a .c file).
14#
15
16# Panic should really be compiled as PIC
17lib-y := udelay.o c-checksum.o dbg.o io.o panic.o memcpy.o copy_user_memcpy.o \
18 page_copy.o page_clear.o iomap.o
19
diff --git a/arch/sh64/lib/c-checksum.c b/arch/sh64/lib/c-checksum.c
deleted file mode 100644
index 053137abd8a0..000000000000
--- a/arch/sh64/lib/c-checksum.c
+++ /dev/null
@@ -1,217 +0,0 @@
1/*
2 * arch/sh64/lib/c-checksum.c
3 *
4 * This file contains network checksum routines that are better done
5 * in an architecture-specific manner due to speed..
6 */
7
8#undef DEBUG
9
10#include <linux/string.h>
11#include <linux/errno.h>
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <asm/byteorder.h>
15#include <asm/uaccess.h>
16
17static inline unsigned short from64to16(unsigned long long x)
18{
19 /* add up 32-bit words for 33 bits */
20 x = (x & 0xffffffff) + (x >> 32);
21 /* add up 16-bit and 17-bit words for 17+c bits */
22 x = (x & 0xffff) + (x >> 16);
23 /* add up 16-bit and 2-bit for 16+c bit */
24 x = (x & 0xffff) + (x >> 16);
25 /* add up carry.. */
26 x = (x & 0xffff) + (x >> 16);
27 return x;
28}
29
30static inline unsigned short foldto16(unsigned long x)
31{
32 /* add up 16-bit for 17 bits */
33 x = (x & 0xffff) + (x >> 16);
34 /* add up carry.. */
35 x = (x & 0xffff) + (x >> 16);
36 return x;
37}
38
39static inline unsigned short myfoldto16(unsigned long long x)
40{
41 /* Fold down to 32-bits so we don't loose in the typedef-less
42 network stack. */
43 /* 64 to 33 */
44 x = (x & 0xffffffff) + (x >> 32);
45 /* 33 to 32 */
46 x = (x & 0xffffffff) + (x >> 32);
47
48 /* add up 16-bit for 17 bits */
49 x = (x & 0xffff) + (x >> 16);
50 /* add up carry.. */
51 x = (x & 0xffff) + (x >> 16);
52 return x;
53}
54
55#define odd(x) ((x)&1)
56#define U16(x) ntohs(x)
57
58static unsigned long do_csum(const unsigned char *buff, int len)
59{
60 int odd, count;
61 unsigned long result = 0;
62
63 pr_debug("do_csum buff %p, len %d (0x%x)\n", buff, len, len);
64#ifdef DEBUG
65 for (i = 0; i < len; i++) {
66 if ((i % 26) == 0)
67 printk("\n");
68 printk("%02X ", buff[i]);
69 }
70#endif
71
72 if (len <= 0)
73 goto out;
74
75 odd = 1 & (unsigned long) buff;
76 if (odd) {
77 result = *buff << 8;
78 len--;
79 buff++;
80 }
81 count = len >> 1; /* nr of 16-bit words.. */
82 if (count) {
83 if (2 & (unsigned long) buff) {
84 result += *(unsigned short *) buff;
85 count--;
86 len -= 2;
87 buff += 2;
88 }
89 count >>= 1; /* nr of 32-bit words.. */
90 if (count) {
91 unsigned long carry = 0;
92 do {
93 unsigned long w = *(unsigned long *) buff;
94 buff += 4;
95 count--;
96 result += carry;
97 result += w;
98 carry = (w > result);
99 } while (count);
100 result += carry;
101 result = (result & 0xffff) + (result >> 16);
102 }
103 if (len & 2) {
104 result += *(unsigned short *) buff;
105 buff += 2;
106 }
107 }
108 if (len & 1)
109 result += *buff;
110 result = foldto16(result);
111 if (odd)
112 result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
113
114 pr_debug("\nCHECKSUM is 0x%lx\n", result);
115
116 out:
117 return result;
118}
119
120/* computes the checksum of a memory block at buff, length len,
121 and adds in "sum" (32-bit) */
122__wsum csum_partial(const void *buff, int len, __wsum sum)
123{
124 unsigned long long result = do_csum(buff, len);
125
126 /* add in old sum, and carry.. */
127 result += (__force u32)sum;
128 /* 32+c bits -> 32 bits */
129 result = (result & 0xffffffff) + (result >> 32);
130
131 pr_debug("csum_partial, buff %p len %d sum 0x%x result=0x%016Lx\n",
132 buff, len, sum, result);
133
134 return (__force __wsum)result;
135}
136
137/* Copy while checksumming, otherwise like csum_partial. */
138__wsum
139csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
140{
141 sum = csum_partial(src, len, sum);
142 memcpy(dst, src, len);
143
144 return sum;
145}
146
147/* Copy from userspace and compute checksum. If we catch an exception
148 then zero the rest of the buffer. */
149__wsum
150csum_partial_copy_from_user(const void __user *src, void *dst, int len,
151 __wsum sum, int *err_ptr)
152{
153 int missing;
154
155 pr_debug
156 ("csum_partial_copy_from_user src %p, dest %p, len %d, sum %08x, err_ptr %p\n",
157 src, dst, len, sum, err_ptr);
158 missing = copy_from_user(dst, src, len);
159 pr_debug(" access_ok %d\n", __access_ok((unsigned long) src, len));
160 pr_debug(" missing %d\n", missing);
161 if (missing) {
162 memset(dst + len - missing, 0, missing);
163 *err_ptr = -EFAULT;
164 }
165
166 return csum_partial(dst, len, sum);
167}
168
169/* Copy to userspace and compute checksum. */
170__wsum
171csum_partial_copy_to_user(const unsigned char *src, unsigned char *dst, int len,
172 __wsum sum, int *err_ptr)
173{
174 sum = csum_partial(src, len, sum);
175
176 if (copy_to_user(dst, src, len))
177 *err_ptr = -EFAULT;
178
179 return sum;
180}
181
182/*
183 * This is a version of ip_compute_csum() optimized for IP headers,
184 * which always checksum on 4 octet boundaries.
185 */
186__sum16 ip_fast_csum(const void *iph, unsigned int ihl)
187{
188 pr_debug("ip_fast_csum %p,%d\n", iph, ihl);
189
190 return (__force __sum16)~do_csum(iph, ihl * 4);
191}
192
193__wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
194 unsigned short len,
195 unsigned short proto, __wsum sum)
196{
197 unsigned long long result;
198
199 pr_debug("ntohs(0x%x)=0x%x\n", 0xdead, ntohs(0xdead));
200 pr_debug("htons(0x%x)=0x%x\n", 0xdead, htons(0xdead));
201
202 result = (__force u64) saddr + (__force u64) daddr +
203 (__force u64) sum + ((len + proto) << 8);
204
205 /* Fold down to 32-bits so we don't loose in the typedef-less
206 network stack. */
207 /* 64 to 33 */
208 result = (result & 0xffffffff) + (result >> 32);
209 /* 33 to 32 */
210 result = (result & 0xffffffff) + (result >> 32);
211
212 pr_debug("%s saddr %x daddr %x len %x proto %x sum %x result %08Lx\n",
213 __FUNCTION__, saddr, daddr, len, proto, sum, result);
214
215 return (__wsum)result;
216}
217EXPORT_SYMBOL(csum_tcpudp_nofold);
diff --git a/arch/sh64/lib/copy_user_memcpy.S b/arch/sh64/lib/copy_user_memcpy.S
deleted file mode 100644
index 2a62816d2ddd..000000000000
--- a/arch/sh64/lib/copy_user_memcpy.S
+++ /dev/null
@@ -1,217 +0,0 @@
1!
2! Fast SH memcpy
3!
4! by Toshiyasu Morita (tm@netcom.com)
5! hacked by J"orn Rernnecke (joern.rennecke@superh.com) ("o for o-umlaut)
6! SH5 code Copyright 2002 SuperH Ltd.
7!
8! Entry: ARG0: destination pointer
9! ARG1: source pointer
10! ARG2: byte count
11!
12! Exit: RESULT: destination pointer
13! any other registers in the range r0-r7: trashed
14!
15! Notes: Usually one wants to do small reads and write a longword, but
16! unfortunately it is difficult in some cases to concatanate bytes
17! into a longword on the SH, so this does a longword read and small
18! writes.
19!
20! This implementation makes two assumptions about how it is called:
21!
22! 1.: If the byte count is nonzero, the address of the last byte to be
23! copied is unsigned greater than the address of the first byte to
24! be copied. This could be easily swapped for a signed comparison,
25! but the algorithm used needs some comparison.
26!
27! 2.: When there are two or three bytes in the last word of an 11-or-more
28! bytes memory chunk to b copied, the rest of the word can be read
29! without side effects.
30! This could be easily changed by increasing the minumum size of
31! a fast memcpy and the amount subtracted from r7 before L_2l_loop be 2,
32! however, this would cost a few extra cyles on average.
33! For SHmedia, the assumption is that any quadword can be read in its
34! enirety if at least one byte is included in the copy.
35
36/* Imported into Linux kernel by Richard Curnow. This is used to implement the
37 __copy_user function in the general case, so it has to be a distinct
38 function from intra-kernel memcpy to allow for exception fix-ups in the
39 event that the user pointer is bad somewhere in the copy (e.g. due to
40 running off the end of the vma).
41
42 Note, this algorithm will be slightly wasteful in the case where the source
43 and destination pointers are equally aligned, because the stlo/sthi pairs
44 could then be merged back into single stores. If there are a lot of cache
45 misses, this is probably offset by the stall lengths on the preloads.
46
47*/
48
49/* NOTE : Prefetches removed and allocos guarded by synco to avoid TAKum03020
50 * erratum. The first two prefetches are nop-ed out to avoid upsetting the
51 * instruction counts used in the jump address calculation.
52 * */
53
54 .section .text..SHmedia32,"ax"
55 .little
56 .balign 32
57 .global copy_user_memcpy
58 .global copy_user_memcpy_end
59copy_user_memcpy:
60
61#define LDUAQ(P,O,D0,D1) ldlo.q P,O,D0; ldhi.q P,O+7,D1
62#define STUAQ(P,O,D0,D1) stlo.q P,O,D0; sthi.q P,O+7,D1
63#define LDUAL(P,O,D0,D1) ldlo.l P,O,D0; ldhi.l P,O+3,D1
64#define STUAL(P,O,D0,D1) stlo.l P,O,D0; sthi.l P,O+3,D1
65
66 nop ! ld.b r3,0,r63 ! TAKum03020
67 pta/l Large,tr0
68 movi 25,r0
69 bgeu/u r4,r0,tr0
70 nsb r4,r0
71 shlli r0,5,r0
72 movi (L1-L0+63*32 + 1) & 0xffff,r1
73 sub r1, r0, r0
74L0: ptrel r0,tr0
75 add r2,r4,r5
76 ptabs r18,tr1
77 add r3,r4,r6
78 blink tr0,r63
79
80/* Rearranged to make cut2 safe */
81 .balign 8
82L4_7: /* 4..7 byte memcpy cntd. */
83 stlo.l r2, 0, r0
84 or r6, r7, r6
85 sthi.l r5, -1, r6
86 stlo.l r5, -4, r6
87 blink tr1,r63
88
89 .balign 8
90L1: /* 0 byte memcpy */
91 nop
92 blink tr1,r63
93 nop
94 nop
95 nop
96 nop
97
98L2_3: /* 2 or 3 byte memcpy cntd. */
99 st.b r5,-1,r6
100 blink tr1,r63
101
102 /* 1 byte memcpy */
103 ld.b r3,0,r0
104 st.b r2,0,r0
105 blink tr1,r63
106
107L8_15: /* 8..15 byte memcpy cntd. */
108 stlo.q r2, 0, r0
109 or r6, r7, r6
110 sthi.q r5, -1, r6
111 stlo.q r5, -8, r6
112 blink tr1,r63
113
114 /* 2 or 3 byte memcpy */
115 ld.b r3,0,r0
116 nop ! ld.b r2,0,r63 ! TAKum03020
117 ld.b r3,1,r1
118 st.b r2,0,r0
119 pta/l L2_3,tr0
120 ld.b r6,-1,r6
121 st.b r2,1,r1
122 blink tr0, r63
123
124 /* 4 .. 7 byte memcpy */
125 LDUAL (r3, 0, r0, r1)
126 pta L4_7, tr0
127 ldlo.l r6, -4, r7
128 or r0, r1, r0
129 sthi.l r2, 3, r0
130 ldhi.l r6, -1, r6
131 blink tr0, r63
132
133 /* 8 .. 15 byte memcpy */
134 LDUAQ (r3, 0, r0, r1)
135 pta L8_15, tr0
136 ldlo.q r6, -8, r7
137 or r0, r1, r0
138 sthi.q r2, 7, r0
139 ldhi.q r6, -1, r6
140 blink tr0, r63
141
142 /* 16 .. 24 byte memcpy */
143 LDUAQ (r3, 0, r0, r1)
144 LDUAQ (r3, 8, r8, r9)
145 or r0, r1, r0
146 sthi.q r2, 7, r0
147 or r8, r9, r8
148 sthi.q r2, 15, r8
149 ldlo.q r6, -8, r7
150 ldhi.q r6, -1, r6
151 stlo.q r2, 8, r8
152 stlo.q r2, 0, r0
153 or r6, r7, r6
154 sthi.q r5, -1, r6
155 stlo.q r5, -8, r6
156 blink tr1,r63
157
158Large:
159 ! ld.b r2, 0, r63 ! TAKum03020
160 pta/l Loop_ua, tr1
161 ori r3, -8, r7
162 sub r2, r7, r22
163 sub r3, r2, r6
164 add r2, r4, r5
165 ldlo.q r3, 0, r0
166 addi r5, -16, r5
167 movi 64+8, r27 ! could subtract r7 from that.
168 stlo.q r2, 0, r0
169 sthi.q r2, 7, r0
170 ldx.q r22, r6, r0
171 bgtu/l r27, r4, tr1
172
173 addi r5, -48, r27
174 pta/l Loop_line, tr0
175 addi r6, 64, r36
176 addi r6, -24, r19
177 addi r6, -16, r20
178 addi r6, -8, r21
179
180Loop_line:
181 ! ldx.q r22, r36, r63 ! TAKum03020
182 alloco r22, 32
183 synco
184 addi r22, 32, r22
185 ldx.q r22, r19, r23
186 sthi.q r22, -25, r0
187 ldx.q r22, r20, r24
188 ldx.q r22, r21, r25
189 stlo.q r22, -32, r0
190 ldx.q r22, r6, r0
191 sthi.q r22, -17, r23
192 sthi.q r22, -9, r24
193 sthi.q r22, -1, r25
194 stlo.q r22, -24, r23
195 stlo.q r22, -16, r24
196 stlo.q r22, -8, r25
197 bgeu r27, r22, tr0
198
199Loop_ua:
200 addi r22, 8, r22
201 sthi.q r22, -1, r0
202 stlo.q r22, -8, r0
203 ldx.q r22, r6, r0
204 bgtu/l r5, r22, tr1
205
206 add r3, r4, r7
207 ldlo.q r7, -8, r1
208 sthi.q r22, 7, r0
209 ldhi.q r7, -1, r7
210 ptabs r18,tr1
211 stlo.q r22, 0, r0
212 or r1, r7, r1
213 sthi.q r5, 15, r1
214 stlo.q r5, 8, r1
215 blink tr1, r63
216copy_user_memcpy_end:
217 nop
diff --git a/arch/sh64/lib/dbg.c b/arch/sh64/lib/dbg.c
deleted file mode 100644
index 97816e0baf19..000000000000
--- a/arch/sh64/lib/dbg.c
+++ /dev/null
@@ -1,430 +0,0 @@
1/*--------------------------------------------------------------------------
2--
3-- Identity : Linux50 Debug Funcions
4--
5-- File : arch/sh64/lib/dbg.C
6--
7-- Copyright 2000, 2001 STMicroelectronics Limited.
8-- Copyright 2004 Richard Curnow (evt_debug etc)
9--
10--------------------------------------------------------------------------*/
11#include <linux/types.h>
12#include <linux/kernel.h>
13#include <linux/sched.h>
14#include <linux/mm.h>
15#include <linux/fs.h>
16#include <asm/mmu_context.h>
17
18typedef u64 regType_t;
19
20static regType_t getConfigReg(u64 id)
21{
22 register u64 reg __asm__("r2");
23 asm volatile ("getcfg %1, 0, %0":"=r" (reg):"r"(id));
24 return (reg);
25}
26
27/* ======================================================================= */
28
29static char *szTab[] = { "4k", "64k", "1M", "512M" };
30static char *protTab[] = { "----",
31 "---R",
32 "--X-",
33 "--XR",
34 "-W--",
35 "-W-R",
36 "-WX-",
37 "-WXR",
38 "U---",
39 "U--R",
40 "U-X-",
41 "U-XR",
42 "UW--",
43 "UW-R",
44 "UWX-",
45 "UWXR"
46};
47#define ITLB_BASE 0x00000000
48#define DTLB_BASE 0x00800000
49#define MAX_TLBs 64
50/* PTE High */
51#define GET_VALID(pte) ((pte) & 0x1)
52#define GET_SHARED(pte) ((pte) & 0x2)
53#define GET_ASID(pte) ((pte >> 2) & 0x0ff)
54#define GET_EPN(pte) ((pte) & 0xfffff000)
55
56/* PTE Low */
57#define GET_CBEHAVIOR(pte) ((pte) & 0x3)
58#define GET_PAGE_SIZE(pte) szTab[((pte >> 3) & 0x3)]
59#define GET_PROTECTION(pte) protTab[((pte >> 6) & 0xf)]
60#define GET_PPN(pte) ((pte) & 0xfffff000)
61
62#define PAGE_1K_MASK 0x00000000
63#define PAGE_4K_MASK 0x00000010
64#define PAGE_64K_MASK 0x00000080
65#define MMU_PAGESIZE_MASK (PAGE_64K_MASK | PAGE_4K_MASK)
66#define PAGE_1MB_MASK MMU_PAGESIZE_MASK
67#define PAGE_1K (1024)
68#define PAGE_4K (1024 * 4)
69#define PAGE_64K (1024 * 64)
70#define PAGE_1MB (1024 * 1024)
71
72#define HOW_TO_READ_TLB_CONTENT \
73 "[ ID] PPN EPN ASID Share CB P.Size PROT.\n"
74
75void print_single_tlb(unsigned long tlb, int single_print)
76{
77 regType_t pteH;
78 regType_t pteL;
79 unsigned int valid, shared, asid, epn, cb, ppn;
80 char *pSize;
81 char *pProt;
82
83 /*
84 ** in case of single print <single_print> is true, this implies:
85 ** 1) print the TLB in any case also if NOT VALID
86 ** 2) print out the header
87 */
88
89 pteH = getConfigReg(tlb);
90 valid = GET_VALID(pteH);
91 if (single_print)
92 printk(HOW_TO_READ_TLB_CONTENT);
93 else if (!valid)
94 return;
95
96 pteL = getConfigReg(tlb + 1);
97
98 shared = GET_SHARED(pteH);
99 asid = GET_ASID(pteH);
100 epn = GET_EPN(pteH);
101 cb = GET_CBEHAVIOR(pteL);
102 pSize = GET_PAGE_SIZE(pteL);
103 pProt = GET_PROTECTION(pteL);
104 ppn = GET_PPN(pteL);
105 printk("[%c%2ld] 0x%08x 0x%08x %03d %02x %02x %4s %s\n",
106 ((valid) ? ' ' : 'u'), ((tlb & 0x0ffff) / TLB_STEP),
107 ppn, epn, asid, shared, cb, pSize, pProt);
108}
109
110void print_dtlb(void)
111{
112 int count;
113 unsigned long tlb;
114
115 printk(" ================= SH-5 D-TLBs Status ===================\n");
116 printk(HOW_TO_READ_TLB_CONTENT);
117 tlb = DTLB_BASE;
118 for (count = 0; count < MAX_TLBs; count++, tlb += TLB_STEP)
119 print_single_tlb(tlb, 0);
120 printk
121 (" =============================================================\n");
122}
123
124void print_itlb(void)
125{
126 int count;
127 unsigned long tlb;
128
129 printk(" ================= SH-5 I-TLBs Status ===================\n");
130 printk(HOW_TO_READ_TLB_CONTENT);
131 tlb = ITLB_BASE;
132 for (count = 0; count < MAX_TLBs; count++, tlb += TLB_STEP)
133 print_single_tlb(tlb, 0);
134 printk
135 (" =============================================================\n");
136}
137
138/* ======================================================================= */
139
140#ifdef CONFIG_POOR_MANS_STRACE
141
142#include "syscalltab.h"
143
144struct ring_node {
145 int evt;
146 int ret_addr;
147 int event;
148 int tra;
149 int pid;
150 unsigned long sp;
151 unsigned long pc;
152};
153
154static struct ring_node event_ring[16];
155static int event_ptr = 0;
156
157struct stored_syscall_data {
158 int pid;
159 int syscall_number;
160};
161
162#define N_STORED_SYSCALLS 16
163
164static struct stored_syscall_data stored_syscalls[N_STORED_SYSCALLS];
165static int syscall_next=0;
166static int syscall_next_print=0;
167
168void evt_debug(int evt, int ret_addr, int event, int tra, struct pt_regs *regs)
169{
170 int syscallno = tra & 0xff;
171 unsigned long sp;
172 unsigned long stack_bottom;
173 int pid;
174 struct ring_node *rr;
175
176 pid = current->pid;
177 stack_bottom = (unsigned long) task_stack_page(current);
178 asm volatile("ori r15, 0, %0" : "=r" (sp));
179 rr = event_ring + event_ptr;
180 rr->evt = evt;
181 rr->ret_addr = ret_addr;
182 rr->event = event;
183 rr->tra = tra;
184 rr->pid = pid;
185 rr->sp = sp;
186 rr->pc = regs->pc;
187
188 if (sp < stack_bottom + 3092) {
189 printk("evt_debug : stack underflow report\n");
190 int i, j;
191 for (j=0, i = event_ptr; j<16; j++) {
192 rr = event_ring + i;
193 printk("evt=%08x event=%08x tra=%08x pid=%5d sp=%08lx pc=%08lx\n",
194 rr->evt, rr->event, rr->tra, rr->pid, rr->sp, rr->pc);
195 i--;
196 i &= 15;
197 }
198 panic("STACK UNDERFLOW\n");
199 }
200
201 event_ptr = (event_ptr + 1) & 15;
202
203 if ((event == 2) && (evt == 0x160)) {
204 if (syscallno < NUM_SYSCALL_INFO_ENTRIES) {
205 /* Store the syscall information to print later. We
206 * can't print this now - currently we're running with
207 * SR.BL=1, so we can't take a tlbmiss (which could occur
208 * in the console drivers under printk).
209 *
210 * Just overwrite old entries on ring overflow - this
211 * is only for last-hope debugging. */
212 stored_syscalls[syscall_next].pid = current->pid;
213 stored_syscalls[syscall_next].syscall_number = syscallno;
214 syscall_next++;
215 syscall_next &= (N_STORED_SYSCALLS - 1);
216 }
217 }
218}
219
220static void drain_syscalls(void) {
221 while (syscall_next_print != syscall_next) {
222 printk("Task %d: %s()\n",
223 stored_syscalls[syscall_next_print].pid,
224 syscall_info_table[stored_syscalls[syscall_next_print].syscall_number].name);
225 syscall_next_print++;
226 syscall_next_print &= (N_STORED_SYSCALLS - 1);
227 }
228}
229
230void evt_debug2(unsigned int ret)
231{
232 drain_syscalls();
233 printk("Task %d: syscall returns %08x\n", current->pid, ret);
234}
235
236void evt_debug_ret_from_irq(struct pt_regs *regs)
237{
238 int pid;
239 struct ring_node *rr;
240
241 pid = current->pid;
242 rr = event_ring + event_ptr;
243 rr->evt = 0xffff;
244 rr->ret_addr = 0;
245 rr->event = 0;
246 rr->tra = 0;
247 rr->pid = pid;
248 rr->pc = regs->pc;
249 event_ptr = (event_ptr + 1) & 15;
250}
251
252void evt_debug_ret_from_exc(struct pt_regs *regs)
253{
254 int pid;
255 struct ring_node *rr;
256
257 pid = current->pid;
258 rr = event_ring + event_ptr;
259 rr->evt = 0xfffe;
260 rr->ret_addr = 0;
261 rr->event = 0;
262 rr->tra = 0;
263 rr->pid = pid;
264 rr->pc = regs->pc;
265 event_ptr = (event_ptr + 1) & 15;
266}
267
268#endif /* CONFIG_POOR_MANS_STRACE */
269
270/* ======================================================================= */
271
272void show_excp_regs(char *from, int trapnr, int signr, struct pt_regs *regs)
273{
274
275 unsigned long long ah, al, bh, bl, ch, cl;
276
277 printk("\n");
278 printk("EXCEPTION - %s: task %d; Linux trap # %d; signal = %d\n",
279 ((from) ? from : "???"), current->pid, trapnr, signr);
280
281 asm volatile ("getcon " __EXPEVT ", %0":"=r"(ah));
282 asm volatile ("getcon " __EXPEVT ", %0":"=r"(al));
283 ah = (ah) >> 32;
284 al = (al) & 0xffffffff;
285 asm volatile ("getcon " __KCR1 ", %0":"=r"(bh));
286 asm volatile ("getcon " __KCR1 ", %0":"=r"(bl));
287 bh = (bh) >> 32;
288 bl = (bl) & 0xffffffff;
289 asm volatile ("getcon " __INTEVT ", %0":"=r"(ch));
290 asm volatile ("getcon " __INTEVT ", %0":"=r"(cl));
291 ch = (ch) >> 32;
292 cl = (cl) & 0xffffffff;
293 printk("EXPE: %08Lx%08Lx KCR1: %08Lx%08Lx INTE: %08Lx%08Lx\n",
294 ah, al, bh, bl, ch, cl);
295
296 asm volatile ("getcon " __PEXPEVT ", %0":"=r"(ah));
297 asm volatile ("getcon " __PEXPEVT ", %0":"=r"(al));
298 ah = (ah) >> 32;
299 al = (al) & 0xffffffff;
300 asm volatile ("getcon " __PSPC ", %0":"=r"(bh));
301 asm volatile ("getcon " __PSPC ", %0":"=r"(bl));
302 bh = (bh) >> 32;
303 bl = (bl) & 0xffffffff;
304 asm volatile ("getcon " __PSSR ", %0":"=r"(ch));
305 asm volatile ("getcon " __PSSR ", %0":"=r"(cl));
306 ch = (ch) >> 32;
307 cl = (cl) & 0xffffffff;
308 printk("PEXP: %08Lx%08Lx PSPC: %08Lx%08Lx PSSR: %08Lx%08Lx\n",
309 ah, al, bh, bl, ch, cl);
310
311 ah = (regs->pc) >> 32;
312 al = (regs->pc) & 0xffffffff;
313 bh = (regs->regs[18]) >> 32;
314 bl = (regs->regs[18]) & 0xffffffff;
315 ch = (regs->regs[15]) >> 32;
316 cl = (regs->regs[15]) & 0xffffffff;
317 printk("PC : %08Lx%08Lx LINK: %08Lx%08Lx SP : %08Lx%08Lx\n",
318 ah, al, bh, bl, ch, cl);
319
320 ah = (regs->sr) >> 32;
321 al = (regs->sr) & 0xffffffff;
322 asm volatile ("getcon " __TEA ", %0":"=r"(bh));
323 asm volatile ("getcon " __TEA ", %0":"=r"(bl));
324 bh = (bh) >> 32;
325 bl = (bl) & 0xffffffff;
326 asm volatile ("getcon " __KCR0 ", %0":"=r"(ch));
327 asm volatile ("getcon " __KCR0 ", %0":"=r"(cl));
328 ch = (ch) >> 32;
329 cl = (cl) & 0xffffffff;
330 printk("SR : %08Lx%08Lx TEA : %08Lx%08Lx KCR0: %08Lx%08Lx\n",
331 ah, al, bh, bl, ch, cl);
332
333 ah = (regs->regs[0]) >> 32;
334 al = (regs->regs[0]) & 0xffffffff;
335 bh = (regs->regs[1]) >> 32;
336 bl = (regs->regs[1]) & 0xffffffff;
337 ch = (regs->regs[2]) >> 32;
338 cl = (regs->regs[2]) & 0xffffffff;
339 printk("R0 : %08Lx%08Lx R1 : %08Lx%08Lx R2 : %08Lx%08Lx\n",
340 ah, al, bh, bl, ch, cl);
341
342 ah = (regs->regs[3]) >> 32;
343 al = (regs->regs[3]) & 0xffffffff;
344 bh = (regs->regs[4]) >> 32;
345 bl = (regs->regs[4]) & 0xffffffff;
346 ch = (regs->regs[5]) >> 32;
347 cl = (regs->regs[5]) & 0xffffffff;
348 printk("R3 : %08Lx%08Lx R4 : %08Lx%08Lx R5 : %08Lx%08Lx\n",
349 ah, al, bh, bl, ch, cl);
350
351 ah = (regs->regs[6]) >> 32;
352 al = (regs->regs[6]) & 0xffffffff;
353 bh = (regs->regs[7]) >> 32;
354 bl = (regs->regs[7]) & 0xffffffff;
355 ch = (regs->regs[8]) >> 32;
356 cl = (regs->regs[8]) & 0xffffffff;
357 printk("R6 : %08Lx%08Lx R7 : %08Lx%08Lx R8 : %08Lx%08Lx\n",
358 ah, al, bh, bl, ch, cl);
359
360 ah = (regs->regs[9]) >> 32;
361 al = (regs->regs[9]) & 0xffffffff;
362 bh = (regs->regs[10]) >> 32;
363 bl = (regs->regs[10]) & 0xffffffff;
364 ch = (regs->regs[11]) >> 32;
365 cl = (regs->regs[11]) & 0xffffffff;
366 printk("R9 : %08Lx%08Lx R10 : %08Lx%08Lx R11 : %08Lx%08Lx\n",
367 ah, al, bh, bl, ch, cl);
368 printk("....\n");
369
370 ah = (regs->tregs[0]) >> 32;
371 al = (regs->tregs[0]) & 0xffffffff;
372 bh = (regs->tregs[1]) >> 32;
373 bl = (regs->tregs[1]) & 0xffffffff;
374 ch = (regs->tregs[2]) >> 32;
375 cl = (regs->tregs[2]) & 0xffffffff;
376 printk("T0 : %08Lx%08Lx T1 : %08Lx%08Lx T2 : %08Lx%08Lx\n",
377 ah, al, bh, bl, ch, cl);
378 printk("....\n");
379
380 print_dtlb();
381 print_itlb();
382}
383
384/* ======================================================================= */
385
386/*
387** Depending on <base> scan the MMU, Data or Instruction side
388** looking for a valid mapping matching Eaddr & asid.
389** Return -1 if not found or the TLB id entry otherwise.
390** Note: it works only for 4k pages!
391*/
392static unsigned long
393lookup_mmu_side(unsigned long base, unsigned long Eaddr, unsigned long asid)
394{
395 regType_t pteH;
396 unsigned long epn;
397 int count;
398
399 epn = Eaddr & 0xfffff000;
400
401 for (count = 0; count < MAX_TLBs; count++, base += TLB_STEP) {
402 pteH = getConfigReg(base);
403 if (GET_VALID(pteH))
404 if ((unsigned long) GET_EPN(pteH) == epn)
405 if ((unsigned long) GET_ASID(pteH) == asid)
406 break;
407 }
408 return ((unsigned long) ((count < MAX_TLBs) ? base : -1));
409}
410
411unsigned long lookup_dtlb(unsigned long Eaddr)
412{
413 unsigned long asid = get_asid();
414 return (lookup_mmu_side((u64) DTLB_BASE, Eaddr, asid));
415}
416
417unsigned long lookup_itlb(unsigned long Eaddr)
418{
419 unsigned long asid = get_asid();
420 return (lookup_mmu_side((u64) ITLB_BASE, Eaddr, asid));
421}
422
423void print_page(struct page *page)
424{
425 printk(" page[%p] -> index 0x%lx, count 0x%x, flags 0x%lx\n",
426 page, page->index, page_count(page), page->flags);
427 printk(" address_space = %p, pages =%ld\n", page->mapping,
428 page->mapping->nrpages);
429
430}
diff --git a/arch/sh64/lib/io.c b/arch/sh64/lib/io.c
deleted file mode 100644
index a3f3a2b8e25b..000000000000
--- a/arch/sh64/lib/io.c
+++ /dev/null
@@ -1,128 +0,0 @@
1/*
2 * Copyright (C) 2000 David J. Mckay (david.mckay@st.com)
3 *
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 * This file contains the I/O routines for use on the overdrive board
8 *
9 */
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <linux/delay.h>
14#include <linux/module.h>
15#include <asm/system.h>
16#include <asm/processor.h>
17#include <asm/io.h>
18
19/* Now for the string version of these functions */
20void outsb(unsigned long port, const void *addr, unsigned long count)
21{
22 int i;
23 unsigned char *p = (unsigned char *) addr;
24
25 for (i = 0; i < count; i++, p++) {
26 outb(*p, port);
27 }
28}
29EXPORT_SYMBOL(outsb);
30
31void insb(unsigned long port, void *addr, unsigned long count)
32{
33 int i;
34 unsigned char *p = (unsigned char *) addr;
35
36 for (i = 0; i < count; i++, p++) {
37 *p = inb(port);
38 }
39}
40EXPORT_SYMBOL(insb);
41
42/* For the 16 and 32 bit string functions, we have to worry about alignment.
43 * The SH does not do unaligned accesses, so we have to read as bytes and
44 * then write as a word or dword.
45 * This can be optimised a lot more, especially in the case where the data
46 * is aligned
47 */
48
49void outsw(unsigned long port, const void *addr, unsigned long count)
50{
51 int i;
52 unsigned short tmp;
53 unsigned char *p = (unsigned char *) addr;
54
55 for (i = 0; i < count; i++, p += 2) {
56 tmp = (*p) | ((*(p + 1)) << 8);
57 outw(tmp, port);
58 }
59}
60EXPORT_SYMBOL(outsw);
61
62void insw(unsigned long port, void *addr, unsigned long count)
63{
64 int i;
65 unsigned short tmp;
66 unsigned char *p = (unsigned char *) addr;
67
68 for (i = 0; i < count; i++, p += 2) {
69 tmp = inw(port);
70 p[0] = tmp & 0xff;
71 p[1] = (tmp >> 8) & 0xff;
72 }
73}
74EXPORT_SYMBOL(insw);
75
76void outsl(unsigned long port, const void *addr, unsigned long count)
77{
78 int i;
79 unsigned tmp;
80 unsigned char *p = (unsigned char *) addr;
81
82 for (i = 0; i < count; i++, p += 4) {
83 tmp = (*p) | ((*(p + 1)) << 8) | ((*(p + 2)) << 16) |
84 ((*(p + 3)) << 24);
85 outl(tmp, port);
86 }
87}
88EXPORT_SYMBOL(outsl);
89
90void insl(unsigned long port, void *addr, unsigned long count)
91{
92 int i;
93 unsigned tmp;
94 unsigned char *p = (unsigned char *) addr;
95
96 for (i = 0; i < count; i++, p += 4) {
97 tmp = inl(port);
98 p[0] = tmp & 0xff;
99 p[1] = (tmp >> 8) & 0xff;
100 p[2] = (tmp >> 16) & 0xff;
101 p[3] = (tmp >> 24) & 0xff;
102
103 }
104}
105EXPORT_SYMBOL(insl);
106
107void memcpy_toio(void __iomem *to, const void *from, long count)
108{
109 unsigned char *p = (unsigned char *) from;
110
111 while (count) {
112 count--;
113 writeb(*p++, to++);
114 }
115}
116EXPORT_SYMBOL(memcpy_toio);
117
118void memcpy_fromio(void *to, void __iomem *from, long count)
119{
120 int i;
121 unsigned char *p = (unsigned char *) to;
122
123 for (i = 0; i < count; i++) {
124 p[i] = readb(from);
125 from++;
126 }
127}
128EXPORT_SYMBOL(memcpy_fromio);
diff --git a/arch/sh64/lib/iomap.c b/arch/sh64/lib/iomap.c
deleted file mode 100644
index 253d1e351d49..000000000000
--- a/arch/sh64/lib/iomap.c
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 * arch/sh64/lib/iomap.c
3 *
4 * Generic sh64 iomap interface
5 *
6 * Copyright (C) 2004 Paul Mundt
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
10 * for more details.
11 */
12#include <linux/pci.h>
13#include <asm/io.h>
14
15void __iomem *__attribute__ ((weak))
16ioport_map(unsigned long port, unsigned int len)
17{
18 return (void __iomem *)port;
19}
20EXPORT_SYMBOL(ioport_map);
21
22void ioport_unmap(void __iomem *addr)
23{
24 /* Nothing .. */
25}
26EXPORT_SYMBOL(ioport_unmap);
27
28#ifdef CONFIG_PCI
29void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
30{
31 unsigned long start = pci_resource_start(dev, bar);
32 unsigned long len = pci_resource_len(dev, bar);
33 unsigned long flags = pci_resource_flags(dev, bar);
34
35 if (!len)
36 return NULL;
37 if (max && len > max)
38 len = max;
39 if (flags & IORESOURCE_IO)
40 return ioport_map(start + pciio_virt, len);
41 if (flags & IORESOURCE_MEM)
42 return (void __iomem *)start;
43
44 /* What? */
45 return NULL;
46}
47EXPORT_SYMBOL(pci_iomap);
48
49void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
50{
51 /* Nothing .. */
52}
53EXPORT_SYMBOL(pci_iounmap);
54#endif
diff --git a/arch/sh64/lib/memcpy.c b/arch/sh64/lib/memcpy.c
deleted file mode 100644
index fba436a92bfa..000000000000
--- a/arch/sh64/lib/memcpy.c
+++ /dev/null
@@ -1,81 +0,0 @@
1/*
2 * Copyright (C) 2002 Mark Debbage (Mark.Debbage@superh.com)
3 *
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 */
8
9#include <linux/types.h>
10#include <asm/string.h>
11
12// This is a simplistic optimization of memcpy to increase the
13// granularity of access beyond one byte using aligned
14// loads and stores. This is not an optimal implementation
15// for SH-5 (especially with regard to prefetching and the cache),
16// and a better version should be provided later ...
17
18void *memcpy(void *dest, const void *src, size_t count)
19{
20 char *d = (char *) dest, *s = (char *) src;
21
22 if (count >= 32) {
23 int i = 8 - (((unsigned long) d) & 0x7);
24
25 if (i != 8)
26 while (i-- && count--) {
27 *d++ = *s++;
28 }
29
30 if (((((unsigned long) d) & 0x7) == 0) &&
31 ((((unsigned long) s) & 0x7) == 0)) {
32 while (count >= 32) {
33 unsigned long long t1, t2, t3, t4;
34 t1 = *(unsigned long long *) (s);
35 t2 = *(unsigned long long *) (s + 8);
36 t3 = *(unsigned long long *) (s + 16);
37 t4 = *(unsigned long long *) (s + 24);
38 *(unsigned long long *) (d) = t1;
39 *(unsigned long long *) (d + 8) = t2;
40 *(unsigned long long *) (d + 16) = t3;
41 *(unsigned long long *) (d + 24) = t4;
42 d += 32;
43 s += 32;
44 count -= 32;
45 }
46 while (count >= 8) {
47 *(unsigned long long *) d =
48 *(unsigned long long *) s;
49 d += 8;
50 s += 8;
51 count -= 8;
52 }
53 }
54
55 if (((((unsigned long) d) & 0x3) == 0) &&
56 ((((unsigned long) s) & 0x3) == 0)) {
57 while (count >= 4) {
58 *(unsigned long *) d = *(unsigned long *) s;
59 d += 4;
60 s += 4;
61 count -= 4;
62 }
63 }
64
65 if (((((unsigned long) d) & 0x1) == 0) &&
66 ((((unsigned long) s) & 0x1) == 0)) {
67 while (count >= 2) {
68 *(unsigned short *) d = *(unsigned short *) s;
69 d += 2;
70 s += 2;
71 count -= 2;
72 }
73 }
74 }
75
76 while (count--) {
77 *d++ = *s++;
78 }
79
80 return d;
81}
diff --git a/arch/sh64/lib/page_clear.S b/arch/sh64/lib/page_clear.S
deleted file mode 100644
index ac0111d669a3..000000000000
--- a/arch/sh64/lib/page_clear.S
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 Copyright 2003 Richard Curnow, SuperH (UK) Ltd.
3
4 This file is subject to the terms and conditions of the GNU General Public
5 License. See the file "COPYING" in the main directory of this archive
6 for more details.
7
8 Tight version of memset for the case of just clearing a page. It turns out
9 that having the alloco's spaced out slightly due to the increment/branch
10 pair causes them to contend less for access to the cache. Similarly,
11 keeping the stores apart from the allocos causes less contention. => Do two
12 separate loops. Do multiple stores per loop to amortise the
13 increment/branch cost a little.
14
15 Parameters:
16 r2 : source effective address (start of page)
17
18 Always clears 4096 bytes.
19
20 Note : alloco guarded by synco to avoid TAKum03020 erratum
21
22*/
23
24 .section .text..SHmedia32,"ax"
25 .little
26
27 .balign 8
28 .global sh64_page_clear
29sh64_page_clear:
30 pta/l 1f, tr1
31 pta/l 2f, tr2
32 ptabs/l r18, tr0
33
34 movi 4096, r7
35 add r2, r7, r7
36 add r2, r63, r6
371:
38 alloco r6, 0
39 synco ! TAKum03020
40 addi r6, 32, r6
41 bgt/l r7, r6, tr1
42
43 add r2, r63, r6
442:
45 st.q r6, 0, r63
46 st.q r6, 8, r63
47 st.q r6, 16, r63
48 st.q r6, 24, r63
49 addi r6, 32, r6
50 bgt/l r7, r6, tr2
51
52 blink tr0, r63
53
54
diff --git a/arch/sh64/lib/page_copy.S b/arch/sh64/lib/page_copy.S
deleted file mode 100644
index e159c3cd2582..000000000000
--- a/arch/sh64/lib/page_copy.S
+++ /dev/null
@@ -1,91 +0,0 @@
1/*
2 Copyright 2003 Richard Curnow, SuperH (UK) Ltd.
3
4 This file is subject to the terms and conditions of the GNU General Public
5 License. See the file "COPYING" in the main directory of this archive
6 for more details.
7
8 Tight version of mempy for the case of just copying a page.
9 Prefetch strategy empirically optimised against RTL simulations
10 of SH5-101 cut2 eval chip with Cayman board DDR memory.
11
12 Parameters:
13 r2 : source effective address (start of page)
14 r3 : destination effective address (start of page)
15
16 Always copies 4096 bytes.
17
18 Points to review.
19 * Currently the prefetch is 4 lines ahead and the alloco is 2 lines ahead.
20 It seems like the prefetch needs to be at at least 4 lines ahead to get
21 the data into the cache in time, and the allocos contend with outstanding
22 prefetches for the same cache set, so it's better to have the numbers
23 different.
24 */
25
26 .section .text..SHmedia32,"ax"
27 .little
28
29 .balign 8
30 .global sh64_page_copy
31sh64_page_copy:
32
33 /* Copy 4096 bytes worth of data from r2 to r3.
34 Do prefetches 4 lines ahead.
35 Do alloco 2 lines ahead */
36
37 pta 1f, tr1
38 pta 2f, tr2
39 pta 3f, tr3
40 ptabs r18, tr0
41
42#if 0
43 /* TAKum03020 */
44 ld.q r2, 0x00, r63
45 ld.q r2, 0x20, r63
46 ld.q r2, 0x40, r63
47 ld.q r2, 0x60, r63
48#endif
49 alloco r3, 0x00
50 synco ! TAKum03020
51 alloco r3, 0x20
52 synco ! TAKum03020
53
54 movi 3968, r6
55 add r3, r6, r6
56 addi r6, 64, r7
57 addi r7, 64, r8
58 sub r2, r3, r60
59 addi r60, 8, r61
60 addi r61, 8, r62
61 addi r62, 8, r23
62 addi r60, 0x80, r22
63
64/* Minimal code size. The extra branches inside the loop don't cost much
65 because they overlap with the time spent waiting for prefetches to
66 complete. */
671:
68#if 0
69 /* TAKum03020 */
70 bge/u r3, r6, tr2 ! skip prefetch for last 4 lines
71 ldx.q r3, r22, r63 ! prefetch 4 lines hence
72#endif
732:
74 bge/u r3, r7, tr3 ! skip alloco for last 2 lines
75 alloco r3, 0x40 ! alloc destination line 2 lines ahead
76 synco ! TAKum03020
773:
78 ldx.q r3, r60, r36
79 ldx.q r3, r61, r37
80 ldx.q r3, r62, r38
81 ldx.q r3, r23, r39
82 st.q r3, 0, r36
83 st.q r3, 8, r37
84 st.q r3, 16, r38
85 st.q r3, 24, r39
86 addi r3, 32, r3
87 bgt/l r8, r3, tr1
88
89 blink tr0, r63 ! return
90
91
diff --git a/arch/sh64/lib/panic.c b/arch/sh64/lib/panic.c
deleted file mode 100644
index c9eb1cb50d97..000000000000
--- a/arch/sh64/lib/panic.c
+++ /dev/null
@@ -1,58 +0,0 @@
1/*
2 * Copyright (C) 2003 Richard Curnow, SuperH UK Limited
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#include <linux/kernel.h>
10#include <asm/io.h>
11#include <asm/registers.h>
12
13/* THIS IS A PHYSICAL ADDRESS */
14#define HDSP2534_ADDR (0x04002100)
15
16#ifdef CONFIG_SH_CAYMAN
17
18static void poor_mans_delay(void)
19{
20 int i;
21 for (i = 0; i < 2500000; i++) {
22 } /* poor man's delay */
23}
24
25static void show_value(unsigned long x)
26{
27 int i;
28 unsigned nibble;
29 for (i = 0; i < 8; i++) {
30 nibble = ((x >> (i * 4)) & 0xf);
31
32 ctrl_outb(nibble + ((nibble > 9) ? 55 : 48),
33 HDSP2534_ADDR + 0xe0 + ((7 - i) << 2));
34 }
35}
36
37#endif
38
39void
40panic_handler(unsigned long panicPC, unsigned long panicSSR,
41 unsigned long panicEXPEVT)
42{
43#ifdef CONFIG_SH_CAYMAN
44 while (1) {
45 /* This piece of code displays the PC on the LED display */
46 show_value(panicPC);
47 poor_mans_delay();
48 show_value(panicSSR);
49 poor_mans_delay();
50 show_value(panicEXPEVT);
51 poor_mans_delay();
52 }
53#endif
54
55 /* Never return from the panic handler */
56 for (;;) ;
57
58}
diff --git a/arch/sh64/lib/udelay.c b/arch/sh64/lib/udelay.c
deleted file mode 100644
index 327653914007..000000000000
--- a/arch/sh64/lib/udelay.c
+++ /dev/null
@@ -1,59 +0,0 @@
1/*
2 * arch/sh64/lib/udelay.c
3 *
4 * Delay routines, using a pre-computed "loops_per_jiffy" value.
5 *
6 * Copyright (C) 2000, 2001 Paolo Alberelli
7 * Copyright (C) 2003, 2004 Paul Mundt
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13#include <linux/sched.h>
14#include <asm/param.h>
15
16extern unsigned long loops_per_jiffy;
17
18/*
19 * Use only for very small delays (< 1 msec).
20 *
21 * The active part of our cycle counter is only 32-bits wide, and
22 * we're treating the difference between two marks as signed. On
23 * a 1GHz box, that's about 2 seconds.
24 */
25
26void __delay(int loops)
27{
28 long long dummy;
29 __asm__ __volatile__("gettr tr0, %1\n\t"
30 "pta $+4, tr0\n\t"
31 "addi %0, -1, %0\n\t"
32 "bne %0, r63, tr0\n\t"
33 "ptabs %1, tr0\n\t":"=r"(loops),
34 "=r"(dummy)
35 :"0"(loops));
36}
37
38void __udelay(unsigned long long usecs, unsigned long lpj)
39{
40 usecs *= (((unsigned long long) HZ << 32) / 1000000) * lpj;
41 __delay((long long) usecs >> 32);
42}
43
44void __ndelay(unsigned long long nsecs, unsigned long lpj)
45{
46 nsecs *= (((unsigned long long) HZ << 32) / 1000000000) * lpj;
47 __delay((long long) nsecs >> 32);
48}
49
50void udelay(unsigned long usecs)
51{
52 __udelay(usecs, loops_per_jiffy);
53}
54
55void ndelay(unsigned long nsecs)
56{
57 __ndelay(nsecs, loops_per_jiffy);
58}
59
diff --git a/arch/sh64/mach-cayman/Makefile b/arch/sh64/mach-cayman/Makefile
deleted file mode 100644
index 67a2258bf8c4..000000000000
--- a/arch/sh64/mach-cayman/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
1#
2# Makefile for the Hitachi Cayman specific parts of the kernel
3#
4# Note! Dependencies are done automagically by 'make dep', which also
5# removes any old dependencies. DON'T put your own dependencies here
6# unless it's something special (ie not a .c file).
7#
8
9obj-y := setup.o irq.o iomap.o
10obj-$(CONFIG_HEARTBEAT) += led.o
11
diff --git a/arch/sh64/mach-cayman/iomap.c b/arch/sh64/mach-cayman/iomap.c
deleted file mode 100644
index a5c645f02d57..000000000000
--- a/arch/sh64/mach-cayman/iomap.c
+++ /dev/null
@@ -1,22 +0,0 @@
1/*
2 * arch/sh64/mach-cayman/iomap.c
3 *
4 * Cayman iomap interface
5 *
6 * Copyright (C) 2004 Paul Mundt
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
10 * for more details.
11 */
12#include <asm/io.h>
13#include <asm/cayman.h>
14
15void __iomem *ioport_map(unsigned long port, unsigned int len)
16{
17 if (port < 0x400)
18 return (void __iomem *)((port << 2) | smsc_superio_virt);
19
20 return (void __iomem *)port;
21}
22
diff --git a/arch/sh64/mach-cayman/irq.c b/arch/sh64/mach-cayman/irq.c
deleted file mode 100644
index aaad36d37d1f..000000000000
--- a/arch/sh64/mach-cayman/irq.c
+++ /dev/null
@@ -1,195 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/irq_cayman.c
7 *
8 * SH-5 Cayman Interrupt Support
9 *
10 * This file handles the board specific parts of the Cayman interrupt system
11 *
12 * Copyright (C) 2002 Stuart Menefy
13 */
14
15#include <asm/irq.h>
16#include <asm/page.h>
17#include <asm/io.h>
18#include <linux/irq.h>
19#include <linux/interrupt.h>
20#include <linux/signal.h>
21#include <asm/cayman.h>
22
23unsigned long epld_virt;
24
25#define EPLD_BASE 0x04002000
26#define EPLD_STATUS_BASE (epld_virt + 0x10)
27#define EPLD_MASK_BASE (epld_virt + 0x20)
28
29/* Note the SMSC SuperIO chip and SMSC LAN chip interrupts are all muxed onto
30 the same SH-5 interrupt */
31
32static irqreturn_t cayman_interrupt_smsc(int irq, void *dev_id)
33{
34 printk(KERN_INFO "CAYMAN: spurious SMSC interrupt\n");
35 return IRQ_NONE;
36}
37
38static irqreturn_t cayman_interrupt_pci2(int irq, void *dev_id)
39{
40 printk(KERN_INFO "CAYMAN: spurious PCI interrupt, IRQ %d\n", irq);
41 return IRQ_NONE;
42}
43
44static struct irqaction cayman_action_smsc = {
45 .name = "Cayman SMSC Mux",
46 .handler = cayman_interrupt_smsc,
47 .flags = IRQF_DISABLED,
48};
49
50static struct irqaction cayman_action_pci2 = {
51 .name = "Cayman PCI2 Mux",
52 .handler = cayman_interrupt_pci2,
53 .flags = IRQF_DISABLED,
54};
55
56static void enable_cayman_irq(unsigned int irq)
57{
58 unsigned long flags;
59 unsigned long mask;
60 unsigned int reg;
61 unsigned char bit;
62
63 irq -= START_EXT_IRQS;
64 reg = EPLD_MASK_BASE + ((irq / 8) << 2);
65 bit = 1<<(irq % 8);
66 local_irq_save(flags);
67 mask = ctrl_inl(reg);
68 mask |= bit;
69 ctrl_outl(mask, reg);
70 local_irq_restore(flags);
71}
72
73void disable_cayman_irq(unsigned int irq)
74{
75 unsigned long flags;
76 unsigned long mask;
77 unsigned int reg;
78 unsigned char bit;
79
80 irq -= START_EXT_IRQS;
81 reg = EPLD_MASK_BASE + ((irq / 8) << 2);
82 bit = 1<<(irq % 8);
83 local_irq_save(flags);
84 mask = ctrl_inl(reg);
85 mask &= ~bit;
86 ctrl_outl(mask, reg);
87 local_irq_restore(flags);
88}
89
90static void ack_cayman_irq(unsigned int irq)
91{
92 disable_cayman_irq(irq);
93}
94
95static void end_cayman_irq(unsigned int irq)
96{
97 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
98 enable_cayman_irq(irq);
99}
100
101static unsigned int startup_cayman_irq(unsigned int irq)
102{
103 enable_cayman_irq(irq);
104 return 0; /* never anything pending */
105}
106
107static void shutdown_cayman_irq(unsigned int irq)
108{
109 disable_cayman_irq(irq);
110}
111
112struct hw_interrupt_type cayman_irq_type = {
113 .typename = "Cayman-IRQ",
114 .startup = startup_cayman_irq,
115 .shutdown = shutdown_cayman_irq,
116 .enable = enable_cayman_irq,
117 .disable = disable_cayman_irq,
118 .ack = ack_cayman_irq,
119 .end = end_cayman_irq,
120};
121
122int cayman_irq_demux(int evt)
123{
124 int irq = intc_evt_to_irq[evt];
125
126 if (irq == SMSC_IRQ) {
127 unsigned long status;
128 int i;
129
130 status = ctrl_inl(EPLD_STATUS_BASE) &
131 ctrl_inl(EPLD_MASK_BASE) & 0xff;
132 if (status == 0) {
133 irq = -1;
134 } else {
135 for (i=0; i<8; i++) {
136 if (status & (1<<i))
137 break;
138 }
139 irq = START_EXT_IRQS + i;
140 }
141 }
142
143 if (irq == PCI2_IRQ) {
144 unsigned long status;
145 int i;
146
147 status = ctrl_inl(EPLD_STATUS_BASE + 3 * sizeof(u32)) &
148 ctrl_inl(EPLD_MASK_BASE + 3 * sizeof(u32)) & 0xff;
149 if (status == 0) {
150 irq = -1;
151 } else {
152 for (i=0; i<8; i++) {
153 if (status & (1<<i))
154 break;
155 }
156 irq = START_EXT_IRQS + (3 * 8) + i;
157 }
158 }
159
160 return irq;
161}
162
163#if defined(CONFIG_PROC_FS) && defined(CONFIG_SYSCTL)
164int cayman_irq_describe(char* p, int irq)
165{
166 if (irq < NR_INTC_IRQS) {
167 return intc_irq_describe(p, irq);
168 } else if (irq < NR_INTC_IRQS + 8) {
169 return sprintf(p, "(SMSC %d)", irq - NR_INTC_IRQS);
170 } else if ((irq >= NR_INTC_IRQS + 24) && (irq < NR_INTC_IRQS + 32)) {
171 return sprintf(p, "(PCI2 %d)", irq - (NR_INTC_IRQS + 24));
172 }
173
174 return 0;
175}
176#endif
177
178void init_cayman_irq(void)
179{
180 int i;
181
182 epld_virt = onchip_remap(EPLD_BASE, 1024, "EPLD");
183 if (!epld_virt) {
184 printk(KERN_ERR "Cayman IRQ: Unable to remap EPLD\n");
185 return;
186 }
187
188 for (i=0; i<NR_EXT_IRQS; i++) {
189 irq_desc[START_EXT_IRQS + i].chip = &cayman_irq_type;
190 }
191
192 /* Setup the SMSC interrupt */
193 setup_irq(SMSC_IRQ, &cayman_action_smsc);
194 setup_irq(PCI2_IRQ, &cayman_action_pci2);
195}
diff --git a/arch/sh64/mach-cayman/led.c b/arch/sh64/mach-cayman/led.c
deleted file mode 100644
index b4e122fd9502..000000000000
--- a/arch/sh64/mach-cayman/led.c
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 * arch/sh64/mach-cayman/led.c
3 *
4 * Copyright (C) 2002 Stuart Menefy <stuart.menefy@st.com>
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * Flash the LEDs
10 */
11#include <asm/io.h>
12
13/*
14** It is supposed these functions to be used for a low level
15** debugging (via Cayman LEDs), hence to be available as soon
16** as possible.
17** Unfortunately Cayman LEDs relies on Cayman EPLD to be mapped
18** (this happen when IRQ are initialized... quite late).
19** These triky dependencies should be removed. Temporary, it
20** may be enough to NOP until EPLD is mapped.
21*/
22
23extern unsigned long epld_virt;
24
25#define LED_ADDR (epld_virt + 0x008)
26#define HDSP2534_ADDR (epld_virt + 0x100)
27
28void mach_led(int position, int value)
29{
30 if (!epld_virt)
31 return;
32
33 if (value)
34 ctrl_outl(0, LED_ADDR);
35 else
36 ctrl_outl(1, LED_ADDR);
37
38}
39
40void mach_alphanum(int position, unsigned char value)
41{
42 if (!epld_virt)
43 return;
44
45 ctrl_outb(value, HDSP2534_ADDR + 0xe0 + (position << 2));
46}
47
48void mach_alphanum_brightness(int setting)
49{
50 ctrl_outb(setting & 7, HDSP2534_ADDR + 0xc0);
51}
diff --git a/arch/sh64/mach-cayman/setup.c b/arch/sh64/mach-cayman/setup.c
deleted file mode 100644
index 726c520d7eb9..000000000000
--- a/arch/sh64/mach-cayman/setup.c
+++ /dev/null
@@ -1,239 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/mach-cayman/setup.c
7 *
8 * SH5 Cayman support
9 *
10 * This file handles the architecture-dependent parts of initialization
11 *
12 * Copyright David J. Mckay.
13 * Needs major work!
14 *
15 * benedict.gaster@superh.com: 3rd May 2002
16 * Added support for ramdisk, removing statically linked romfs at the same time.
17 *
18 * lethal@linux-sh.org: 15th May 2003
19 * Use the generic procfs cpuinfo interface, just return a valid board name.
20 */
21#include <linux/init.h>
22#include <linux/kernel.h>
23#include <asm/platform.h>
24#include <asm/irq.h>
25#include <asm/io.h>
26
27/*
28 * Platform Dependent Interrupt Priorities.
29 */
30
31/* Using defaults defined in irq.h */
32#define RES NO_PRIORITY /* Disabled */
33#define IR0 IRL0_PRIORITY /* IRLs */
34#define IR1 IRL1_PRIORITY
35#define IR2 IRL2_PRIORITY
36#define IR3 IRL3_PRIORITY
37#define PCA INTA_PRIORITY /* PCI Ints */
38#define PCB INTB_PRIORITY
39#define PCC INTC_PRIORITY
40#define PCD INTD_PRIORITY
41#define SER TOP_PRIORITY
42#define ERR TOP_PRIORITY
43#define PW0 TOP_PRIORITY
44#define PW1 TOP_PRIORITY
45#define PW2 TOP_PRIORITY
46#define PW3 TOP_PRIORITY
47#define DM0 NO_PRIORITY /* DMA Ints */
48#define DM1 NO_PRIORITY
49#define DM2 NO_PRIORITY
50#define DM3 NO_PRIORITY
51#define DAE NO_PRIORITY
52#define TU0 TIMER_PRIORITY /* TMU Ints */
53#define TU1 NO_PRIORITY
54#define TU2 NO_PRIORITY
55#define TI2 NO_PRIORITY
56#define ATI NO_PRIORITY /* RTC Ints */
57#define PRI NO_PRIORITY
58#define CUI RTC_PRIORITY
59#define ERI SCIF_PRIORITY /* SCIF Ints */
60#define RXI SCIF_PRIORITY
61#define BRI SCIF_PRIORITY
62#define TXI SCIF_PRIORITY
63#define ITI TOP_PRIORITY /* WDT Ints */
64
65/* Setup for the SMSC FDC37C935 */
66#define SMSC_SUPERIO_BASE 0x04000000
67#define SMSC_CONFIG_PORT_ADDR 0x3f0
68#define SMSC_INDEX_PORT_ADDR SMSC_CONFIG_PORT_ADDR
69#define SMSC_DATA_PORT_ADDR 0x3f1
70
71#define SMSC_ENTER_CONFIG_KEY 0x55
72#define SMSC_EXIT_CONFIG_KEY 0xaa
73
74#define SMCS_LOGICAL_DEV_INDEX 0x07
75#define SMSC_DEVICE_ID_INDEX 0x20
76#define SMSC_DEVICE_REV_INDEX 0x21
77#define SMSC_ACTIVATE_INDEX 0x30
78#define SMSC_PRIMARY_BASE_INDEX 0x60
79#define SMSC_SECONDARY_BASE_INDEX 0x62
80#define SMSC_PRIMARY_INT_INDEX 0x70
81#define SMSC_SECONDARY_INT_INDEX 0x72
82
83#define SMSC_IDE1_DEVICE 1
84#define SMSC_KEYBOARD_DEVICE 7
85#define SMSC_CONFIG_REGISTERS 8
86
87#define SMSC_SUPERIO_READ_INDEXED(index) ({ \
88 outb((index), SMSC_INDEX_PORT_ADDR); \
89 inb(SMSC_DATA_PORT_ADDR); })
90#define SMSC_SUPERIO_WRITE_INDEXED(val, index) ({ \
91 outb((index), SMSC_INDEX_PORT_ADDR); \
92 outb((val), SMSC_DATA_PORT_ADDR); })
93
94#define IDE1_PRIMARY_BASE 0x01f0
95#define IDE1_SECONDARY_BASE 0x03f6
96
97unsigned long smsc_superio_virt;
98
99/*
100 * Platform dependent structures: maps and parms block.
101 */
102struct resource io_resources[] = {
103 /* To be updated with external devices */
104};
105
106struct resource kram_resources[] = {
107 /* These must be last in the array */
108 { .name = "Kernel code", .start = 0, .end = 0 },
109 /* These must be last in the array */
110 { .name = "Kernel data", .start = 0, .end = 0 }
111};
112
113struct resource xram_resources[] = {
114 /* To be updated with external devices */
115};
116
117struct resource rom_resources[] = {
118 /* To be updated with external devices */
119};
120
121struct sh64_platform platform_parms = {
122 .readonly_rootfs = 1,
123 .initial_root_dev = 0x0100,
124 .loader_type = 1,
125 .io_res_p = io_resources,
126 .io_res_count = ARRAY_SIZE(io_resources),
127 .kram_res_p = kram_resources,
128 .kram_res_count = ARRAY_SIZE(kram_resources),
129 .xram_res_p = xram_resources,
130 .xram_res_count = ARRAY_SIZE(xram_resources),
131 .rom_res_p = rom_resources,
132 .rom_res_count = ARRAY_SIZE(rom_resources),
133};
134
135int platform_int_priority[NR_INTC_IRQS] = {
136 IR0, IR1, IR2, IR3, PCA, PCB, PCC, PCD, /* IRQ 0- 7 */
137 RES, RES, RES, RES, SER, ERR, PW3, PW2, /* IRQ 8-15 */
138 PW1, PW0, DM0, DM1, DM2, DM3, DAE, RES, /* IRQ 16-23 */
139 RES, RES, RES, RES, RES, RES, RES, RES, /* IRQ 24-31 */
140 TU0, TU1, TU2, TI2, ATI, PRI, CUI, ERI, /* IRQ 32-39 */
141 RXI, BRI, TXI, RES, RES, RES, RES, RES, /* IRQ 40-47 */
142 RES, RES, RES, RES, RES, RES, RES, RES, /* IRQ 48-55 */
143 RES, RES, RES, RES, RES, RES, RES, ITI, /* IRQ 56-63 */
144};
145
146static int __init smsc_superio_setup(void)
147{
148 unsigned char devid, devrev;
149
150 smsc_superio_virt = onchip_remap(SMSC_SUPERIO_BASE, 1024, "SMSC SuperIO");
151 if (!smsc_superio_virt) {
152 panic("Unable to remap SMSC SuperIO\n");
153 }
154
155 /* Initially the chip is in run state */
156 /* Put it into configuration state */
157 outb(SMSC_ENTER_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
158 outb(SMSC_ENTER_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
159
160 /* Read device ID info */
161 devid = SMSC_SUPERIO_READ_INDEXED(SMSC_DEVICE_ID_INDEX);
162 devrev = SMSC_SUPERIO_READ_INDEXED(SMSC_DEVICE_REV_INDEX);
163 printk("SMSC SuperIO devid %02x rev %02x\n", devid, devrev);
164
165 /* Select the keyboard device */
166 SMSC_SUPERIO_WRITE_INDEXED(SMSC_KEYBOARD_DEVICE, SMCS_LOGICAL_DEV_INDEX);
167
168 /* enable it */
169 SMSC_SUPERIO_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
170
171 /* Select the interrupts */
172 /* On a PC keyboard is IRQ1, mouse is IRQ12 */
173 SMSC_SUPERIO_WRITE_INDEXED(1, SMSC_PRIMARY_INT_INDEX);
174 SMSC_SUPERIO_WRITE_INDEXED(12, SMSC_SECONDARY_INT_INDEX);
175
176#ifdef CONFIG_IDE
177 /*
178 * Only IDE1 exists on the Cayman
179 */
180
181 /* Power it on */
182 SMSC_SUPERIO_WRITE_INDEXED(1 << SMSC_IDE1_DEVICE, 0x22);
183
184 SMSC_SUPERIO_WRITE_INDEXED(SMSC_IDE1_DEVICE, SMCS_LOGICAL_DEV_INDEX);
185 SMSC_SUPERIO_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
186
187 SMSC_SUPERIO_WRITE_INDEXED(IDE1_PRIMARY_BASE >> 8,
188 SMSC_PRIMARY_BASE_INDEX + 0);
189 SMSC_SUPERIO_WRITE_INDEXED(IDE1_PRIMARY_BASE & 0xff,
190 SMSC_PRIMARY_BASE_INDEX + 1);
191
192 SMSC_SUPERIO_WRITE_INDEXED(IDE1_SECONDARY_BASE >> 8,
193 SMSC_SECONDARY_BASE_INDEX + 0);
194 SMSC_SUPERIO_WRITE_INDEXED(IDE1_SECONDARY_BASE & 0xff,
195 SMSC_SECONDARY_BASE_INDEX + 1);
196
197 SMSC_SUPERIO_WRITE_INDEXED(14, SMSC_PRIMARY_INT_INDEX);
198
199 SMSC_SUPERIO_WRITE_INDEXED(SMSC_CONFIG_REGISTERS,
200 SMCS_LOGICAL_DEV_INDEX);
201
202 SMSC_SUPERIO_WRITE_INDEXED(0x00, 0xc2); /* GP42 = nIDE1_OE */
203 SMSC_SUPERIO_WRITE_INDEXED(0x01, 0xc5); /* GP45 = IDE1_IRQ */
204 SMSC_SUPERIO_WRITE_INDEXED(0x00, 0xc6); /* GP46 = nIOROP */
205 SMSC_SUPERIO_WRITE_INDEXED(0x00, 0xc7); /* GP47 = nIOWOP */
206#endif
207
208 /* Exit the configuration state */
209 outb(SMSC_EXIT_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
210
211 return 0;
212}
213
214/* This is grotty, but, because kernel is always referenced on the link line
215 * before any devices, this is safe.
216 */
217__initcall(smsc_superio_setup);
218
219void __init platform_setup(void)
220{
221 /* Cayman platform leaves the decision to head.S, for now */
222 platform_parms.fpu_flags = fpu_in_use;
223}
224
225void __init platform_monitor(void)
226{
227 /* Nothing yet .. */
228}
229
230void __init platform_reserve(void)
231{
232 /* Nothing yet .. */
233}
234
235const char *get_system_type(void)
236{
237 return "Hitachi Cayman";
238}
239
diff --git a/arch/sh64/mach-harp/Makefile b/arch/sh64/mach-harp/Makefile
deleted file mode 100644
index 2f2963fa2131..000000000000
--- a/arch/sh64/mach-harp/Makefile
+++ /dev/null
@@ -1 +0,0 @@
1obj-y := setup.o
diff --git a/arch/sh64/mach-harp/setup.c b/arch/sh64/mach-harp/setup.c
deleted file mode 100644
index 05011cb369bb..000000000000
--- a/arch/sh64/mach-harp/setup.c
+++ /dev/null
@@ -1,129 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/mach-harp/setup.c
7 *
8 * SH-5 Simulator Platform Support
9 *
10 * This file handles the architecture-dependent parts of initialization
11 *
12 * Copyright (C) 2000, 2001 Paolo Alberelli
13 *
14 * benedict.gaster@superh.com: 3rd May 2002
15 * Added support for ramdisk, removing statically linked romfs at the same time. *
16 *
17 * lethal@linux-sh.org: 15th May 2003
18 * Use the generic procfs cpuinfo interface, just return a valid board name.
19 */
20#include <linux/init.h>
21#include <linux/kernel.h>
22#include <asm/platform.h>
23#include <asm/irq.h>
24
25/*
26 * Platform Dependent Interrupt Priorities.
27 */
28
29/* Using defaults defined in irq.h */
30#define RES NO_PRIORITY /* Disabled */
31#define IR0 IRL0_PRIORITY /* IRLs */
32#define IR1 IRL1_PRIORITY
33#define IR2 IRL2_PRIORITY
34#define IR3 IRL3_PRIORITY
35#define PCA INTA_PRIORITY /* PCI Ints */
36#define PCB INTB_PRIORITY
37#define PCC INTC_PRIORITY
38#define PCD INTD_PRIORITY
39#define SER TOP_PRIORITY
40#define ERR TOP_PRIORITY
41#define PW0 TOP_PRIORITY
42#define PW1 TOP_PRIORITY
43#define PW2 TOP_PRIORITY
44#define PW3 TOP_PRIORITY
45#define DM0 NO_PRIORITY /* DMA Ints */
46#define DM1 NO_PRIORITY
47#define DM2 NO_PRIORITY
48#define DM3 NO_PRIORITY
49#define DAE NO_PRIORITY
50#define TU0 TIMER_PRIORITY /* TMU Ints */
51#define TU1 NO_PRIORITY
52#define TU2 NO_PRIORITY
53#define TI2 NO_PRIORITY
54#define ATI NO_PRIORITY /* RTC Ints */
55#define PRI NO_PRIORITY
56#define CUI RTC_PRIORITY
57#define ERI SCIF_PRIORITY /* SCIF Ints */
58#define RXI SCIF_PRIORITY
59#define BRI SCIF_PRIORITY
60#define TXI SCIF_PRIORITY
61#define ITI TOP_PRIORITY /* WDT Ints */
62
63/*
64 * Platform dependent structures: maps and parms block.
65 */
66struct resource io_resources[] = {
67 /* To be updated with external devices */
68};
69
70struct resource kram_resources[] = {
71 /* These must be last in the array */
72 { .name = "Kernel code", .start = 0, .end = 0 },
73 /* These must be last in the array */
74 { .name = "Kernel data", .start = 0, .end = 0 }
75};
76
77struct resource xram_resources[] = {
78 /* To be updated with external devices */
79};
80
81struct resource rom_resources[] = {
82 /* To be updated with external devices */
83};
84
85struct sh64_platform platform_parms = {
86 .readonly_rootfs = 1,
87 .initial_root_dev = 0x0100,
88 .loader_type = 1,
89 .io_res_p = io_resources,
90 .io_res_count = ARRAY_SIZE(io_resources),
91 .kram_res_p = kram_resources,
92 .kram_res_count = ARRAY_SIZE(kram_resources),
93 .xram_res_p = xram_resources,
94 .xram_res_count = ARRAY_SIZE(xram_resources),
95 .rom_res_p = rom_resources,
96 .rom_res_count = ARRAY_SIZE(rom_resources),
97};
98
99int platform_int_priority[NR_INTC_IRQS] = {
100 IR0, IR1, IR2, IR3, PCA, PCB, PCC, PCD, /* IRQ 0- 7 */
101 RES, RES, RES, RES, SER, ERR, PW3, PW2, /* IRQ 8-15 */
102 PW1, PW0, DM0, DM1, DM2, DM3, DAE, RES, /* IRQ 16-23 */
103 RES, RES, RES, RES, RES, RES, RES, RES, /* IRQ 24-31 */
104 TU0, TU1, TU2, TI2, ATI, PRI, CUI, ERI, /* IRQ 32-39 */
105 RXI, BRI, TXI, RES, RES, RES, RES, RES, /* IRQ 40-47 */
106 RES, RES, RES, RES, RES, RES, RES, RES, /* IRQ 48-55 */
107 RES, RES, RES, RES, RES, RES, RES, ITI, /* IRQ 56-63 */
108};
109
110void __init platform_setup(void)
111{
112 /* Harp platform leaves the decision to head.S, for now */
113 platform_parms.fpu_flags = fpu_in_use;
114}
115
116void __init platform_monitor(void)
117{
118 /* Nothing yet .. */
119}
120
121void __init platform_reserve(void)
122{
123 /* Nothing yet .. */
124}
125
126const char *get_system_type(void)
127{
128 return "ST50 Harp";
129}
diff --git a/arch/sh64/mach-sim/Makefile b/arch/sh64/mach-sim/Makefile
deleted file mode 100644
index 2f2963fa2131..000000000000
--- a/arch/sh64/mach-sim/Makefile
+++ /dev/null
@@ -1 +0,0 @@
1obj-y := setup.o
diff --git a/arch/sh64/mach-sim/setup.c b/arch/sh64/mach-sim/setup.c
deleted file mode 100644
index e3386ec1ce1f..000000000000
--- a/arch/sh64/mach-sim/setup.c
+++ /dev/null
@@ -1,126 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/mach-sim/setup.c
7 *
8 * ST50 Simulator Platform Support
9 *
10 * This file handles the architecture-dependent parts of initialization
11 *
12 * Copyright (C) 2000, 2001 Paolo Alberelli
13 *
14 * lethal@linux-sh.org: 15th May 2003
15 * Use the generic procfs cpuinfo interface, just return a valid board name.
16 */
17#include <linux/init.h>
18#include <linux/kernel.h>
19#include <asm/platform.h>
20#include <asm/irq.h>
21
22/*
23 * Platform Dependent Interrupt Priorities.
24 */
25
26/* Using defaults defined in irq.h */
27#define RES NO_PRIORITY /* Disabled */
28#define IR0 IRL0_PRIORITY /* IRLs */
29#define IR1 IRL1_PRIORITY
30#define IR2 IRL2_PRIORITY
31#define IR3 IRL3_PRIORITY
32#define PCA INTA_PRIORITY /* PCI Ints */
33#define PCB INTB_PRIORITY
34#define PCC INTC_PRIORITY
35#define PCD INTD_PRIORITY
36#define SER TOP_PRIORITY
37#define ERR TOP_PRIORITY
38#define PW0 TOP_PRIORITY
39#define PW1 TOP_PRIORITY
40#define PW2 TOP_PRIORITY
41#define PW3 TOP_PRIORITY
42#define DM0 NO_PRIORITY /* DMA Ints */
43#define DM1 NO_PRIORITY
44#define DM2 NO_PRIORITY
45#define DM3 NO_PRIORITY
46#define DAE NO_PRIORITY
47#define TU0 TIMER_PRIORITY /* TMU Ints */
48#define TU1 NO_PRIORITY
49#define TU2 NO_PRIORITY
50#define TI2 NO_PRIORITY
51#define ATI NO_PRIORITY /* RTC Ints */
52#define PRI NO_PRIORITY
53#define CUI RTC_PRIORITY
54#define ERI SCIF_PRIORITY /* SCIF Ints */
55#define RXI SCIF_PRIORITY
56#define BRI SCIF_PRIORITY
57#define TXI SCIF_PRIORITY
58#define ITI TOP_PRIORITY /* WDT Ints */
59
60/*
61 * Platform dependent structures: maps and parms block.
62 */
63struct resource io_resources[] = {
64 /* Nothing yet .. */
65};
66
67struct resource kram_resources[] = {
68 /* These must be last in the array */
69 { .name = "Kernel code", .start = 0, .end = 0 },
70 /* These must be last in the array */
71 { .name = "Kernel data", .start = 0, .end = 0 }
72};
73
74struct resource xram_resources[] = {
75 /* Nothing yet .. */
76};
77
78struct resource rom_resources[] = {
79 /* Nothing yet .. */
80};
81
82struct sh64_platform platform_parms = {
83 .readonly_rootfs = 1,
84 .initial_root_dev = 0x0100,
85 .loader_type = 1,
86 .io_res_p = io_resources,
87 .io_res_count = ARRAY_SIZE(io_resources),
88 .kram_res_p = kram_resources,
89 .kram_res_count = ARRAY_SIZE(kram_resources),
90 .xram_res_p = xram_resources,
91 .xram_res_count = ARRAY_SIZE(xram_resources),
92 .rom_res_p = rom_resources,
93 .rom_res_count = ARRAY_SIZE(rom_resources),
94};
95
96int platform_int_priority[NR_IRQS] = {
97 IR0, IR1, IR2, IR3, PCA, PCB, PCC, PCD, /* IRQ 0- 7 */
98 RES, RES, RES, RES, SER, ERR, PW3, PW2, /* IRQ 8-15 */
99 PW1, PW0, DM0, DM1, DM2, DM3, DAE, RES, /* IRQ 16-23 */
100 RES, RES, RES, RES, RES, RES, RES, RES, /* IRQ 24-31 */
101 TU0, TU1, TU2, TI2, ATI, PRI, CUI, ERI, /* IRQ 32-39 */
102 RXI, BRI, TXI, RES, RES, RES, RES, RES, /* IRQ 40-47 */
103 RES, RES, RES, RES, RES, RES, RES, RES, /* IRQ 48-55 */
104 RES, RES, RES, RES, RES, RES, RES, ITI, /* IRQ 56-63 */
105};
106
107void __init platform_setup(void)
108{
109 /* Simulator platform leaves the decision to head.S */
110 platform_parms.fpu_flags = fpu_in_use;
111}
112
113void __init platform_monitor(void)
114{
115 /* Nothing yet .. */
116}
117
118void __init platform_reserve(void)
119{
120 /* Nothing yet .. */
121}
122
123const char *get_system_type(void)
124{
125 return "SH-5 Simulator";
126}
diff --git a/arch/sh64/mm/Makefile b/arch/sh64/mm/Makefile
deleted file mode 100644
index d0e813632480..000000000000
--- a/arch/sh64/mm/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
1#
2# This file is subject to the terms and conditions of the GNU General Public
3# License. See the file "COPYING" in the main directory of this archive
4# for more details.
5#
6# Copyright (C) 2000, 2001 Paolo Alberelli
7# Copyright (C) 2003, 2004 Paul Mundt
8#
9# Makefile for the sh64-specific parts of the Linux memory manager.
10#
11# Note! Dependencies are done automagically by 'make dep', which also
12# removes any old dependencies. DON'T put your own dependencies here
13# unless it's something special (ie not a .c file).
14#
15
16obj-y := cache.o consistent.o extable.o fault.o init.o ioremap.o \
17 tlbmiss.o tlb.o
18
19obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
20
21# Special flags for tlbmiss.o. This puts restrictions on the number of
22# caller-save registers that the compiler can target when building this file.
23# This is required because the code is called from a context in entry.S where
24# very few registers have been saved in the exception handler (for speed
25# reasons).
26# The caller save registers that have been saved and which can be used are
27# r2,r3,r4,r5 : argument passing
28# r15, r18 : SP and LINK
29# tr0-4 : allow all caller-save TR's. The compiler seems to be able to make
30# use of them, so it's probably beneficial to performance to save them
31# and have them available for it.
32#
33# The resources not listed below are callee save, i.e. the compiler is free to
34# use any of them and will spill them to the stack itself.
35
36CFLAGS_tlbmiss.o += -ffixed-r7 \
37 -ffixed-r8 -ffixed-r9 -ffixed-r10 -ffixed-r11 -ffixed-r12 \
38 -ffixed-r13 -ffixed-r14 -ffixed-r16 -ffixed-r17 -ffixed-r19 \
39 -ffixed-r20 -ffixed-r21 -ffixed-r22 -ffixed-r23 \
40 -ffixed-r24 -ffixed-r25 -ffixed-r26 -ffixed-r27 \
41 -ffixed-r36 -ffixed-r37 -ffixed-r38 -ffixed-r39 -ffixed-r40 \
42 -ffixed-r41 -ffixed-r42 -ffixed-r43 \
43 -ffixed-r60 -ffixed-r61 -ffixed-r62 \
44 -fomit-frame-pointer
diff --git a/arch/sh64/mm/cache.c b/arch/sh64/mm/cache.c
deleted file mode 100644
index 421487cfff4c..000000000000
--- a/arch/sh64/mm/cache.c
+++ /dev/null
@@ -1,1032 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/mm/cache.c
7 *
8 * Original version Copyright (C) 2000, 2001 Paolo Alberelli
9 * Second version Copyright (C) benedict.gaster@superh.com 2002
10 * Third version Copyright Richard.Curnow@superh.com 2003
11 * Hacks to third version Copyright (C) 2003 Paul Mundt
12 */
13
14/****************************************************************************/
15
16#include <linux/init.h>
17#include <linux/mman.h>
18#include <linux/mm.h>
19#include <linux/threads.h>
20#include <asm/page.h>
21#include <asm/pgtable.h>
22#include <asm/processor.h>
23#include <asm/cache.h>
24#include <asm/tlb.h>
25#include <asm/io.h>
26#include <asm/uaccess.h>
27#include <asm/mmu_context.h>
28#include <asm/pgalloc.h> /* for flush_itlb_range */
29
30#include <linux/proc_fs.h>
31
32/* This function is in entry.S */
33extern unsigned long switch_and_save_asid(unsigned long new_asid);
34
35/* Wired TLB entry for the D-cache */
36static unsigned long long dtlb_cache_slot;
37
38/**
39 * sh64_cache_init()
40 *
41 * This is pretty much just a straightforward clone of the SH
42 * detect_cpu_and_cache_system().
43 *
44 * This function is responsible for setting up all of the cache
45 * info dynamically as well as taking care of CPU probing and
46 * setting up the relevant subtype data.
47 *
48 * FIXME: For the time being, we only really support the SH5-101
49 * out of the box, and don't support dynamic probing for things
50 * like the SH5-103 or even cut2 of the SH5-101. Implement this
51 * later!
52 */
53int __init sh64_cache_init(void)
54{
55 /*
56 * First, setup some sane values for the I-cache.
57 */
58 cpu_data->icache.ways = 4;
59 cpu_data->icache.sets = 256;
60 cpu_data->icache.linesz = L1_CACHE_BYTES;
61
62 /*
63 * FIXME: This can probably be cleaned up a bit as well.. for example,
64 * do we really need the way shift _and_ the way_step_shift ?? Judging
65 * by the existing code, I would guess no.. is there any valid reason
66 * why we need to be tracking this around?
67 */
68 cpu_data->icache.way_shift = 13;
69 cpu_data->icache.entry_shift = 5;
70 cpu_data->icache.set_shift = 4;
71 cpu_data->icache.way_step_shift = 16;
72 cpu_data->icache.asid_shift = 2;
73
74 /*
75 * way offset = cache size / associativity, so just don't factor in
76 * associativity in the first place..
77 */
78 cpu_data->icache.way_ofs = cpu_data->icache.sets *
79 cpu_data->icache.linesz;
80
81 cpu_data->icache.asid_mask = 0x3fc;
82 cpu_data->icache.idx_mask = 0x1fe0;
83 cpu_data->icache.epn_mask = 0xffffe000;
84 cpu_data->icache.flags = 0;
85
86 /*
87 * Next, setup some sane values for the D-cache.
88 *
89 * On the SH5, these are pretty consistent with the I-cache settings,
90 * so we just copy over the existing definitions.. these can be fixed
91 * up later, especially if we add runtime CPU probing.
92 *
93 * Though in the meantime it saves us from having to duplicate all of
94 * the above definitions..
95 */
96 cpu_data->dcache = cpu_data->icache;
97
98 /*
99 * Setup any cache-related flags here
100 */
101#if defined(CONFIG_DCACHE_WRITE_THROUGH)
102 set_bit(SH_CACHE_MODE_WT, &(cpu_data->dcache.flags));
103#elif defined(CONFIG_DCACHE_WRITE_BACK)
104 set_bit(SH_CACHE_MODE_WB, &(cpu_data->dcache.flags));
105#endif
106
107 /*
108 * We also need to reserve a slot for the D-cache in the DTLB, so we
109 * do this now ..
110 */
111 dtlb_cache_slot = sh64_get_wired_dtlb_entry();
112
113 return 0;
114}
115
116#ifdef CONFIG_DCACHE_DISABLED
117#define sh64_dcache_purge_all() do { } while (0)
118#define sh64_dcache_purge_coloured_phy_page(paddr, eaddr) do { } while (0)
119#define sh64_dcache_purge_user_range(mm, start, end) do { } while (0)
120#define sh64_dcache_purge_phy_page(paddr) do { } while (0)
121#define sh64_dcache_purge_virt_page(mm, eaddr) do { } while (0)
122#define sh64_dcache_purge_kernel_range(start, end) do { } while (0)
123#define sh64_dcache_wback_current_user_range(start, end) do { } while (0)
124#endif
125
126/*##########################################################################*/
127
128/* From here onwards, a rewrite of the implementation,
129 by Richard.Curnow@superh.com.
130
131 The major changes in this compared to the old version are;
132 1. use more selective purging through OCBP instead of using ALLOCO to purge
133 by natural replacement. This avoids purging out unrelated cache lines
134 that happen to be in the same set.
135 2. exploit the APIs copy_user_page and clear_user_page better
136 3. be more selective about I-cache purging, in particular use invalidate_all
137 more sparingly.
138
139 */
140
141/*##########################################################################
142 SUPPORT FUNCTIONS
143 ##########################################################################*/
144
145/****************************************************************************/
146/* The following group of functions deal with mapping and unmapping a temporary
147 page into the DTLB slot that have been set aside for our exclusive use. */
148/* In order to accomplish this, we use the generic interface for adding and
149 removing a wired slot entry as defined in arch/sh64/mm/tlb.c */
150/****************************************************************************/
151
152static unsigned long slot_own_flags;
153
154static inline void sh64_setup_dtlb_cache_slot(unsigned long eaddr, unsigned long asid, unsigned long paddr)
155{
156 local_irq_save(slot_own_flags);
157 sh64_setup_tlb_slot(dtlb_cache_slot, eaddr, asid, paddr);
158}
159
160static inline void sh64_teardown_dtlb_cache_slot(void)
161{
162 sh64_teardown_tlb_slot(dtlb_cache_slot);
163 local_irq_restore(slot_own_flags);
164}
165
166/****************************************************************************/
167
168#ifndef CONFIG_ICACHE_DISABLED
169
170static void __inline__ sh64_icache_inv_all(void)
171{
172 unsigned long long addr, flag, data;
173 unsigned int flags;
174
175 addr=ICCR0;
176 flag=ICCR0_ICI;
177 data=0;
178
179 /* Make this a critical section for safety (probably not strictly necessary.) */
180 local_irq_save(flags);
181
182 /* Without %1 it gets unexplicably wrong */
183 asm volatile("getcfg %3, 0, %0\n\t"
184 "or %0, %2, %0\n\t"
185 "putcfg %3, 0, %0\n\t"
186 "synci"
187 : "=&r" (data)
188 : "0" (data), "r" (flag), "r" (addr));
189
190 local_irq_restore(flags);
191}
192
193static void sh64_icache_inv_kernel_range(unsigned long start, unsigned long end)
194{
195 /* Invalidate range of addresses [start,end] from the I-cache, where
196 * the addresses lie in the kernel superpage. */
197
198 unsigned long long ullend, addr, aligned_start;
199#if (NEFF == 32)
200 aligned_start = (unsigned long long)(signed long long)(signed long) start;
201#else
202#error "NEFF != 32"
203#endif
204 aligned_start &= L1_CACHE_ALIGN_MASK;
205 addr = aligned_start;
206#if (NEFF == 32)
207 ullend = (unsigned long long) (signed long long) (signed long) end;
208#else
209#error "NEFF != 32"
210#endif
211 while (addr <= ullend) {
212 asm __volatile__ ("icbi %0, 0" : : "r" (addr));
213 addr += L1_CACHE_BYTES;
214 }
215}
216
217static void sh64_icache_inv_user_page(struct vm_area_struct *vma, unsigned long eaddr)
218{
219 /* If we get called, we know that vma->vm_flags contains VM_EXEC.
220 Also, eaddr is page-aligned. */
221
222 unsigned long long addr, end_addr;
223 unsigned long flags = 0;
224 unsigned long running_asid, vma_asid;
225 addr = eaddr;
226 end_addr = addr + PAGE_SIZE;
227
228 /* Check whether we can use the current ASID for the I-cache
229 invalidation. For example, if we're called via
230 access_process_vm->flush_cache_page->here, (e.g. when reading from
231 /proc), 'running_asid' will be that of the reader, not of the
232 victim.
233
234 Also, note the risk that we might get pre-empted between the ASID
235 compare and blocking IRQs, and before we regain control, the
236 pid->ASID mapping changes. However, the whole cache will get
237 invalidated when the mapping is renewed, so the worst that can
238 happen is that the loop below ends up invalidating somebody else's
239 cache entries.
240 */
241
242 running_asid = get_asid();
243 vma_asid = (vma->vm_mm->context & MMU_CONTEXT_ASID_MASK);
244 if (running_asid != vma_asid) {
245 local_irq_save(flags);
246 switch_and_save_asid(vma_asid);
247 }
248 while (addr < end_addr) {
249 /* Worth unrolling a little */
250 asm __volatile__("icbi %0, 0" : : "r" (addr));
251 asm __volatile__("icbi %0, 32" : : "r" (addr));
252 asm __volatile__("icbi %0, 64" : : "r" (addr));
253 asm __volatile__("icbi %0, 96" : : "r" (addr));
254 addr += 128;
255 }
256 if (running_asid != vma_asid) {
257 switch_and_save_asid(running_asid);
258 local_irq_restore(flags);
259 }
260}
261
262/****************************************************************************/
263
264static void sh64_icache_inv_user_page_range(struct mm_struct *mm,
265 unsigned long start, unsigned long end)
266{
267 /* Used for invalidating big chunks of I-cache, i.e. assume the range
268 is whole pages. If 'start' or 'end' is not page aligned, the code
269 is conservative and invalidates to the ends of the enclosing pages.
270 This is functionally OK, just a performance loss. */
271
272 /* See the comments below in sh64_dcache_purge_user_range() regarding
273 the choice of algorithm. However, for the I-cache option (2) isn't
274 available because there are no physical tags so aliases can't be
275 resolved. The icbi instruction has to be used through the user
276 mapping. Because icbi is cheaper than ocbp on a cache hit, it
277 would be cheaper to use the selective code for a large range than is
278 possible with the D-cache. Just assume 64 for now as a working
279 figure.
280 */
281
282 int n_pages;
283
284 if (!mm) return;
285
286 n_pages = ((end - start) >> PAGE_SHIFT);
287 if (n_pages >= 64) {
288 sh64_icache_inv_all();
289 } else {
290 unsigned long aligned_start;
291 unsigned long eaddr;
292 unsigned long after_last_page_start;
293 unsigned long mm_asid, current_asid;
294 unsigned long long flags = 0ULL;
295
296 mm_asid = mm->context & MMU_CONTEXT_ASID_MASK;
297 current_asid = get_asid();
298
299 if (mm_asid != current_asid) {
300 /* Switch ASID and run the invalidate loop under cli */
301 local_irq_save(flags);
302 switch_and_save_asid(mm_asid);
303 }
304
305 aligned_start = start & PAGE_MASK;
306 after_last_page_start = PAGE_SIZE + ((end - 1) & PAGE_MASK);
307
308 while (aligned_start < after_last_page_start) {
309 struct vm_area_struct *vma;
310 unsigned long vma_end;
311 vma = find_vma(mm, aligned_start);
312 if (!vma || (aligned_start <= vma->vm_end)) {
313 /* Avoid getting stuck in an error condition */
314 aligned_start += PAGE_SIZE;
315 continue;
316 }
317 vma_end = vma->vm_end;
318 if (vma->vm_flags & VM_EXEC) {
319 /* Executable */
320 eaddr = aligned_start;
321 while (eaddr < vma_end) {
322 sh64_icache_inv_user_page(vma, eaddr);
323 eaddr += PAGE_SIZE;
324 }
325 }
326 aligned_start = vma->vm_end; /* Skip to start of next region */
327 }
328 if (mm_asid != current_asid) {
329 switch_and_save_asid(current_asid);
330 local_irq_restore(flags);
331 }
332 }
333}
334
335static void sh64_icache_inv_user_small_range(struct mm_struct *mm,
336 unsigned long start, int len)
337{
338
339 /* Invalidate a small range of user context I-cache, not necessarily
340 page (or even cache-line) aligned. */
341
342 unsigned long long eaddr = start;
343 unsigned long long eaddr_end = start + len;
344 unsigned long current_asid, mm_asid;
345 unsigned long long flags;
346 unsigned long long epage_start;
347
348 /* Since this is used inside ptrace, the ASID in the mm context
349 typically won't match current_asid. We'll have to switch ASID to do
350 this. For safety, and given that the range will be small, do all
351 this under cli.
352
353 Note, there is a hazard that the ASID in mm->context is no longer
354 actually associated with mm, i.e. if the mm->context has started a
355 new cycle since mm was last active. However, this is just a
356 performance issue: all that happens is that we invalidate lines
357 belonging to another mm, so the owning process has to refill them
358 when that mm goes live again. mm itself can't have any cache
359 entries because there will have been a flush_cache_all when the new
360 mm->context cycle started. */
361
362 /* Align to start of cache line. Otherwise, suppose len==8 and start
363 was at 32N+28 : the last 4 bytes wouldn't get invalidated. */
364 eaddr = start & L1_CACHE_ALIGN_MASK;
365 eaddr_end = start + len;
366
367 local_irq_save(flags);
368 mm_asid = mm->context & MMU_CONTEXT_ASID_MASK;
369 current_asid = switch_and_save_asid(mm_asid);
370
371 epage_start = eaddr & PAGE_MASK;
372
373 while (eaddr < eaddr_end)
374 {
375 asm __volatile__("icbi %0, 0" : : "r" (eaddr));
376 eaddr += L1_CACHE_BYTES;
377 }
378 switch_and_save_asid(current_asid);
379 local_irq_restore(flags);
380}
381
382static void sh64_icache_inv_current_user_range(unsigned long start, unsigned long end)
383{
384 /* The icbi instruction never raises ITLBMISS. i.e. if there's not a
385 cache hit on the virtual tag the instruction ends there, without a
386 TLB lookup. */
387
388 unsigned long long aligned_start;
389 unsigned long long ull_end;
390 unsigned long long addr;
391
392 ull_end = end;
393
394 /* Just invalidate over the range using the natural addresses. TLB
395 miss handling will be OK (TBC). Since it's for the current process,
396 either we're already in the right ASID context, or the ASIDs have
397 been recycled since we were last active in which case we might just
398 invalidate another processes I-cache entries : no worries, just a
399 performance drop for him. */
400 aligned_start = start & L1_CACHE_ALIGN_MASK;
401 addr = aligned_start;
402 while (addr < ull_end) {
403 asm __volatile__ ("icbi %0, 0" : : "r" (addr));
404 asm __volatile__ ("nop");
405 asm __volatile__ ("nop");
406 addr += L1_CACHE_BYTES;
407 }
408}
409
410#endif /* !CONFIG_ICACHE_DISABLED */
411
412/****************************************************************************/
413
414#ifndef CONFIG_DCACHE_DISABLED
415
416/* Buffer used as the target of alloco instructions to purge data from cache
417 sets by natural eviction. -- RPC */
418#define DUMMY_ALLOCO_AREA_SIZE L1_CACHE_SIZE_BYTES + (1024 * 4)
419static unsigned char dummy_alloco_area[DUMMY_ALLOCO_AREA_SIZE] __cacheline_aligned = { 0, };
420
421/****************************************************************************/
422
423static void __inline__ sh64_dcache_purge_sets(int sets_to_purge_base, int n_sets)
424{
425 /* Purge all ways in a particular block of sets, specified by the base
426 set number and number of sets. Can handle wrap-around, if that's
427 needed. */
428
429 int dummy_buffer_base_set;
430 unsigned long long eaddr, eaddr0, eaddr1;
431 int j;
432 int set_offset;
433
434 dummy_buffer_base_set = ((int)&dummy_alloco_area & cpu_data->dcache.idx_mask) >> cpu_data->dcache.entry_shift;
435 set_offset = sets_to_purge_base - dummy_buffer_base_set;
436
437 for (j=0; j<n_sets; j++, set_offset++) {
438 set_offset &= (cpu_data->dcache.sets - 1);
439 eaddr0 = (unsigned long long)dummy_alloco_area + (set_offset << cpu_data->dcache.entry_shift);
440
441 /* Do one alloco which hits the required set per cache way. For
442 write-back mode, this will purge the #ways resident lines. There's
443 little point unrolling this loop because the allocos stall more if
444 they're too close together. */
445 eaddr1 = eaddr0 + cpu_data->dcache.way_ofs * cpu_data->dcache.ways;
446 for (eaddr=eaddr0; eaddr<eaddr1; eaddr+=cpu_data->dcache.way_ofs) {
447 asm __volatile__ ("alloco %0, 0" : : "r" (eaddr));
448 asm __volatile__ ("synco"); /* TAKum03020 */
449 }
450
451 eaddr1 = eaddr0 + cpu_data->dcache.way_ofs * cpu_data->dcache.ways;
452 for (eaddr=eaddr0; eaddr<eaddr1; eaddr+=cpu_data->dcache.way_ofs) {
453 /* Load from each address. Required because alloco is a NOP if
454 the cache is write-through. Write-through is a config option. */
455 if (test_bit(SH_CACHE_MODE_WT, &(cpu_data->dcache.flags)))
456 *(volatile unsigned char *)(int)eaddr;
457 }
458 }
459
460 /* Don't use OCBI to invalidate the lines. That costs cycles directly.
461 If the dummy block is just left resident, it will naturally get
462 evicted as required. */
463
464 return;
465}
466
467/****************************************************************************/
468
469static void sh64_dcache_purge_all(void)
470{
471 /* Purge the entire contents of the dcache. The most efficient way to
472 achieve this is to use alloco instructions on a region of unused
473 memory equal in size to the cache, thereby causing the current
474 contents to be discarded by natural eviction. The alternative,
475 namely reading every tag, setting up a mapping for the corresponding
476 page and doing an OCBP for the line, would be much more expensive.
477 */
478
479 sh64_dcache_purge_sets(0, cpu_data->dcache.sets);
480
481 return;
482
483}
484
485/****************************************************************************/
486
487static void sh64_dcache_purge_kernel_range(unsigned long start, unsigned long end)
488{
489 /* Purge the range of addresses [start,end] from the D-cache. The
490 addresses lie in the superpage mapping. There's no harm if we
491 overpurge at either end - just a small performance loss. */
492 unsigned long long ullend, addr, aligned_start;
493#if (NEFF == 32)
494 aligned_start = (unsigned long long)(signed long long)(signed long) start;
495#else
496#error "NEFF != 32"
497#endif
498 aligned_start &= L1_CACHE_ALIGN_MASK;
499 addr = aligned_start;
500#if (NEFF == 32)
501 ullend = (unsigned long long) (signed long long) (signed long) end;
502#else
503#error "NEFF != 32"
504#endif
505 while (addr <= ullend) {
506 asm __volatile__ ("ocbp %0, 0" : : "r" (addr));
507 addr += L1_CACHE_BYTES;
508 }
509 return;
510}
511
512/* Assumes this address (+ (2**n_synbits) pages up from it) aren't used for
513 anything else in the kernel */
514#define MAGIC_PAGE0_START 0xffffffffec000000ULL
515
516static void sh64_dcache_purge_coloured_phy_page(unsigned long paddr, unsigned long eaddr)
517{
518 /* Purge the physical page 'paddr' from the cache. It's known that any
519 cache lines requiring attention have the same page colour as the the
520 address 'eaddr'.
521
522 This relies on the fact that the D-cache matches on physical tags
523 when no virtual tag matches. So we create an alias for the original
524 page and purge through that. (Alternatively, we could have done
525 this by switching ASID to match the original mapping and purged
526 through that, but that involves ASID switching cost + probably a
527 TLBMISS + refill anyway.)
528 */
529
530 unsigned long long magic_page_start;
531 unsigned long long magic_eaddr, magic_eaddr_end;
532
533 magic_page_start = MAGIC_PAGE0_START + (eaddr & CACHE_OC_SYN_MASK);
534
535 /* As long as the kernel is not pre-emptible, this doesn't need to be
536 under cli/sti. */
537
538 sh64_setup_dtlb_cache_slot(magic_page_start, get_asid(), paddr);
539
540 magic_eaddr = magic_page_start;
541 magic_eaddr_end = magic_eaddr + PAGE_SIZE;
542 while (magic_eaddr < magic_eaddr_end) {
543 /* Little point in unrolling this loop - the OCBPs are blocking
544 and won't go any quicker (i.e. the loop overhead is parallel
545 to part of the OCBP execution.) */
546 asm __volatile__ ("ocbp %0, 0" : : "r" (magic_eaddr));
547 magic_eaddr += L1_CACHE_BYTES;
548 }
549
550 sh64_teardown_dtlb_cache_slot();
551}
552
553/****************************************************************************/
554
555static void sh64_dcache_purge_phy_page(unsigned long paddr)
556{
557 /* Pure a page given its physical start address, by creating a
558 temporary 1 page mapping and purging across that. Even if we know
559 the virtual address (& vma or mm) of the page, the method here is
560 more elegant because it avoids issues of coping with page faults on
561 the purge instructions (i.e. no special-case code required in the
562 critical path in the TLB miss handling). */
563
564 unsigned long long eaddr_start, eaddr, eaddr_end;
565 int i;
566
567 /* As long as the kernel is not pre-emptible, this doesn't need to be
568 under cli/sti. */
569
570 eaddr_start = MAGIC_PAGE0_START;
571 for (i=0; i < (1 << CACHE_OC_N_SYNBITS); i++) {
572 sh64_setup_dtlb_cache_slot(eaddr_start, get_asid(), paddr);
573
574 eaddr = eaddr_start;
575 eaddr_end = eaddr + PAGE_SIZE;
576 while (eaddr < eaddr_end) {
577 asm __volatile__ ("ocbp %0, 0" : : "r" (eaddr));
578 eaddr += L1_CACHE_BYTES;
579 }
580
581 sh64_teardown_dtlb_cache_slot();
582 eaddr_start += PAGE_SIZE;
583 }
584}
585
586static void sh64_dcache_purge_user_pages(struct mm_struct *mm,
587 unsigned long addr, unsigned long end)
588{
589 pgd_t *pgd;
590 pmd_t *pmd;
591 pte_t *pte;
592 pte_t entry;
593 spinlock_t *ptl;
594 unsigned long paddr;
595
596 if (!mm)
597 return; /* No way to find physical address of page */
598
599 pgd = pgd_offset(mm, addr);
600 if (pgd_bad(*pgd))
601 return;
602
603 pmd = pmd_offset(pgd, addr);
604 if (pmd_none(*pmd) || pmd_bad(*pmd))
605 return;
606
607 pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
608 do {
609 entry = *pte;
610 if (pte_none(entry) || !pte_present(entry))
611 continue;
612 paddr = pte_val(entry) & PAGE_MASK;
613 sh64_dcache_purge_coloured_phy_page(paddr, addr);
614 } while (pte++, addr += PAGE_SIZE, addr != end);
615 pte_unmap_unlock(pte - 1, ptl);
616}
617/****************************************************************************/
618
619static void sh64_dcache_purge_user_range(struct mm_struct *mm,
620 unsigned long start, unsigned long end)
621{
622 /* There are at least 5 choices for the implementation of this, with
623 pros (+), cons(-), comments(*):
624
625 1. ocbp each line in the range through the original user's ASID
626 + no lines spuriously evicted
627 - tlbmiss handling (must either handle faults on demand => extra
628 special-case code in tlbmiss critical path), or map the page in
629 advance (=> flush_tlb_range in advance to avoid multiple hits)
630 - ASID switching
631 - expensive for large ranges
632
633 2. temporarily map each page in the range to a special effective
634 address and ocbp through the temporary mapping; relies on the
635 fact that SH-5 OCB* always do TLB lookup and match on ptags (they
636 never look at the etags)
637 + no spurious evictions
638 - expensive for large ranges
639 * surely cheaper than (1)
640
641 3. walk all the lines in the cache, check the tags, if a match
642 occurs create a page mapping to ocbp the line through
643 + no spurious evictions
644 - tag inspection overhead
645 - (especially for small ranges)
646 - potential cost of setting up/tearing down page mapping for
647 every line that matches the range
648 * cost partly independent of range size
649
650 4. walk all the lines in the cache, check the tags, if a match
651 occurs use 4 * alloco to purge the line (+3 other probably
652 innocent victims) by natural eviction
653 + no tlb mapping overheads
654 - spurious evictions
655 - tag inspection overhead
656
657 5. implement like flush_cache_all
658 + no tag inspection overhead
659 - spurious evictions
660 - bad for small ranges
661
662 (1) can be ruled out as more expensive than (2). (2) appears best
663 for small ranges. The choice between (3), (4) and (5) for large
664 ranges and the range size for the large/small boundary need
665 benchmarking to determine.
666
667 For now use approach (2) for small ranges and (5) for large ones.
668
669 */
670
671 int n_pages;
672
673 n_pages = ((end - start) >> PAGE_SHIFT);
674 if (n_pages >= 64 || ((start ^ (end - 1)) & PMD_MASK)) {
675#if 1
676 sh64_dcache_purge_all();
677#else
678 unsigned long long set, way;
679 unsigned long mm_asid = mm->context & MMU_CONTEXT_ASID_MASK;
680 for (set = 0; set < cpu_data->dcache.sets; set++) {
681 unsigned long long set_base_config_addr = CACHE_OC_ADDRESS_ARRAY + (set << cpu_data->dcache.set_shift);
682 for (way = 0; way < cpu_data->dcache.ways; way++) {
683 unsigned long long config_addr = set_base_config_addr + (way << cpu_data->dcache.way_step_shift);
684 unsigned long long tag0;
685 unsigned long line_valid;
686
687 asm __volatile__("getcfg %1, 0, %0" : "=r" (tag0) : "r" (config_addr));
688 line_valid = tag0 & SH_CACHE_VALID;
689 if (line_valid) {
690 unsigned long cache_asid;
691 unsigned long epn;
692
693 cache_asid = (tag0 & cpu_data->dcache.asid_mask) >> cpu_data->dcache.asid_shift;
694 /* The next line needs some
695 explanation. The virtual tags
696 encode bits [31:13] of the virtual
697 address, bit [12] of the 'tag' being
698 implied by the cache set index. */
699 epn = (tag0 & cpu_data->dcache.epn_mask) | ((set & 0x80) << cpu_data->dcache.entry_shift);
700
701 if ((cache_asid == mm_asid) && (start <= epn) && (epn < end)) {
702 /* TODO : could optimise this
703 call by batching multiple
704 adjacent sets together. */
705 sh64_dcache_purge_sets(set, 1);
706 break; /* Don't waste time inspecting other ways for this set */
707 }
708 }
709 }
710 }
711#endif
712 } else {
713 /* Small range, covered by a single page table page */
714 start &= PAGE_MASK; /* should already be so */
715 end = PAGE_ALIGN(end); /* should already be so */
716 sh64_dcache_purge_user_pages(mm, start, end);
717 }
718 return;
719}
720
721static void sh64_dcache_wback_current_user_range(unsigned long start, unsigned long end)
722{
723 unsigned long long aligned_start;
724 unsigned long long ull_end;
725 unsigned long long addr;
726
727 ull_end = end;
728
729 /* Just wback over the range using the natural addresses. TLB miss
730 handling will be OK (TBC) : the range has just been written to by
731 the signal frame setup code, so the PTEs must exist.
732
733 Note, if we have CONFIG_PREEMPT and get preempted inside this loop,
734 it doesn't matter, even if the pid->ASID mapping changes whilst
735 we're away. In that case the cache will have been flushed when the
736 mapping was renewed. So the writebacks below will be nugatory (and
737 we'll doubtless have to fault the TLB entry/ies in again with the
738 new ASID), but it's a rare case.
739 */
740 aligned_start = start & L1_CACHE_ALIGN_MASK;
741 addr = aligned_start;
742 while (addr < ull_end) {
743 asm __volatile__ ("ocbwb %0, 0" : : "r" (addr));
744 addr += L1_CACHE_BYTES;
745 }
746}
747
748/****************************************************************************/
749
750/* These *MUST* lie in an area of virtual address space that's otherwise unused. */
751#define UNIQUE_EADDR_START 0xe0000000UL
752#define UNIQUE_EADDR_END 0xe8000000UL
753
754static unsigned long sh64_make_unique_eaddr(unsigned long user_eaddr, unsigned long paddr)
755{
756 /* Given a physical address paddr, and a user virtual address
757 user_eaddr which will eventually be mapped to it, create a one-off
758 kernel-private eaddr mapped to the same paddr. This is used for
759 creating special destination pages for copy_user_page and
760 clear_user_page */
761
762 static unsigned long current_pointer = UNIQUE_EADDR_START;
763 unsigned long coloured_pointer;
764
765 if (current_pointer == UNIQUE_EADDR_END) {
766 sh64_dcache_purge_all();
767 current_pointer = UNIQUE_EADDR_START;
768 }
769
770 coloured_pointer = (current_pointer & ~CACHE_OC_SYN_MASK) | (user_eaddr & CACHE_OC_SYN_MASK);
771 sh64_setup_dtlb_cache_slot(coloured_pointer, get_asid(), paddr);
772
773 current_pointer += (PAGE_SIZE << CACHE_OC_N_SYNBITS);
774
775 return coloured_pointer;
776}
777
778/****************************************************************************/
779
780static void sh64_copy_user_page_coloured(void *to, void *from, unsigned long address)
781{
782 void *coloured_to;
783
784 /* Discard any existing cache entries of the wrong colour. These are
785 present quite often, if the kernel has recently used the page
786 internally, then given it up, then it's been allocated to the user.
787 */
788 sh64_dcache_purge_coloured_phy_page(__pa(to), (unsigned long) to);
789
790 coloured_to = (void *) sh64_make_unique_eaddr(address, __pa(to));
791 sh64_page_copy(from, coloured_to);
792
793 sh64_teardown_dtlb_cache_slot();
794}
795
796static void sh64_clear_user_page_coloured(void *to, unsigned long address)
797{
798 void *coloured_to;
799
800 /* Discard any existing kernel-originated lines of the wrong colour (as
801 above) */
802 sh64_dcache_purge_coloured_phy_page(__pa(to), (unsigned long) to);
803
804 coloured_to = (void *) sh64_make_unique_eaddr(address, __pa(to));
805 sh64_page_clear(coloured_to);
806
807 sh64_teardown_dtlb_cache_slot();
808}
809
810#endif /* !CONFIG_DCACHE_DISABLED */
811
812/****************************************************************************/
813
814/*##########################################################################
815 EXTERNALLY CALLABLE API.
816 ##########################################################################*/
817
818/* These functions are described in Documentation/cachetlb.txt.
819 Each one of these functions varies in behaviour depending on whether the
820 I-cache and/or D-cache are configured out.
821
822 Note that the Linux term 'flush' corresponds to what is termed 'purge' in
823 the sh/sh64 jargon for the D-cache, i.e. write back dirty data then
824 invalidate the cache lines, and 'invalidate' for the I-cache.
825 */
826
827#undef FLUSH_TRACE
828
829void flush_cache_all(void)
830{
831 /* Invalidate the entire contents of both caches, after writing back to
832 memory any dirty data from the D-cache. */
833 sh64_dcache_purge_all();
834 sh64_icache_inv_all();
835}
836
837/****************************************************************************/
838
839void flush_cache_mm(struct mm_struct *mm)
840{
841 /* Invalidate an entire user-address space from both caches, after
842 writing back dirty data (e.g. for shared mmap etc). */
843
844 /* This could be coded selectively by inspecting all the tags then
845 doing 4*alloco on any set containing a match (as for
846 flush_cache_range), but fork/exit/execve (where this is called from)
847 are expensive anyway. */
848
849 /* Have to do a purge here, despite the comments re I-cache below.
850 There could be odd-coloured dirty data associated with the mm still
851 in the cache - if this gets written out through natural eviction
852 after the kernel has reused the page there will be chaos.
853 */
854
855 sh64_dcache_purge_all();
856
857 /* The mm being torn down won't ever be active again, so any Icache
858 lines tagged with its ASID won't be visible for the rest of the
859 lifetime of this ASID cycle. Before the ASID gets reused, there
860 will be a flush_cache_all. Hence we don't need to touch the
861 I-cache. This is similar to the lack of action needed in
862 flush_tlb_mm - see fault.c. */
863}
864
865/****************************************************************************/
866
867void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
868 unsigned long end)
869{
870 struct mm_struct *mm = vma->vm_mm;
871
872 /* Invalidate (from both caches) the range [start,end) of virtual
873 addresses from the user address space specified by mm, after writing
874 back any dirty data.
875
876 Note, 'end' is 1 byte beyond the end of the range to flush. */
877
878 sh64_dcache_purge_user_range(mm, start, end);
879 sh64_icache_inv_user_page_range(mm, start, end);
880}
881
882/****************************************************************************/
883
884void flush_cache_page(struct vm_area_struct *vma, unsigned long eaddr, unsigned long pfn)
885{
886 /* Invalidate any entries in either cache for the vma within the user
887 address space vma->vm_mm for the page starting at virtual address
888 'eaddr'. This seems to be used primarily in breaking COW. Note,
889 the I-cache must be searched too in case the page in question is
890 both writable and being executed from (e.g. stack trampolines.)
891
892 Note, this is called with pte lock held.
893 */
894
895 sh64_dcache_purge_phy_page(pfn << PAGE_SHIFT);
896
897 if (vma->vm_flags & VM_EXEC) {
898 sh64_icache_inv_user_page(vma, eaddr);
899 }
900}
901
902/****************************************************************************/
903
904#ifndef CONFIG_DCACHE_DISABLED
905
906void copy_user_page(void *to, void *from, unsigned long address, struct page *page)
907{
908 /* 'from' and 'to' are kernel virtual addresses (within the superpage
909 mapping of the physical RAM). 'address' is the user virtual address
910 where the copy 'to' will be mapped after. This allows a custom
911 mapping to be used to ensure that the new copy is placed in the
912 right cache sets for the user to see it without having to bounce it
913 out via memory. Note however : the call to flush_page_to_ram in
914 (generic)/mm/memory.c:(break_cow) undoes all this good work in that one
915 very important case!
916
917 TBD : can we guarantee that on every call, any cache entries for
918 'from' are in the same colour sets as 'address' also? i.e. is this
919 always used just to deal with COW? (I suspect not). */
920
921 /* There are two possibilities here for when the page 'from' was last accessed:
922 * by the kernel : this is OK, no purge required.
923 * by the/a user (e.g. for break_COW) : need to purge.
924
925 If the potential user mapping at 'address' is the same colour as
926 'from' there is no need to purge any cache lines from the 'from'
927 page mapped into cache sets of colour 'address'. (The copy will be
928 accessing the page through 'from').
929 */
930
931 if (((address ^ (unsigned long) from) & CACHE_OC_SYN_MASK) != 0) {
932 sh64_dcache_purge_coloured_phy_page(__pa(from), address);
933 }
934
935 if (((address ^ (unsigned long) to) & CACHE_OC_SYN_MASK) == 0) {
936 /* No synonym problem on destination */
937 sh64_page_copy(from, to);
938 } else {
939 sh64_copy_user_page_coloured(to, from, address);
940 }
941
942 /* Note, don't need to flush 'from' page from the cache again - it's
943 done anyway by the generic code */
944}
945
946void clear_user_page(void *to, unsigned long address, struct page *page)
947{
948 /* 'to' is a kernel virtual address (within the superpage
949 mapping of the physical RAM). 'address' is the user virtual address
950 where the 'to' page will be mapped after. This allows a custom
951 mapping to be used to ensure that the new copy is placed in the
952 right cache sets for the user to see it without having to bounce it
953 out via memory.
954 */
955
956 if (((address ^ (unsigned long) to) & CACHE_OC_SYN_MASK) == 0) {
957 /* No synonym problem on destination */
958 sh64_page_clear(to);
959 } else {
960 sh64_clear_user_page_coloured(to, address);
961 }
962}
963
964#endif /* !CONFIG_DCACHE_DISABLED */
965
966/****************************************************************************/
967
968void flush_dcache_page(struct page *page)
969{
970 sh64_dcache_purge_phy_page(page_to_phys(page));
971 wmb();
972}
973
974/****************************************************************************/
975
976void flush_icache_range(unsigned long start, unsigned long end)
977{
978 /* Flush the range [start,end] of kernel virtual adddress space from
979 the I-cache. The corresponding range must be purged from the
980 D-cache also because the SH-5 doesn't have cache snooping between
981 the caches. The addresses will be visible through the superpage
982 mapping, therefore it's guaranteed that there no cache entries for
983 the range in cache sets of the wrong colour.
984
985 Primarily used for cohering the I-cache after a module has
986 been loaded. */
987
988 /* We also make sure to purge the same range from the D-cache since
989 flush_page_to_ram() won't be doing this for us! */
990
991 sh64_dcache_purge_kernel_range(start, end);
992 wmb();
993 sh64_icache_inv_kernel_range(start, end);
994}
995
996/****************************************************************************/
997
998void flush_icache_user_range(struct vm_area_struct *vma,
999 struct page *page, unsigned long addr, int len)
1000{
1001 /* Flush the range of user (defined by vma->vm_mm) address space
1002 starting at 'addr' for 'len' bytes from the cache. The range does
1003 not straddle a page boundary, the unique physical page containing
1004 the range is 'page'. This seems to be used mainly for invalidating
1005 an address range following a poke into the program text through the
1006 ptrace() call from another process (e.g. for BRK instruction
1007 insertion). */
1008
1009 sh64_dcache_purge_coloured_phy_page(page_to_phys(page), addr);
1010 mb();
1011
1012 if (vma->vm_flags & VM_EXEC) {
1013 sh64_icache_inv_user_small_range(vma->vm_mm, addr, len);
1014 }
1015}
1016
1017/*##########################################################################
1018 ARCH/SH64 PRIVATE CALLABLE API.
1019 ##########################################################################*/
1020
1021void flush_cache_sigtramp(unsigned long start, unsigned long end)
1022{
1023 /* For the address range [start,end), write back the data from the
1024 D-cache and invalidate the corresponding region of the I-cache for
1025 the current process. Used to flush signal trampolines on the stack
1026 to make them executable. */
1027
1028 sh64_dcache_wback_current_user_range(start, end);
1029 wmb();
1030 sh64_icache_inv_current_user_range(start, end);
1031}
1032
diff --git a/arch/sh64/mm/consistent.c b/arch/sh64/mm/consistent.c
deleted file mode 100644
index c439620402cb..000000000000
--- a/arch/sh64/mm/consistent.c
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
3 * Copyright (C) 2003 Paul Mundt (lethal@linux-sh.org)
4 *
5 * May be copied or modified under the terms of the GNU General Public
6 * License. See linux/COPYING for more information.
7 *
8 * Dynamic DMA mapping support.
9 */
10#include <linux/types.h>
11#include <linux/mm.h>
12#include <linux/string.h>
13#include <linux/pci.h>
14#include <linux/dma-mapping.h>
15#include <linux/module.h>
16#include <asm/io.h>
17
18void *consistent_alloc(struct pci_dev *hwdev, size_t size,
19 dma_addr_t *dma_handle)
20{
21 void *ret;
22 int gfp = GFP_ATOMIC;
23 void *vp;
24
25 if (hwdev == NULL || hwdev->dma_mask != 0xffffffff)
26 gfp |= GFP_DMA;
27
28 ret = (void *)__get_free_pages(gfp, get_order(size));
29
30 /* now call our friend ioremap_nocache to give us an uncached area */
31 vp = ioremap_nocache(virt_to_phys(ret), size);
32
33 if (vp != NULL) {
34 memset(vp, 0, size);
35 *dma_handle = virt_to_phys(ret);
36 dma_cache_sync(NULL, ret, size, DMA_BIDIRECTIONAL);
37 }
38
39 return vp;
40}
41EXPORT_SYMBOL(consistent_alloc);
42
43void consistent_free(struct pci_dev *hwdev, size_t size,
44 void *vaddr, dma_addr_t dma_handle)
45{
46 void *alloc;
47
48 alloc = phys_to_virt((unsigned long)dma_handle);
49 free_pages((unsigned long)alloc, get_order(size));
50
51 iounmap(vaddr);
52}
53EXPORT_SYMBOL(consistent_free);
diff --git a/arch/sh64/mm/extable.c b/arch/sh64/mm/extable.c
deleted file mode 100644
index a2e6e0563772..000000000000
--- a/arch/sh64/mm/extable.c
+++ /dev/null
@@ -1,80 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/mm/extable.c
7 *
8 * Copyright (C) 2003 Richard Curnow
9 * Copyright (C) 2003, 2004 Paul Mundt
10 *
11 * Cloned from the 2.5 SH version..
12 */
13#include <linux/rwsem.h>
14#include <linux/module.h>
15#include <asm/uaccess.h>
16
17extern unsigned long copy_user_memcpy, copy_user_memcpy_end;
18extern void __copy_user_fixup(void);
19
20static const struct exception_table_entry __copy_user_fixup_ex = {
21 .fixup = (unsigned long)&__copy_user_fixup,
22};
23
24/* Some functions that may trap due to a bad user-mode address have too many loads
25 and stores in them to make it at all practical to label each one and put them all in
26 the main exception table.
27
28 In particular, the fast memcpy routine is like this. It's fix-up is just to fall back
29 to a slow byte-at-a-time copy, which is handled the conventional way. So it's functionally
30 OK to just handle any trap occurring in the fast memcpy with that fixup. */
31static const struct exception_table_entry *check_exception_ranges(unsigned long addr)
32{
33 if ((addr >= (unsigned long)&copy_user_memcpy) &&
34 (addr <= (unsigned long)&copy_user_memcpy_end))
35 return &__copy_user_fixup_ex;
36
37 return NULL;
38}
39
40/* Simple binary search */
41const struct exception_table_entry *
42search_extable(const struct exception_table_entry *first,
43 const struct exception_table_entry *last,
44 unsigned long value)
45{
46 const struct exception_table_entry *mid;
47
48 mid = check_exception_ranges(value);
49 if (mid)
50 return mid;
51
52 while (first <= last) {
53 long diff;
54
55 mid = (last - first) / 2 + first;
56 diff = mid->insn - value;
57 if (diff == 0)
58 return mid;
59 else if (diff < 0)
60 first = mid+1;
61 else
62 last = mid-1;
63 }
64
65 return NULL;
66}
67
68int fixup_exception(struct pt_regs *regs)
69{
70 const struct exception_table_entry *fixup;
71
72 fixup = search_exception_tables(regs->pc);
73 if (fixup) {
74 regs->pc = fixup->fixup;
75 return 1;
76 }
77
78 return 0;
79}
80
diff --git a/arch/sh64/mm/fault.c b/arch/sh64/mm/fault.c
deleted file mode 100644
index 7c79a1ba8059..000000000000
--- a/arch/sh64/mm/fault.c
+++ /dev/null
@@ -1,602 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/mm/fault.c
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003 Richard Curnow (/proc/tlb, bug fixes)
10 * Copyright (C) 2003 Paul Mundt
11 *
12 */
13
14#include <linux/signal.h>
15#include <linux/rwsem.h>
16#include <linux/sched.h>
17#include <linux/kernel.h>
18#include <linux/errno.h>
19#include <linux/string.h>
20#include <linux/types.h>
21#include <linux/ptrace.h>
22#include <linux/mman.h>
23#include <linux/mm.h>
24#include <linux/smp.h>
25#include <linux/interrupt.h>
26
27#include <asm/system.h>
28#include <asm/io.h>
29#include <asm/tlb.h>
30#include <asm/uaccess.h>
31#include <asm/pgalloc.h>
32#include <asm/mmu_context.h>
33#include <asm/registers.h> /* required by inline asm statements */
34
35#if defined(CONFIG_SH64_PROC_TLB)
36#include <linux/init.h>
37#include <linux/proc_fs.h>
38/* Count numbers of tlb refills in each region */
39static unsigned long long calls_to_update_mmu_cache = 0ULL;
40static unsigned long long calls_to_flush_tlb_page = 0ULL;
41static unsigned long long calls_to_flush_tlb_range = 0ULL;
42static unsigned long long calls_to_flush_tlb_mm = 0ULL;
43static unsigned long long calls_to_flush_tlb_all = 0ULL;
44unsigned long long calls_to_do_slow_page_fault = 0ULL;
45unsigned long long calls_to_do_fast_page_fault = 0ULL;
46
47/* Count size of ranges for flush_tlb_range */
48static unsigned long long flush_tlb_range_1 = 0ULL;
49static unsigned long long flush_tlb_range_2 = 0ULL;
50static unsigned long long flush_tlb_range_3_4 = 0ULL;
51static unsigned long long flush_tlb_range_5_7 = 0ULL;
52static unsigned long long flush_tlb_range_8_11 = 0ULL;
53static unsigned long long flush_tlb_range_12_15 = 0ULL;
54static unsigned long long flush_tlb_range_16_up = 0ULL;
55
56static unsigned long long page_not_present = 0ULL;
57
58#endif
59
60extern void die(const char *,struct pt_regs *,long);
61
62#define PFLAG(val,flag) (( (val) & (flag) ) ? #flag : "" )
63#define PPROT(flag) PFLAG(pgprot_val(prot),flag)
64
65static inline void print_prots(pgprot_t prot)
66{
67 printk("prot is 0x%08lx\n",pgprot_val(prot));
68
69 printk("%s %s %s %s %s\n",PPROT(_PAGE_SHARED),PPROT(_PAGE_READ),
70 PPROT(_PAGE_EXECUTE),PPROT(_PAGE_WRITE),PPROT(_PAGE_USER));
71}
72
73static inline void print_vma(struct vm_area_struct *vma)
74{
75 printk("vma start 0x%08lx\n", vma->vm_start);
76 printk("vma end 0x%08lx\n", vma->vm_end);
77
78 print_prots(vma->vm_page_prot);
79 printk("vm_flags 0x%08lx\n", vma->vm_flags);
80}
81
82static inline void print_task(struct task_struct *tsk)
83{
84 printk("Task pid %d\n", task_pid_nr(tsk));
85}
86
87static pte_t *lookup_pte(struct mm_struct *mm, unsigned long address)
88{
89 pgd_t *dir;
90 pmd_t *pmd;
91 pte_t *pte;
92 pte_t entry;
93
94 dir = pgd_offset(mm, address);
95 if (pgd_none(*dir)) {
96 return NULL;
97 }
98
99 pmd = pmd_offset(dir, address);
100 if (pmd_none(*pmd)) {
101 return NULL;
102 }
103
104 pte = pte_offset_kernel(pmd, address);
105 entry = *pte;
106
107 if (pte_none(entry)) {
108 return NULL;
109 }
110 if (!pte_present(entry)) {
111 return NULL;
112 }
113
114 return pte;
115}
116
117/*
118 * This routine handles page faults. It determines the address,
119 * and the problem, and then passes it off to one of the appropriate
120 * routines.
121 */
122asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
123 unsigned long textaccess, unsigned long address)
124{
125 struct task_struct *tsk;
126 struct mm_struct *mm;
127 struct vm_area_struct * vma;
128 const struct exception_table_entry *fixup;
129 pte_t *pte;
130 int fault;
131
132#if defined(CONFIG_SH64_PROC_TLB)
133 ++calls_to_do_slow_page_fault;
134#endif
135
136 /* SIM
137 * Note this is now called with interrupts still disabled
138 * This is to cope with being called for a missing IO port
139 * address with interrupts disabled. This should be fixed as
140 * soon as we have a better 'fast path' miss handler.
141 *
142 * Plus take care how you try and debug this stuff.
143 * For example, writing debug data to a port which you
144 * have just faulted on is not going to work.
145 */
146
147 tsk = current;
148 mm = tsk->mm;
149
150 /* Not an IO address, so reenable interrupts */
151 local_irq_enable();
152
153 /*
154 * If we're in an interrupt or have no user
155 * context, we must not take the fault..
156 */
157 if (in_atomic() || !mm)
158 goto no_context;
159
160 /* TLB misses upon some cache flushes get done under cli() */
161 down_read(&mm->mmap_sem);
162
163 vma = find_vma(mm, address);
164
165 if (!vma) {
166#ifdef DEBUG_FAULT
167 print_task(tsk);
168 printk("%s:%d fault, address is 0x%08x PC %016Lx textaccess %d writeaccess %d\n",
169 __FUNCTION__,__LINE__,
170 address,regs->pc,textaccess,writeaccess);
171 show_regs(regs);
172#endif
173 goto bad_area;
174 }
175 if (vma->vm_start <= address) {
176 goto good_area;
177 }
178
179 if (!(vma->vm_flags & VM_GROWSDOWN)) {
180#ifdef DEBUG_FAULT
181 print_task(tsk);
182 printk("%s:%d fault, address is 0x%08x PC %016Lx textaccess %d writeaccess %d\n",
183 __FUNCTION__,__LINE__,
184 address,regs->pc,textaccess,writeaccess);
185 show_regs(regs);
186
187 print_vma(vma);
188#endif
189 goto bad_area;
190 }
191 if (expand_stack(vma, address)) {
192#ifdef DEBUG_FAULT
193 print_task(tsk);
194 printk("%s:%d fault, address is 0x%08x PC %016Lx textaccess %d writeaccess %d\n",
195 __FUNCTION__,__LINE__,
196 address,regs->pc,textaccess,writeaccess);
197 show_regs(regs);
198#endif
199 goto bad_area;
200 }
201/*
202 * Ok, we have a good vm_area for this memory access, so
203 * we can handle it..
204 */
205good_area:
206 if (textaccess) {
207 if (!(vma->vm_flags & VM_EXEC))
208 goto bad_area;
209 } else {
210 if (writeaccess) {
211 if (!(vma->vm_flags & VM_WRITE))
212 goto bad_area;
213 } else {
214 if (!(vma->vm_flags & VM_READ))
215 goto bad_area;
216 }
217 }
218
219 /*
220 * If for any reason at all we couldn't handle the fault,
221 * make sure we exit gracefully rather than endlessly redo
222 * the fault.
223 */
224survive:
225 fault = handle_mm_fault(mm, vma, address, writeaccess);
226 if (unlikely(fault & VM_FAULT_ERROR)) {
227 if (fault & VM_FAULT_OOM)
228 goto out_of_memory;
229 else if (fault & VM_FAULT_SIGBUS)
230 goto do_sigbus;
231 BUG();
232 }
233 if (fault & VM_FAULT_MAJOR)
234 tsk->maj_flt++;
235 else
236 tsk->min_flt++;
237
238 /* If we get here, the page fault has been handled. Do the TLB refill
239 now from the newly-setup PTE, to avoid having to fault again right
240 away on the same instruction. */
241 pte = lookup_pte (mm, address);
242 if (!pte) {
243 /* From empirical evidence, we can get here, due to
244 !pte_present(pte). (e.g. if a swap-in occurs, and the page
245 is swapped back out again before the process that wanted it
246 gets rescheduled?) */
247 goto no_pte;
248 }
249
250 __do_tlb_refill(address, textaccess, pte);
251
252no_pte:
253
254 up_read(&mm->mmap_sem);
255 return;
256
257/*
258 * Something tried to access memory that isn't in our memory map..
259 * Fix it, but check if it's kernel or user first..
260 */
261bad_area:
262#ifdef DEBUG_FAULT
263 printk("fault:bad area\n");
264#endif
265 up_read(&mm->mmap_sem);
266
267 if (user_mode(regs)) {
268 static int count=0;
269 siginfo_t info;
270 if (count < 4) {
271 /* This is really to help debug faults when starting
272 * usermode, so only need a few */
273 count++;
274 printk("user mode bad_area address=%08lx pid=%d (%s) pc=%08lx\n",
275 address, task_pid_nr(current), current->comm,
276 (unsigned long) regs->pc);
277#if 0
278 show_regs(regs);
279#endif
280 }
281 if (is_global_init(tsk)) {
282 panic("INIT had user mode bad_area\n");
283 }
284 tsk->thread.address = address;
285 tsk->thread.error_code = writeaccess;
286 info.si_signo = SIGSEGV;
287 info.si_errno = 0;
288 info.si_addr = (void *) address;
289 force_sig_info(SIGSEGV, &info, tsk);
290 return;
291 }
292
293no_context:
294#ifdef DEBUG_FAULT
295 printk("fault:No context\n");
296#endif
297 /* Are we prepared to handle this kernel fault? */
298 fixup = search_exception_tables(regs->pc);
299 if (fixup) {
300 regs->pc = fixup->fixup;
301 return;
302 }
303
304/*
305 * Oops. The kernel tried to access some bad page. We'll have to
306 * terminate things with extreme prejudice.
307 *
308 */
309 if (address < PAGE_SIZE)
310 printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
311 else
312 printk(KERN_ALERT "Unable to handle kernel paging request");
313 printk(" at virtual address %08lx\n", address);
314 printk(KERN_ALERT "pc = %08Lx%08Lx\n", regs->pc >> 32, regs->pc & 0xffffffff);
315 die("Oops", regs, writeaccess);
316 do_exit(SIGKILL);
317
318/*
319 * We ran out of memory, or some other thing happened to us that made
320 * us unable to handle the page fault gracefully.
321 */
322out_of_memory:
323 if (is_global_init(current)) {
324 panic("INIT out of memory\n");
325 yield();
326 goto survive;
327 }
328 printk("fault:Out of memory\n");
329 up_read(&mm->mmap_sem);
330 if (is_global_init(current)) {
331 yield();
332 down_read(&mm->mmap_sem);
333 goto survive;
334 }
335 printk("VM: killing process %s\n", tsk->comm);
336 if (user_mode(regs))
337 do_group_exit(SIGKILL);
338 goto no_context;
339
340do_sigbus:
341 printk("fault:Do sigbus\n");
342 up_read(&mm->mmap_sem);
343
344 /*
345 * Send a sigbus, regardless of whether we were in kernel
346 * or user mode.
347 */
348 tsk->thread.address = address;
349 tsk->thread.error_code = writeaccess;
350 tsk->thread.trap_no = 14;
351 force_sig(SIGBUS, tsk);
352
353 /* Kernel mode? Handle exceptions or die */
354 if (!user_mode(regs))
355 goto no_context;
356}
357
358
359void flush_tlb_all(void);
360
361void update_mmu_cache(struct vm_area_struct * vma,
362 unsigned long address, pte_t pte)
363{
364#if defined(CONFIG_SH64_PROC_TLB)
365 ++calls_to_update_mmu_cache;
366#endif
367
368 /*
369 * This appears to get called once for every pte entry that gets
370 * established => I don't think it's efficient to try refilling the
371 * TLBs with the pages - some may not get accessed even. Also, for
372 * executable pages, it is impossible to determine reliably here which
373 * TLB they should be mapped into (or both even).
374 *
375 * So, just do nothing here and handle faults on demand. In the
376 * TLBMISS handling case, the refill is now done anyway after the pte
377 * has been fixed up, so that deals with most useful cases.
378 */
379}
380
381static void __flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
382{
383 unsigned long long match, pteh=0, lpage;
384 unsigned long tlb;
385 struct mm_struct *mm;
386
387 mm = vma->vm_mm;
388
389 if (mm->context == NO_CONTEXT)
390 return;
391
392 /*
393 * Sign-extend based on neff.
394 */
395 lpage = (page & NEFF_SIGN) ? (page | NEFF_MASK) : page;
396 match = ((mm->context & MMU_CONTEXT_ASID_MASK) << PTEH_ASID_SHIFT) | PTEH_VALID;
397 match |= lpage;
398
399 /* Do ITLB : don't bother for pages in non-exectutable VMAs */
400 if (vma->vm_flags & VM_EXEC) {
401 for_each_itlb_entry(tlb) {
402 asm volatile ("getcfg %1, 0, %0"
403 : "=r" (pteh)
404 : "r" (tlb) );
405
406 if (pteh == match) {
407 __flush_tlb_slot(tlb);
408 break;
409 }
410
411 }
412 }
413
414 /* Do DTLB : any page could potentially be in here. */
415 for_each_dtlb_entry(tlb) {
416 asm volatile ("getcfg %1, 0, %0"
417 : "=r" (pteh)
418 : "r" (tlb) );
419
420 if (pteh == match) {
421 __flush_tlb_slot(tlb);
422 break;
423 }
424
425 }
426}
427
428void flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
429{
430 unsigned long flags;
431
432#if defined(CONFIG_SH64_PROC_TLB)
433 ++calls_to_flush_tlb_page;
434#endif
435
436 if (vma->vm_mm) {
437 page &= PAGE_MASK;
438 local_irq_save(flags);
439 __flush_tlb_page(vma, page);
440 local_irq_restore(flags);
441 }
442}
443
444void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
445 unsigned long end)
446{
447 unsigned long flags;
448 unsigned long long match, pteh=0, pteh_epn, pteh_low;
449 unsigned long tlb;
450 struct mm_struct *mm;
451
452 mm = vma->vm_mm;
453
454#if defined(CONFIG_SH64_PROC_TLB)
455 ++calls_to_flush_tlb_range;
456
457 {
458 unsigned long size = (end - 1) - start;
459 size >>= 12; /* divide by PAGE_SIZE */
460 size++; /* end=start+4096 => 1 page */
461 switch (size) {
462 case 1 : flush_tlb_range_1++; break;
463 case 2 : flush_tlb_range_2++; break;
464 case 3 ... 4 : flush_tlb_range_3_4++; break;
465 case 5 ... 7 : flush_tlb_range_5_7++; break;
466 case 8 ... 11 : flush_tlb_range_8_11++; break;
467 case 12 ... 15 : flush_tlb_range_12_15++; break;
468 default : flush_tlb_range_16_up++; break;
469 }
470 }
471#endif
472
473 if (mm->context == NO_CONTEXT)
474 return;
475
476 local_irq_save(flags);
477
478 start &= PAGE_MASK;
479 end &= PAGE_MASK;
480
481 match = ((mm->context & MMU_CONTEXT_ASID_MASK) << PTEH_ASID_SHIFT) | PTEH_VALID;
482
483 /* Flush ITLB */
484 for_each_itlb_entry(tlb) {
485 asm volatile ("getcfg %1, 0, %0"
486 : "=r" (pteh)
487 : "r" (tlb) );
488
489 pteh_epn = pteh & PAGE_MASK;
490 pteh_low = pteh & ~PAGE_MASK;
491
492 if (pteh_low == match && pteh_epn >= start && pteh_epn <= end)
493 __flush_tlb_slot(tlb);
494 }
495
496 /* Flush DTLB */
497 for_each_dtlb_entry(tlb) {
498 asm volatile ("getcfg %1, 0, %0"
499 : "=r" (pteh)
500 : "r" (tlb) );
501
502 pteh_epn = pteh & PAGE_MASK;
503 pteh_low = pteh & ~PAGE_MASK;
504
505 if (pteh_low == match && pteh_epn >= start && pteh_epn <= end)
506 __flush_tlb_slot(tlb);
507 }
508
509 local_irq_restore(flags);
510}
511
512void flush_tlb_mm(struct mm_struct *mm)
513{
514 unsigned long flags;
515
516#if defined(CONFIG_SH64_PROC_TLB)
517 ++calls_to_flush_tlb_mm;
518#endif
519
520 if (mm->context == NO_CONTEXT)
521 return;
522
523 local_irq_save(flags);
524
525 mm->context=NO_CONTEXT;
526 if(mm==current->mm)
527 activate_context(mm);
528
529 local_irq_restore(flags);
530
531}
532
533void flush_tlb_all(void)
534{
535 /* Invalidate all, including shared pages, excluding fixed TLBs */
536
537 unsigned long flags, tlb;
538
539#if defined(CONFIG_SH64_PROC_TLB)
540 ++calls_to_flush_tlb_all;
541#endif
542
543 local_irq_save(flags);
544
545 /* Flush each ITLB entry */
546 for_each_itlb_entry(tlb) {
547 __flush_tlb_slot(tlb);
548 }
549
550 /* Flush each DTLB entry */
551 for_each_dtlb_entry(tlb) {
552 __flush_tlb_slot(tlb);
553 }
554
555 local_irq_restore(flags);
556}
557
558void flush_tlb_kernel_range(unsigned long start, unsigned long end)
559{
560 /* FIXME: Optimize this later.. */
561 flush_tlb_all();
562}
563
564#if defined(CONFIG_SH64_PROC_TLB)
565/* Procfs interface to read the performance information */
566
567static int
568tlb_proc_info(char *buf, char **start, off_t fpos, int length, int *eof, void *data)
569{
570 int len=0;
571 len += sprintf(buf+len, "do_fast_page_fault called %12lld times\n", calls_to_do_fast_page_fault);
572 len += sprintf(buf+len, "do_slow_page_fault called %12lld times\n", calls_to_do_slow_page_fault);
573 len += sprintf(buf+len, "update_mmu_cache called %12lld times\n", calls_to_update_mmu_cache);
574 len += sprintf(buf+len, "flush_tlb_page called %12lld times\n", calls_to_flush_tlb_page);
575 len += sprintf(buf+len, "flush_tlb_range called %12lld times\n", calls_to_flush_tlb_range);
576 len += sprintf(buf+len, "flush_tlb_mm called %12lld times\n", calls_to_flush_tlb_mm);
577 len += sprintf(buf+len, "flush_tlb_all called %12lld times\n", calls_to_flush_tlb_all);
578 len += sprintf(buf+len, "flush_tlb_range_sizes\n"
579 " 1 : %12lld\n"
580 " 2 : %12lld\n"
581 " 3 - 4 : %12lld\n"
582 " 5 - 7 : %12lld\n"
583 " 8 - 11 : %12lld\n"
584 "12 - 15 : %12lld\n"
585 "16+ : %12lld\n",
586 flush_tlb_range_1, flush_tlb_range_2, flush_tlb_range_3_4,
587 flush_tlb_range_5_7, flush_tlb_range_8_11, flush_tlb_range_12_15,
588 flush_tlb_range_16_up);
589 len += sprintf(buf+len, "page not present %12lld times\n", page_not_present);
590 *eof = 1;
591 return len;
592}
593
594static int __init register_proc_tlb(void)
595{
596 create_proc_read_entry("tlb", 0, NULL, tlb_proc_info, NULL);
597 return 0;
598}
599
600__initcall(register_proc_tlb);
601
602#endif
diff --git a/arch/sh64/mm/hugetlbpage.c b/arch/sh64/mm/hugetlbpage.c
deleted file mode 100644
index fa66daa2dfa9..000000000000
--- a/arch/sh64/mm/hugetlbpage.c
+++ /dev/null
@@ -1,105 +0,0 @@
1/*
2 * arch/sh64/mm/hugetlbpage.c
3 *
4 * SuperH HugeTLB page support.
5 *
6 * Cloned from sparc64 by Paul Mundt.
7 *
8 * Copyright (C) 2002, 2003 David S. Miller (davem@redhat.com)
9 */
10
11#include <linux/init.h>
12#include <linux/fs.h>
13#include <linux/mm.h>
14#include <linux/hugetlb.h>
15#include <linux/pagemap.h>
16#include <linux/slab.h>
17#include <linux/sysctl.h>
18
19#include <asm/mman.h>
20#include <asm/pgalloc.h>
21#include <asm/tlb.h>
22#include <asm/tlbflush.h>
23#include <asm/cacheflush.h>
24
25pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
26{
27 pgd_t *pgd;
28 pmd_t *pmd;
29 pte_t *pte = NULL;
30
31 pgd = pgd_offset(mm, addr);
32 if (pgd) {
33 pmd = pmd_alloc(mm, pgd, addr);
34 if (pmd)
35 pte = pte_alloc_map(mm, pmd, addr);
36 }
37 return pte;
38}
39
40pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
41{
42 pgd_t *pgd;
43 pmd_t *pmd;
44 pte_t *pte = NULL;
45
46 pgd = pgd_offset(mm, addr);
47 if (pgd) {
48 pmd = pmd_offset(pgd, addr);
49 if (pmd)
50 pte = pte_offset_map(pmd, addr);
51 }
52 return pte;
53}
54
55int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
56{
57 return 0;
58}
59
60void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
61 pte_t *ptep, pte_t entry)
62{
63 int i;
64
65 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
66 set_pte_at(mm, addr, ptep, entry);
67 ptep++;
68 addr += PAGE_SIZE;
69 pte_val(entry) += PAGE_SIZE;
70 }
71}
72
73pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
74 pte_t *ptep)
75{
76 pte_t entry;
77 int i;
78
79 entry = *ptep;
80
81 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
82 pte_clear(mm, addr, ptep);
83 addr += PAGE_SIZE;
84 ptep++;
85 }
86
87 return entry;
88}
89
90struct page *follow_huge_addr(struct mm_struct *mm,
91 unsigned long address, int write)
92{
93 return ERR_PTR(-EINVAL);
94}
95
96int pmd_huge(pmd_t pmd)
97{
98 return 0;
99}
100
101struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
102 pmd_t *pmd, int write)
103{
104 return NULL;
105}
diff --git a/arch/sh64/mm/init.c b/arch/sh64/mm/init.c
deleted file mode 100644
index 21cf42de23e2..000000000000
--- a/arch/sh64/mm/init.c
+++ /dev/null
@@ -1,189 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/mm/init.c
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003, 2004 Paul Mundt
10 *
11 */
12
13#include <linux/init.h>
14#include <linux/rwsem.h>
15#include <linux/mm.h>
16#include <linux/swap.h>
17#include <linux/bootmem.h>
18
19#include <asm/mmu_context.h>
20#include <asm/page.h>
21#include <asm/pgalloc.h>
22#include <asm/pgtable.h>
23#include <asm/tlb.h>
24
25DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
26
27/*
28 * Cache of MMU context last used.
29 */
30unsigned long mmu_context_cache;
31pgd_t * mmu_pdtp_cache;
32int after_bootmem = 0;
33
34/*
35 * BAD_PAGE is the page that is used for page faults when linux
36 * is out-of-memory. Older versions of linux just did a
37 * do_exit(), but using this instead means there is less risk
38 * for a process dying in kernel mode, possibly leaving an inode
39 * unused etc..
40 *
41 * BAD_PAGETABLE is the accompanying page-table: it is initialized
42 * to point to BAD_PAGE entries.
43 *
44 * ZERO_PAGE is a special page that is used for zero-initialized
45 * data and COW.
46 */
47
48extern unsigned char empty_zero_page[PAGE_SIZE];
49extern unsigned char empty_bad_page[PAGE_SIZE];
50extern pte_t empty_bad_pte_table[PTRS_PER_PTE];
51extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
52
53extern char _text, _etext, _edata, __bss_start, _end;
54extern char __init_begin, __init_end;
55
56/* It'd be good if these lines were in the standard header file. */
57#define START_PFN (NODE_DATA(0)->bdata->node_boot_start >> PAGE_SHIFT)
58#define MAX_LOW_PFN (NODE_DATA(0)->bdata->node_low_pfn)
59
60
61void show_mem(void)
62{
63 int i, total = 0, reserved = 0;
64 int shared = 0, cached = 0;
65
66 printk("Mem-info:\n");
67 show_free_areas();
68 printk("Free swap: %6ldkB\n",nr_swap_pages<<(PAGE_SHIFT-10));
69 i = max_mapnr;
70 while (i-- > 0) {
71 total++;
72 if (PageReserved(mem_map+i))
73 reserved++;
74 else if (PageSwapCache(mem_map+i))
75 cached++;
76 else if (page_count(mem_map+i))
77 shared += page_count(mem_map+i) - 1;
78 }
79 printk("%d pages of RAM\n",total);
80 printk("%d reserved pages\n",reserved);
81 printk("%d pages shared\n",shared);
82 printk("%d pages swap cached\n",cached);
83 printk("%ld pages in page table cache\n", quicklist_total_size());
84}
85
86/*
87 * paging_init() sets up the page tables.
88 *
89 * head.S already did a lot to set up address translation for the kernel.
90 * Here we comes with:
91 * . MMU enabled
92 * . ASID set (SR)
93 * . some 512MB regions being mapped of which the most relevant here is:
94 * . CACHED segment (ASID 0 [irrelevant], shared AND NOT user)
95 * . possible variable length regions being mapped as:
96 * . UNCACHED segment (ASID 0 [irrelevant], shared AND NOT user)
97 * . All of the memory regions are placed, independently from the platform
98 * on high addresses, above 0x80000000.
99 * . swapper_pg_dir is already cleared out by the .space directive
100 * in any case swapper does not require a real page directory since
101 * it's all kernel contained.
102 *
103 * Those pesky NULL-reference errors in the kernel are then
104 * dealt with by not mapping address 0x00000000 at all.
105 *
106 */
107void __init paging_init(void)
108{
109 unsigned long zones_size[MAX_NR_ZONES] = {0, };
110
111 pgd_init((unsigned long)swapper_pg_dir);
112 pgd_init((unsigned long)swapper_pg_dir +
113 sizeof(pgd_t) * USER_PTRS_PER_PGD);
114
115 mmu_context_cache = MMU_CONTEXT_FIRST_VERSION;
116
117 zones_size[ZONE_NORMAL] = MAX_LOW_PFN - START_PFN;
118 NODE_DATA(0)->node_mem_map = NULL;
119 free_area_init_node(0, NODE_DATA(0), zones_size, __MEMORY_START >> PAGE_SHIFT, 0);
120}
121
122void __init mem_init(void)
123{
124 int codesize, reservedpages, datasize, initsize;
125 int tmp;
126
127 max_mapnr = num_physpages = MAX_LOW_PFN - START_PFN;
128 high_memory = (void *)__va(MAX_LOW_PFN * PAGE_SIZE);
129
130 /*
131 * Clear the zero-page.
132 * This is not required but we might want to re-use
133 * this very page to pass boot parameters, one day.
134 */
135 memset(empty_zero_page, 0, PAGE_SIZE);
136
137 /* this will put all low memory onto the freelists */
138 totalram_pages += free_all_bootmem_node(NODE_DATA(0));
139 reservedpages = 0;
140 for (tmp = 0; tmp < num_physpages; tmp++)
141 /*
142 * Only count reserved RAM pages
143 */
144 if (PageReserved(mem_map+tmp))
145 reservedpages++;
146
147 after_bootmem = 1;
148
149 codesize = (unsigned long) &_etext - (unsigned long) &_text;
150 datasize = (unsigned long) &_edata - (unsigned long) &_etext;
151 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
152
153 printk("Memory: %luk/%luk available (%dk kernel code, %dk reserved, %dk data, %dk init)\n",
154 (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
155 max_mapnr << (PAGE_SHIFT-10),
156 codesize >> 10,
157 reservedpages << (PAGE_SHIFT-10),
158 datasize >> 10,
159 initsize >> 10);
160}
161
162void free_initmem(void)
163{
164 unsigned long addr;
165
166 addr = (unsigned long)(&__init_begin);
167 for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
168 ClearPageReserved(virt_to_page(addr));
169 init_page_count(virt_to_page(addr));
170 free_page(addr);
171 totalram_pages++;
172 }
173 printk ("Freeing unused kernel memory: %ldk freed\n", (&__init_end - &__init_begin) >> 10);
174}
175
176#ifdef CONFIG_BLK_DEV_INITRD
177void free_initrd_mem(unsigned long start, unsigned long end)
178{
179 unsigned long p;
180 for (p = start; p < end; p += PAGE_SIZE) {
181 ClearPageReserved(virt_to_page(p));
182 init_page_count(virt_to_page(p));
183 free_page(p);
184 totalram_pages++;
185 }
186 printk ("Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
187}
188#endif
189
diff --git a/arch/sh64/mm/ioremap.c b/arch/sh64/mm/ioremap.c
deleted file mode 100644
index 535304e6601f..000000000000
--- a/arch/sh64/mm/ioremap.c
+++ /dev/null
@@ -1,388 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/mm/ioremap.c
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003, 2004 Paul Mundt
10 *
11 * Mostly derived from arch/sh/mm/ioremap.c which, in turn is mostly
12 * derived from arch/i386/mm/ioremap.c .
13 *
14 * (C) Copyright 1995 1996 Linus Torvalds
15 */
16#include <linux/kernel.h>
17#include <linux/slab.h>
18#include <linux/vmalloc.h>
19#include <linux/sched.h>
20#include <linux/string.h>
21#include <linux/io.h>
22#include <linux/ioport.h>
23#include <linux/bootmem.h>
24#include <linux/proc_fs.h>
25#include <linux/module.h>
26#include <asm/pgalloc.h>
27#include <asm/tlbflush.h>
28
29static void shmedia_mapioaddr(unsigned long, unsigned long);
30static unsigned long shmedia_ioremap(struct resource *, u32, int);
31
32/*
33 * Generic mapping function (not visible outside):
34 */
35
36/*
37 * Remap an arbitrary physical address space into the kernel virtual
38 * address space. Needed when the kernel wants to access high addresses
39 * directly.
40 *
41 * NOTE! We need to allow non-page-aligned mappings too: we will obviously
42 * have to convert them into an offset in a page-aligned mapping, but the
43 * caller shouldn't need to know that small detail.
44 */
45void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
46{
47 void * addr;
48 struct vm_struct * area;
49 unsigned long offset, last_addr;
50 pgprot_t pgprot;
51
52 /* Don't allow wraparound or zero size */
53 last_addr = phys_addr + size - 1;
54 if (!size || last_addr < phys_addr)
55 return NULL;
56
57 pgprot = __pgprot(_PAGE_PRESENT | _PAGE_READ |
58 _PAGE_WRITE | _PAGE_DIRTY |
59 _PAGE_ACCESSED | _PAGE_SHARED | flags);
60
61 /*
62 * Mappings have to be page-aligned
63 */
64 offset = phys_addr & ~PAGE_MASK;
65 phys_addr &= PAGE_MASK;
66 size = PAGE_ALIGN(last_addr + 1) - phys_addr;
67
68 /*
69 * Ok, go for it..
70 */
71 area = get_vm_area(size, VM_IOREMAP);
72 pr_debug("Get vm_area returns %p addr %p\n",area,area->addr);
73 if (!area)
74 return NULL;
75 area->phys_addr = phys_addr;
76 addr = area->addr;
77 if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size,
78 phys_addr, pgprot)) {
79 vunmap(addr);
80 return NULL;
81 }
82 return (void *) (offset + (char *)addr);
83}
84EXPORT_SYMBOL(__ioremap);
85
86void iounmap(void *addr)
87{
88 struct vm_struct *area;
89
90 vfree((void *) (PAGE_MASK & (unsigned long) addr));
91 area = remove_vm_area((void *) (PAGE_MASK & (unsigned long) addr));
92 if (!area) {
93 printk(KERN_ERR "iounmap: bad address %p\n", addr);
94 return;
95 }
96
97 kfree(area);
98}
99EXPORT_SYMBOL(iounmap);
100
101static struct resource shmedia_iomap = {
102 .name = "shmedia_iomap",
103 .start = IOBASE_VADDR + PAGE_SIZE,
104 .end = IOBASE_END - 1,
105};
106
107static void shmedia_mapioaddr(unsigned long pa, unsigned long va);
108static void shmedia_unmapioaddr(unsigned long vaddr);
109static unsigned long shmedia_ioremap(struct resource *res, u32 pa, int sz);
110
111/*
112 * We have the same problem as the SPARC, so lets have the same comment:
113 * Our mini-allocator...
114 * Boy this is gross! We need it because we must map I/O for
115 * timers and interrupt controller before the kmalloc is available.
116 */
117
118#define XNMLN 15
119#define XNRES 10
120
121struct xresource {
122 struct resource xres; /* Must be first */
123 int xflag; /* 1 == used */
124 char xname[XNMLN+1];
125};
126
127static struct xresource xresv[XNRES];
128
129static struct xresource *xres_alloc(void)
130{
131 struct xresource *xrp;
132 int n;
133
134 xrp = xresv;
135 for (n = 0; n < XNRES; n++) {
136 if (xrp->xflag == 0) {
137 xrp->xflag = 1;
138 return xrp;
139 }
140 xrp++;
141 }
142 return NULL;
143}
144
145static void xres_free(struct xresource *xrp)
146{
147 xrp->xflag = 0;
148}
149
150static struct resource *shmedia_find_resource(struct resource *root,
151 unsigned long vaddr)
152{
153 struct resource *res;
154
155 for (res = root->child; res; res = res->sibling)
156 if (res->start <= vaddr && res->end >= vaddr)
157 return res;
158
159 return NULL;
160}
161
162static unsigned long shmedia_alloc_io(unsigned long phys, unsigned long size,
163 const char *name)
164{
165 static int printed_full = 0;
166 struct xresource *xres;
167 struct resource *res;
168 char *tack;
169 int tlen;
170
171 if (name == NULL) name = "???";
172
173 if ((xres = xres_alloc()) != 0) {
174 tack = xres->xname;
175 res = &xres->xres;
176 } else {
177 if (!printed_full) {
178 printk("%s: done with statics, switching to kmalloc\n",
179 __FUNCTION__);
180 printed_full = 1;
181 }
182 tlen = strlen(name);
183 tack = kmalloc(sizeof (struct resource) + tlen + 1, GFP_KERNEL);
184 if (!tack)
185 return -ENOMEM;
186 memset(tack, 0, sizeof(struct resource));
187 res = (struct resource *) tack;
188 tack += sizeof (struct resource);
189 }
190
191 strncpy(tack, name, XNMLN);
192 tack[XNMLN] = 0;
193 res->name = tack;
194
195 return shmedia_ioremap(res, phys, size);
196}
197
198static unsigned long shmedia_ioremap(struct resource *res, u32 pa, int sz)
199{
200 unsigned long offset = ((unsigned long) pa) & (~PAGE_MASK);
201 unsigned long round_sz = (offset + sz + PAGE_SIZE-1) & PAGE_MASK;
202 unsigned long va;
203 unsigned int psz;
204
205 if (allocate_resource(&shmedia_iomap, res, round_sz,
206 shmedia_iomap.start, shmedia_iomap.end,
207 PAGE_SIZE, NULL, NULL) != 0) {
208 panic("alloc_io_res(%s): cannot occupy\n",
209 (res->name != NULL)? res->name: "???");
210 }
211
212 va = res->start;
213 pa &= PAGE_MASK;
214
215 psz = (res->end - res->start + (PAGE_SIZE - 1)) / PAGE_SIZE;
216
217 /* log at boot time ... */
218 printk("mapioaddr: %6s [%2d page%s] va 0x%08lx pa 0x%08x\n",
219 ((res->name != NULL) ? res->name : "???"),
220 psz, psz == 1 ? " " : "s", va, pa);
221
222 for (psz = res->end - res->start + 1; psz != 0; psz -= PAGE_SIZE) {
223 shmedia_mapioaddr(pa, va);
224 va += PAGE_SIZE;
225 pa += PAGE_SIZE;
226 }
227
228 res->start += offset;
229 res->end = res->start + sz - 1; /* not strictly necessary.. */
230
231 return res->start;
232}
233
234static void shmedia_free_io(struct resource *res)
235{
236 unsigned long len = res->end - res->start + 1;
237
238 BUG_ON((len & (PAGE_SIZE - 1)) != 0);
239
240 while (len) {
241 len -= PAGE_SIZE;
242 shmedia_unmapioaddr(res->start + len);
243 }
244
245 release_resource(res);
246}
247
248static __init_refok void *sh64_get_page(void)
249{
250 extern int after_bootmem;
251 void *page;
252
253 if (after_bootmem) {
254 page = (void *)get_zeroed_page(GFP_ATOMIC);
255 } else {
256 page = alloc_bootmem_pages(PAGE_SIZE);
257 }
258
259 if (!page || ((unsigned long)page & ~PAGE_MASK))
260 panic("sh64_get_page: Out of memory already?\n");
261
262 return page;
263}
264
265static void shmedia_mapioaddr(unsigned long pa, unsigned long va)
266{
267 pgd_t *pgdp;
268 pmd_t *pmdp;
269 pte_t *ptep, pte;
270 pgprot_t prot;
271 unsigned long flags = 1; /* 1 = CB0-1 device */
272
273 pr_debug("shmedia_mapiopage pa %08lx va %08lx\n", pa, va);
274
275 pgdp = pgd_offset_k(va);
276 if (pgd_none(*pgdp) || !pgd_present(*pgdp)) {
277 pmdp = (pmd_t *)sh64_get_page();
278 set_pgd(pgdp, __pgd((unsigned long)pmdp | _KERNPG_TABLE));
279 }
280
281 pmdp = pmd_offset(pgdp, va);
282 if (pmd_none(*pmdp) || !pmd_present(*pmdp) ) {
283 ptep = (pte_t *)sh64_get_page();
284 set_pmd(pmdp, __pmd((unsigned long)ptep + _PAGE_TABLE));
285 }
286
287 prot = __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE |
288 _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_SHARED | flags);
289
290 pte = pfn_pte(pa >> PAGE_SHIFT, prot);
291 ptep = pte_offset_kernel(pmdp, va);
292
293 if (!pte_none(*ptep) &&
294 pte_val(*ptep) != pte_val(pte))
295 pte_ERROR(*ptep);
296
297 set_pte(ptep, pte);
298
299 flush_tlb_kernel_range(va, PAGE_SIZE);
300}
301
302static void shmedia_unmapioaddr(unsigned long vaddr)
303{
304 pgd_t *pgdp;
305 pmd_t *pmdp;
306 pte_t *ptep;
307
308 pgdp = pgd_offset_k(vaddr);
309 pmdp = pmd_offset(pgdp, vaddr);
310
311 if (pmd_none(*pmdp) || pmd_bad(*pmdp))
312 return;
313
314 ptep = pte_offset_kernel(pmdp, vaddr);
315
316 if (pte_none(*ptep) || !pte_present(*ptep))
317 return;
318
319 clear_page((void *)ptep);
320 pte_clear(&init_mm, vaddr, ptep);
321}
322
323unsigned long onchip_remap(unsigned long phys, unsigned long size, const char *name)
324{
325 if (size < PAGE_SIZE)
326 size = PAGE_SIZE;
327
328 return shmedia_alloc_io(phys, size, name);
329}
330
331void onchip_unmap(unsigned long vaddr)
332{
333 struct resource *res;
334 unsigned int psz;
335
336 res = shmedia_find_resource(&shmedia_iomap, vaddr);
337 if (!res) {
338 printk(KERN_ERR "%s: Failed to free 0x%08lx\n",
339 __FUNCTION__, vaddr);
340 return;
341 }
342
343 psz = (res->end - res->start + (PAGE_SIZE - 1)) / PAGE_SIZE;
344
345 printk(KERN_DEBUG "unmapioaddr: %6s [%2d page%s] freed\n",
346 res->name, psz, psz == 1 ? " " : "s");
347
348 shmedia_free_io(res);
349
350 if ((char *)res >= (char *)xresv &&
351 (char *)res < (char *)&xresv[XNRES]) {
352 xres_free((struct xresource *)res);
353 } else {
354 kfree(res);
355 }
356}
357
358#ifdef CONFIG_PROC_FS
359static int
360ioremap_proc_info(char *buf, char **start, off_t fpos, int length, int *eof,
361 void *data)
362{
363 char *p = buf, *e = buf + length;
364 struct resource *r;
365 const char *nm;
366
367 for (r = ((struct resource *)data)->child; r != NULL; r = r->sibling) {
368 if (p + 32 >= e) /* Better than nothing */
369 break;
370 if ((nm = r->name) == 0) nm = "???";
371 p += sprintf(p, "%08lx-%08lx: %s\n",
372 (unsigned long)r->start,
373 (unsigned long)r->end, nm);
374 }
375
376 return p-buf;
377}
378#endif /* CONFIG_PROC_FS */
379
380static int __init register_proc_onchip(void)
381{
382#ifdef CONFIG_PROC_FS
383 create_proc_read_entry("io_map",0,0, ioremap_proc_info, &shmedia_iomap);
384#endif
385 return 0;
386}
387
388__initcall(register_proc_onchip);
diff --git a/arch/sh64/mm/tlb.c b/arch/sh64/mm/tlb.c
deleted file mode 100644
index d517e7d70340..000000000000
--- a/arch/sh64/mm/tlb.c
+++ /dev/null
@@ -1,166 +0,0 @@
1/*
2 * arch/sh64/mm/tlb.c
3 *
4 * Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
5 * Copyright (C) 2003 Richard Curnow <richard.curnow@superh.com>
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 */
12#include <linux/mm.h>
13#include <linux/init.h>
14#include <asm/page.h>
15#include <asm/tlb.h>
16#include <asm/mmu_context.h>
17
18/**
19 * sh64_tlb_init
20 *
21 * Perform initial setup for the DTLB and ITLB.
22 */
23int __init sh64_tlb_init(void)
24{
25 /* Assign some sane DTLB defaults */
26 cpu_data->dtlb.entries = 64;
27 cpu_data->dtlb.step = 0x10;
28
29 cpu_data->dtlb.first = DTLB_FIXED | cpu_data->dtlb.step;
30 cpu_data->dtlb.next = cpu_data->dtlb.first;
31
32 cpu_data->dtlb.last = DTLB_FIXED |
33 ((cpu_data->dtlb.entries - 1) *
34 cpu_data->dtlb.step);
35
36 /* And again for the ITLB */
37 cpu_data->itlb.entries = 64;
38 cpu_data->itlb.step = 0x10;
39
40 cpu_data->itlb.first = ITLB_FIXED | cpu_data->itlb.step;
41 cpu_data->itlb.next = cpu_data->itlb.first;
42 cpu_data->itlb.last = ITLB_FIXED |
43 ((cpu_data->itlb.entries - 1) *
44 cpu_data->itlb.step);
45
46 return 0;
47}
48
49/**
50 * sh64_next_free_dtlb_entry
51 *
52 * Find the next available DTLB entry
53 */
54unsigned long long sh64_next_free_dtlb_entry(void)
55{
56 return cpu_data->dtlb.next;
57}
58
59/**
60 * sh64_get_wired_dtlb_entry
61 *
62 * Allocate a wired (locked-in) entry in the DTLB
63 */
64unsigned long long sh64_get_wired_dtlb_entry(void)
65{
66 unsigned long long entry = sh64_next_free_dtlb_entry();
67
68 cpu_data->dtlb.first += cpu_data->dtlb.step;
69 cpu_data->dtlb.next += cpu_data->dtlb.step;
70
71 return entry;
72}
73
74/**
75 * sh64_put_wired_dtlb_entry
76 *
77 * @entry: Address of TLB slot.
78 *
79 * Free a wired (locked-in) entry in the DTLB.
80 *
81 * Works like a stack, last one to allocate must be first one to free.
82 */
83int sh64_put_wired_dtlb_entry(unsigned long long entry)
84{
85 __flush_tlb_slot(entry);
86
87 /*
88 * We don't do any particularly useful tracking of wired entries,
89 * so this approach works like a stack .. last one to be allocated
90 * has to be the first one to be freed.
91 *
92 * We could potentially load wired entries into a list and work on
93 * rebalancing the list periodically (which also entails moving the
94 * contents of a TLB entry) .. though I have a feeling that this is
95 * more trouble than it's worth.
96 */
97
98 /*
99 * Entry must be valid .. we don't want any ITLB addresses!
100 */
101 if (entry <= DTLB_FIXED)
102 return -EINVAL;
103
104 /*
105 * Next, check if we're within range to be freed. (ie, must be the
106 * entry beneath the first 'free' entry!
107 */
108 if (entry < (cpu_data->dtlb.first - cpu_data->dtlb.step))
109 return -EINVAL;
110
111 /* If we are, then bring this entry back into the list */
112 cpu_data->dtlb.first -= cpu_data->dtlb.step;
113 cpu_data->dtlb.next = entry;
114
115 return 0;
116}
117
118/**
119 * sh64_setup_tlb_slot
120 *
121 * @config_addr: Address of TLB slot.
122 * @eaddr: Virtual address.
123 * @asid: Address Space Identifier.
124 * @paddr: Physical address.
125 *
126 * Load up a virtual<->physical translation for @eaddr<->@paddr in the
127 * pre-allocated TLB slot @config_addr (see sh64_get_wired_dtlb_entry).
128 */
129inline void sh64_setup_tlb_slot(unsigned long long config_addr,
130 unsigned long eaddr,
131 unsigned long asid,
132 unsigned long paddr)
133{
134 unsigned long long pteh, ptel;
135
136 /* Sign extension */
137#if (NEFF == 32)
138 pteh = (unsigned long long)(signed long long)(signed long) eaddr;
139#else
140#error "Can't sign extend more than 32 bits yet"
141#endif
142 pteh &= PAGE_MASK;
143 pteh |= (asid << PTEH_ASID_SHIFT) | PTEH_VALID;
144#if (NEFF == 32)
145 ptel = (unsigned long long)(signed long long)(signed long) paddr;
146#else
147#error "Can't sign extend more than 32 bits yet"
148#endif
149 ptel &= PAGE_MASK;
150 ptel |= (_PAGE_CACHABLE | _PAGE_READ | _PAGE_WRITE);
151
152 asm volatile("putcfg %0, 1, %1\n\t"
153 "putcfg %0, 0, %2\n"
154 : : "r" (config_addr), "r" (ptel), "r" (pteh));
155}
156
157/**
158 * sh64_teardown_tlb_slot
159 *
160 * @config_addr: Address of TLB slot.
161 *
162 * Teardown any existing mapping in the TLB slot @config_addr.
163 */
164inline void sh64_teardown_tlb_slot(unsigned long long config_addr)
165 __attribute__ ((alias("__flush_tlb_slot")));
166
diff --git a/arch/sh64/mm/tlbmiss.c b/arch/sh64/mm/tlbmiss.c
deleted file mode 100644
index b767d6cff72f..000000000000
--- a/arch/sh64/mm/tlbmiss.c
+++ /dev/null
@@ -1,279 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/mm/tlbmiss.c
7 *
8 * Original code from fault.c
9 * Copyright (C) 2000, 2001 Paolo Alberelli
10 *
11 * Fast PTE->TLB refill path
12 * Copyright (C) 2003 Richard.Curnow@superh.com
13 *
14 * IMPORTANT NOTES :
15 * The do_fast_page_fault function is called from a context in entry.S where very few registers
16 * have been saved. In particular, the code in this file must be compiled not to use ANY
17 * caller-save registers that are not part of the restricted save set. Also, it means that
18 * code in this file must not make calls to functions elsewhere in the kernel, or else the
19 * excepting context will see corruption in its caller-save registers. Plus, the entry.S save
20 * area is non-reentrant, so this code has to run with SR.BL==1, i.e. no interrupts taken inside
21 * it and panic on any exception.
22 *
23 */
24
25#include <linux/signal.h>
26#include <linux/sched.h>
27#include <linux/kernel.h>
28#include <linux/errno.h>
29#include <linux/string.h>
30#include <linux/types.h>
31#include <linux/ptrace.h>
32#include <linux/mman.h>
33#include <linux/mm.h>
34#include <linux/smp.h>
35#include <linux/interrupt.h>
36
37#include <asm/system.h>
38#include <asm/tlb.h>
39#include <asm/io.h>
40#include <asm/uaccess.h>
41#include <asm/pgalloc.h>
42#include <asm/mmu_context.h>
43#include <asm/registers.h> /* required by inline asm statements */
44
45/* Callable from fault.c, so not static */
46inline void __do_tlb_refill(unsigned long address,
47 unsigned long long is_text_not_data, pte_t *pte)
48{
49 unsigned long long ptel;
50 unsigned long long pteh=0;
51 struct tlb_info *tlbp;
52 unsigned long long next;
53
54 /* Get PTEL first */
55 ptel = pte_val(*pte);
56
57 /*
58 * Set PTEH register
59 */
60 pteh = address & MMU_VPN_MASK;
61
62 /* Sign extend based on neff. */
63#if (NEFF == 32)
64 /* Faster sign extension */
65 pteh = (unsigned long long)(signed long long)(signed long)pteh;
66#else
67 /* General case */
68 pteh = (pteh & NEFF_SIGN) ? (pteh | NEFF_MASK) : pteh;
69#endif
70
71 /* Set the ASID. */
72 pteh |= get_asid() << PTEH_ASID_SHIFT;
73 pteh |= PTEH_VALID;
74
75 /* Set PTEL register, set_pte has performed the sign extension */
76 ptel &= _PAGE_FLAGS_HARDWARE_MASK; /* drop software flags */
77
78 tlbp = is_text_not_data ? &(cpu_data->itlb) : &(cpu_data->dtlb);
79 next = tlbp->next;
80 __flush_tlb_slot(next);
81 asm volatile ("putcfg %0,1,%2\n\n\t"
82 "putcfg %0,0,%1\n"
83 : : "r" (next), "r" (pteh), "r" (ptel) );
84
85 next += TLB_STEP;
86 if (next > tlbp->last) next = tlbp->first;
87 tlbp->next = next;
88
89}
90
91static int handle_vmalloc_fault(struct mm_struct *mm, unsigned long protection_flags,
92 unsigned long long textaccess,
93 unsigned long address)
94{
95 pgd_t *dir;
96 pmd_t *pmd;
97 static pte_t *pte;
98 pte_t entry;
99
100 dir = pgd_offset_k(address);
101 pmd = pmd_offset(dir, address);
102
103 if (pmd_none(*pmd)) {
104 return 0;
105 }
106
107 if (pmd_bad(*pmd)) {
108 pmd_clear(pmd);
109 return 0;
110 }
111
112 pte = pte_offset_kernel(pmd, address);
113 entry = *pte;
114
115 if (pte_none(entry) || !pte_present(entry)) {
116 return 0;
117 }
118
119 if ((pte_val(entry) & protection_flags) != protection_flags) {
120 return 0;
121 }
122
123 __do_tlb_refill(address, textaccess, pte);
124
125 return 1;
126}
127
128static int handle_tlbmiss(struct mm_struct *mm, unsigned long long protection_flags,
129 unsigned long long textaccess,
130 unsigned long address)
131{
132 pgd_t *dir;
133 pmd_t *pmd;
134 pte_t *pte;
135 pte_t entry;
136
137 /* NB. The PGD currently only contains a single entry - there is no
138 page table tree stored for the top half of the address space since
139 virtual pages in that region should never be mapped in user mode.
140 (In kernel mode, the only things in that region are the 512Mb super
141 page (locked in), and vmalloc (modules) + I/O device pages (handled
142 by handle_vmalloc_fault), so no PGD for the upper half is required
143 by kernel mode either).
144
145 See how mm->pgd is allocated and initialised in pgd_alloc to see why
146 the next test is necessary. - RPC */
147 if (address >= (unsigned long) TASK_SIZE) {
148 /* upper half - never has page table entries. */
149 return 0;
150 }
151 dir = pgd_offset(mm, address);
152 if (pgd_none(*dir)) {
153 return 0;
154 }
155 if (!pgd_present(*dir)) {
156 return 0;
157 }
158
159 pmd = pmd_offset(dir, address);
160 if (pmd_none(*pmd)) {
161 return 0;
162 }
163 if (!pmd_present(*pmd)) {
164 return 0;
165 }
166 pte = pte_offset_kernel(pmd, address);
167 entry = *pte;
168 if (pte_none(entry)) {
169 return 0;
170 }
171 if (!pte_present(entry)) {
172 return 0;
173 }
174
175 /* If the page doesn't have sufficient protection bits set to service the
176 kind of fault being handled, there's not much point doing the TLB refill.
177 Punt the fault to the general handler. */
178 if ((pte_val(entry) & protection_flags) != protection_flags) {
179 return 0;
180 }
181
182 __do_tlb_refill(address, textaccess, pte);
183
184 return 1;
185}
186
187/* Put all this information into one structure so that everything is just arithmetic
188 relative to a single base address. This reduces the number of movi/shori pairs needed
189 just to load addresses of static data. */
190struct expevt_lookup {
191 unsigned short protection_flags[8];
192 unsigned char is_text_access[8];
193 unsigned char is_write_access[8];
194};
195
196#define PRU (1<<9)
197#define PRW (1<<8)
198#define PRX (1<<7)
199#define PRR (1<<6)
200
201#define DIRTY (_PAGE_DIRTY | _PAGE_ACCESSED)
202#define YOUNG (_PAGE_ACCESSED)
203
204/* Sized as 8 rather than 4 to allow checking the PTE's PRU bit against whether
205 the fault happened in user mode or privileged mode. */
206static struct expevt_lookup expevt_lookup_table = {
207 .protection_flags = {PRX, PRX, 0, 0, PRR, PRR, PRW, PRW},
208 .is_text_access = {1, 1, 0, 0, 0, 0, 0, 0}
209};
210
211/*
212 This routine handles page faults that can be serviced just by refilling a
213 TLB entry from an existing page table entry. (This case represents a very
214 large majority of page faults.) Return 1 if the fault was successfully
215 handled. Return 0 if the fault could not be handled. (This leads into the
216 general fault handling in fault.c which deals with mapping file-backed
217 pages, stack growth, segmentation faults, swapping etc etc)
218 */
219asmlinkage int do_fast_page_fault(unsigned long long ssr_md, unsigned long long expevt,
220 unsigned long address)
221{
222 struct task_struct *tsk;
223 struct mm_struct *mm;
224 unsigned long long textaccess;
225 unsigned long long protection_flags;
226 unsigned long long index;
227 unsigned long long expevt4;
228
229 /* The next few lines implement a way of hashing EXPEVT into a small array index
230 which can be used to lookup parameters specific to the type of TLBMISS being
231 handled. Note:
232 ITLBMISS has EXPEVT==0xa40
233 RTLBMISS has EXPEVT==0x040
234 WTLBMISS has EXPEVT==0x060
235 */
236
237 expevt4 = (expevt >> 4);
238 /* TODO : xor ssr_md into this expression too. Then we can check that PRU is set
239 when it needs to be. */
240 index = expevt4 ^ (expevt4 >> 5);
241 index &= 7;
242 protection_flags = expevt_lookup_table.protection_flags[index];
243 textaccess = expevt_lookup_table.is_text_access[index];
244
245#ifdef CONFIG_SH64_PROC_TLB
246 ++calls_to_do_fast_page_fault;
247#endif
248
249 /* SIM
250 * Note this is now called with interrupts still disabled
251 * This is to cope with being called for a missing IO port
252 * address with interrupts disabled. This should be fixed as
253 * soon as we have a better 'fast path' miss handler.
254 *
255 * Plus take care how you try and debug this stuff.
256 * For example, writing debug data to a port which you
257 * have just faulted on is not going to work.
258 */
259
260 tsk = current;
261 mm = tsk->mm;
262
263 if ((address >= VMALLOC_START && address < VMALLOC_END) ||
264 (address >= IOBASE_VADDR && address < IOBASE_END)) {
265 if (ssr_md) {
266 /* Process-contexts can never have this address range mapped */
267 if (handle_vmalloc_fault(mm, protection_flags, textaccess, address)) {
268 return 1;
269 }
270 }
271 } else if (!in_interrupt() && mm) {
272 if (handle_tlbmiss(mm, protection_flags, textaccess, address)) {
273 return 1;
274 }
275 }
276
277 return 0;
278}
279
diff --git a/arch/sh64/oprofile/Makefile b/arch/sh64/oprofile/Makefile
deleted file mode 100644
index 11a451f6a9c3..000000000000
--- a/arch/sh64/oprofile/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
1obj-$(CONFIG_OPROFILE) += oprofile.o
2
3DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
4 oprof.o cpu_buffer.o buffer_sync.o \
5 event_buffer.o oprofile_files.o \
6 oprofilefs.o oprofile_stats.o \
7 timer_int.o )
8
9profdrvr-y := op_model_null.o
10
11oprofile-y := $(DRIVER_OBJS) $(profdrvr-y)
12
diff --git a/arch/sh64/oprofile/op_model_null.c b/arch/sh64/oprofile/op_model_null.c
deleted file mode 100644
index a750ea1fee98..000000000000
--- a/arch/sh64/oprofile/op_model_null.c
+++ /dev/null
@@ -1,23 +0,0 @@
1/*
2 * arch/sh64/oprofile/op_model_null.c
3 *
4 * Copyright (C) 2003 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/kernel.h>
11#include <linux/oprofile.h>
12#include <linux/init.h>
13#include <linux/errno.h>
14
15int __init oprofile_arch_init(struct oprofile_operations *ops)
16{
17 return -ENODEV;
18}
19
20void oprofile_arch_exit(void)
21{
22}
23