OSDN Git Service

rx: Add RX support files
authorYoshinori Sato <ysato@users.sourceforge.jp>
Wed, 23 Dec 2015 16:50:30 +0000 (01:50 +0900)
committerYoshinori Sato <yo-satoh@sios.com>
Fri, 28 Jan 2022 12:35:31 +0000 (21:35 +0900)
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
162 files changed:
arch/rx/Kconfig [new file with mode: 0644]
arch/rx/Kconfig.debug [new file with mode: 0644]
arch/rx/Makefile [new file with mode: 0644]
arch/rx/boards/Makefile [new file with mode: 0644]
arch/rx/boards/ap-rx64m-0a/Makefile [new file with mode: 0644]
arch/rx/boards/ap-rx64m-0a/ap-rx64m-0a.c [new file with mode: 0644]
arch/rx/boards/ap-rx64m-0a/exception.S [new file with mode: 0644]
arch/rx/boards/rx-mega/Makefile [new file with mode: 0644]
arch/rx/boards/rx-mega/exception.S [new file with mode: 0644]
arch/rx/boards/sim/Makefile [new file with mode: 0644]
arch/rx/boards/sim/crt0.S [new file with mode: 0644]
arch/rx/boards/tkdn-rx62n/Makefile [new file with mode: 0644]
arch/rx/boards/tkdn-rx62n/exception.S [new file with mode: 0644]
arch/rx/boards/tkdn-rx62n/tkdn-rx62n.c [new file with mode: 0644]
arch/rx/boot/Makefile [new file with mode: 0644]
arch/rx/boot/compressed/Makefile [new file with mode: 0644]
arch/rx/boot/compressed/head.S [new file with mode: 0644]
arch/rx/boot/compressed/misc.c [new file with mode: 0644]
arch/rx/boot/compressed/vmlinux.scr [new file with mode: 0644]
arch/rx/defconfig [new file with mode: 0644]
arch/rx/include/asm/Kbuild [new file with mode: 0644]
arch/rx/include/asm/asm-offsets.h [new file with mode: 0644]
arch/rx/include/asm/atomic.h [new file with mode: 0644]
arch/rx/include/asm/auxvec.h [new file with mode: 0644]
arch/rx/include/asm/bitops.h [new file with mode: 0644]
arch/rx/include/asm/bitsperlong.h [new file with mode: 0644]
arch/rx/include/asm/bug.h [new file with mode: 0644]
arch/rx/include/asm/bugs.h [new file with mode: 0644]
arch/rx/include/asm/byteorder.h [new file with mode: 0644]
arch/rx/include/asm/cache.h [new file with mode: 0644]
arch/rx/include/asm/cacheflush.h [new file with mode: 0644]
arch/rx/include/asm/checksum.h [new file with mode: 0644]
arch/rx/include/asm/clock.h [new file with mode: 0644]
arch/rx/include/asm/cputime.h [new file with mode: 0644]
arch/rx/include/asm/current.h [new file with mode: 0644]
arch/rx/include/asm/delay.h [new file with mode: 0644]
arch/rx/include/asm/device.h [new file with mode: 0644]
arch/rx/include/asm/div64.h [new file with mode: 0644]
arch/rx/include/asm/dma-mapping.h [new file with mode: 0644]
arch/rx/include/asm/dma.h [new file with mode: 0644]
arch/rx/include/asm/elf.h [new file with mode: 0644]
arch/rx/include/asm/emergency-restart.h [new file with mode: 0644]
arch/rx/include/asm/errno.h [new file with mode: 0644]
arch/rx/include/asm/fcntl.h [new file with mode: 0644]
arch/rx/include/asm/flat.h [new file with mode: 0644]
arch/rx/include/asm/ftrace.h [new file with mode: 0644]
arch/rx/include/asm/futex.h [new file with mode: 0644]
arch/rx/include/asm/guard.rb [new file with mode: 0644]
arch/rx/include/asm/guard.sed [new file with mode: 0644]
arch/rx/include/asm/hardirq.h [new file with mode: 0644]
arch/rx/include/asm/hw_irq.h [new file with mode: 0644]
arch/rx/include/asm/io.h [new file with mode: 0644]
arch/rx/include/asm/ioctl.h [new file with mode: 0644]
arch/rx/include/asm/ioctls.h [new file with mode: 0644]
arch/rx/include/asm/ipcbuf.h [new file with mode: 0644]
arch/rx/include/asm/irq.h [new file with mode: 0644]
arch/rx/include/asm/irq_regs.h [new file with mode: 0644]
arch/rx/include/asm/irqflags.h [new file with mode: 0644]
arch/rx/include/asm/kdebug.h [new file with mode: 0644]
arch/rx/include/asm/kmap_types.h [new file with mode: 0644]
arch/rx/include/asm/linkage.h [new file with mode: 0644]
arch/rx/include/asm/local.h [new file with mode: 0644]
arch/rx/include/asm/mc146818rtc.h [new file with mode: 0644]
arch/rx/include/asm/mman.h [new file with mode: 0644]
arch/rx/include/asm/mmu.h [new file with mode: 0644]
arch/rx/include/asm/mmu_context.h [new file with mode: 0644]
arch/rx/include/asm/module.h [new file with mode: 0644]
arch/rx/include/asm/msgbuf.h [new file with mode: 0644]
arch/rx/include/asm/mutex.h [new file with mode: 0644]
arch/rx/include/asm/omit-guard.rb [new file with mode: 0644]
arch/rx/include/asm/page.h [new file with mode: 0644]
arch/rx/include/asm/page_offset.h [new file with mode: 0644]
arch/rx/include/asm/param.h [new file with mode: 0644]
arch/rx/include/asm/pci.h [new file with mode: 0644]
arch/rx/include/asm/percpu.h [new file with mode: 0644]
arch/rx/include/asm/pgalloc.h [new file with mode: 0644]
arch/rx/include/asm/pgtable.h [new file with mode: 0644]
arch/rx/include/asm/poll.h [new file with mode: 0644]
arch/rx/include/asm/posix_types.h [new file with mode: 0644]
arch/rx/include/asm/processor.h [new file with mode: 0644]
arch/rx/include/asm/ptrace.h [new file with mode: 0644]
arch/rx/include/asm/reloc.rb [new file with mode: 0644]
arch/rx/include/asm/reloc.txt [new file with mode: 0644]
arch/rx/include/asm/resource.h [new file with mode: 0644]
arch/rx/include/asm/scatterlist.h [new file with mode: 0644]
arch/rx/include/asm/sections.h [new file with mode: 0644]
arch/rx/include/asm/segment.h [new file with mode: 0644]
arch/rx/include/asm/sembuf.h [new file with mode: 0644]
arch/rx/include/asm/setup.h [new file with mode: 0644]
arch/rx/include/asm/sh_eth.h [new file with mode: 0644]
arch/rx/include/asm/shmbuf.h [new file with mode: 0644]
arch/rx/include/asm/shmparam.h [new file with mode: 0644]
arch/rx/include/asm/sigcontext.h [new file with mode: 0644]
arch/rx/include/asm/sigframe.h [new file with mode: 0644]
arch/rx/include/asm/siginfo.h [new file with mode: 0644]
arch/rx/include/asm/signal.h [new file with mode: 0644]
arch/rx/include/asm/smp.h [new file with mode: 0644]
arch/rx/include/asm/socket.h [new file with mode: 0644]
arch/rx/include/asm/sockios.h [new file with mode: 0644]
arch/rx/include/asm/spinlock.h [new file with mode: 0644]
arch/rx/include/asm/stat.h [new file with mode: 0644]
arch/rx/include/asm/statfs.h [new file with mode: 0644]
arch/rx/include/asm/string.h [new file with mode: 0644]
arch/rx/include/asm/swab.h [new file with mode: 0644]
arch/rx/include/asm/syscall.h [new file with mode: 0644]
arch/rx/include/asm/system.h [new file with mode: 0644]
arch/rx/include/asm/target_time.h [new file with mode: 0644]
arch/rx/include/asm/termbits.h [new file with mode: 0644]
arch/rx/include/asm/termios.h [new file with mode: 0644]
arch/rx/include/asm/thread_info.h [new file with mode: 0644]
arch/rx/include/asm/timex.h [new file with mode: 0644]
arch/rx/include/asm/tlb.h [new file with mode: 0644]
arch/rx/include/asm/tlbflush.h [new file with mode: 0644]
arch/rx/include/asm/topology.h [new file with mode: 0644]
arch/rx/include/asm/types.h [new file with mode: 0644]
arch/rx/include/asm/uaccess.h [new file with mode: 0644]
arch/rx/include/asm/ucontext.h [new file with mode: 0644]
arch/rx/include/asm/unaligned.h [new file with mode: 0644]
arch/rx/include/asm/unistd.h [new file with mode: 0644]
arch/rx/include/asm/user.h [new file with mode: 0644]
arch/rx/include/asm/vmlinux.lds.h [new file with mode: 0644]
arch/rx/kernel/.gitignore [new file with mode: 0644]
arch/rx/kernel/Makefile [new file with mode: 0644]
arch/rx/kernel/asm-offsets.c [new file with mode: 0644]
arch/rx/kernel/cpu/Makefile [new file with mode: 0644]
arch/rx/kernel/cpu/clock.c [new file with mode: 0644]
arch/rx/kernel/cpu/irq/Makefile [new file with mode: 0644]
arch/rx/kernel/cpu/irq/icua.c [new file with mode: 0644]
arch/rx/kernel/cpu/irq/ipr.c [new file with mode: 0644]
arch/rx/kernel/cpu/rx610/Makefile [new file with mode: 0644]
arch/rx/kernel/cpu/rx610/clock.c [new file with mode: 0644]
arch/rx/kernel/cpu/rx610/setup.c [new file with mode: 0644]
arch/rx/kernel/cpu/rx62n/Makefile [new file with mode: 0644]
arch/rx/kernel/cpu/rx62n/clock.c [new file with mode: 0644]
arch/rx/kernel/cpu/rx62n/setup.c [new file with mode: 0644]
arch/rx/kernel/cpu/rx64m/Makefile [new file with mode: 0644]
arch/rx/kernel/cpu/rx64m/clock.c [new file with mode: 0644]
arch/rx/kernel/cpu/rx64m/setup.c [new file with mode: 0644]
arch/rx/kernel/dma-nommu.c [new file with mode: 0644]
arch/rx/kernel/early-printk.c [new file with mode: 0644]
arch/rx/kernel/entry.S [new file with mode: 0644]
arch/rx/kernel/head.S [new file with mode: 0644]
arch/rx/kernel/init_task.c [new file with mode: 0644]
arch/rx/kernel/irq.c [new file with mode: 0644]
arch/rx/kernel/process.c [new file with mode: 0644]
arch/rx/kernel/ptrace.c [new file with mode: 0644]
arch/rx/kernel/setup.c [new file with mode: 0644]
arch/rx/kernel/signal.c [new file with mode: 0644]
arch/rx/kernel/sys_rx.c [new file with mode: 0644]
arch/rx/kernel/syscalls.S [new file with mode: 0644]
arch/rx/kernel/time.c [new file with mode: 0644]
arch/rx/kernel/timer/Makefile [new file with mode: 0644]
arch/rx/kernel/timer/cmt.c [new file with mode: 0644]
arch/rx/kernel/traps.c [new file with mode: 0644]
arch/rx/kernel/vmlinux.lds.S [new file with mode: 0644]
arch/rx/lib/Makefile [new file with mode: 0644]
arch/rx/lib/delay.c [new file with mode: 0644]
arch/rx/mm/Makefile [new file with mode: 0644]
arch/rx/mm/fault.c [new file with mode: 0644]
arch/rx/mm/init.c [new file with mode: 0644]
arch/rx/mm/memory.c [new file with mode: 0644]
drivers/tty/serial/Kconfig

diff --git a/arch/rx/Kconfig b/arch/rx/Kconfig
new file mode 100644 (file)
index 0000000..d8889f9
--- /dev/null
@@ -0,0 +1,224 @@
+#
+# For a description of the syntax of this configuration file,
+# see Documentation/kbuild/kconfig-language.txt.
+#
+
+config RX
+        def_bool y
+               select EMBEDDED
+       select HAVE_CLK
+       select HAVE_SYSCALL_TRACEPOINTS
+       select HAVE_KERNEL_GZIP
+       select HAVE_DMA_ATTRS
+       select HAVE_GENERIC_DMA_COHERENT
+config MMU
+       def_bool n
+
+config SWAP
+       def_bool n
+
+config ZONE_DMA
+       def_bool n
+
+config FPU
+       def_bool n
+
+config RWSEM_GENERIC_SPINLOCK
+       def_bool y
+
+config RWSEM_XCHGADD_ALGORITHM
+       def_bool n
+
+config ARCH_HAS_ILOG2_U32
+       def_bool n
+
+config ARCH_HAS_ILOG2_U64
+       def_bool n
+
+config GENERIC_FIND_NEXT_BIT
+       def_bool y
+
+config GENERIC_HWEIGHT
+       def_bool y
+
+config GENERIC_HARDIRQS
+       def_bool y
+
+config GENERIC_CALIBRATE_DELAY
+       def_bool y
+
+config GENERIC_TIME
+       def_bool y
+
+config GENERIC_BUG
+        bool
+        depends on BUG
+
+config GENERIC_CSUM
+        def_bool y
+
+config NEED_SG_DMA_LENGTH
+        def_bool y
+
+config TIME_LOW_RES
+       def_bool y
+
+config NO_IOPORT
+       def_bool y
+
+config NO_DMA
+       def_bool n
+
+config ISA
+       def_bool n
+
+config PCI
+       bool
+       default n
+
+config HZ
+       int
+       default 100
+
+config GENERIC_IRQ_SHOW
+       def_bool y
+
+source "init/Kconfig"
+
+source "kernel/Kconfig.freezer"
+
+menu "Processor type and features"
+
+source "kernel/time/Kconfig"
+
+choice
+       prompt "Platform"
+       default RX_GDB_SIM
+
+config RX_GDB_SIM
+       bool "GDB Simulator"
+       select CPU_RX610
+       help
+         GDB Simulator
+
+config TKDN_RX62N
+       bool "TKDN-RX62N-BRD"
+       select CPU_RX62N
+       help
+         TokushuDenshiKairo Inc, Ultimate RX62N Board (NP1040)
+
+config RXMEGA
+       bool "FRK-62N w/ RX-MEGA"
+       select CPU_RX62N
+       help
+         CQ publising, FRK-RX62N with TokushuDenshiKairo Inc, RX-MEGA expantion board.
+
+config AP_RX64M
+       bool "AP-RX64M-0A"
+       select CPU_RX64M
+endchoice
+
+config CPU_RX610
+       bool
+       select RX_IPR
+
+config CPU_RX62N
+       bool
+       select RX_ICUA
+
+config CPU_RX64M
+       bool
+       select RXV2
+       select RX_ICUA
+
+config RX_IPR
+       bool
+
+config RX_ICUA
+       bool
+
+config CPU_LITTLE_ENDIAN
+       def_bool y
+
+config INPUT_CLOCK_FREQ
+       int "Input clock frequency"
+
+config PCLK_MULT
+       int "Peripheral clock multiple rate"
+
+choice
+       prompt "Kernel executes from"
+       ---help---
+         Choose the memory type that the kernel will be running in.
+
+config RAMKERNEL
+       bool "RAM"
+       help
+         The kernel will be resident in RAM when running.
+
+config ROMKERNEL
+       bool "ROM"
+       help
+         The kernel will be resident in FLASH/ROM when running.
+endchoice
+
+menu "memory map"
+config ROMSTART
+       depends on ROMKERNEL
+       hex "ROM start address"
+config ROMEND
+       depends on ROMKERNEL
+       hex "ROM end address"
+config RAMSTART
+       hex "RAM start address"
+config RAMEND
+       hex "RAM end address"
+config INITIAL_STACK
+       hex "Initial stack address"
+config BOOT_LINK_OFFSET
+       hex "Link offset of zImage"
+endmenu
+
+choice
+       prompt "Timer"
+config RX_CMT
+       bool "CMT"
+endchoice
+
+config RX_CMT_CH
+       int "Channel"
+       depends on RX_CMT
+       help 
+         unit0-channel0 = 0
+         unit0-channel1 = 1
+         unit1-channel0 = 2
+         unit1-channel1 = 3
+
+config PREEMPT
+       bool "Preemptible Kernel"
+       default n
+
+source "mm/Kconfig"
+
+endmenu
+
+menu "Executable file formats"
+
+source "fs/Kconfig.binfmt"
+
+endmenu
+
+source "net/Kconfig"
+
+source "drivers/Kconfig"
+
+source "fs/Kconfig"
+
+source "arch/rx/Kconfig.debug"
+
+source "security/Kconfig"
+
+source "crypto/Kconfig"
+
+source "lib/Kconfig"
diff --git a/arch/rx/Kconfig.debug b/arch/rx/Kconfig.debug
new file mode 100644 (file)
index 0000000..c060d7b
--- /dev/null
@@ -0,0 +1,8 @@
+menu "Kernel Hacking"
+
+source "lib/Kconfig.debug"
+
+config EARLY_PRINTK
+        bool "Early printk support"
+
+endmenu
diff --git a/arch/rx/Makefile b/arch/rx/Makefile
new file mode 100644 (file)
index 0000000..b1322e4
--- /dev/null
@@ -0,0 +1,41 @@
+#
+# arch/rx/Makefile
+#
+# This file is subject to the terms and conditions of the GNU General Public
+# License.  See the file "COPYING" in the main directory of this archive
+# for more details.
+#
+# (C) Copyright 2009 Yoshinori Sato <ysato@users.sourceforge.jp>
+#
+
+KBUILD_CFLAGS += $(cflags-y)
+KBUILD_CFLAGS += -g
+KBUILD_CFLAGS += -D__linux__
+KBUILD_CFLAGS += -DUTS_SYSNAME=\"uClinux\"
+LDFLAGS += $(ldflags-y)
+LDFLAGS += --no-flag-mismatch-warnings
+KBUILD_AFLAGS += -Wa,-mcpu=rxv2
+
+LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
+
+core-y += arch/$(ARCH)/kernel/ \
+          arch/$(ARCH)/mm/ \
+           arch/$(ARCH)/boards/ \
+          arch/$(ARCH)/lib/ 
+libs-y += $(LIBGCC)
+
+boot := arch/$(ARCH)/boot
+
+archmrproper:
+
+archclean:
+       $(Q)$(MAKE) $(clean)=$(boot)
+
+vmlinux.srec vmlinux.bin zImage uImage uImage.bin: vmlinux
+       $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
+
+define archhelp
+  @echo  'vmlinux.bin  - Create raw binary'
+  @echo  'vmlinux.srec - Create srec binary'
+  @echo  'zImage       - Compressed kernel image'
+endef
diff --git a/arch/rx/boards/Makefile b/arch/rx/boards/Makefile
new file mode 100644 (file)
index 0000000..dd0d572
--- /dev/null
@@ -0,0 +1,4 @@
+obj-$(CONFIG_RX_GDB_SIM) = sim/
+obj-$(CONFIG_TKDN_RX62N) = tkdn-rx62n/
+obj-$(CONFIG_RXMEGA) = rx-mega/
+obj-$(CONFIG_AP_RX64M) = ap-rx64m-0a/
diff --git a/arch/rx/boards/ap-rx64m-0a/Makefile b/arch/rx/boards/ap-rx64m-0a/Makefile
new file mode 100644 (file)
index 0000000..0a5f764
--- /dev/null
@@ -0,0 +1 @@
+obj-y=exception.o ap-rx64m-0a.o
diff --git a/arch/rx/boards/ap-rx64m-0a/ap-rx64m-0a.c b/arch/rx/boards/ap-rx64m-0a/ap-rx64m-0a.c
new file mode 100644 (file)
index 0000000..242b3f7
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * AP-RX64M-0A board on-board peripheral setup
+ *
+ *  Copyright (C) 2015  Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/serial_sci.h>
+#include <asm/sh_eth.h>
+#include <asm/io.h>
+
+static struct sh_eth_plat_data rx_eth_plat_data = {
+       .phy = 0,
+       .edmac_endian = EDMAC_LITTLE_ENDIAN,
+};
+
+static struct resource eth_resources[] = {
+       [0] = {
+               .start = 0x000c0000,
+               .end =   0x000c01fc,
+               .flags = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start = 32,
+               .end = 32,
+               .flags = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device eth_device = {
+       .name = "sh-eth",
+       .id     = -1,
+       .dev = {
+               .platform_data = &rx_eth_plat_data,
+       },
+       .num_resources = ARRAY_SIZE(eth_resources),
+       .resource = eth_resources,
+};
+
+static struct platform_device *ap_rx64m_0a_devices[] __initdata = {
+#ifdef CONFIG_NET
+       &eth_device,
+#endif
+};
+
+static int __init init_board(void)
+{
+#ifdef CONFIG_NET
+       /* Use RMII interface */
+       writeb(0x82, (void __iomem *)0x8c10e);
+       writeb(readb((void __iomem *)0x8c065) | 0x10, (void __iomem *)0x8c065);
+       writeb(readb((void __iomem *)0x8c067) | 0xf2, (void __iomem *)0x8c067);
+       writeb(readb((void __iomem *)0x8c068) | 0x08, (void __iomem *)0x8c068);
+       /* enable EDMAC */
+       writel(readl((void __iomem *)0x80014) & ~0x00008000, 
+              (void __iomem *)0x80014);
+
+#endif
+       return platform_add_devices(ap_rx64m_0a_devices,
+                                   ARRAY_SIZE(ap_rx64m_0a_devices));
+}
+arch_initcall(init_board);
+
diff --git a/arch/rx/boards/ap-rx64m-0a/exception.S b/arch/rx/boards/ap-rx64m-0a/exception.S
new file mode 100644 (file)
index 0000000..5eaa101
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * arch/rx/board/tkdn-rx62n/exception.S
+ *  Copyright (C) 2011 Yoshinori Sato
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <asm/ptrace.h>
+       
+       .global install_exception_entry
+       .section        ".rx.exception","ax"
+       .rept   32
+1:     
+       bsr.a   2f
+       .endr
+2:     
+       sub     #4,r0
+       pushm   r1-r15
+       mov.l   r0,r13
+       add     #-(19*4),r13
+       mov.l   r13,[-r0]
+       mvfc    usp,r13
+       mov.l   r13,OFF_USP[r0]
+       mov.l   OFF_VEC[r0],r13
+       mov.l   #1b,r14
+       sub     [r14],r13
+       shlr    #2,r13
+       sub     #1,r13
+       /* r13 is exception no */
+       mov     #rx_exception_handler,r1
+       jmp     r1
+
+
+       .text
+install_exception_entry:
+       mvtc    #ram_exception_handler,extb
+       rts
+
+       .end
diff --git a/arch/rx/boards/rx-mega/Makefile b/arch/rx/boards/rx-mega/Makefile
new file mode 100644 (file)
index 0000000..4917118
--- /dev/null
@@ -0,0 +1 @@
+obj-y=exception.o
diff --git a/arch/rx/boards/rx-mega/exception.S b/arch/rx/boards/rx-mega/exception.S
new file mode 100644 (file)
index 0000000..0c88b21
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * arch/rx/board/rx-mega/exception.S
+ *  Copyright (C) 2011 Yoshinori Sato
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <asm/ptrace.h>
+       
+       .global install_exception_entry
+       .section        ".rx.exception","ax"
+       .rept   32
+1:     
+       bsr.a   2f
+       .endr
+2:     
+       sub     #4,r0
+       pushm   r1-r15
+       mov.l   r0,r13
+       add     #-(19*4),r13
+       mov.l   r13,[-r0]
+       mvfc    usp,r13
+       mov.l   r13,OFF_USP[r0]
+       mov.l   OFF_VEC[r0],r13
+       mov.l   #exception_top,r14
+       sub     [r14],r13
+       shlr    #2,r13
+       sub     #1,r13
+       /* r13 is exception no */
+       mov     #rx_exception_handler,r1
+       jmp     r1
+
+
+       .text
+install_exception_entry:
+       mov.l   #0xfffffff8,r1  /* NMI entry */
+       mov.l   [r1],r1
+       sub     #31*4,r1
+       mov.l   #exception_top,r2
+       mov.l   r1,[r2]
+       mov.l   #ram_exception_handler,r2
+       mov.l   #sizeof_ram_exception_handler,r3
+       smovf
+       rts
+
+       .bss
+exception_top:
+       .space  4
+
+       .end
diff --git a/arch/rx/boards/sim/Makefile b/arch/rx/boards/sim/Makefile
new file mode 100644 (file)
index 0000000..9ef2103
--- /dev/null
@@ -0,0 +1 @@
+obj-y=crt0.o
diff --git a/arch/rx/boards/sim/crt0.S b/arch/rx/boards/sim/crt0.S
new file mode 100644 (file)
index 0000000..17ecc74
--- /dev/null
@@ -0,0 +1,35 @@
+#include <asm/ptrace.h>
+
+       .section        .vector,"a"
+no     =       0
+       .rept   32
+       .long   rx_exp_table + (no * 4)
+no     =       no + 1  
+       .endr
+
+       .section        ".rx.exception","ax"
+rx_exp_table:  
+       .rept   32
+1:     
+       bsr.a   2f
+       .endr
+2:     
+       sub     #4,r0
+       pushm   r1-r15
+       mov.l   r0,r13
+       add     #-(19*4),r13
+       mov.l   r13,[-r0]
+       mvfc    usp,r13
+       mov.l   r13,OFF_USP[r0]
+       mov.l   OFF_VEC[r0],r13
+       mov.l   #rx_exp_table,r14
+       sub     [r14],r13
+       shlr    #2,r13
+       sub     #1,r13
+       /* r13 is exception no */
+       mov     #rx_exception_handler,r1
+       jmp     r1
+       .section        .commandline,"a"
+       .space  1024
+       
+       .end
diff --git a/arch/rx/boards/tkdn-rx62n/Makefile b/arch/rx/boards/tkdn-rx62n/Makefile
new file mode 100644 (file)
index 0000000..d163385
--- /dev/null
@@ -0,0 +1 @@
+obj-y=exception.o tkdn-rx62n.o
diff --git a/arch/rx/boards/tkdn-rx62n/exception.S b/arch/rx/boards/tkdn-rx62n/exception.S
new file mode 100644 (file)
index 0000000..8e7201f
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * arch/rx/board/tkdn-rx62n/exception.S
+ *  Copyright (C) 2011 Yoshinori Sato
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <asm/ptrace.h>
+       
+       .global install_exception_entry
+       .section        ".rx.exception","ax"
+       .rept   32
+1:     
+       bsr.a   2f
+       .endr
+2:     
+       sub     #4,r0
+       pushm   r1-r15
+       mov.l   r0,r13
+       add     #-(19*4),r13
+       mov.l   r13,[-r0]
+       mvfc    usp,r13
+       mov.l   r13,OFF_USP[r0]
+       mov.l   OFF_VEC[r0],r13
+       mov.l   #exception_top,r14
+       sub     [r14],r13
+       shlr    #2,r13
+       sub     #1,r13
+       /* r13 is exception no */
+       mov     #rx_exception_handler,r1
+       jmp     r1
+
+
+       .text
+install_exception_entry:
+       mov.l   #0xfffffff8,r1  /* NMI entry */
+       mov.l   [r1],r1
+       sub     #31*4,r1
+       mov.l   #exception_top,r2
+       mov.l   r1,[r2]
+       mov.l   #ram_exception_handler,r2
+       mov.l   #sizeof_ram_exception_handler,r3
+       smovf
+       rts
+
+       .bss
+exception_top:
+       .space  4
+
+       .end
diff --git a/arch/rx/boards/tkdn-rx62n/tkdn-rx62n.c b/arch/rx/boards/tkdn-rx62n/tkdn-rx62n.c
new file mode 100644 (file)
index 0000000..e9f15d7
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * Extream RX62N board on-board peripheral setup
+ *
+ *  Copyright (C) 2011  Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/serial_sci.h>
+#include <asm/sh_eth.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/spi_rspi.h>
+#include <asm/io.h>
+
+static void tkdn_rx62n_spi_cs(struct spi_device *spi, int is_on);
+
+static struct sh_eth_plat_data rx_eth_plat_data = {
+       .phy = 0,
+       .edmac_endian = EDMAC_LITTLE_ENDIAN,
+};
+
+static struct resource eth_resources[] = {
+       [0] = {
+               .start = 0x000c0000,
+               .end =   0x000c01fc,
+               .flags = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start = 32,
+               .end = 32,
+               .flags = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device eth_device = {
+       .name = "sh-eth",
+       .id     = -1,
+       .dev = {
+               .platform_data = &rx_eth_plat_data,
+       },
+       .num_resources = ARRAY_SIZE(eth_resources),
+       .resource = eth_resources,
+};
+
+static struct spi_board_info tkdn_rx62n_spi_flash[] = {
+       [0] = {
+               .mode = 3,
+               .bus_num = 1,
+               .chip_select = 0,
+               .max_speed_hz = 2500UL,
+               .modalias = "m25p80",
+       },
+};
+
+static struct rspi_platform_data rspi_platform_data[] = {
+       [0] = {
+               .num_cs = 0,
+               .csfunc = NULL,
+               .num_devices = 0,
+               .devices = NULL,
+       },
+       [1] = {
+               .num_cs = 1,
+               .csfunc = tkdn_rx62n_spi_cs,
+               .num_devices = 1,
+               .devices = tkdn_rx62n_spi_flash,
+       },
+};
+
+static struct resource rspi_resources[2][2] = {
+       {
+               [0] = {
+                       .start = 0x00088380,
+                       .end =   0x0008839f,
+                       .flags = IORESOURCE_MEM,
+               },
+               [1] = {
+                       .start = 44,
+                       .end = 47,
+                       .flags = IORESOURCE_IRQ,
+               },
+       },
+       {
+               [0] = {
+                       .start = 0x000883a0,
+                       .end =   0x000883bf,
+                       .flags = IORESOURCE_MEM,
+               },
+               [1] = {
+                       .start = 48,
+                       .end = 51,
+                       .flags = IORESOURCE_IRQ,
+               },
+       },
+};
+
+static struct platform_device rspi_device = {
+       .name           = "rspi",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &rspi_platform_data[1],
+       },
+       .num_resources = ARRAY_SIZE(rspi_resources[1]),
+       .resource = rspi_resources[1],
+};
+
+static struct platform_device *tkdn_rx62n_devices[] __initdata = {
+#ifdef CONFIG_NET
+       &eth_device,
+#endif
+#ifdef CONFIG_SPI
+       &rspi_device,
+#endif
+};
+
+static int __init init_board(void)
+{
+#ifdef CONFIG_NET
+       /* Use RMII interface */
+       writeb(0x82, (void __iomem *)0x8c10e);
+       writeb(readb((void __iomem *)0x8c065) | 0x10, (void __iomem *)0x8c065);
+       writeb(readb((void __iomem *)0x8c067) | 0xf2, (void __iomem *)0x8c067);
+       writeb(readb((void __iomem *)0x8c068) | 0x08, (void __iomem *)0x8c068);
+       /* enable EDMAC */
+       writel(readl((void __iomem *)0x80014) & ~0x00008000, 
+              (void __iomem *)0x80014);
+
+#endif
+#ifdef CONFIG_SPI
+       /* Use RSPI1-A 4-wire interface */
+       writeb(0x0e, (void __iomem *)0x8c111);
+       writeb(readb((void __iomem *)0x8c063) | 0x01, (void __iomem *)0x8c063);
+       writeb(readb((void __iomem *)0x8c023) | 0x02, (void __iomem *)0x8c023);
+       writeb(readb((void __iomem *)0x8c003) | 0x02, (void __iomem *)0x8c003);
+       /* enable RSPI1 */
+       writel(readl((void __iomem *)0x80014) & ~0x00010000,
+              (void __iomem *)0x80014);
+#endif
+       return platform_add_devices(tkdn_rx62n_devices,
+                                   ARRAY_SIZE(tkdn_rx62n_devices));
+}
+arch_initcall(init_board);
+
+static void tkdn_rx62n_spi_cs(struct spi_device *spi, int is_on)
+{
+       unsigned char dr;
+       dr = readb((void __iomem *)0x8c023);
+       if (is_on)
+               dr &= ~0x02;
+       else
+               dr |= 0x02;
+       writeb(dr, (void __iomem *)0x8c023);
+}
diff --git a/arch/rx/boot/Makefile b/arch/rx/boot/Makefile
new file mode 100644 (file)
index 0000000..cac659f
--- /dev/null
@@ -0,0 +1,85 @@
+# arch/rx/boot/Makefile
+
+MKIMAGE := $(srctree)/scripts/mkuboot.sh
+
+suffix-y := bin
+suffix-$(CONFIG_KERNEL_GZIP)   := gz
+suffix-$(CONFIG_KERNEL_BZIP2)  := bz2
+suffix-$(CONFIG_KERNEL_LZMA)   := lzma
+suffix-$(CONFIG_KERNEL_XZ)     := xz
+suffix-$(CONFIG_KERNEL_LZO)    := lzo
+
+targets := vmlinux.srec vmlinux.bin zImage uImage
+subdir- := compressed
+
+OBJCOPYFLAGS_vmlinux.srec := -Osrec -R .note.gnu.build-id
+OBJCOPYFLAGS_vmlinux.bin  := -Obinary -R .note.gnu.build-id
+
+CONFIG_MEMORY_START    ?= 0x08000000
+CONFIG_BOOT_LINK_OFFSET        ?= 0x00800000
+CONFIG_ENTRY_OFFSET    ?= 0x00001000
+
+$(obj)/vmlinux.srec $(obj)/vmlinux.bin:  vmlinux FORCE
+       $(call if_changed,objcopy)
+       @echo '  Kernel: $@ is ready'
+
+$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
+       $(call if_changed,objcopy)
+       @echo 'Kernel: $@ is ready'
+
+$(obj)/compressed/vmlinux: FORCE
+       $(Q)$(MAKE) $(build)=$(obj)/compressed $@
+
+KERNEL_LOAD    := $(shell /bin/bash -c 'printf "0x%08x" \
+                    $$[$(CONFIG_MEMORY_START) + \
+                       $(CONFIG_ENTRY_OFFSET)]')
+
+KERNEL_ENTRY   := $(shell /bin/bash -c 'printf "0x%08x" \
+                    $$[$(CONFIG_MEMORY_START) + \
+                       $(CONFIG_ENTRY_OFFSET)]')
+
+quiet_cmd_uimage = UIMAGE  $@
+      cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A rx -O linux -T kernel \
+                  -C $(2) -a $(KERNEL_LOAD) -e $(KERNEL_ENTRY) \
+                  -n 'Linux-$(KERNELRELEASE)' -d $< $@
+
+$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
+       $(call if_changed,gzip)
+
+$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
+       $(call if_changed,bzip2)
+
+$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
+       $(call if_changed,lzma)
+
+$(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
+       $(call if_changed,xzkern)
+
+$(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
+       $(call if_changed,lzo)
+
+$(obj)/uImage.bz2: $(obj)/vmlinux.bin.bz2
+       $(call if_changed,uimage,bzip2)
+
+$(obj)/uImage.gz: $(obj)/vmlinux.bin.gz
+       $(call if_changed,uimage,gzip)
+
+$(obj)/uImage.lzma: $(obj)/vmlinux.bin.lzma
+       $(call if_changed,uimage,lzma)
+
+$(obj)/uImage.xz: $(obj)/vmlinux.bin.xz
+       $(call if_changed,uimage,xz)
+
+$(obj)/uImage.lzo: $(obj)/vmlinux.bin.lzo
+       $(call if_changed,uimage,lzo)
+
+$(obj)/uImage.bin: $(obj)/vmlinux.bin
+       $(call if_changed,uimage,none)
+
+$(obj)/uImage: $(obj)/uImage.$(suffix-y)
+       @ln -sf $(notdir $<) $@
+       @echo '  Image $@ is ready'
+
+CLEAN_FILES += arch/$(ARCH)/vmlinux.bin arch/$(ARCH)/vmlinux.srec
+
+export CONFIG_MEMORY_START CONFIG_BOOT_LINK_OFFSET CONFIG_ENTRY_OFFSET
diff --git a/arch/rx/boot/compressed/Makefile b/arch/rx/boot/compressed/Makefile
new file mode 100644 (file)
index 0000000..c72586f
--- /dev/null
@@ -0,0 +1,56 @@
+#
+# linux/arch/rx/boot/compressed/Makefile
+#
+# create a compressed vmlinux image from the original vmlinux
+#
+
+targets                := vmlinux vmlinux.bin vmlinux.bin.gz \
+                  vmlinux.bin.bz2 vmlinux.bin.lzma \
+                  vmlinux.bin.xz vmlinux.bin.lzo \
+                  head.o misc.o piggy.o
+
+OBJECTS = $(obj)/head_$(BITS).o $(obj)/misc.o $(obj)/cache.o
+
+#
+# IMAGE_OFFSET is the load offset of the compression loader
+#
+IMAGE_OFFSET   := $(shell /bin/bash -c 'printf "0x%08x" \
+                    $$[$(CONFIG_MEMORY_START)  + \
+                       $(CONFIG_BOOT_LINK_OFFSET)]')
+
+LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
+
+ifeq ($(CONFIG_MCOUNT),y)
+ORIG_CFLAGS := $(KBUILD_CFLAGS)
+KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
+endif
+
+LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \
+                  -T $(obj)/../../kernel/vmlinux.lds
+
+$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(LIBGCC) FORCE
+       $(call if_changed,ld)
+       @:
+
+$(obj)/vmlinux.bin: vmlinux FORCE
+       $(call if_changed,objcopy)
+
+vmlinux.bin.all-y := $(obj)/vmlinux.bin
+
+$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE
+       $(call if_changed,gzip)
+$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
+       $(call if_changed,bzip2)
+$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
+       $(call if_changed,lzma)
+$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
+       $(call if_changed,xzkern)
+$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
+       $(call if_changed,lzo)
+
+OBJCOPYFLAGS += -R .empty_zero_page
+
+LDFLAGS_piggy.o := -r --format binary --oformat $(ld-bfd) -T
+
+$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE
+       $(call if_changed,ld)
diff --git a/arch/rx/boot/compressed/head.S b/arch/rx/boot/compressed/head.S
new file mode 100644 (file)
index 0000000..989b60d
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ *  linux/arch/rx/boot/compressed/head.S
+ *
+ *  Copyright (C) 2011 Yoshinori Sato <ysato@users.sourceforge.jp>
+ */
+
+       .text
+
+#include <asm/page.h>
+
+       .global startup
+startup:
+       mov.l   #initsp,r0
+       mov.l   #_sbss,r1
+       mov.l   #_ebss,r3
+       sub     r1,r3
+       mov.l   #0,r2
+       sstr.b
+       mov.l   #decompress_kernel, r1
+       jsr     r1
+       mov.l   #_text+PAGE_SIZE, r1
+       jmp     r1
+       
+       .align  9
+fake_headers_as_bzImage:
+       .word   0
+       .ascii  "HdrS"          ! header signature
+       .word   0x0202          ! header version number (>= 0x0105)
+                               ! or else old loadlin-1.5 will fail)
+       .word   0               ! default_switch
+       .word   0               ! SETUPSEG
+       .word   0x1000
+       .word   0               ! pointing to kernel version string
+       .byte   0               ! = 0, old one (LILO, Loadlin,
+                               ! 0xTV: T=0 for LILO
+                               !       V = version
+       .byte   1               ! Load flags bzImage=1
+       .word   0x8000          ! size to move, when setup is not
+       .long   0x100000        ! 0x100000 = default for big kernel
+       .long   0               ! address of loaded ramdisk image
+       .long   0               # its size in bytes
diff --git a/arch/rx/boot/compressed/misc.c b/arch/rx/boot/compressed/misc.c
new file mode 100644 (file)
index 0000000..5d1e2d0
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * arch/rx/boot/compressed/misc.c
+ *
+ * This is a collection of several routines from gzip-1.0.3
+ * adapted for Linux.
+ *
+ * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
+ *
+ */
+
+#include <asm/uaccess.h>
+#include <asm/addrspace.h>
+#include <asm/page.h>
+
+/*
+ * gzip declarations
+ */
+
+#define STATIC static
+
+#undef memset
+#undef memcpy
+#define memzero(s, n)     memset ((s), 0, (n))
+
+extern char input_data[];
+extern int input_len;
+static unsigned char *output;
+
+static void error(char *m);
+
+int puts(const char *);
+
+extern int _text;              /* Defined in vmlinux.lds.S */
+extern int _end;
+static unsigned long free_mem_ptr;
+static unsigned long free_mem_end_ptr;
+
+#ifdef CONFIG_HAVE_KERNEL_BZIP2
+#define HEAP_SIZE      0x400000
+#else
+#define HEAP_SIZE      0x10000
+#endif
+
+#ifdef CONFIG_KERNEL_GZIP
+#include "../../../../lib/decompress_inflate.c"
+#endif
+
+#ifdef CONFIG_KERNEL_BZIP2
+#include "../../../../lib/decompress_bunzip2.c"
+#endif
+
+#ifdef CONFIG_KERNEL_LZMA
+#include "../../../../lib/decompress_unlzma.c"
+#endif
+
+#ifdef CONFIG_KERNEL_XZ
+#include "../../../../lib/decompress_unxz.c"
+#endif
+
+#ifdef CONFIG_KERNEL_LZO
+#include "../../../../lib/decompress_unlzo.c"
+#endif
+
+int puts(const char *s)
+{
+       /* This should be updated to use the sh-sci routines */
+       return 0;
+}
+
+void* memset(void* s, int c, size_t n)
+{
+       int i;
+       char *ss = (char*)s;
+
+       for (i=0;i<n;i++) ss[i] = c;
+       return s;
+}
+
+void* memcpy(void* __dest, __const void* __src,
+                           size_t __n)
+{
+       int i;
+       char *d = (char *)__dest, *s = (char *)__src;
+
+       for (i=0;i<__n;i++) d[i] = s[i];
+       return __dest;
+}
+
+static void error(char *x)
+{
+       puts("\n\n");
+       puts(x);
+       puts("\n\n -- System halted");
+
+       while(1);       /* Halt */
+}
+
+void decompress_kernel(void)
+{
+       unsigned long output_addr;
+
+       output = (unsigned char *)&_text+PAGE_SIZE;
+       free_mem_ptr = (unsigned long)&_end;
+       free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
+
+       puts("Uncompressing Linux... ");
+       decompress(input_data, input_len, NULL, NULL, output, NULL, error);
+       puts("Ok, booting the kernel.\n");
+}
diff --git a/arch/rx/boot/compressed/vmlinux.scr b/arch/rx/boot/compressed/vmlinux.scr
new file mode 100644 (file)
index 0000000..862d748
--- /dev/null
@@ -0,0 +1,10 @@
+SECTIONS
+{
+  .rodata..compressed : {
+       input_len = .;
+       LONG(input_data_end - input_data) input_data = .;
+       *(.data)
+       output_len = . - 4;
+       input_data_end = .;
+       }
+}
diff --git a/arch/rx/defconfig b/arch/rx/defconfig
new file mode 100644 (file)
index 0000000..20b3698
--- /dev/null
@@ -0,0 +1,49 @@
+CONFIG_EXPERIMENTAL=y
+# CONFIG_LOCALVERSION_AUTO is not set
+# CONFIG_KALLSYMS is not set
+# CONFIG_HOTPLUG is not set
+# CONFIG_ELF_CORE is not set
+# CONFIG_BASE_FULL is not set
+# CONFIG_FUTEX is not set
+# CONFIG_EPOLL is not set
+# CONFIG_SIGNALFD is not set
+# CONFIG_TIMERFD is not set
+# CONFIG_EVENTFD is not set
+# CONFIG_AIO is not set
+# CONFIG_VM_EVENT_COUNTERS is not set
+# CONFIG_COMPAT_BRK is not set
+# CONFIG_BLOCK is not set
+CONFIG_INPUT_CLOCK_FREQ=20000000
+CONFIG_PCLK_MULT=2
+CONFIG_ROMKERNEL=y
+CONFIG_ROMSTART=0xff000000
+CONFIG_ROMEND=0xffffffff
+CONFIG_RAMSTART=0x10000000
+CONFIG_RAMEND=0x11000000
+CONFIG_INITIAL_STACK=0x11000000
+CONFIG_RX_CMT_CH=0
+CONFIG_BINFMT_FLAT=y
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+# CONFIG_FW_LOADER is not set
+# CONFIG_INPUT is not set
+# CONFIG_SERIO is not set
+# CONFIG_VT is not set
+# CONFIG_DEVKMEM is not set
+CONFIG_SERIAL_SH_SCI=y
+CONFIG_SERIAL_SH_SCI_CONSOLE=y
+# CONFIG_UNIX98_PTYS is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_HW_RANDOM is not set
+# CONFIG_HWMON is not set
+# CONFIG_MFD_SUPPORT is not set
+# CONFIG_USB_SUPPORT is not set
+# CONFIG_FILE_LOCKING is not set
+# CONFIG_DNOTIFY is not set
+# CONFIG_INOTIFY_USER is not set
+# CONFIG_PROC_FS is not set
+# CONFIG_SYSFS is not set
+# CONFIG_MISC_FILESYSTEMS is not set
+# CONFIG_ENABLE_WARN_DEPRECATED is not set
+# CONFIG_ENABLE_MUST_CHECK is not set
+CONFIG_EARLY_PRINTK=y
+# CONFIG_CRC32 is not set
diff --git a/arch/rx/include/asm/Kbuild b/arch/rx/include/asm/Kbuild
new file mode 100644 (file)
index 0000000..9523434
--- /dev/null
@@ -0,0 +1,5 @@
+include include/asm-generic/Kbuild.asm
+
+header-y += posix_types.h
+header-y += ptrace.h
+header-y += unistd.h
diff --git a/arch/rx/include/asm/asm-offsets.h b/arch/rx/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
diff --git a/arch/rx/include/asm/atomic.h b/arch/rx/include/asm/atomic.h
new file mode 100644 (file)
index 0000000..2309fb6
--- /dev/null
@@ -0,0 +1,148 @@
+#ifndef __ASM_RX_ATOMIC_H__
+#define __ASM_RX_ATOMIC_H__
+
+#include <linux/types.h>
+
+/*
+ * Atomic operations that C can't guarantee us.  Useful for
+ * resource counting etc..
+ */
+
+#define ATOMIC_INIT(i) { (i) }
+
+#define atomic_read(v)         ((v)->counter)
+#define atomic_set(v, i)       (((v)->counter) = i)
+
+#include <asm/system.h>
+#include <linux/kernel.h>
+
+static __inline__ int atomic_add_return(int i, atomic_t *v)
+{
+       int ret;
+       unsigned long psw;
+       local_irq_save(psw);
+       ret = v->counter += i;
+       local_irq_restore(psw);
+       return ret;
+}
+
+#define atomic_add(i, v) atomic_add_return(i, v)
+#define atomic_add_negative(a, v)      (atomic_add_return((a), (v)) < 0)
+
+static __inline__ int atomic_sub_return(int i, atomic_t *v)
+{
+       int ret;
+       unsigned long psw;
+       local_irq_save(psw);
+       ret = v->counter -= i;
+       local_irq_restore(psw);
+       return ret;
+}
+
+#define atomic_sub(i, v) atomic_sub_return(i, v)
+#define atomic_sub_and_test(i,v) (atomic_sub_return(i, v) == 0)
+
+static __inline__ int atomic_inc_return(atomic_t *v)
+{
+       int ret;
+       unsigned long psw;
+       local_irq_save(psw);
+       v->counter++;
+       ret = v->counter;
+       local_irq_restore(psw);
+       return ret;
+}
+
+#define atomic_inc(v) atomic_inc_return(v)
+
+/*
+ * atomic_inc_and_test - increment and test
+ * @v: pointer of type atomic_t
+ *
+ * Atomically increments @v by 1
+ * and returns true if the result is zero, or false for all
+ * other cases.
+ */
+#define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
+
+static __inline__ int atomic_dec_return(atomic_t *v)
+{
+       int ret;
+       unsigned long psw;
+       local_irq_save(psw);
+       --v->counter;
+       ret = v->counter;
+       local_irq_restore(psw);
+       return ret;
+}
+
+#define atomic_dec(v) atomic_dec_return(v)
+
+static __inline__ int atomic_dec_and_test(atomic_t *v)
+{
+       int ret;
+       unsigned long psw;
+       local_irq_save(psw);
+       --v->counter;
+       ret = v->counter;
+       local_irq_restore(psw);
+       return ret == 0;
+}
+
+static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
+{
+       int ret;
+       unsigned long psw;
+
+       local_irq_save(psw);
+       ret = v->counter;
+       if (likely(ret == old))
+               v->counter = new;
+       local_irq_restore(psw);
+       return ret;
+}
+
+#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
+
+static inline int __atomic_add_unless(atomic_t *v, int a, int u)
+{
+       int c, old;
+       c = atomic_read(v);
+       for (;;) {
+               if (unlikely(c == (u)))
+                       break;
+               old = atomic_cmpxchg((v), c, c + (a));
+               if (likely(old == c))
+                       break;
+               c = old;
+       }
+       return c;
+}
+
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
+static __inline__ void atomic_clear_mask(unsigned long mask, atomic_t *v)
+{
+       unsigned long psw;
+
+       local_irq_save(psw);
+       v->counter &= ~mask;
+       local_irq_restore(psw);
+}
+
+static __inline__ void atomic_set_mask(unsigned long mask, atomic_t *v)
+{
+       unsigned long psw;
+
+       local_irq_save(psw);
+       v->counter &= mask;
+       local_irq_restore(psw);
+}
+
+/* Atomic operations are already serializing */
+#define smp_mb__before_atomic_dec()    barrier()
+#define smp_mb__after_atomic_dec() barrier()
+#define smp_mb__before_atomic_inc()    barrier()
+#define smp_mb__after_atomic_inc() barrier()
+
+#endif /* __ASM_RX_ATOMIC_H__ */
diff --git a/arch/rx/include/asm/auxvec.h b/arch/rx/include/asm/auxvec.h
new file mode 100644 (file)
index 0000000..d994743
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef __ASM_RX_AUXVEC_H__
+#define __ASM_RX_AUXVEC_H__
+
+#endif
diff --git a/arch/rx/include/asm/bitops.h b/arch/rx/include/asm/bitops.h
new file mode 100644 (file)
index 0000000..2bce2e7
--- /dev/null
@@ -0,0 +1,135 @@
+#ifndef __ASM_RX_BITOPS_H__
+#define __ASM_RX_BITOPS_H__
+
+#include <linux/compiler.h>
+#include <asm/system.h>
+
+#ifdef __KERNEL__
+
+#ifndef _LINUX_BITOPS_H
+#error only <linux/bitops.h> can be included directly
+#endif
+
+/*
+ * Function prototypes to keep gcc -Wall happy
+ */
+
+/*
+ * ffz = Find First Zero in word. Undefined if no zero exists,
+ * so code should check against ~0UL first..
+ */
+static __inline__ unsigned long ffz(unsigned long word)
+{
+       unsigned long result = -1;
+
+       __asm__("1:\n\t"
+               "add #1,%0\n\t"
+               "shlr #1,%1\n\t"
+               "bc 1b"
+               : "=r" (result)
+               : "r" (word), "0"(result));
+       return result;
+}
+
+#define RX_GEN_BITOP(FNAME,OP)                                         \
+static __inline__ void FNAME(int nr, volatile unsigned long* addr)     \
+{                                                                      \
+       volatile unsigned char *b_addr;                                 \
+       b_addr = (volatile unsigned char *)addr + ((nr >> 3));          \
+       __asm__ volatile (OP " %1,%0.b":"=m"(*b_addr):"ri"(nr & 7));    \
+}
+/*
+ * clear_bit() doesn't provide any barrier for the compiler.
+ */
+#define smp_mb__before_clear_bit()     barrier()
+#define smp_mb__after_clear_bit()      barrier()
+
+RX_GEN_BITOP(set_bit   ,"bset")
+RX_GEN_BITOP(clear_bit ,"bclr")
+RX_GEN_BITOP(change_bit,"bnot")
+#define __set_bit(nr,addr)    set_bit((nr),(addr))
+#define __clear_bit(nr,addr)  clear_bit((nr),(addr))
+#define __change_bit(nr,addr) change_bit((nr),(addr))
+
+#undef RX_GEN_BITOP
+#undef RX_GEN_BITOP_CONST
+
+static __inline__ int test_bit(int nr, const unsigned long* addr)
+{
+       volatile unsigned char *b_addr;
+       int result;
+       b_addr = (volatile unsigned char *)addr + ((nr >> 3));
+       __asm__ volatile ("btst %1, %2.b\n\t"
+                         "scnz.l %0"
+                         :"=r"(result):"ri"(nr & 7), "Q"(*b_addr));
+       return result;
+}
+
+#define __test_bit(nr, addr) test_bit(nr, addr)
+
+#define RX_GEN_TEST_BITOP(FNNAME,OP)                           \
+static __inline__ int FNNAME(int nr, volatile void * addr)     \
+{                                                              \
+       int result;                                             \
+       unsigned long psw;                                      \
+       volatile unsigned char *b_addr;                         \
+       b_addr = (volatile unsigned char *)addr + ((nr >> 3));  \
+       __asm__ volatile("mvfc psw, %2\n\t"                     \
+                        "clrpsw i\n\t"                         \
+                        "btst %3, %1.b\n\t"                    \
+                        OP " %3, %1.b\n\t"                     \
+                        "scnz.l %0\n\t"                        \
+                        "mvtc %2, psw"                         \
+                        : "=r"(result),"+m"(*b_addr),"=r"(psw) \
+                        :"ri"(nr & 7):"cc");                   \
+       return result;                                          \
+}                                                              \
+                                                               \
+static __inline__ int __ ## FNNAME(int nr, volatile void * addr)\
+{                                                              \
+       int result;                                             \
+       volatile unsigned char *b_addr;                         \
+       b_addr = (volatile unsigned char *)addr + ((nr >> 3));  \
+       __asm__ volatile("btst %2, %1.b\n\t"                    \
+                        OP " %2, %1.b\n\t"                     \
+                        "scnz.l %0"                            \
+                        :"=r"(result),"+m"(*b_addr)            \
+                        :"ri"(nr & 7));                        \
+       return result;                                          \
+}
+
+RX_GEN_TEST_BITOP(test_and_set_bit,   "bset")
+RX_GEN_TEST_BITOP(test_and_clear_bit, "bclr")
+RX_GEN_TEST_BITOP(test_and_change_bit,"bnot")
+#undef RX_GEN_TEST_BITOP_CONST
+#undef RX_GEN_TEST_BITOP
+
+#include <asm-generic/bitops/ffs.h>
+
+static __inline__ unsigned long __ffs(unsigned long word)
+{
+       unsigned long result;
+
+       result = -1;
+       __asm__ volatile("1:\n\t"
+                        "add #1,%0\n\t"
+                        "shlr #1,%1\n\t"
+                        "bnc 1b"
+                        : "=r" (result)
+                        : "r"(word),"0"(result));
+       return result;
+}
+
+#include <asm-generic/bitops/find.h>
+#include <asm-generic/bitops/sched.h>
+#include <asm-generic/bitops/hweight.h>
+#include <asm-generic/bitops/lock.h>
+#include <asm-generic/bitops/ext2-atomic.h>
+
+#endif /* __KERNEL__ */
+
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+
+#endif /* __ASM_RX_BITOPS_H__ */
diff --git a/arch/rx/include/asm/bitsperlong.h b/arch/rx/include/asm/bitsperlong.h
new file mode 100644 (file)
index 0000000..6dc0bb0
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/bitsperlong.h>
diff --git a/arch/rx/include/asm/bug.h b/arch/rx/include/asm/bug.h
new file mode 100644 (file)
index 0000000..2e36ae7
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __ASM_RX_BUG_H__
+#define __ASM_RX_BUG_H__
+
+/* always true */
+#define is_valid_bugaddr(addr) (1)
+
+#include <asm-generic/bug.h>
+#endif
diff --git a/arch/rx/include/asm/bugs.h b/arch/rx/include/asm/bugs.h
new file mode 100644 (file)
index 0000000..61791e1
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/bugs.h>
diff --git a/arch/rx/include/asm/byteorder.h b/arch/rx/include/asm/byteorder.h
new file mode 100644 (file)
index 0000000..9558416
--- /dev/null
@@ -0,0 +1 @@
+#include <linux/byteorder/little_endian.h>
diff --git a/arch/rx/include/asm/cache.h b/arch/rx/include/asm/cache.h
new file mode 100644 (file)
index 0000000..38f3c68
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __ASM_RX_CACHE_H__
+#define __ASM_RX_CACHE_H__
+
+#define        L1_CACHE_BYTES  16
+
+#define __cacheline_aligned
+#define ____cacheline_aligned
+
+#endif
diff --git a/arch/rx/include/asm/cacheflush.h b/arch/rx/include/asm/cacheflush.h
new file mode 100644 (file)
index 0000000..cc7bda3
--- /dev/null
@@ -0,0 +1,3 @@
+#include <asm-generic/cacheflush.h>
+
+#define __flush_purge_region(ptr, size) do { } while(0)
diff --git a/arch/rx/include/asm/checksum.h b/arch/rx/include/asm/checksum.h
new file mode 100644 (file)
index 0000000..adbb5e6
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/checksum.h>
diff --git a/arch/rx/include/asm/clock.h b/arch/rx/include/asm/clock.h
new file mode 100644 (file)
index 0000000..7dc4faf
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef __ASM_RX_CLOCK_H__
+#define __ASM_RX_CLOCK_H__
+
+#include <linux/list.h>
+#include <linux/seq_file.h>
+#include <linux/cpufreq.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+
+#define DIV_NR 4
+
+struct clk {
+       struct list_head        node;
+       const char              *name;
+       int                     id;
+       struct module           *owner;
+
+       struct clk              *parent;
+       int (*set_rate)(struct clk *clk, unsigned long rate);
+       int (*update)(struct clk *clk);
+
+       struct list_head        children;
+       struct list_head        sibling;        /* node for children */
+
+       int                     usecount;
+
+       unsigned long           rate;
+       unsigned long           flags;
+
+       void __iomem            *mstpcr;
+       unsigned int            mstpbit;
+
+       unsigned long           arch_flags;
+       void                    *priv;
+       struct dentry           *dentry;
+       int                     nr_selectable;
+       int                     selectable[DIV_NR];
+};
+
+struct clk_lookup {
+       struct list_head        node;
+       const char              *dev_id;
+       const char              *con_id;
+       struct clk              *clk;
+};
+
+#define CLK_ENABLE_ON_INIT     (1 << 0)
+
+int __init arch_clk_init(void);
+
+int clk_init(void);
+unsigned long followparent_recalc(struct clk *);
+void recalculate_root_clocks(void);
+void propagate_rate(struct clk *);
+int clk_reparent(struct clk *child, struct clk *parent);
+int clk_register(struct clk *);
+void clk_unregister(struct clk *);
+
+#endif /* __ASM_RX_CLOCK_H__ */
diff --git a/arch/rx/include/asm/cputime.h b/arch/rx/include/asm/cputime.h
new file mode 100644 (file)
index 0000000..6d68ad7
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/cputime.h>
diff --git a/arch/rx/include/asm/current.h b/arch/rx/include/asm/current.h
new file mode 100644 (file)
index 0000000..4c51401
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/current.h>
diff --git a/arch/rx/include/asm/delay.h b/arch/rx/include/asm/delay.h
new file mode 100644 (file)
index 0000000..9670e12
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/delay.h>
diff --git a/arch/rx/include/asm/device.h b/arch/rx/include/asm/device.h
new file mode 100644 (file)
index 0000000..d8f9872
--- /dev/null
@@ -0,0 +1,7 @@
+/*
+ * Arch specific extensions to struct device
+ *
+ * This file is released under the GPLv2
+ */
+#include <asm-generic/device.h>
+
diff --git a/arch/rx/include/asm/div64.h b/arch/rx/include/asm/div64.h
new file mode 100644 (file)
index 0000000..6cd978c
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/div64.h>
diff --git a/arch/rx/include/asm/dma-mapping.h b/arch/rx/include/asm/dma-mapping.h
new file mode 100644 (file)
index 0000000..8fab2bf
--- /dev/null
@@ -0,0 +1,83 @@
+#ifndef __ASM_RX_DMA_MAPPING_H
+#define __ASM_RX_DMA_MAPPING_H
+
+extern struct dma_map_ops *dma_ops;
+extern void no_iommu_init(void);
+
+static inline struct dma_map_ops *get_dma_ops(struct device *dev)
+{
+       return dma_ops;
+}
+
+#include <asm-generic/dma-coherent.h>
+#include <asm-generic/dma-mapping-common.h>
+
+static inline int dma_supported(struct device *dev, u64 mask)
+{
+       struct dma_map_ops *ops = get_dma_ops(dev);
+
+       if (ops->dma_supported)
+               return ops->dma_supported(dev, mask);
+
+       return 1;
+}
+
+static inline int dma_set_mask(struct device *dev, u64 mask)
+{
+       struct dma_map_ops *ops = get_dma_ops(dev);
+
+       if (!dev->dma_mask || !dma_supported(dev, mask))
+               return -EIO;
+       if (ops->set_dma_mask)
+               return ops->set_dma_mask(dev, mask);
+
+       *dev->dma_mask = mask;
+
+       return 0;
+}
+
+void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
+                   enum dma_data_direction dir);
+
+#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
+#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
+
+static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
+{
+       struct dma_map_ops *ops = get_dma_ops(dev);
+
+       if (ops->mapping_error)
+               return ops->mapping_error(dev, dma_addr);
+
+       return dma_addr == 0;
+}
+
+static inline void *dma_alloc_coherent(struct device *dev, size_t size,
+                                      dma_addr_t *dma_handle, gfp_t gfp)
+{
+       struct dma_map_ops *ops = get_dma_ops(dev);
+       void *memory;
+
+       if (dma_alloc_from_coherent(dev, size, dma_handle, &memory))
+               return memory;
+       if (!ops->alloc_coherent)
+               return NULL;
+
+       memory = ops->alloc_coherent(dev, size, dma_handle, gfp);
+
+       return memory;
+}
+
+static inline void dma_free_coherent(struct device *dev, size_t size,
+                                    void *vaddr, dma_addr_t dma_handle)
+{
+       struct dma_map_ops *ops = get_dma_ops(dev);
+
+       if (dma_release_from_coherent(dev, get_order(size), vaddr))
+               return;
+
+       if (ops->free_coherent)
+               ops->free_coherent(dev, size, vaddr, dma_handle);
+}
+
+#endif /* __ASM_RX_DMA_MAPPING_H */
diff --git a/arch/rx/include/asm/dma.h b/arch/rx/include/asm/dma.h
new file mode 100644 (file)
index 0000000..7ce20d9
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/dma.h>
diff --git a/arch/rx/include/asm/elf.h b/arch/rx/include/asm/elf.h
new file mode 100644 (file)
index 0000000..de5c12c
--- /dev/null
@@ -0,0 +1,120 @@
+#ifndef __ASM_RX_ELF_H__
+#define __ASM_RX_ELF_H__
+
+/*
+ * ELF register definitions..
+ */
+
+#include <asm/ptrace.h>
+#include <asm/user.h>
+
+typedef unsigned long elf_greg_t;
+
+#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+typedef unsigned long elf_fpregset_t;
+
+/*
+ * This is used to ensure we don't load something for the wrong architecture.
+ */
+#define elf_check_arch(x) ((x)->e_machine == EM_RX)
+
+/*
+ * These are used to set parameters in the core dumps.
+ */
+#define ELF_CLASS      ELFCLASS32
+#define ELF_DATA       ELFDATA2LSB
+#define ELF_ARCH       EM_RX
+
+#define USE_ELF_CORE_DUMP
+#define ELF_EXEC_PAGESIZE      4096
+
+/* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
+   use of this is to invoke "./ld.so someprog" to test out a new version of
+   the loader.  We need to make sure that it is out of the way of the program
+   that it will "exec", and that there is sufficient room for the brk.  */
+
+#define ELF_ET_DYN_BASE         0xD0000000UL
+
+/* This yields a mask that user programs can use to figure out what
+   instruction set this cpu supports.  */
+
+#define ELF_HWCAP      (0)
+
+/* This yields a string that ld.so will use to load implementation
+   specific libraries for optimization.  This is more specific in
+   intent than poking at uname or /proc/cpuinfo.  */
+
+#define ELF_PLATFORM  (NULL)
+
+#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
+
+#define R_RX_NONE      0
+#define R_RX_DIR32     1
+#define R_RX_DIR24S    2
+#define R_RX_DIR16     3
+#define R_RX_DIR16U    4
+#define R_RX_DIR16S    5
+#define R_RX_DIR8      6
+#define R_RX_DIR8U     7
+#define R_RX_DIR8S     8
+#define R_RX_DIR24S_PCREL      9
+#define R_RX_DIR16S_PCREL      10
+#define R_RX_DIR8S_PCREL       11
+#define R_RX_DIR16UL   12
+#define R_RX_DIR16UW   13
+#define R_RX_DIR8UL    14
+#define R_RX_DIR8UW    15
+#define R_RX_DIR32_REV 16
+#define R_RX_DIR16_REV 17
+#define R_RX_DIR3U_PCREL       18
+#define R_RX_RH_3_PCREL        32
+#define R_RX_RH_16_OP  33
+#define R_RX_RH_24_OP  34
+#define R_RX_RH_32_OP  35
+#define R_RX_RH_24_UNS 36
+#define R_RX_RH_8_NEG  37
+#define R_RX_RH_16_NEG 38
+#define R_RX_RH_24_NEG 39
+#define R_RX_RH_32_NEG 40
+#define R_RX_RH_DIFF   41
+#define R_RX_RH_GPRELB 42
+#define R_RX_RH_GPRELW 43
+#define R_RX_RH_GPRELL 44
+#define R_RX_RH_RELAX  45
+#define R_RX_ABS32     65
+#define R_RX_ABS24S    66
+#define R_RX_ABS16     67
+#define R_RX_ABS16U    68
+#define R_RX_ABS16S    69
+#define R_RX_ABS8      70
+#define R_RX_ABS8U     71
+#define R_RX_ABS8S     72
+#define R_RX_ABS24S_PCREL      73
+#define R_RX_ABS16S_PCREL      74
+#define R_RX_ABS8S_PCREL       75
+#define R_RX_ABS16UL   76
+#define R_RX_ABS16UW   77
+#define R_RX_ABS8UL    78
+#define R_RX_ABS8UW    79
+#define R_RX_ABS32_REV 80
+#define R_RX_ABS16_REV 81
+#define R_RX_SYM       128
+#define R_RX_OPneg     129
+#define R_RX_OPadd     130
+#define R_RX_OPsub     131
+#define R_RX_OPmul     132
+#define R_RX_OPdiv     133
+#define R_RX_OPshla    134
+#define R_RX_OPshra    135
+#define R_RX_OPsctsize 136
+#define R_RX_OPscttop  141
+#define R_RX_OPand     144
+#define R_RX_OPor      145
+#define R_RX_OPxor     146
+#define R_RX_OPnot     147
+#define R_RX_OPmod     148
+#define R_RX_OPromtop  149
+#define R_RX_OPramtop  150
+
+#endif
diff --git a/arch/rx/include/asm/emergency-restart.h b/arch/rx/include/asm/emergency-restart.h
new file mode 100644 (file)
index 0000000..3711bd9
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/emergency-restart.h>
diff --git a/arch/rx/include/asm/errno.h b/arch/rx/include/asm/errno.h
new file mode 100644 (file)
index 0000000..4c82b50
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/errno.h>
diff --git a/arch/rx/include/asm/fcntl.h b/arch/rx/include/asm/fcntl.h
new file mode 100644 (file)
index 0000000..cefb302
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef __ASM_RX_FCNTL_H__
+#define __ASM_RX_FCNTL_H__
+
+#define O_DIRECTORY    040000  /* must be a directory */
+#define O_NOFOLLOW     0100000 /* don't follow links */
+#define O_DIRECT       0200000 /* direct disk access hint - currently ignored */
+#define O_LARGEFILE    0400000
+
+#include <asm-generic/fcntl.h>
+
+#endif /* __ASM_RX_FCNTL_H__ */
diff --git a/arch/rx/include/asm/flat.h b/arch/rx/include/asm/flat.h
new file mode 100644 (file)
index 0000000..a26f99c
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef __ASM_RX_FLAT_H__
+#define __ASM_RX_FLAT_H__
+
+#define        flat_argvp_envp_on_stack()              0
+#define        flat_old_ram_flag(flags)                1
+#define        flat_reloc_valid(reloc, size)           ((reloc) <= (size))
+#define        flat_set_persistent(relval, p)          0
+
+#define        flat_get_relocate_addr(rel)             (rel)
+#define flat_get_addr_from_rp(rp, relval, flags, persistent) \
+        get_unaligned(rp)
+#define flat_put_addr_at_rp(rp, addr, rel) \
+       put_unaligned (addr, rp)
+
+#endif /* __ASM_RX_FLAT_H__ */
diff --git a/arch/rx/include/asm/ftrace.h b/arch/rx/include/asm/ftrace.h
new file mode 100644 (file)
index 0000000..40a8c17
--- /dev/null
@@ -0,0 +1 @@
+/* empty */
diff --git a/arch/rx/include/asm/futex.h b/arch/rx/include/asm/futex.h
new file mode 100644 (file)
index 0000000..0b74582
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/futex.h>
diff --git a/arch/rx/include/asm/guard.rb b/arch/rx/include/asm/guard.rb
new file mode 100644 (file)
index 0000000..32700c1
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/ruby
+
+def normalize(sym)
+  sym.sub!(/^_H8300/,"__ASM_RX")
+  sym.sub!(/^__ARCH_H8300/,"__ASM_RX")
+  sym.sub!(/^_ASM_H8300/,"__ASM_RX")
+  sym.sub!(/^__ASM_H8300/,"__ASM_RX")
+  sym.sub!(/^__ASMH8300/,"__ASM_RX")
+  sym.sub!(/^__H8300/,"__ASM_RX")
+  sym.sub!(/H_*$/,"H__")
+  return sym
+end
+
+STDIN.each_line { |line|
+  if line.index("H8300") then
+    line.sub!(/^#ifndef\s+(\S+)$/) { "#ifndef #{normalize($1)}" }
+    line.sub!(/^#define\s+(\S+)$/) { "#define #{normalize($1)}" }
+    line.sub!(/^#endif\s+\/\*\s+(\S+)\s+\*\/$/) { "#endif /* #{normalize($1)} */" }
+  end
+  print line
+}
diff --git a/arch/rx/include/asm/guard.sed b/arch/rx/include/asm/guard.sed
new file mode 100644 (file)
index 0000000..52c7fa0
--- /dev/null
@@ -0,0 +1,11 @@
+s/^#ifndef\ _H8300/#ifndef __ASM_RX/g
+s/^#define\ _H8300/#define __ASM_RX/g
+s/^#ifndef\ __ARCH_H8300/#ifndef\ __ASM_RX/g
+s/^#define\ __ARCH_H8300/#define\ __ASM_RX/g
+s/^#ifndef\ _ASM_H8300/#ifndef __ASM_RX/g
+s/^#define\ _ASM_H8300/#define __ASM_RX/g
+s/^#ifndef\ __ASMH8300/#ifndef __ASM_RX/g
+s/^#define\ __ASMH8300/#define __ASM_RX/g
+s/^#ifndef\ __H8300/#ifndef __ASM_RX/g
+s/^#define\ __H8300/#define __ASM_RX/g
+s/^#\(.*\)H_*$/#\1H__/g
diff --git a/arch/rx/include/asm/hardirq.h b/arch/rx/include/asm/hardirq.h
new file mode 100644 (file)
index 0000000..19f4a4d
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef __ASM_RX_HARDIRQ_H__
+#define __ASM_RX_HARDIRQ_H__
+
+#include <asm/irq.h>
+
+#define HARDIRQ_BITS   8
+
+/*
+ * The hardirq mask has to be large enough to have
+ * space for potentially all IRQ sources in the system
+ * nesting on a single CPU:
+ */
+#if (1 << HARDIRQ_BITS) < NR_IRQS
+# error HARDIRQ_BITS is too low!
+#endif
+
+#include <asm-generic/hardirq.h>
+
+#endif
diff --git a/arch/rx/include/asm/hw_irq.h b/arch/rx/include/asm/hw_irq.h
new file mode 100644 (file)
index 0000000..d75a5a1
--- /dev/null
@@ -0,0 +1 @@
+/* Do Nothing */
diff --git a/arch/rx/include/asm/io.h b/arch/rx/include/asm/io.h
new file mode 100644 (file)
index 0000000..4ee5d09
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/io.h>
diff --git a/arch/rx/include/asm/ioctl.h b/arch/rx/include/asm/ioctl.h
new file mode 100644 (file)
index 0000000..b279fe0
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/ioctl.h>
diff --git a/arch/rx/include/asm/ioctls.h b/arch/rx/include/asm/ioctls.h
new file mode 100644 (file)
index 0000000..ec34c76
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/ioctls.h>
diff --git a/arch/rx/include/asm/ipcbuf.h b/arch/rx/include/asm/ipcbuf.h
new file mode 100644 (file)
index 0000000..84c7e51
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/ipcbuf.h>
diff --git a/arch/rx/include/asm/irq.h b/arch/rx/include/asm/irq.h
new file mode 100644 (file)
index 0000000..b438a1d
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef __ASM_RX_IRQ_H__
+#define __ASM_RX_IRQ_H__
+
+#define NR_IRQS 256
+#define EXT_IRQ0 64
+#define EXT_IRQS 16
+#define RX_MIN_IRQ 21
+
+static __inline__ int irq_canonicalize(int irq)
+{
+       return irq;
+}
+
+void rx_force_interrupt(unsigned int no);
+
+#endif /* __ASM_RX_IRQ_H__ */
diff --git a/arch/rx/include/asm/irq_regs.h b/arch/rx/include/asm/irq_regs.h
new file mode 100644 (file)
index 0000000..3dd9c0b
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/irq_regs.h>
diff --git a/arch/rx/include/asm/irqflags.h b/arch/rx/include/asm/irqflags.h
new file mode 100644 (file)
index 0000000..dada51a
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef _RX_IRQFLAGS_H_
+#define _RX_IRQFLAGS_H_
+
+static inline unsigned long arch_local_irq_save_flags(void)
+{
+       unsigned long iflag;
+       asm volatile ("mvfc psw, %0\n\t"
+                     : "=r"(iflag));
+       return iflag;
+}
+
+static inline void arch_local_irq_disable(void)
+{
+       asm volatile ("clrpsw i");
+}
+
+static inline void arch_local_irq_enable(void)
+{
+       asm volatile ("setpsw i");
+}
+
+static inline unsigned long arch_local_irq_save(void)
+{
+       unsigned long iflag;
+       iflag = arch_local_irq_save_flags();
+       arch_local_irq_disable();
+       return iflag;
+}
+
+static inline void arch_local_irq_restore(unsigned long iflag)
+{
+       asm volatile("btst #16, %0\n\t"
+                    "mvfc psw, %0\n\t"
+                    "bmc  #16, %0\n\t"
+                    "mvtc %0, psw"
+                    ::"r"(iflag):"cc");
+}
+               
+static inline int arch_irqs_disabled_flags(unsigned long psw)
+{
+       return (psw & 0x10000) == 0;
+}
+
+static inline int arch_irqs_disabled(void)
+{
+       return arch_irqs_disabled_flags(arch_local_irq_save_flags());
+}
+
+#endif
diff --git a/arch/rx/include/asm/kdebug.h b/arch/rx/include/asm/kdebug.h
new file mode 100644 (file)
index 0000000..99277c0
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef __ASM_RX_KDEBUG_H__
+#define __ASM_RX_KDEBUG_H__
+
+#include <asm/ptrace.h>
+
+enum die_val {
+       DIE_NONE,
+       DIE_TRAP,
+       DIE_NMI,
+};
+extern void die(const char *err, struct pt_regs *regs);
+
+#endif
diff --git a/arch/rx/include/asm/kmap_types.h b/arch/rx/include/asm/kmap_types.h
new file mode 100644 (file)
index 0000000..3575c64
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/kmap_types.h>
diff --git a/arch/rx/include/asm/linkage.h b/arch/rx/include/asm/linkage.h
new file mode 100644 (file)
index 0000000..4ad6a02
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef __ASM_RX_LINKAGE_H__
+#define __ASM_RX_LINKAGE_H__
+
+#undef SYMBOL_NAME_LABEL
+#undef SYMBOL_NAME
+#endif
diff --git a/arch/rx/include/asm/local.h b/arch/rx/include/asm/local.h
new file mode 100644 (file)
index 0000000..c11c530
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/local.h>
diff --git a/arch/rx/include/asm/mc146818rtc.h b/arch/rx/include/asm/mc146818rtc.h
new file mode 100644 (file)
index 0000000..46be370
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+ * Machine dependent access functions for RTC registers.
+ */
+#ifndef __ASM_RX_MC146818RTC_H__
+#define __ASM_RX_MC146818RTC_H__
+
+/* empty include file to satisfy the include in genrtc.c/ide-geometry.c */
+
+#endif /* __ASM_RX_MC146818RTC_H__ */
diff --git a/arch/rx/include/asm/mman.h b/arch/rx/include/asm/mman.h
new file mode 100644 (file)
index 0000000..8eebf89
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/mman.h>
diff --git a/arch/rx/include/asm/mmu.h b/arch/rx/include/asm/mmu.h
new file mode 100644 (file)
index 0000000..2caa6ed
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/mmu.h>
diff --git a/arch/rx/include/asm/mmu_context.h b/arch/rx/include/asm/mmu_context.h
new file mode 100644 (file)
index 0000000..7739fe1
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/mmu_context.h>
diff --git a/arch/rx/include/asm/module.h b/arch/rx/include/asm/module.h
new file mode 100644 (file)
index 0000000..0881e22
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef __ASM_RX_MODULE_H__
+#define __ASM_RX_MODULE_H__
+
+#include <asm-generic/module.h>
+
+#endif /* __ASM_RX_MODULE_H__ */
diff --git a/arch/rx/include/asm/msgbuf.h b/arch/rx/include/asm/msgbuf.h
new file mode 100644 (file)
index 0000000..809134c
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/msgbuf.h>
diff --git a/arch/rx/include/asm/mutex.h b/arch/rx/include/asm/mutex.h
new file mode 100644 (file)
index 0000000..6c2390a
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/mutex.h>
diff --git a/arch/rx/include/asm/omit-guard.rb b/arch/rx/include/asm/omit-guard.rb
new file mode 100644 (file)
index 0000000..6153f0f
--- /dev/null
@@ -0,0 +1,10 @@
+#!/usr/bin/ruby
+
+file = readlines
+if file.size ==6 then
+  if file[2] == "\n" && file[4] == "\n" && /^#include\s+<asm-generic/ =~ file[3]
+    print file[3]
+    exit 0
+  end
+end
+print file
diff --git a/arch/rx/include/asm/page.h b/arch/rx/include/asm/page.h
new file mode 100644 (file)
index 0000000..1a8b627
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/page.h>
diff --git a/arch/rx/include/asm/page_offset.h b/arch/rx/include/asm/page_offset.h
new file mode 100644 (file)
index 0000000..f870646
--- /dev/null
@@ -0,0 +1,3 @@
+
+#define PAGE_OFFSET_RAW                0x00000000
+
diff --git a/arch/rx/include/asm/param.h b/arch/rx/include/asm/param.h
new file mode 100644 (file)
index 0000000..965d454
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/param.h>
diff --git a/arch/rx/include/asm/pci.h b/arch/rx/include/asm/pci.h
new file mode 100644 (file)
index 0000000..51bb557
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef __ASM_RX_PCI_H__
+#define __ASM_RX_PCI_H__
+
+/*
+ * pci.h - RX specific PCI declarations.
+ *
+ * Yoshinori Sato <ysato@users.sourceforge.jp>
+ */
+
+#define pcibios_assign_all_busses()    0
+
+static inline void pcibios_set_master(struct pci_dev *dev)
+{
+       /* No special bus mastering setup handling */
+}
+
+static inline void pcibios_penalize_isa_irq(int irq, int active)
+{
+       /* We don't do dynamic PCI IRQ allocation */
+}
+
+#define PCI_DMA_BUS_IS_PHYS    (1)
+
+#endif /* __ASM_RX_PCI_H__ */
diff --git a/arch/rx/include/asm/percpu.h b/arch/rx/include/asm/percpu.h
new file mode 100644 (file)
index 0000000..06a959d
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/percpu.h>
diff --git a/arch/rx/include/asm/pgalloc.h b/arch/rx/include/asm/pgalloc.h
new file mode 100644 (file)
index 0000000..f261cb7
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/pgalloc.h>
diff --git a/arch/rx/include/asm/pgtable.h b/arch/rx/include/asm/pgtable.h
new file mode 100644 (file)
index 0000000..96b2680
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef __ASM_RX_PGTABLE_H__
+#define __ASM_RX_PGTABLE_H__
+
+#include <asm-generic/pgtable-nopud.h>
+#include <asm-generic/pgtable.h>
+
+#define pgtable_cache_init() do {} while(0)
+void paging_init(void);
+
+#define PAGE_NONE              __pgprot(0)    /* these mean nothing to NO_MM */
+#define PAGE_SHARED            __pgprot(0)    /* these mean nothing to NO_MM */
+#define PAGE_COPY              __pgprot(0)    /* these mean nothing to NO_MM */
+#define PAGE_READONLY  __pgprot(0)    /* these mean nothing to NO_MM */
+#define PAGE_KERNEL            __pgprot(0)    /* these mean nothing to NO_MM */
+#define swapper_pg_dir ((pgd_t *) 0)
+
+#define __swp_type(x)          (0)
+#define __swp_offset(x)                (0)
+#define __swp_entry(typ,off)   ((swp_entry_t) { ((typ) | ((off) << 7)) })
+#define __pte_to_swp_entry(pte)        ((swp_entry_t) { pte_val(pte) })
+#define __swp_entry_to_pte(x)  ((pte_t) { (x).val })
+
+static inline int pte_file(pte_t pte) { return 0; }
+
+/*
+ * All 32bit addresses are effectively valid for vmalloc...
+ * Sort of meaningless for non-VM targets.
+ */
+#define        VMALLOC_START   0
+#define        VMALLOC_END     0xffffffff
+
+#endif
diff --git a/arch/rx/include/asm/poll.h b/arch/rx/include/asm/poll.h
new file mode 100644 (file)
index 0000000..c445e60
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef __ASM_RX_POLL_H__
+#define __ASM_RX_POLL_H__
+
+#define POLLWRNORM     POLLOUT
+#define POLLWRBAND     256
+
+#include <asm-generic/poll.h>
+
+#undef POLLREMOVE
+
+#endif
diff --git a/arch/rx/include/asm/posix_types.h b/arch/rx/include/asm/posix_types.h
new file mode 100644 (file)
index 0000000..22cae62
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/posix_types.h>
diff --git a/arch/rx/include/asm/processor.h b/arch/rx/include/asm/processor.h
new file mode 100644 (file)
index 0000000..9a9dba1
--- /dev/null
@@ -0,0 +1,108 @@
+#ifndef __ASM_RX_PROCESSOR_H__
+#define __ASM_RX_PROCESSOR_H__
+
+/*
+ * Default implementation of macro that returns current
+ * instruction pointer ("program counter").
+ */
+#define current_text_addr() ({ __label__ _l; _l: &&_l;})
+
+#include <linux/compiler.h>
+#include <asm/segment.h>
+#include <asm/ptrace.h>
+#include <asm/current.h>
+
+/*
+ * User space process size: 3.75GB. This is hardcoded into a few places,
+ * so don't change it unless you know what you are doing.
+ */
+#define TASK_SIZE      (0xFFFFFFFFUL)
+
+#ifdef __KERNEL__
+#define STACK_TOP      TASK_SIZE
+#define STACK_TOP_MAX  STACK_TOP
+#endif
+
+/*
+ * This decides where the kernel will search for a free chunk of vm
+ * space during mmap's. We won't be using it
+ */
+#define TASK_UNMAPPED_BASE     0
+
+struct thread_struct {
+       unsigned long  pc;
+       unsigned long  sp;              /* kernel stack pointer */
+       unsigned long  psw;             /* saved status register */
+       unsigned long  esp0;            /* points to SR of stack frame */
+       struct {
+               unsigned short *addr;
+               unsigned char inst;
+       } breakinfo;
+};
+
+#define INIT_THREAD  {                                         \
+       .pc = 0,                                                \
+       .sp  = sizeof(init_stack) + (unsigned long)init_stack,  \
+       .psw  = 0x00010000,                                     \
+       .esp0 = 0,                                              \
+       .breakinfo = {                                          \
+               .addr = (unsigned short *)-1,                   \
+               .inst = 0                                       \
+       }                                                       \
+}
+
+/*
+ * Do necessary setup to start up a newly executed thread.
+ *
+ * pass the data segment into user programs if it exists,
+ * it can't hurt anything as far as I can tell
+ */
+#define start_thread(_regs, _pc, _usp)                         \
+do {                                                           \
+       set_fs(USER_DS);           /* reads from user space */  \
+       (_regs)->pc = (_pc);                                    \
+       (_regs)->psw = (1<<20) | (1<<16); /* user mode */       \
+       (_regs)->usp = (_usp);                                  \
+} while(0)
+
+/* Forward declaration, a strange C thing */
+struct task_struct;
+
+/* Free all resources held by a thread. */
+static inline void release_thread(struct task_struct *dead_task)
+{
+}
+
+extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
+
+static inline void prepare_to_copy(struct task_struct *tsk)
+{
+}
+
+/*
+ * Free current thread data structures etc..
+ */
+static inline void exit_thread(void)
+{
+}
+
+static inline void flush_thread(void)
+{
+}
+
+/*
+ * Return saved PC of a blocked thread.
+ */
+#define thread_saved_pc(tsk)   (tsk->thread.pc)
+
+unsigned long get_wchan(struct task_struct *p);
+void show_trace(struct task_struct *tsk, unsigned long *sp,
+               struct pt_regs *regs);
+
+#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.esp0 - 1)
+#define        KSTK_EIP(tsk) (task_pt_regs(task)->pc)
+#define        KSTK_ESP(tsk) (task_pt_regs(task)->r[0])
+
+#define cpu_relax()    barrier()
+
+#endif
diff --git a/arch/rx/include/asm/ptrace.h b/arch/rx/include/asm/ptrace.h
new file mode 100644 (file)
index 0000000..840c9e2
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef __ASM_RX_PTRACE_H__
+#define __ASM_RX_PTRACE_H__
+
+#ifndef __ASSEMBLY__
+
+/* this struct defines the way the registers are stored on the
+   stack during a system call. */
+
+struct pt_regs {
+       unsigned long r[16];
+       unsigned long usp;
+       unsigned long vec;
+       unsigned long pc;
+       unsigned long psw;
+};
+
+/* Find the stack offset for a register, relative to thread.esp0. */
+#define PT_REG(reg)    ((long)&((struct pt_regs *)0)->reg)
+
+#define user_mode(regs) (((regs)->psw & (1<<20)))
+#define instruction_pointer(regs) ((regs)->pc)
+#define profile_pc(regs) instruction_pointer(regs)
+extern void show_regs(struct pt_regs *);
+#endif /* __ASSEMBLY__ */
+#define        OFF_R1  (1*4)
+#define        OFF_R2  (2*4)
+#define        OFF_R3  (3*4)
+#define        OFF_R4  (4*4)
+#define        OFF_R5  (5*4)
+#define        OFF_R7  (7*4)
+#define OFF_USP (16*4)
+#define OFF_VEC (17*4)
+#define OFF_PSW (19*4)
+#endif /* __ASM_RX_PTRACE_H__ */
diff --git a/arch/rx/include/asm/reloc.rb b/arch/rx/include/asm/reloc.rb
new file mode 100644 (file)
index 0000000..248d1db
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/ruby
+
+STDIN.each { |line|
+  next if /RELOC_NUMBER \((\S+),\s+0x([0-9a-f]+)\)/ !~ line
+  puts "#define #{$1}\t#{$2.hex.to_s}"
+}
diff --git a/arch/rx/include/asm/reloc.txt b/arch/rx/include/asm/reloc.txt
new file mode 100644 (file)
index 0000000..8c4e1b8
--- /dev/null
@@ -0,0 +1,67 @@
+#define R_RX_NONE      0
+#define R_RX_DIR32     1
+#define R_RX_DIR24S    2
+#define R_RX_DIR16     3
+#define R_RX_DIR16U    4
+#define R_RX_DIR16S    5
+#define R_RX_DIR8      6
+#define R_RX_DIR8U     7
+#define R_RX_DIR8S     8
+#define R_RX_DIR24S_PCREL      9
+#define R_RX_DIR16S_PCREL      10
+#define R_RX_DIR8S_PCREL       11
+#define R_RX_DIR16UL   12
+#define R_RX_DIR16UW   13
+#define R_RX_DIR8UL    14
+#define R_RX_DIR8UW    15
+#define R_RX_DIR32_REV 16
+#define R_RX_DIR16_REV 17
+#define R_RX_DIR3U_PCREL       18
+#define R_RX_RH_3_PCREL        32
+#define R_RX_RH_16_OP  33
+#define R_RX_RH_24_OP  34
+#define R_RX_RH_32_OP  35
+#define R_RX_RH_24_UNS 36
+#define R_RX_RH_8_NEG  37
+#define R_RX_RH_16_NEG 38
+#define R_RX_RH_24_NEG 39
+#define R_RX_RH_32_NEG 40
+#define R_RX_RH_DIFF   41
+#define R_RX_RH_GPRELB 42
+#define R_RX_RH_GPRELW 43
+#define R_RX_RH_GPRELL 44
+#define R_RX_RH_RELAX  45
+#define R_RX_ABS32     65
+#define R_RX_ABS24S    66
+#define R_RX_ABS16     67
+#define R_RX_ABS16U    68
+#define R_RX_ABS16S    69
+#define R_RX_ABS8      70
+#define R_RX_ABS8U     71
+#define R_RX_ABS8S     72
+#define R_RX_ABS24S_PCREL      73
+#define R_RX_ABS16S_PCREL      74
+#define R_RX_ABS8S_PCREL       75
+#define R_RX_ABS16UL   76
+#define R_RX_ABS16UW   77
+#define R_RX_ABS8UL    78
+#define R_RX_ABS8UW    79
+#define R_RX_ABS32_REV 80
+#define R_RX_ABS16_REV 81
+#define R_RX_SYM       128
+#define R_RX_OPneg     129
+#define R_RX_OPadd     130
+#define R_RX_OPsub     131
+#define R_RX_OPmul     132
+#define R_RX_OPdiv     133
+#define R_RX_OPshla    134
+#define R_RX_OPshra    135
+#define R_RX_OPsctsize 136
+#define R_RX_OPscttop  141
+#define R_RX_OPand     144
+#define R_RX_OPor      145
+#define R_RX_OPxor     146
+#define R_RX_OPnot     147
+#define R_RX_OPmod     148
+#define R_RX_OPromtop  149
+#define R_RX_OPramtop  150
diff --git a/arch/rx/include/asm/resource.h b/arch/rx/include/asm/resource.h
new file mode 100644 (file)
index 0000000..04bc4db
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/resource.h>
diff --git a/arch/rx/include/asm/scatterlist.h b/arch/rx/include/asm/scatterlist.h
new file mode 100644 (file)
index 0000000..35d786f
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/scatterlist.h>
diff --git a/arch/rx/include/asm/sections.h b/arch/rx/include/asm/sections.h
new file mode 100644 (file)
index 0000000..2b8c516
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/sections.h>
diff --git a/arch/rx/include/asm/segment.h b/arch/rx/include/asm/segment.h
new file mode 100644 (file)
index 0000000..c9a9521
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __ASM_RX_SEGMENT_H__
+#define __ASM_RX_SEGMENT_H__
+
+#ifndef __ASSEMBLY__
+typedef struct {
+       unsigned long seg;
+} mm_segment_t;
+#endif
+
+#endif
diff --git a/arch/rx/include/asm/sembuf.h b/arch/rx/include/asm/sembuf.h
new file mode 100644 (file)
index 0000000..7673b83
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/sembuf.h>
diff --git a/arch/rx/include/asm/setup.h b/arch/rx/include/asm/setup.h
new file mode 100644 (file)
index 0000000..177c824
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef __ASM_RX_SETUP_H__
+#define __ASM_RX_SETUP_H__
+
+#define COMMAND_LINE_SIZE      512
+
+#endif
diff --git a/arch/rx/include/asm/sh_eth.h b/arch/rx/include/asm/sh_eth.h
new file mode 100644 (file)
index 0000000..f739061
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef __ASM_SH_ETH_H__
+#define __ASM_SH_ETH_H__
+
+enum {EDMAC_LITTLE_ENDIAN, EDMAC_BIG_ENDIAN};
+
+struct sh_eth_plat_data {
+       int phy;
+       int edmac_endian;
+
+       unsigned char mac_addr[6];
+       unsigned no_ether_link:1;
+       unsigned ether_link_active_low:1;
+};
+
+#endif
diff --git a/arch/rx/include/asm/shmbuf.h b/arch/rx/include/asm/shmbuf.h
new file mode 100644 (file)
index 0000000..83c05fc
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/shmbuf.h>
diff --git a/arch/rx/include/asm/shmparam.h b/arch/rx/include/asm/shmparam.h
new file mode 100644 (file)
index 0000000..93f30de
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/shmparam.h>
diff --git a/arch/rx/include/asm/sigcontext.h b/arch/rx/include/asm/sigcontext.h
new file mode 100644 (file)
index 0000000..e173dce
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef __ASM_RX_SIGCONTEXT_H__
+#define __ASM_RX_SIGCONTEXT_H__
+
+struct sigcontext {
+       unsigned long  sc_mask;         /* old sigmask */
+       unsigned long  sc_usp;          /* old user stack pointer */
+       unsigned long  sc_r[16];
+       unsigned long  sc_psw;
+       unsigned long  sc_pc;
+};
+
+#endif
diff --git a/arch/rx/include/asm/sigframe.h b/arch/rx/include/asm/sigframe.h
new file mode 100644 (file)
index 0000000..e173dce
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef __ASM_RX_SIGCONTEXT_H__
+#define __ASM_RX_SIGCONTEXT_H__
+
+struct sigcontext {
+       unsigned long  sc_mask;         /* old sigmask */
+       unsigned long  sc_usp;          /* old user stack pointer */
+       unsigned long  sc_r[16];
+       unsigned long  sc_psw;
+       unsigned long  sc_pc;
+};
+
+#endif
diff --git a/arch/rx/include/asm/siginfo.h b/arch/rx/include/asm/siginfo.h
new file mode 100644 (file)
index 0000000..0815d29
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/siginfo.h>
diff --git a/arch/rx/include/asm/signal.h b/arch/rx/include/asm/signal.h
new file mode 100644 (file)
index 0000000..7b1573c
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/signal.h>
diff --git a/arch/rx/include/asm/smp.h b/arch/rx/include/asm/smp.h
new file mode 100644 (file)
index 0000000..9e9bd7e
--- /dev/null
@@ -0,0 +1 @@
+/* nothing required here yet */
diff --git a/arch/rx/include/asm/socket.h b/arch/rx/include/asm/socket.h
new file mode 100644 (file)
index 0000000..6b71384
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/socket.h>
diff --git a/arch/rx/include/asm/sockios.h b/arch/rx/include/asm/sockios.h
new file mode 100644 (file)
index 0000000..def6d47
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/sockios.h>
diff --git a/arch/rx/include/asm/spinlock.h b/arch/rx/include/asm/spinlock.h
new file mode 100644 (file)
index 0000000..90c10c4
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef __ASM_RX_SPINLOCK_H__
+#define __ASM_RX_SPINLOCK_H__
+
+#error "RX doesn't do SMP yet"
+
+#endif
diff --git a/arch/rx/include/asm/stat.h b/arch/rx/include/asm/stat.h
new file mode 100644 (file)
index 0000000..3dc90fa
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/stat.h>
diff --git a/arch/rx/include/asm/statfs.h b/arch/rx/include/asm/statfs.h
new file mode 100644 (file)
index 0000000..0b91fe1
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/statfs.h>
diff --git a/arch/rx/include/asm/string.h b/arch/rx/include/asm/string.h
new file mode 100644 (file)
index 0000000..67dd2bc
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef __ASM_RX_STRING_H__
+#define __ASM_RX_STRING_H__
+
+#ifdef __KERNEL__ /* only set these up for kernel code */
+
+#include <asm/setup.h>
+#include <asm/page.h>
+
+#define __HAVE_ARCH_MEMSET
+extern void * memset(void * s, int c, size_t count);
+
+#define __HAVE_ARCH_MEMCPY
+extern void * memcpy(void *d, const void *s, size_t count);
+
+#else /* KERNEL */
+
+/*
+ *     let user libraries deal with these,
+ *     IMHO the kernel has no place defining these functions for user apps
+ */
+
+#define __HAVE_ARCH_STRCPY 1
+#define __HAVE_ARCH_STRNCPY 1
+#define __HAVE_ARCH_STRCAT 1
+#define __HAVE_ARCH_STRNCAT 1
+#define __HAVE_ARCH_STRCMP 1
+#define __HAVE_ARCH_STRNCMP 1
+#define __HAVE_ARCH_STRNICMP 1
+#define __HAVE_ARCH_STRCHR 1
+#define __HAVE_ARCH_STRRCHR 1
+#define __HAVE_ARCH_STRSTR 1
+#define __HAVE_ARCH_STRLEN 1
+#define __HAVE_ARCH_STRNLEN 1
+#define __HAVE_ARCH_MEMSET 1
+#define __HAVE_ARCH_MEMCPY 1
+#define __HAVE_ARCH_MEMMOVE 1
+#define __HAVE_ARCH_MEMSCAN 1
+#define __HAVE_ARCH_MEMCMP 1
+#define __HAVE_ARCH_MEMCHR 1
+#define __HAVE_ARCH_STRTOK 1
+
+#endif /* KERNEL */
+
+#endif /* __ASM_RX_STRING_H__ */
diff --git a/arch/rx/include/asm/swab.h b/arch/rx/include/asm/swab.h
new file mode 100644 (file)
index 0000000..7847e56
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/swab.h>
diff --git a/arch/rx/include/asm/syscall.h b/arch/rx/include/asm/syscall.h
new file mode 100644 (file)
index 0000000..8879411
--- /dev/null
@@ -0,0 +1,91 @@
+#ifndef __ASM_RX_SYSCALL_H__
+#define __ASM_RX_SYSCALL_H__
+
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/err.h>
+#include <asm/ptrace.h>
+
+/* The system call number is given by the user in R3 */
+static inline long syscall_get_nr(struct task_struct *task,
+                                 struct pt_regs *regs)
+{
+       return (regs->vec >= 0x1000) ? regs->r[8] : -1L;
+}
+
+static inline void syscall_rollback(struct task_struct *task,
+                                   struct pt_regs *regs)
+{
+}
+
+static inline long syscall_get_error(struct task_struct *task,
+                                    struct pt_regs *regs)
+{
+       return IS_ERR_VALUE(regs->r[1]) ? regs->r[1] : 0;
+}
+
+static inline long syscall_get_return_value(struct task_struct *task,
+                                           struct pt_regs *regs)
+{
+       return regs->r[1];
+}
+
+static inline void syscall_set_return_value(struct task_struct *task,
+                                           struct pt_regs *regs,
+                                           int error, long val)
+{
+       if (error)
+               regs->r[1] = -error;
+       else
+               regs->r[1] = val;
+}
+
+static inline void syscall_get_arguments(struct task_struct *task,
+                                        struct pt_regs *regs,
+                                        unsigned int i, unsigned int n,
+                                        unsigned long *args)
+{
+       /*
+        * Do this simply for now. If we need to start supporting
+        * fetching arguments from arbitrary indices, this will need some
+        * extra logic. Presently there are no in-tree users that depend
+        * on this behaviour.
+        */
+       BUG_ON(i);
+
+       switch (n) {
+       case 6: args[5] = regs->r[7];
+       case 5: args[4] = regs->r[5];
+       case 4: args[3] = regs->r[4];
+       case 3: args[2] = regs->r[3];
+       case 2: args[1] = regs->r[2];
+       case 1: args[0] = regs->r[1];
+       case 0:
+               break;
+       default:
+               BUG();
+       }
+}
+
+static inline void syscall_set_arguments(struct task_struct *task,
+                                        struct pt_regs *regs,
+                                        unsigned int i, unsigned int n,
+                                        const unsigned long *args)
+{
+       /* Same note as above applies */
+       BUG_ON(i);
+
+       switch (n) {
+       case 6: regs->r[7] = args[5];
+       case 5: regs->r[5] = args[4];
+       case 4: regs->r[4] = args[3];
+       case 3: regs->r[3] = args[2];
+       case 2: regs->r[2] = args[1];
+       case 1: regs->r[1] = args[0];
+               break;
+       default:
+               BUG();
+       }
+}
+
+#endif /* __ASM_RX_SYSCALL_H__ */
diff --git a/arch/rx/include/asm/system.h b/arch/rx/include/asm/system.h
new file mode 100644 (file)
index 0000000..8767af0
--- /dev/null
@@ -0,0 +1,86 @@
+#ifndef __ASM_RX_SYSTEM_H__
+#define __ASM_RX_SYSTEM_H__
+
+#include <linux/types.h>
+#include <linux/linkage.h>
+#include <linux/irqflags.h>
+
+#define switch_to(prev,next,last)                      \
+do {                                                   \
+__asm__ volatile("switch_to:");                                \
+       __asm__ volatile("pushm r1-r15\n\t"             \
+                        "mov.l #1f,%0\n\t"             \
+                        "mov.l r0,%1\n\t"              \
+                        "mov.l %3,r0\n\t"              \
+                        "jmp %2\n"                     \
+                        "1:\n\t"                       \
+                        "popm r1-r15\n\t"              \
+                        ::"m"(prev->thread.pc),        \
+                                "m"(prev->thread.sp),  \
+                                "r"(next->thread.pc),  \
+                                "g"(next->thread.sp)); \
+       last = prev;                                    \
+} while(0)
+
+
+#define nop()  asm volatile ("nop"::)
+#define mb()   asm volatile (""   : : :"memory")
+#define rmb()  asm volatile (""   : : :"memory")
+#define wmb()  asm volatile (""   : : :"memory")
+#define set_mb(var, value) do { var = value; } while (0)
+
+#define smp_mb()       barrier()
+#define smp_rmb()      barrier()
+#define smp_wmb()      barrier()
+#define smp_read_barrier_depends()     do { } while(0)
+
+#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
+
+struct __xchg_dummy { unsigned long a[100]; };
+#define __xg(x) ((volatile struct __xchg_dummy *)(x))
+
+static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
+{
+       unsigned long tmp, flags;
+
+       switch (size) {
+       case 1:
+               local_irq_save(flags);
+               tmp = *(u8 *)__xg(ptr);
+               *(u8 *)__xg(ptr) = x;
+               local_irq_restore(flags);
+               break;
+       case 2:
+               local_irq_save(flags);
+               tmp = *(u16 *)__xg(ptr);
+               *(u16 *)__xg(ptr) = x;
+               local_irq_restore(flags);
+               break;
+       case 4:
+               __asm__ volatile("xchg %0, %1"
+                                :"=m"(__xg(ptr)),"=r"(x));
+               break;
+       default:
+               tmp = 0;          
+       }
+       return tmp;
+}
+
+#include <asm-generic/cmpxchg-local.h>
+
+/*
+ * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
+ * them available.
+ */
+#define cmpxchg_local(ptr, o, n)                                              \
+       ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
+                       (unsigned long)(n), sizeof(*(ptr))))
+#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
+
+#ifndef CONFIG_SMP
+#include <asm-generic/cmpxchg.h>
+#endif
+
+#define arch_align_stack(x) (x)
+
+#endif /* __ASM_RX_SYSTEM_H__ */
diff --git a/arch/rx/include/asm/target_time.h b/arch/rx/include/asm/target_time.h
new file mode 100644 (file)
index 0000000..9f2a9aa
--- /dev/null
@@ -0,0 +1,4 @@
+extern int platform_timer_setup(void (*timer_int)(int, void *, struct pt_regs *));
+extern void platform_timer_eoi(void);
+extern void platform_gettod(unsigned int *year, unsigned int *mon, unsigned int *day, 
+                            unsigned int *hour, unsigned int *min, unsigned int *sec);
diff --git a/arch/rx/include/asm/termbits.h b/arch/rx/include/asm/termbits.h
new file mode 100644 (file)
index 0000000..3935b10
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/termbits.h>
diff --git a/arch/rx/include/asm/termios.h b/arch/rx/include/asm/termios.h
new file mode 100644 (file)
index 0000000..280d78a
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/termios.h>
diff --git a/arch/rx/include/asm/thread_info.h b/arch/rx/include/asm/thread_info.h
new file mode 100644 (file)
index 0000000..05907f5
--- /dev/null
@@ -0,0 +1,123 @@
+#ifndef __ASM_RX_THREAD_INFO_H__
+#define __ASM_RX_THREAD_INFO_H__
+
+#include <asm/page.h>
+#include <asm/segment.h>
+
+#ifdef __KERNEL__
+
+/*
+ * Size of kernel stack for each process. This must be a power of 2...
+ */
+#define THREAD_SIZE_ORDER      1
+#define THREAD_SIZE            8192    /* 2 pages */
+
+#ifndef __ASSEMBLY__
+
+/*
+ * low level task data.
+ * If you change this, change the TI_* offsets below to match.
+ */
+struct thread_info {
+       struct task_struct *task;               /* main task structure */
+       struct exec_domain *exec_domain;        /* execution domain */
+       unsigned long      flags;               /* low level flags */
+       int                cpu;                 /* cpu we're on */
+       int                preempt_count;       /* 0 => preemptable, <0 => BUG */
+       mm_segment_t            addr_limit;     /* thread address space */
+       struct restart_block restart_block;
+};
+
+/*
+ * macros/functions for gaining access to the thread information structure
+ */
+#define INIT_THREAD_INFO(tsk)                  \
+{                                              \
+       .task =         &tsk,                   \
+       .exec_domain =  &default_exec_domain,   \
+       .flags =        0,                      \
+       .cpu =          0,                      \
+       .preempt_count = INIT_PREEMPT_COUNT,    \
+       .addr_limit     = KERNEL_DS,            \
+       .restart_block  = {                     \
+               .fn = do_no_restart_syscall,    \
+       },                                      \
+}
+
+#define init_thread_info       (init_thread_union.thread_info)
+#define init_stack             (init_thread_union.stack)
+
+
+/* how to get the thread information struct from C */
+static inline struct thread_info *current_thread_info(void)
+{
+       struct thread_info *ti;
+       __asm__("mov    %1,%0\n\t"
+               "and    r0,%0"
+               : "=&r"(ti)
+               : "i"(~(THREAD_SIZE-1))
+               );
+       return ti;
+}
+
+#endif /* __ASSEMBLY__ */
+
+/*
+ * Offsets in thread_info structure, used in assembly code
+ */
+#define TI_TASK                0
+#define TI_EXECDOMAIN  4
+#define TI_FLAGS       8
+#define TI_CPU         12
+#define TI_PRE_COUNT   16
+
+#define        PREEMPT_ACTIVE  0x4000000
+
+/*
+ * thread information flag bit numbers
+ */
+#define TIF_SYSCALL_TRACE      0       /* syscall trace active */
+#define TIF_SIGPENDING         1       /* signal pending */
+#define TIF_NEED_RESCHED       2       /* rescheduling necessary */
+#define TIF_POLLING_NRFLAG     3       /* true if poll_idle() is polling
+                                          TIF_NEED_RESCHED */
+#define TIF_MEMDIE             4
+#define TIF_RESTORE_SIGMASK    5       /* restore signal mask in do_signal() */
+#define TIF_NOTIFY_RESUME      6       /* callback before returning to user */
+#define TIF_SYSCALL_AUDIT      7       /* syscall auditing active */
+#define TIF_SECCOMP            8       /* secure computing */
+#define TIF_SYSCALL_TRACEPOINT 9       /* for ftrace syscall instrumentation */
+#define TIF_SINGLESTEP         10      /* singlestepping */
+#define TIF_FREEZE             16      /* is freezing for suspend */
+
+/* as above, but as bit values */
+#define _TIF_SYSCALL_TRACE     (1<<TIF_SYSCALL_TRACE)
+#define _TIF_SIGPENDING                (1<<TIF_SIGPENDING)
+#define _TIF_NEED_RESCHED      (1<<TIF_NEED_RESCHED)
+#define _TIF_POLLING_NRFLAG    (1<<TIF_POLLING_NRFLAG)
+#define _TIF_RESTORE_SIGMASK   (1<<TIF_RESTORE_SIGMASK)
+#define _TIF_NOTIFY_RESUME     (1<<TIF_NOTIFY_RESUME)
+#define _TIF_SYSCALL_AUDIT     (1<<TIF_SYSCALL_AUDIT)
+#define _TIF_SECCOMP           (1<<TIF_SECCOMP)
+#define _TIF_SYSCALL_TRACEPOINT        (1<<TIF_SYSCALL_TRACEPOINT)
+#define _TIF_SINGLESTEP                (1<<TIF_SINGLESTEP)
+#define _TIF_FREEZE            (1<<TIF_FREEZE)
+
+/* work to do in syscall trace */
+#define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
+                                _TIF_SYSCALL_AUDIT | _TIF_SECCOMP    | \
+                                _TIF_SYSCALL_TRACEPOINT)
+
+/* work to do on any return to u-space */
+#define _TIF_ALLWORK_MASK      (_TIF_SYSCALL_TRACE | _TIF_SIGPENDING      | \
+                                _TIF_NEED_RESCHED  | _TIF_SYSCALL_AUDIT   | \
+                                _TIF_SINGLESTEP    | _TIF_RESTORE_SIGMASK | \
+                                _TIF_NOTIFY_RESUME | _TIF_SYSCALL_TRACEPOINT)
+
+/* work to do on interrupt/exception return */
+#define _TIF_WORK_MASK         (_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \
+                                _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP))
+
+#endif /* __KERNEL__ */
+
+#endif /* __ASM_RX_THREAD_INFO_H__ */
diff --git a/arch/rx/include/asm/timex.h b/arch/rx/include/asm/timex.h
new file mode 100644 (file)
index 0000000..d4a1919
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __ASM_RX_TIMEX_H__
+#define __ASM_RX_TIMEX_H__
+
+#define CLOCK_TICK_RATE (CONFIG_INPUT_CLOCK_FREQ * CONFIG_PCLK_MULT)
+
+#include <asm-generic/timex.h>
+
+#endif
diff --git a/arch/rx/include/asm/tlb.h b/arch/rx/include/asm/tlb.h
new file mode 100644 (file)
index 0000000..2d36d93
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __ASM_RX_TLB_H__
+#define __ASM_RX_TLB_H__
+
+#define tlb_flush(tlb) do { } while(0)
+
+#include <asm-generic/tlb.h>
+
+#endif
diff --git a/arch/rx/include/asm/tlbflush.h b/arch/rx/include/asm/tlbflush.h
new file mode 100644 (file)
index 0000000..f1a06c0
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/tlbflush.h>
diff --git a/arch/rx/include/asm/topology.h b/arch/rx/include/asm/topology.h
new file mode 100644 (file)
index 0000000..5428f33
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/topology.h>
diff --git a/arch/rx/include/asm/types.h b/arch/rx/include/asm/types.h
new file mode 100644 (file)
index 0000000..b9e79bc
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/types.h>
diff --git a/arch/rx/include/asm/uaccess.h b/arch/rx/include/asm/uaccess.h
new file mode 100644 (file)
index 0000000..04db760
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/uaccess.h>
diff --git a/arch/rx/include/asm/ucontext.h b/arch/rx/include/asm/ucontext.h
new file mode 100644 (file)
index 0000000..29b8d39
--- /dev/null
@@ -0,0 +1,2 @@
+#include <asm/sigcontext.h>
+#include <asm-generic/ucontext.h>
diff --git a/arch/rx/include/asm/unaligned.h b/arch/rx/include/asm/unaligned.h
new file mode 100644 (file)
index 0000000..6cecbbb
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/unaligned.h>
diff --git a/arch/rx/include/asm/unistd.h b/arch/rx/include/asm/unistd.h
new file mode 100644 (file)
index 0000000..3b33c73
--- /dev/null
@@ -0,0 +1,377 @@
+#ifndef __ASM_RX_UNISTD_H__
+#define __ASM_RX_UNISTD_H__
+
+/*
+ * This file contains the system call numbers.
+ */
+
+#define __NR_restart_syscall      0
+#define __NR_exit                1
+#define __NR_fork                2
+#define __NR_read                3
+#define __NR_write               4
+#define __NR_open                5
+#define __NR_close               6
+#define __NR_waitpid             7
+#define __NR_creat               8
+#define __NR_link                9
+#define __NR_unlink             10
+#define __NR_execve             11
+#define __NR_chdir              12
+#define __NR_time               13
+#define __NR_mknod              14
+#define __NR_chmod              15
+#define __NR_lchown             16
+#define __NR_break              17
+#define __NR_oldstat            18
+#define __NR_lseek              19
+#define __NR_getpid             20
+#define __NR_mount              21
+#define __NR_umount             22
+#define __NR_setuid             23
+#define __NR_getuid             24
+#define __NR_stime              25
+#define __NR_ptrace             26
+#define __NR_alarm              27
+#define __NR_oldfstat           28
+#define __NR_pause              29
+#define __NR_utime              30
+#define __NR_stty               31
+#define __NR_gtty               32
+#define __NR_access             33
+#define __NR_nice               34
+#define __NR_ftime              35
+#define __NR_sync               36
+#define __NR_kill               37
+#define __NR_rename             38
+#define __NR_mkdir              39
+#define __NR_rmdir              40
+#define __NR_dup                41
+#define __NR_pipe               42
+#define __NR_times              43
+#define __NR_prof               44
+#define __NR_brk                45
+#define __NR_setgid             46
+#define __NR_getgid             47
+#define __NR_signal             48
+#define __NR_geteuid            49
+#define __NR_getegid            50
+#define __NR_acct               51
+#define __NR_umount2            52
+#define __NR_lock               53
+#define __NR_ioctl              54
+#define __NR_fcntl              55
+#define __NR_mpx                56
+#define __NR_setpgid            57
+#define __NR_ulimit             58
+#define __NR_oldolduname        59
+#define __NR_umask              60
+#define __NR_chroot             61
+#define __NR_ustat              62
+#define __NR_dup2               63
+#define __NR_getppid            64
+#define __NR_getpgrp            65
+#define __NR_setsid             66
+#define __NR_sigaction          67
+#define __NR_sgetmask           68
+#define __NR_ssetmask           69
+#define __NR_setreuid           70
+#define __NR_setregid           71
+#define __NR_sigsuspend                 72
+#define __NR_sigpending                 73
+#define __NR_sethostname        74
+#define __NR_setrlimit          75
+#define __NR_getrlimit          76   /* Back compatible 2Gig limited rlimit */
+#define __NR_getrusage          77
+#define __NR_gettimeofday       78
+#define __NR_settimeofday       79
+#define __NR_getgroups          80
+#define __NR_setgroups          81
+#define __NR_select             82
+#define __NR_symlink            83
+#define __NR_oldlstat           84
+#define __NR_readlink           85
+#define __NR_uselib             86
+#define __NR_swapon             87
+#define __NR_reboot             88
+#define __NR_readdir            89
+#define __NR_mmap               90
+#define __NR_munmap             91
+#define __NR_truncate           92
+#define __NR_ftruncate          93
+#define __NR_fchmod             94
+#define __NR_fchown             95
+#define __NR_getpriority        96
+#define __NR_setpriority        97
+#define __NR_profil             98
+#define __NR_statfs             99
+#define __NR_fstatfs           100
+#define __NR_ioperm            101
+#define __NR_socketcall                102
+#define __NR_syslog            103
+#define __NR_setitimer         104
+#define __NR_getitimer         105
+#define __NR_stat              106
+#define __NR_lstat             107
+#define __NR_fstat             108
+#define __NR_olduname          109
+#define __NR_iopl              110
+#define __NR_vhangup           111
+#define __NR_idle              112
+#define __NR_vm86old           113
+#define __NR_wait4             114
+#define __NR_swapoff           115
+#define __NR_sysinfo           116
+#define __NR_ipc               117
+#define __NR_fsync             118
+#define __NR_sigreturn         119
+#define __NR_clone             120
+#define __NR_setdomainname     121
+#define __NR_uname             122
+#define __NR_modify_ldt                123
+#define __NR_adjtimex          124
+#define __NR_mprotect          125
+#define __NR_sigprocmask       126
+#define __NR_create_module     127
+#define __NR_init_module       128
+#define __NR_delete_module     129
+#define __NR_get_kernel_syms   130
+#define __NR_quotactl          131
+#define __NR_getpgid           132
+#define __NR_fchdir            133
+#define __NR_bdflush           134
+#define __NR_sysfs             135
+#define __NR_personality       136
+#define __NR_afs_syscall       137 /* Syscall for Andrew File System */
+#define __NR_setfsuid          138
+#define __NR_setfsgid          139
+#define __NR_llseek            140
+#define __NR_getdents          141
+#define __NR_newselect         142
+#define __NR_flock             143
+#define __NR_msync             144
+#define __NR_readv             145
+#define __NR_writev            146
+#define __NR_getsid            147
+#define __NR_fdatasync         148
+#define __NR_sysctl            149
+#define __NR_mlock             150
+#define __NR_munlock           151
+#define __NR_mlockall          152
+#define __NR_munlockall                153
+#define __NR_sched_setparam            154
+#define __NR_sched_getparam            155
+#define __NR_sched_setscheduler                156
+#define __NR_sched_getscheduler                157
+#define __NR_sched_yield               158
+#define __NR_sched_get_priority_max    159
+#define __NR_sched_get_priority_min    160
+#define __NR_sched_rr_get_interval     161
+#define __NR_nanosleep         162
+#define __NR_mremap            163
+#define __NR_setresuid         164
+#define __NR_getresuid         165
+#define __NR_vm86              166
+#define __NR_query_module      167
+#define __NR_poll              168
+#define __NR_nfsservctl                169
+#define __NR_setresgid         170
+#define __NR_getresgid         171
+#define __NR_prctl              172
+#define __NR_rt_sigreturn      173
+#define __NR_rt_sigaction      174
+#define __NR_rt_sigprocmask    175
+#define __NR_rt_sigpending     176
+#define __NR_rt_sigtimedwait   177
+#define __NR_rt_sigqueueinfo   178
+#define __NR_rt_sigsuspend     179
+#define __NR_pread64           180
+#define __NR_pwrite64          181
+#define __NR_chown             182
+#define __NR_getcwd            183
+#define __NR_capget            184
+#define __NR_capset            185
+#define __NR_sigaltstack       186
+#define __NR_sendfile          187
+#define __NR_getpmsg           188     /* some people actually want streams */
+#define __NR_putpmsg           189     /* some people actually want streams */
+#define __NR_vfork             190
+#define __NR_ugetrlimit                191     /* SuS compliant getrlimit */
+#define __NR_mmap2             192
+#define __NR_truncate64                193
+#define __NR_ftruncate64       194
+#define __NR_stat64            195
+#define __NR_lstat64           196
+#define __NR_fstat64           197
+#define __NR_lchown32          198
+#define __NR_getuid32          199
+#define __NR_getgid32          200
+#define __NR_geteuid32         201
+#define __NR_getegid32         202
+#define __NR_setreuid32                203
+#define __NR_setregid32                204
+#define __NR_getgroups32       205
+#define __NR_setgroups32       206
+#define __NR_fchown32          207
+#define __NR_setresuid32       208
+#define __NR_getresuid32       209
+#define __NR_setresgid32       210
+#define __NR_getresgid32       211
+#define __NR_chown32           212
+#define __NR_setuid32          213
+#define __NR_setgid32          214
+#define __NR_setfsuid32                215
+#define __NR_setfsgid32                216
+#define __NR_pivot_root                217
+#define __NR_mincore           218
+#define __NR_madvise           219
+#define __NR_madvise1          219     /* delete when C lib stub is removed */
+#define __NR_getdents64                220
+#define __NR_fcntl64           221
+/* 222 is unused */
+/* 223 is unused */
+#define __NR_gettid            224
+#define __NR_readahead         225
+#define __NR_setxattr          226
+#define __NR_lsetxattr         227
+#define __NR_fsetxattr         228
+#define __NR_getxattr          229
+#define __NR_lgetxattr         230
+#define __NR_fgetxattr         231
+#define __NR_listxattr         232
+#define __NR_llistxattr                233
+#define __NR_flistxattr                234
+#define __NR_removexattr       235
+#define __NR_lremovexattr      236
+#define __NR_fremovexattr      237
+#define __NR_tkill             238
+#define __NR_sendfile64                239
+#define __NR_futex             240
+#define __NR_sched_setaffinity 241
+#define __NR_sched_getaffinity 242
+#define __NR_set_thread_area   243
+#define __NR_get_thread_area   244
+#define __NR_io_setup          245
+#define __NR_io_destroy                246
+#define __NR_io_getevents      247
+#define __NR_io_submit         248
+#define __NR_io_cancel         249
+#define __NR_fadvise64         250
+/* 251 is available for reuse (was briefly sys_set_zone_reclaim) */
+#define __NR_exit_group                252
+#define __NR_lookup_dcookie    253
+#define __NR_epoll_create      254
+#define __NR_epoll_ctl         255
+#define __NR_epoll_wait                256
+#define __NR_remap_file_pages  257
+#define __NR_set_tid_address   258
+#define __NR_timer_create      259
+#define __NR_timer_settime     (__NR_timer_create+1)
+#define __NR_timer_gettime     (__NR_timer_create+2)
+#define __NR_timer_getoverrun  (__NR_timer_create+3)
+#define __NR_timer_delete      (__NR_timer_create+4)
+#define __NR_clock_settime     (__NR_timer_create+5)
+#define __NR_clock_gettime     (__NR_timer_create+6)
+#define __NR_clock_getres      (__NR_timer_create+7)
+#define __NR_clock_nanosleep   (__NR_timer_create+8)
+#define __NR_statfs64          268
+#define __NR_fstatfs64         269
+#define __NR_tgkill            270
+#define __NR_utimes            271
+#define __NR_fadvise64_64      272
+#define __NR_vserver           273
+#define __NR_mbind             274
+#define __NR_get_mempolicy     275
+#define __NR_set_mempolicy     276
+#define __NR_mq_open           277
+#define __NR_mq_unlink         (__NR_mq_open+1)
+#define __NR_mq_timedsend      (__NR_mq_open+2)
+#define __NR_mq_timedreceive   (__NR_mq_open+3)
+#define __NR_mq_notify         (__NR_mq_open+4)
+#define __NR_mq_getsetattr     (__NR_mq_open+5)
+#define __NR_kexec_load                283
+#define __NR_waitid            284
+/* #define __NR_sys_setaltroot 285 */
+#define __NR_add_key           286
+#define __NR_request_key       287
+#define __NR_keyctl            288
+#define __NR_ioprio_set                289
+#define __NR_ioprio_get                290
+#define __NR_inotify_init      291
+#define __NR_inotify_add_watch 292
+#define __NR_inotify_rm_watch  293
+#define __NR_migrate_pages     294
+#define __NR_openat            295
+#define __NR_mkdirat           296
+#define __NR_mknodat           297
+#define __NR_fchownat          298
+#define __NR_futimesat         299
+#define __NR_fstatat64         300
+#define __NR_unlinkat          301
+#define __NR_renameat          302
+#define __NR_linkat            303
+#define __NR_symlinkat         304
+#define __NR_readlinkat                305
+#define __NR_fchmodat          306
+#define __NR_faccessat         307
+#define __NR_pselect6          308
+#define __NR_ppoll             309
+#define __NR_unshare           310
+#define __NR_set_robust_list   311
+#define __NR_get_robust_list   312
+#define __NR_splice            313
+#define __NR_sync_file_range   314
+#define __NR_tee               315
+#define __NR_vmsplice          316
+#define __NR_move_pages                317
+#define __NR_getcpu            318
+#define __NR_epoll_pwait       319
+#define __NR_utimensat         320
+#define __NR_signalfd          321
+#define __NR_timerfd_create    322
+#define __NR_eventfd           323
+#define __NR_fallocate         324
+#define __NR_timerfd_settime   325
+#define __NR_timerfd_gettime   326
+#define __NR_signalfd4         327
+#define __NR_eventfd2          328
+#define __NR_epoll_create1     329
+#define __NR_dup3              330
+#define __NR_pipe2             331
+#define __NR_inotify_init1     332
+#define __NR_preadv            333
+#define __NR_pwritev           334
+#define __NR_rt_tgsigqueueinfo 335
+#define __NR_perf_event_open   336
+
+#ifdef __KERNEL__
+
+#define NR_syscalls 337
+
+#define __ARCH_WANT_IPC_PARSE_VERSION
+#define __ARCH_WANT_STAT64
+#define __ARCH_WANT_SYS_ALARM
+#define __ARCH_WANT_SYS_GETHOSTNAME
+#define __ARCH_WANT_SYS_PAUSE
+#define __ARCH_WANT_SYS_SGETMASK
+#define __ARCH_WANT_SYS_SIGNAL
+#define __ARCH_WANT_SYS_TIME
+#define __ARCH_WANT_SYS_UTIME
+#define __ARCH_WANT_SYS_WAITPID
+#define __ARCH_WANT_SYS_SOCKETCALL
+#define __ARCH_WANT_SYS_FADVISE64
+#define __ARCH_WANT_SYS_GETPGRP
+#define __ARCH_WANT_SYS_LLSEEK
+#define __ARCH_WANT_SYS_NICE
+#define __ARCH_WANT_SYS_OLD_GETRLIMIT
+#define __ARCH_WANT_SYS_OLDUMOUNT
+#define __ARCH_WANT_SYS_SIGPENDING
+#define __ARCH_WANT_SYS_SIGPROCMASK
+#define __ARCH_WANT_SYS_RT_SIGACTION
+#define __ARCH_WANT_SYS_RT_SIGSUSPEND
+#define __ARCH_WANT_SYS_OLD_READDIR
+
+#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall")
+
+#endif /* __KERNEL__ */
+#endif /* __ASM_RX_UNISTD_H__ */
diff --git a/arch/rx/include/asm/user.h b/arch/rx/include/asm/user.h
new file mode 100644 (file)
index 0000000..1797743
--- /dev/null
@@ -0,0 +1,74 @@
+#ifndef __ASM_RX_USER_H__
+#define __ASM_RX_USER_H__
+
+#include <asm/page.h>
+
+/* Core file format: The core file is written in such a way that gdb
+   can understand it and provide useful information to the user (under
+   linux we use the 'trad-core' bfd).  There are quite a number of
+   obstacles to being able to view the contents of the floating point
+   registers, and until these are solved you will not be able to view the
+   contents of them.  Actually, you can read in the core file and look at
+   the contents of the user struct to find out what the floating point
+   registers contain.
+   The actual file contents are as follows:
+   UPAGE: 1 page consisting of a user struct that tells gdb what is present
+   in the file.  Directly after this is a copy of the task_struct, which
+   is currently not used by gdb, but it may come in useful at some point.
+   All of the registers are stored as part of the upage.  The upage should
+   always be only one page.
+   DATA: The data area is stored.  We use current->end_text to
+   current->brk to pick up all of the user variables, plus any memory
+   that may have been malloced.  No attempt is made to determine if a page
+   is demand-zero or if a page is totally unused, we just cover the entire
+   range.  All of the addresses are rounded in such a way that an integral
+   number of pages is written.
+   STACK: We need the stack information in order to get a meaningful
+   backtrace.  We need to write the data from (esp) to
+   current->start_stack, so we round each of these off in order to be able
+   to write an integer number of pages.
+   The minimum core file size is 3 pages, or 12288 bytes.
+*/
+
+/* This is the old layout of "struct pt_regs" as of Linux 1.x, and
+   is still the layout used by user (the new pt_regs doesn't have
+   all registers). */
+struct user_regs_struct {
+       long r[16];
+       long usp;
+       long vec;
+       long pc;
+       long psw;
+};
+
+       
+/* When the kernel dumps core, it starts by dumping the user struct -
+   this will be used by gdb to figure out where the data and stack segments
+   are within the file, and what virtual addresses to use. */
+struct user{
+/* We start with the registers, to mimic the way that "memory" is returned
+   from the ptrace(3,...) function.  */
+  struct user_regs_struct regs;        /* Where the registers are actually stored */
+/* ptrace does not yet supply these.  Someday.... */
+/* The rest of this junk is to help gdb figure out what goes where */
+  unsigned long int u_tsize;   /* Text segment size (pages). */
+  unsigned long int u_dsize;   /* Data segment size (pages). */
+  unsigned long int u_ssize;   /* Stack segment size (pages). */
+  unsigned long start_code;     /* Starting virtual address of text. */
+  unsigned long start_stack;   /* Starting virtual address of stack area.
+                                  This is actually the bottom of the stack,
+                                  the top of the stack is always found in the
+                                  esp register.  */
+  long int signal;                     /* Signal that caused the core dump. */
+  int reserved;                        /* No longer used */
+  unsigned long u_ar0;         /* Used by gdb to help find the values for */
+                               /* the registers. */
+  unsigned long magic;         /* To uniquely identify a core file */
+  char u_comm[32];             /* User command that was responsible */
+};
+#define NBPG PAGE_SIZE
+#define UPAGES 1
+#define HOST_TEXT_START_ADDR (u.start_code)
+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
+
+#endif
diff --git a/arch/rx/include/asm/vmlinux.lds.h b/arch/rx/include/asm/vmlinux.lds.h
new file mode 100644 (file)
index 0000000..1084c97
--- /dev/null
@@ -0,0 +1 @@
+#include <asm-generic/vmlinux.lds.h>
diff --git a/arch/rx/kernel/.gitignore b/arch/rx/kernel/.gitignore
new file mode 100644 (file)
index 0000000..c5f676c
--- /dev/null
@@ -0,0 +1 @@
+vmlinux.lds
diff --git a/arch/rx/kernel/Makefile b/arch/rx/kernel/Makefile
new file mode 100644 (file)
index 0000000..833b085
--- /dev/null
@@ -0,0 +1,11 @@
+#
+# Makefile for the linux kernel.
+#
+
+extra-y := vmlinux.lds
+
+obj-y := head.o process.o traps.o irq.o sys_rx.o time.o signal.o \
+         setup.o syscalls.o entry.o init_task.o ptrace.o dma-nommu.o \
+        timer/ cpu/
+
+obj-$(CONFIG_EARLY_PRINTK) += early-printk.o
diff --git a/arch/rx/kernel/asm-offsets.c b/arch/rx/kernel/asm-offsets.c
new file mode 100644 (file)
index 0000000..5b299f2
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * This program is used to generate definitions needed by
+ * assembly language modules.
+ *
+ * We use the technique used in the OSF Mach kernel code:
+ * generate asm statements containing #defines,
+ * compile this file to assembler, and then extract the
+ * #defines from the assembly-language output.
+ */
+
+#include <linux/stddef.h>
+#include <linux/sched.h>
+#include <linux/kernel_stat.h>
+#include <linux/ptrace.h>
+#include <linux/hardirq.h>
+#include <linux/kbuild.h>
+#include <asm/irq.h>
+#include <asm/ptrace.h>
+
+int main(void)
+{
+       /* offsets into the task struct */
+       DEFINE(TASK_STATE, offsetof(struct task_struct, state));
+       DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
+       DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
+       DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked));
+       DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
+       DEFINE(TASK_THREAD_INFO, offsetof(struct task_struct, stack));
+       DEFINE(TASK_MM, offsetof(struct task_struct, mm));
+       DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
+
+       /* offsets into the irq_cpustat_t struct */
+       DEFINE(CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t, __softirq_pending));
+       return 0;
+}
diff --git a/arch/rx/kernel/cpu/Makefile b/arch/rx/kernel/cpu/Makefile
new file mode 100644 (file)
index 0000000..5be27af
--- /dev/null
@@ -0,0 +1,5 @@
+obj-y = clock.o irq/
+
+obj-$(CONFIG_CPU_RX610) += rx610/
+obj-$(CONFIG_CPU_RX62N) += rx62n/
+obj-$(CONFIG_CPU_RX64M) += rx64m/
diff --git a/arch/rx/kernel/cpu/clock.c b/arch/rx/kernel/cpu/clock.c
new file mode 100644 (file)
index 0000000..c72ebdc
--- /dev/null
@@ -0,0 +1,471 @@
+/*
+ * arch/rx/kernel/cpu/clock.c - RX clock framework
+ *
+ * Based on SH version by:
+ * 
+ *  Copyright (C) 2005 - 2009  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/list.h>
+#include <linux/kobject.h>
+#include <linux/seq_file.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/debugfs.h>
+#include <linux/cpufreq.h>
+#include <asm/clock.h>
+#include <asm/io.h>
+
+static LIST_HEAD(clock_list);
+static DEFINE_SPINLOCK(clock_lock);
+static DEFINE_MUTEX(clock_list_sem);
+
+static void __clk_disable(struct clk *clk)
+{
+       if (clk->usecount == 0) {
+               printk(KERN_ERR "Trying disable clock %s with 0 usecount\n",
+                      clk->name);
+               WARN_ON(1);
+               return;
+       }
+
+       if (!(--clk->usecount)) {
+               if (likely(clk->mstpcr)) {
+                       unsigned char mstpcr;
+                       mstpcr = __raw_readb(clk->mstpcr);
+                       mstpcr |= clk->mstpbit;
+                       __raw_writeb(mstpcr,clk->mstpcr);
+               }
+               if (likely(clk->parent))
+                       __clk_disable(clk->parent);
+       }
+}
+
+void clk_disable(struct clk *clk)
+{
+       unsigned long flags;
+
+       if (!clk)
+               return;
+
+       spin_lock_irqsave(&clock_lock, flags);
+       __clk_disable(clk);
+       spin_unlock_irqrestore(&clock_lock, flags);
+}
+EXPORT_SYMBOL_GPL(clk_disable);
+
+static int __clk_enable(struct clk *clk)
+{
+       int ret = 0;
+
+       if (clk->usecount++ == 0) {
+               if (clk->parent) {
+                       ret = __clk_enable(clk->parent);
+                       if (unlikely(ret))
+                               goto err;
+               }
+               if (likely(clk->mstpcr)) {
+                       unsigned char mstpcr;
+                       mstpcr = __raw_readb(clk->mstpcr);
+                       mstpcr &= ~clk->mstpbit;
+                       __raw_writeb(mstpcr,clk->mstpcr);
+               }
+       }
+
+       return ret;
+err:
+       clk->usecount--;
+       return ret;
+}
+
+int clk_enable(struct clk *clk)
+{
+       unsigned long flags;
+       int ret;
+
+       if (!clk)
+               return -EINVAL;
+
+       spin_lock_irqsave(&clock_lock, flags);
+       ret = __clk_enable(clk);
+       spin_unlock_irqrestore(&clock_lock, flags);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(clk_enable);
+
+static LIST_HEAD(root_clks);
+
+int clk_register(struct clk *clk)
+{
+       if (clk == NULL || IS_ERR(clk))
+               return -EINVAL;
+
+       /*
+        * trap out already registered clocks
+        */
+       if (clk->node.next || clk->node.prev)
+               return 0;
+
+       mutex_lock(&clock_list_sem);
+
+       INIT_LIST_HEAD(&clk->children);
+       clk->usecount = 0;
+
+       if (clk->parent)
+               list_add(&clk->sibling, &clk->parent->children);
+       else
+               list_add(&clk->sibling, &root_clks);
+
+       list_add(&clk->node, &clock_list);
+       mutex_unlock(&clock_list_sem);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(clk_register);
+
+void clk_unregister(struct clk *clk)
+{
+       mutex_lock(&clock_list_sem);
+       list_del(&clk->sibling);
+       list_del(&clk->node);
+       mutex_unlock(&clock_list_sem);
+}
+EXPORT_SYMBOL_GPL(clk_unregister);
+
+static void clk_enable_init_clocks(void)
+{
+       struct clk *clkp;
+
+       list_for_each_entry(clkp, &clock_list, node)
+               if (clkp->flags & CLK_ENABLE_ON_INIT)
+                       clk_enable(clkp);
+}
+
+int clk_reparent(struct clk *child, struct clk *parent)
+{
+       list_del_init(&child->sibling);
+       if (parent)
+               list_add(&child->sibling, &parent->children);
+       child->parent = parent;
+
+       /* now do the debugfs renaming to reattach the child
+          to the proper parent */
+
+       return 0;
+}
+
+unsigned long clk_get_rate(struct clk *clk)
+{
+       return clk->rate?clk->rate:clk->selectable[clk->nr_selectable];
+}
+EXPORT_SYMBOL_GPL(clk_get_rate);
+
+int clk_set_rate(struct clk *clk, unsigned long rate)
+{
+       int ret = -EOPNOTSUPP;
+       unsigned long flags;
+       struct clk *clkp;
+
+       spin_lock_irqsave(&clock_lock, flags);
+
+       if (likely(clk->set_rate)) {
+               ret = clk->set_rate(clk, rate);
+               if (ret != 0)
+                       goto out_unlock;
+       } else {
+               clk->rate = rate;
+               ret = 0;
+       }
+       list_for_each_entry(clkp, &clk->children, sibling)
+               if (likely(clk->update))
+                       clk->update(clkp);
+out_unlock:
+       spin_unlock_irqrestore(&clock_lock, flags);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(clk_set_rate);
+
+int clk_set_parent(struct clk *clk, struct clk *parent)
+{
+       unsigned long flags;
+       int ret = -EINVAL;
+
+       if (!parent || !clk)
+               return ret;
+       if (clk->parent == parent)
+               return 0;
+
+       spin_lock_irqsave(&clock_lock, flags);
+       if (clk->usecount == 0) {
+               ret = clk_reparent(clk, parent);
+
+               if (ret == 0) {
+                       pr_debug("clock: set parent of %s to %s (new rate %ld)\n",
+                                clk->name, clk->parent->name, clk->rate);
+               }
+       } else
+               ret = -EBUSY;
+       spin_unlock_irqrestore(&clock_lock, flags);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(clk_set_parent);
+
+struct clk *clk_get_parent(struct clk *clk)
+{
+       return clk->parent;
+}
+EXPORT_SYMBOL_GPL(clk_get_parent);
+
+long clk_round_rate(struct clk *clk, unsigned long rate)
+{
+       unsigned long flags;
+       if (clk->nr_selectable > 0) {
+               int idx, roundclk;
+
+               spin_lock_irqsave(&clock_lock, flags);
+               roundclk = clk->selectable[clk->nr_selectable - 1];
+               for(idx = 0; idx < clk->nr_selectable; idx++) {
+                       if (rate < clk->selectable[idx]) {
+                               if (idx > 0 && 
+                                   ((rate - clk->selectable[idx - 1]) < (clk->selectable[idx ])))
+                                       roundclk =  clk->selectable[idx - 1];
+                               else
+                                       roundclk = clk->selectable[idx];
+                               break;
+                       }
+               }
+               spin_unlock_irqrestore(&clock_lock, flags);
+
+               return roundclk;
+       }
+
+       return clk_get_rate(clk);
+}
+EXPORT_SYMBOL_GPL(clk_round_rate);
+
+/*
+ * Find the correct struct clk for the device and connection ID.
+ * We do slightly fuzzy matching here:
+ *  An entry with a NULL ID is assumed to be a wildcard.
+ *  If an entry has a device ID, it must match
+ *  If an entry has a connection ID, it must match
+ * Then we take the most specific entry - with the following
+ * order of precidence: dev+con > dev only > con only.
+ */
+static struct clk *clk_find(const char *dev_id, const char *con_id)
+{
+       struct clk_lookup *p;
+       struct clk *clk = NULL;
+       int match, best = 0;
+
+       list_for_each_entry(p, &clock_list, node) {
+               match = 0;
+               if (p->dev_id) {
+                       if (!dev_id || strcmp(p->dev_id, dev_id))
+                               continue;
+                       match += 2;
+               }
+               if (p->con_id) {
+                       if (!con_id || strcmp(p->con_id, con_id))
+                               continue;
+                       match += 1;
+               }
+               if (match == 0)
+                       continue;
+
+               if (match > best) {
+                       clk = p->clk;
+                       best = match;
+               }
+       }
+       return clk;
+}
+
+struct clk *clk_get_sys(const char *dev_id, const char *con_id)
+{
+       struct clk *clk;
+
+       mutex_lock(&clock_list_sem);
+       clk = clk_find(dev_id, con_id);
+       mutex_unlock(&clock_list_sem);
+
+       return clk ? clk : ERR_PTR(-ENOENT);
+}
+EXPORT_SYMBOL_GPL(clk_get_sys);
+
+/*
+ * Returns a clock. Note that we first try to use device id on the bus
+ * and clock name. If this fails, we try to use clock name only.
+ */
+struct clk *clk_get(struct device *dev, const char *id)
+{
+       const char *dev_id = dev ? dev_name(dev) : NULL;
+       struct clk *p, *clk = ERR_PTR(-ENOENT);
+       int idno;
+
+       clk = clk_get_sys(dev_id, id);
+       if (clk && !IS_ERR(clk))
+               return clk;
+
+       if (dev == NULL || dev->bus != &platform_bus_type)
+               idno = -1;
+       else
+               idno = to_platform_device(dev)->id;
+
+       mutex_lock(&clock_list_sem);
+       list_for_each_entry(p, &clock_list, node) {
+               if (p->id == idno &&
+                   strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
+                       clk = p;
+                       goto found;
+               }
+       }
+
+       list_for_each_entry(p, &clock_list, node) {
+               if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
+                       clk = p;
+                       break;
+               }
+       }
+
+found:
+       mutex_unlock(&clock_list_sem);
+
+       return clk;
+}
+EXPORT_SYMBOL_GPL(clk_get);
+
+void clk_put(struct clk *clk)
+{
+       if (clk && !IS_ERR(clk))
+               module_put(clk->owner);
+}
+EXPORT_SYMBOL_GPL(clk_put);
+
+int __init clk_init(void)
+{
+       int ret;
+       struct clk *clkp;
+               struct clk *child_clkp;
+
+       ret = arch_clk_init();
+       if (unlikely(ret)) {
+               pr_err("%s: CPU clock registration failed.\n", __func__);
+               return ret;
+       }
+
+       list_for_each_entry(clkp, &root_clks, sibling) {
+               if (likely(clkp->update))
+                       clkp->update(clkp);
+               list_for_each_entry(child_clkp, &clkp->children, sibling) {
+                       if (likely(child_clkp->update))
+                               child_clkp->update(child_clkp);
+               }
+       }
+
+       /* Enable the necessary init clocks */
+       clk_enable_init_clocks();
+
+       return ret;
+}
+
+#ifdef CONFIG_DEBUG_FS
+/*
+ *     debugfs support to trace clock tree hierarchy and attributes
+ */
+static struct dentry *clk_debugfs_root;
+
+static int clk_debugfs_register_one(struct clk *c)
+{
+       int err;
+       struct dentry *d, *child;
+       struct clk *pa = c->parent;
+       char s[255];
+       char *p = s;
+
+       p += sprintf(p, "%s", c->name);
+       if (c->id >= 0)
+               sprintf(p, ":%d", c->id);
+       d = debugfs_create_dir(s, pa ? pa->dentry : clk_debugfs_root);
+       if (!d)
+               return -ENOMEM;
+       c->dentry = d;
+
+       d = debugfs_create_u8("usecount", S_IRUGO, c->dentry, (u8 *)&c->usecount);
+       if (!d) {
+               err = -ENOMEM;
+               goto err_out;
+       }
+       d = debugfs_create_u32("rate", S_IRUGO, c->dentry, (u32 *)&c->rate);
+       if (!d) {
+               err = -ENOMEM;
+               goto err_out;
+       }
+       d = debugfs_create_x32("flags", S_IRUGO, c->dentry, (u32 *)&c->flags);
+       if (!d) {
+               err = -ENOMEM;
+               goto err_out;
+       }
+       return 0;
+
+err_out:
+       d = c->dentry;
+       list_for_each_entry(child, &d->d_subdirs, d_u.d_child)
+               debugfs_remove(child);
+       debugfs_remove(c->dentry);
+       return err;
+}
+
+static int clk_debugfs_register(struct clk *c)
+{
+       int err;
+       struct clk *pa = c->parent;
+
+       if (pa && !pa->dentry) {
+               err = clk_debugfs_register(pa);
+               if (err)
+                       return err;
+       }
+
+       if (!c->dentry) {
+               err = clk_debugfs_register_one(c);
+               if (err)
+                       return err;
+       }
+       return 0;
+}
+
+static int __init clk_debugfs_init(void)
+{
+       struct clk *c;
+       struct dentry *d;
+       int err;
+
+       d = debugfs_create_dir("clock", NULL);
+       if (!d)
+               return -ENOMEM;
+       clk_debugfs_root = d;
+
+       list_for_each_entry(c, &clock_list, node) {
+               err = clk_debugfs_register(c);
+               if (err)
+                       goto err_out;
+       }
+       return 0;
+err_out:
+       debugfs_remove(clk_debugfs_root); /* REVISIT: Cleanup correctly */
+       return err;
+}
+late_initcall(clk_debugfs_init);
+#endif
diff --git a/arch/rx/kernel/cpu/irq/Makefile b/arch/rx/kernel/cpu/irq/Makefile
new file mode 100644 (file)
index 0000000..87e6330
--- /dev/null
@@ -0,0 +1 @@
+obj-$(CONFIG_RX_ICUA) = icua.o
diff --git a/arch/rx/kernel/cpu/irq/icua.c b/arch/rx/kernel/cpu/irq/icua.c
new file mode 100644 (file)
index 0000000..c1a32ea
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Interrupt handling for RX ICUa
+ *
+ * Copyright (C) 2011  Yoshinori Sato
+ *
+ */
+
+#include <linux/linkage.h>
+#include <linux/interrupt.h>
+#include <linux/export.h>
+#include <asm/io.h>
+
+#define IER (0x00087200)
+#define IPR (0x00087300)
+
+static void disable_icua_irq(struct irq_data *data);
+static void enable_icua_irq(struct irq_data *data);
+static void dummy_ack(struct irq_data *data);
+
+struct irq_chip chip = {
+       .name   = "RX-ICUa",
+       .irq_mask       = disable_icua_irq,
+       .irq_unmask = enable_icua_irq,
+       .irq_ack = dummy_ack,
+       .irq_mask_ack = disable_icua_irq,
+};
+
+static void disable_icua_irq(struct irq_data *data)
+{
+       void __iomem *ier = (void *)(IER + (data->irq >> 3));
+       unsigned char val;
+       val = __raw_readb(ier);
+       val &= ~(1 << (data->irq & 7));
+       __raw_writeb(val, ier);
+}
+
+static void enable_icua_irq(struct irq_data *data)
+{
+       void __iomem *ier = (void *)(IER + (data->irq >> 3));
+       unsigned char val;
+       val = __raw_readb(ier);
+       val |= 1 << (data->irq & 7);
+       __raw_writeb(val, ier);
+}
+
+static void dummy_ack(struct irq_data *data)
+{
+}
+
+void __init setup_rx_irq_desc(void)
+{
+       int i;
+
+       for (i = 16; i < 256; i++) {
+               struct irq_desc *irq_desc;
+
+               irq_desc = irq_alloc_desc_at(i, numa_node_id());
+               if (unlikely(!irq_desc)) {
+                       printk(KERN_INFO "can not get irq_desc for %d\n", i);
+                       continue;
+               }
+
+               disable_irq_nosync(i);
+               irq_set_chip_and_handler_name(i, &chip, handle_simple_irq, "level");
+       }
+       for (i = 0; i < 0x90; i++)
+               __raw_writeb(1, (void __iomem *)(IPR + i));
+}
diff --git a/arch/rx/kernel/cpu/irq/ipr.c b/arch/rx/kernel/cpu/irq/ipr.c
new file mode 100644 (file)
index 0000000..e6de9a0
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * Interrupt handling for RX-INTC IPR
+ *
+ * Copyright (C) 2010  Yoshinori Sato
+ *
+ */
+
+#include <linux/linkage.h>
+#include <linux/interrupt.h>
+#include <asm/io.h>
+#define IR (0x00087000)
+#define IER (0x00087200)
+
+static void disable_ipr_irq(unsigned int irq)
+{
+       void *ipr = get_irq_chip_data(irq);
+       __raw_writeb(0, ipr);
+}
+
+static void enable_ipr_irq(unsigned int irq)
+{
+       unsigned int offset;
+       unsigned int bit;
+       u8 ier;
+       void *ipr = get_irq_chip_data(irq);
+       __raw_writeb(1, ipr);
+       offset = irq / 8;
+       bit = irq % 8;
+       ier = __raw_readb((void __iomem *)(IER + offset));
+       ier |= (1 << bit);              /* enable IRQ on ICU */
+       __raw_writeb(ier, (void __iomem *)(IER + offset));
+}
+
+const static struct {
+       int irq;
+       int ipr;
+} irq_info[] __initdata = {
+#if defined(CONFIG_CPU_RX610)
+       { 20, 0x01}, { 22, 0x02}, /* FCU */
+       { 28, 0x04}, { 29, 0x05}, { 30, 0x06}, { 31, 0x07}, /* CMT */
+       { 64, 0x20}, { 65, 0x21}, { 66, 0x22}, { 67, 0x23}, /* EXT */
+       { 68, 0x24}, { 69, 0x25}, { 70, 0x26}, { 71, 0x27},
+       { 72, 0x28}, { 73, 0x29}, { 74, 0x2a}, { 75, 0x2b},
+       { 76, 0x2c}, { 77, 0x2d}, { 78, 0x2e}, { 79, 0x2f},
+       { 96, 0x40}, /* WDT */
+       { 98, 0x44}, { 99, 0x45}, {100, 0x46}, {101, 0x47}, /* ADC */
+       {104, 0x4c}, {105, 0x4c}, {106, 0x4c}, {107, 0x4c}, /* TPU */
+       {108, 0x4d}, 
+       {111, 0x4e}, {112, 0x4e}, {115, 0x4f}, {116, 0x4f},
+       {117, 0x50}, {118, 0x50}, {120, 0x51}, {121, 0x51},
+       {122, 0x52}, {123, 0x52}, {124, 0x52}, {125, 0x52},
+       {126, 0x53}, 
+       {127, 0x54}, {128, 0x54}, {131, 0x55}, {132, 0x55},
+       {133, 0x56}, {134, 0x56}, {136, 0x57}, {137, 0x57},
+       {138, 0x58}, {139, 0x58}, {140, 0x58}, {141, 0x58},
+       {142, 0x59}, 
+       {145, 0x5a}, {146, 0x5a}, {149, 0x5b}, {150, 0x5b},
+       {151, 0x5c}, {152, 0x5c}, {154, 0x5d}, {155, 0x5d},
+       {156, 0x5e}, {157, 0x5e}, {158, 0x5e}, {159, 0x5e},
+       {160, 0x5f}, 
+       {161, 0x60}, {162, 0x60}, {165, 0x61}, {166, 0x61},
+       {167, 0x62}, {168, 0x62}, {170, 0x63}, {171, 0x63},
+       {174, 0x68}, {175, 0x68}, {176, 0x68}, /* TMR */
+       {177, 0x69}, {178, 0x69}, {179, 0x69},
+       {180, 0x6a}, {181, 0x6a}, {182, 0x6a},
+       {183, 0x6b}, {184, 0x6b}, {185, 0x6b},
+       {198, 0x70}, {199, 0x71}, {200, 0x72}, {201, 0x73}, /* DMA */
+       {214, 0x80}, {215, 0x80}, {216, 0x80}, {217, 0x80}, /* SCI */
+       {218, 0x81}, {219, 0x81}, {220, 0x81}, {221, 0x81},
+       {222, 0x82}, {223, 0x82}, {224, 0x82}, {225, 0x82},
+       {226, 0x83}, {227, 0x83}, {228, 0x83}, {229, 0x83},
+       {230, 0x84}, {231, 0x84}, {232, 0x84}, {233, 0x84},
+       {234, 0x85}, {235, 0x85}, {236, 0x85}, {237, 0x85},
+       {238, 0x86}, {239, 0x86}, {240, 0x86}, {241, 0x86},
+       {246, 0x88}, {247, 0x89}, {248, 0x8a}, {249, 0x8b}, /* RIIC */
+       {250, 0x8c}, {251, 0x8d}, {252, 0x8e}, {253, 0x8f},
+#endif
+#if defined(CONFIG_CPU_RX62N)
+       { 20, 0x01}, { 22, 0x02}, /* FCU */
+       { 28, 0x04}, { 29, 0x05}, { 30, 0x06}, { 31, 0x07}, /* CMT */
+       { 32, 0x08}, /* EINT */
+       { 36, 0x0c}, { 37, 0x0d}, { 38, 0x0e}, /* USB */
+       { 40, 0x10}, { 41, 0x11}, { 42, 0x12},
+       { 44, 0x14}, { 45, 0x14}, { 46, 0x14}, { 47, 0x14}, /* RSPI0 */
+       { 48, 0x15}, { 49, 0x15}, { 50, 0x15}, { 51, 0x15},
+       { 56, 0x18}, { 57, 0x18}, { 58, 0x18}, { 59, 0x18}, { 60, 0x18}, /* CAN */
+       { 62, 0x1e}, { 63, 0x1f}, /* RTC */
+       { 64, 0x20}, { 65, 0x21}, { 66, 0x22}, { 67, 0x23}, /* EXT */
+       { 68, 0x24}, { 69, 0x25}, { 70, 0x26}, { 71, 0x27},
+       { 72, 0x28}, { 73, 0x29}, { 74, 0x2a}, { 75, 0x2b},
+       { 76, 0x2c}, { 77, 0x2d}, { 78, 0x2e}, { 79, 0x2f},
+       { 90, 0x3a}, { 91, 0x3b}, /* USB */
+       { 92, 0x3c}, /* RTC */
+       { 96, 0x40}, /* WDT */
+       { 98, 0x44}, { 99, 0x45}, {102, 0x48}, /* ADC */
+       {114, 0x51}, {115, 0x51}, {116, 0x51}, {117, 0x51}, /* MTU */
+       {118, 0x52}, {119, 0x52}, {120, 0x52},
+       {121, 0x53}, {122, 0x53}, {123, 0x54}, {124, 0x54},
+       {125, 0x55}, {126, 0x55}, {127, 0x56}, {128, 0x56},
+       {129, 0x57}, {130, 0x57}, {131, 0x57}, {132, 0x57}, {133, 0x58},
+       {134, 0x59}, {135, 0x59}, {136, 0x59}, {137, 0x59}, {138, 0x5a},
+       {139, 0x5b}, {140, 0x5b}, {141, 0x5b},
+       {142, 0x5c}, {143, 0x5c}, {144, 0x5c}, {145, 0x5c},
+       {146, 0x5d}, {147, 0x5d}, {148, 0x5d},
+       {149, 0x5e}, {150, 0x5e}, {151, 0x5f}, {152, 0x5f},
+       {153, 0x60}, {154, 0x60}, {155, 0x61}, {156, 0x61},
+       {157, 0x62}, {158, 0x62}, {159, 0x62}, {160, 0x62}, {161, 0x63},
+       {162, 0x64}, {163, 0x64}, {164, 0x64}, {165, 0x64}, {166, 0x65},
+       {167, 0x66}, {168, 0x66}, {169, 0x66},
+       {170, 0x67}, {171, 0x67}, {172, 0x67}, {173, 0x67}, /* POE */
+       {174, 0x68}, {175, 0x68}, {176, 0x68}, /* TMR */
+       {177, 0x69}, {178, 0x69}, {179, 0x69},
+       {180, 0x6a}, {181, 0x6a}, {182, 0x6a},
+       {183, 0x6b}, {184, 0x6b}, {185, 0x6b},
+       {198, 0x70}, {199, 0x71}, {200, 0x72}, {201, 0x73}, /* DMAC */
+       {202, 0x74}, {203, 0x75}, /* EXDMA */
+       {214, 0x80}, {215, 0x80}, {216, 0x80}, {217, 0x80}, /* SCI */
+       {218, 0x81}, {219, 0x81}, {220, 0x81}, {221, 0x81},
+       {222, 0x82}, {223, 0x82}, {224, 0x82}, {225, 0x82},
+       {226, 0x83}, {227, 0x83}, {228, 0x83}, {229, 0x83},
+       {234, 0x85}, {235, 0x85}, {236, 0x85}, {237, 0x85},
+       {238, 0x86}, {239, 0x86}, {240, 0x86}, {241, 0x86},
+       {246, 0x88}, {247, 0x89}, {248, 0x8a}, {249, 0x8b}, /* RIIC */
+       {250, 0x8c}, {251, 0x8d}, {252, 0x8e}, {253, 0x8f},
+#endif
+};
+
+void __init setup_rx_irq_desc(struct irq_chip *chip)
+{
+       int i;
+
+       chip->mask = disable_ipr_irq;
+       chip->unmask = enable_ipr_irq;
+       chip->mask_ack = disable_ipr_irq;
+
+       for (i = 0; i < ARRAY_SIZE(irq_info); i++) {
+               struct irq_desc *irq_desc;
+
+               irq_desc = irq_to_desc_alloc_node(irq_info[i].irq, numa_node_id());
+               if (unlikely(!irq_desc)) {
+                       printk(KERN_INFO "can not get irq_desc for %d\n",
+                              irq_info[i].irq);
+                       continue;
+               }
+
+               disable_irq_nosync(irq_info[i].irq);
+               set_irq_chip_and_handler_name(irq_info[i].irq, chip, handle_level_irq,"");
+               set_irq_chip_data(irq_info[i].irq, (void *)(0x00087300 +irq_info[i].ipr));
+               disable_ipr_irq(irq_info[i].irq);
+       }
+}
diff --git a/arch/rx/kernel/cpu/rx610/Makefile b/arch/rx/kernel/cpu/rx610/Makefile
new file mode 100644 (file)
index 0000000..e4919bd
--- /dev/null
@@ -0,0 +1 @@
+obj-y = setup.o clock.o
diff --git a/arch/rx/kernel/cpu/rx610/clock.c b/arch/rx/kernel/cpu/rx610/clock.c
new file mode 100644 (file)
index 0000000..de1b030
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * RX610 CPG setup
+ *
+ *  Copyright (C) 2009  Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+/*
+ * clock diagram
+ * xtal/ext clock -- *8 pll -+- div1 -- cpu core
+ *                           |
+ *                           +- div2 -- internal peripheral
+ *                           |
+ *                           +- div3 -- external bus
+ */
+
+#include <linux/linkage.h>
+#include <linux/clk.h>
+#include <asm/clock.h>
+#include <asm/io.h>
+
+#define MHz 1000000
+
+/* pll output clock */
+static struct clk master = {
+       .name  = "master_clk",
+        .flags = CLK_ENABLE_ON_INIT,
+        .rate  = CONFIG_INPUT_CLOCK_FREQ * 8,
+       .set_rate = NULL,
+       .update = NULL,
+};
+
+const int __initdata div_rate[] = {1, 2, 4, 8};
+
+static int update_clock(struct clk *clk, unsigned long rate, int bits)
+{
+       unsigned long master_freq = clk_get_rate(clk->parent);
+       int i;
+       rate = clk_round_rate(clk, rate);
+       for (i = 0; i < ARRAY_SIZE(div_rate); i++)
+               if (rate == master_freq / div_rate[i]) {
+                       unsigned long flags;
+                       unsigned long sckcr;
+                       local_irq_save(flags);
+                       sckcr = __raw_readl((void *)0x00080020);
+                       sckcr &= ~(0x0f << bits);
+                       sckcr |= i << bits;
+                       __raw_writel(sckcr, (void *)0x00080020);
+                       local_irq_restore(flags);
+                       clk->rate = rate;
+                       return 0;
+               }
+       return 1;
+}
+
+
+static int cpu_set_rate(struct clk *clk, unsigned long rate)
+{
+       if (rate > 100 * MHz)
+               return 1;
+       return update_clock(clk, rate, 24);
+}
+
+static int cpu_update(struct clk *clk)
+{
+       return update_clock(clk, clk->rate, 24);
+}
+
+static struct clk cpu = {
+       .name   = "cpu_clk",
+       .parent = &master,
+       .flags  = CLK_ENABLE_ON_INIT,
+       .set_rate = cpu_set_rate,
+       .update = cpu_update,
+};
+
+static int peripheral_set_rate(struct clk *clk, unsigned long rate)
+{
+       if (rate > 50 * MHz)
+               return 1;
+       return update_clock(clk, rate, 8);
+}
+
+static int peripheral_update(struct clk *clk)
+{
+       return update_clock(clk, clk->rate, 8);
+}
+
+static struct clk peripheral = {
+       .name   = "peripheral_clk",
+       .parent = &master,
+       .flags  = CLK_ENABLE_ON_INIT,
+       .set_rate = peripheral_set_rate,
+       .update = peripheral_update,
+};
+
+static int bus_set_rate(struct clk *clk, unsigned long rate)
+{
+       if (rate > 25 * MHz)
+               return 1;
+       return update_clock(clk, rate, 16);
+}
+
+static int bus_update(struct clk *clk)
+{
+       return update_clock(clk, clk->rate, 16);
+}
+
+static struct clk bus = {
+       .name   = "bus_clk",
+       .parent = &master,
+       .flags  = CLK_ENABLE_ON_INIT,
+       .set_rate = bus_set_rate,
+       .update = bus_update,
+};
+
+static void __init set_selectable(struct clk *clk, int limit)
+{
+       int i, nr;
+       for(i = ARRAY_SIZE(div_rate) - 1, nr = 0; i >= 0; i--) {
+               int f = (CONFIG_INPUT_CLOCK_FREQ * 8) / div_rate[i];
+               if (f > limit)
+                       break;
+               clk->selectable[nr++] = f;
+       }
+       clk->nr_selectable = nr;
+}
+
+int __init arch_clk_init(void)
+{
+       int ret;
+       if ((ret = clk_register(&master)))
+               pr_err("%s: CPU clock registration failed.\n", __func__);
+
+       set_selectable(&cpu, 100 * MHz);
+       if ((ret = clk_register(&cpu))) {
+               pr_err("%s: CPU clock registration failed.\n", __func__);
+               goto end;
+       }
+       set_selectable(&peripheral, 50 * MHz);
+       if ((ret = clk_register(&peripheral))) {
+               pr_err("%s: CPU clock registration failed.\n", __func__);
+               goto end;
+       }
+       set_selectable(&bus, 25 * MHz);
+       if ((ret = clk_register(&bus))) {
+               pr_err("%s: CPU clock registration failed.\n", __func__);
+               goto end;
+       }
+end:
+       return ret;
+}
diff --git a/arch/rx/kernel/cpu/rx610/setup.c b/arch/rx/kernel/cpu/rx610/setup.c
new file mode 100644 (file)
index 0000000..4754936
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * RX610 Internal peripheral setup
+ *
+ *  Copyright (C) 2009  Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/serial_sci.h>
+
+static struct plat_sci_port sci_platform_data[] = {
+       /* SCI0 to SCI2 */
+       {
+               .mapbase        = 0x00088240,
+               .flags          = UPF_BOOT_AUTOCONF,
+               .type           = PORT_SCI,
+               .irqs           = { 214, 215, 216, 0 },
+       }, {
+               .mapbase        = 0x00088248,
+               .flags          = UPF_BOOT_AUTOCONF,
+               .type           = PORT_SCI,
+               .irqs           = { 218, 219, 220, 0 },
+       }, {
+               .mapbase        = 0x00088250,
+               .flags          = UPF_BOOT_AUTOCONF,
+               .type           = PORT_SCI,
+               .irqs           = { 222, 223, 224, 0 },
+       }, {
+               .flags = 0,
+       }
+};
+
+static struct platform_device sci_device[] = {
+       {
+               .name           = "sh-sci",
+               .id             = 0,
+               .dev            = {
+                       .platform_data  = &sci_platform_data[0],
+               },
+       },
+       {
+               .name           = "sh-sci",
+               .id             = 1,
+               .dev            = {
+                       .platform_data  = &sci_platform_data[1],
+               },
+       },
+       {
+               .name           = "sh-sci",
+               .id             = 2,
+               .dev            = {
+                       .platform_data  = &sci_platform_data[2],
+               },
+       },
+};
+
+static struct platform_device *rx62n_devices[] __initdata = {
+       &sci_device[0],
+       &sci_device[1],
+       &sci_device[2],
+};
+
+static int __init devices_register(void)
+{
+       return platform_add_devices(rx62n_devices,
+                                   ARRAY_SIZE(rx62n_devices));
+}
+arch_initcall(devices_register);
+
+void __init early_device_register(void)
+{
+       early_platform_add_devices(rx62n_devices,
+                                  ARRAY_SIZE(rx62n_devices));
+}
diff --git a/arch/rx/kernel/cpu/rx62n/Makefile b/arch/rx/kernel/cpu/rx62n/Makefile
new file mode 100644 (file)
index 0000000..e4919bd
--- /dev/null
@@ -0,0 +1 @@
+obj-y = setup.o clock.o
diff --git a/arch/rx/kernel/cpu/rx62n/clock.c b/arch/rx/kernel/cpu/rx62n/clock.c
new file mode 100644 (file)
index 0000000..d087017
--- /dev/null
@@ -0,0 +1,165 @@
+/*
+ * RX62N CPG setup
+ *
+ *  Copyright (C) 2011  Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+/*
+ * clock diagram
+ * xtal/ext clock -- *8 pll -+- div1 -- cpu core
+ *                           |
+ *                           +- div2 -- internal peripheral
+ *                           |
+ *                           +- div3 -- external bus
+ */
+
+#include <linux/linkage.h>
+#include <linux/clk.h>
+#include <asm/clock.h>
+#include <asm/io.h>
+
+#define MHz 1000000
+
+/* pll output clock */
+static struct clk master = {
+       .name  = "master_clk",
+        .flags = CLK_ENABLE_ON_INIT,
+        .rate  = CONFIG_INPUT_CLOCK_FREQ * 8,
+       .set_rate = NULL,
+};
+
+const int __initdata div_rate[] = {8, 4, 2, 1};
+
+static int update_clock(struct clk *clk, unsigned long rate, int bits)
+{
+       unsigned long master_freq = clk_get_rate(clk->parent);
+       int i;
+       rate = clk_round_rate(clk, rate);
+       for (i = 0; i < ARRAY_SIZE(div_rate); i++)
+               if (rate == master_freq / div_rate[i]) {
+                       unsigned long flags;
+                       unsigned long sckcr;
+                       local_irq_save(flags);
+                       sckcr = __raw_readl((void *)0x00080020);
+                       sckcr &= ~(0x0f << bits);
+                       sckcr |= i << bits;
+                       __raw_writel(sckcr, (void *)0x00080020);
+                       local_irq_restore(flags);
+                       clk->rate = rate;
+                       return 0;
+               }
+       return 1;
+}
+
+
+static int cpu_set_rate(struct clk *clk, unsigned long rate)
+{
+       if (rate > 100 * MHz)
+               return 1;
+       return update_clock(clk, rate, 24);
+}
+
+static int cpu_update(struct clk *clk)
+{
+       return update_clock(clk, clk->rate, 24);
+}
+
+static struct clk cpu = {
+       .name   = "cpu_clk",
+       .parent = &master,
+       .flags  = CLK_ENABLE_ON_INIT,
+       .set_rate = cpu_set_rate,
+};
+
+static int peripheral_set_rate(struct clk *clk, unsigned long rate)
+{
+       if (rate > 50 * MHz)
+               return 1;
+       return update_clock(clk, rate, 8);
+}
+
+static int peripheral_update(struct clk *clk)
+{
+       return update_clock(clk, clk->rate, 8);
+}
+
+static struct clk peripheral = {
+       .name   = "peripheral_clk",
+       .parent = &master,
+       .flags  = CLK_ENABLE_ON_INIT,
+       .set_rate = peripheral_set_rate,
+};
+
+static int bus_set_rate(struct clk *clk, unsigned long rate)
+{
+       if (rate > 50 * MHz)
+               return 1;
+       return update_clock(clk, rate, 16);
+}
+
+static int bus_update(struct clk *clk)
+{
+       return update_clock(clk, clk->rate, 16);
+}
+
+static struct clk bus = {
+       .name   = "bus_clk",
+       .parent = &master,
+       .flags  = CLK_ENABLE_ON_INIT,
+       .set_rate = bus_set_rate,
+};
+
+static void __init set_selectable(struct clk *clk, int limit)
+{
+       int i, nr, max;
+       for(i = 0, nr = 0, max = 0; i < ARRAY_SIZE(div_rate); i++) {
+               int f = (CONFIG_INPUT_CLOCK_FREQ * 8) / div_rate[i];
+               if (f <= limit) {
+                       if (f > max) {
+                               clk->nr_selectable = nr;
+                               max = f;
+                       }
+                       clk->selectable[nr++] = f;
+               }
+       }
+}
+
+static void __init set_clock_nr(struct clk *clk, int freq)
+{
+       int i;
+       for (i = 0; i < DIV_NR; i++)
+               if (clk->selectable[i] == freq) {
+                       clk->nr_selectable = i;
+                       break;
+               }
+}
+
+int __init arch_clk_init(void)
+{
+       int ret;
+       if ((ret = clk_register(&master)))
+               pr_err("%s: CPU clock registration failed.\n", __func__);
+
+       set_selectable(&cpu, 100 * MHz);
+       if ((ret = clk_register(&cpu))) {
+               pr_err("%s: CPU clock registration failed.\n", __func__);
+               goto end;
+       }
+       set_selectable(&peripheral, 50 * MHz);
+       set_clock_nr(&peripheral, CONFIG_INPUT_CLOCK_FREQ * CONFIG_PCLK_MULT);
+       if ((ret = clk_register(&peripheral))) {
+               pr_err("%s: CPU clock registration failed.\n", __func__);
+               goto end;
+       }
+       set_selectable(&bus, 50 * MHz);
+       if ((ret = clk_register(&bus))) {
+               pr_err("%s: CPU clock registration failed.\n", __func__);
+               goto end;
+       }
+end:
+       return ret;
+}
diff --git a/arch/rx/kernel/cpu/rx62n/setup.c b/arch/rx/kernel/cpu/rx62n/setup.c
new file mode 100644 (file)
index 0000000..97d80c4
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * RX62N Internal peripheral setup
+ *
+ *  Copyright (C) 2011  Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/serial_sci.h>
+
+static struct plat_sci_port sci_platform_data[] = {
+       /* SCI0 to SCI1 */
+       {
+               .mapbase        = 0x00088240,
+               .flags          = UPF_BOOT_AUTOCONF,
+               .type           = PORT_SCI,
+               .scscr          = SCSCR_RE | SCSCR_TE,
+               .scbrr_algo_id  = -1,
+               .irqs           = { 214, 215, 216, 0 },
+       }, {
+               .mapbase        = 0x00088248,
+               .flags          = UPF_BOOT_AUTOCONF,
+               .type           = PORT_SCI,
+               .scscr          = SCSCR_RE | SCSCR_TE,
+               .scbrr_algo_id  = -1,
+               .irqs           = { 218, 219, 220, 0 },
+       }, {
+               .flags = 0,
+       }
+};
+
+static struct platform_device sci_device[] = {
+       {
+               .name           = "sh-sci",
+               .id             = 0,
+               .dev            = {
+                       .platform_data  = &sci_platform_data[0],
+               },
+       },
+       {
+               .name           = "sh-sci",
+               .id             = 1,
+               .dev            = {
+                       .platform_data  = &sci_platform_data[1],
+               },
+       },
+};
+
+static struct platform_device *rx62n_devices[] __initdata = {
+       &sci_device[0],
+       &sci_device[1],
+};
+
+static int __init devices_register(void)
+{
+       return platform_add_devices(rx62n_devices,
+                                   ARRAY_SIZE(rx62n_devices));
+}
+arch_initcall(devices_register);
+
+void __init early_device_register(void)
+{
+       early_platform_add_devices(rx62n_devices,
+                                  ARRAY_SIZE(rx62n_devices));
+       *(volatile unsigned long *)0x00080010 &= ~0x00008000;
+}
diff --git a/arch/rx/kernel/cpu/rx64m/Makefile b/arch/rx/kernel/cpu/rx64m/Makefile
new file mode 100644 (file)
index 0000000..e4919bd
--- /dev/null
@@ -0,0 +1 @@
+obj-y = setup.o clock.o
diff --git a/arch/rx/kernel/cpu/rx64m/clock.c b/arch/rx/kernel/cpu/rx64m/clock.c
new file mode 100644 (file)
index 0000000..d087017
--- /dev/null
@@ -0,0 +1,165 @@
+/*
+ * RX62N CPG setup
+ *
+ *  Copyright (C) 2011  Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+/*
+ * clock diagram
+ * xtal/ext clock -- *8 pll -+- div1 -- cpu core
+ *                           |
+ *                           +- div2 -- internal peripheral
+ *                           |
+ *                           +- div3 -- external bus
+ */
+
+#include <linux/linkage.h>
+#include <linux/clk.h>
+#include <asm/clock.h>
+#include <asm/io.h>
+
+#define MHz 1000000
+
+/* pll output clock */
+static struct clk master = {
+       .name  = "master_clk",
+        .flags = CLK_ENABLE_ON_INIT,
+        .rate  = CONFIG_INPUT_CLOCK_FREQ * 8,
+       .set_rate = NULL,
+};
+
+const int __initdata div_rate[] = {8, 4, 2, 1};
+
+static int update_clock(struct clk *clk, unsigned long rate, int bits)
+{
+       unsigned long master_freq = clk_get_rate(clk->parent);
+       int i;
+       rate = clk_round_rate(clk, rate);
+       for (i = 0; i < ARRAY_SIZE(div_rate); i++)
+               if (rate == master_freq / div_rate[i]) {
+                       unsigned long flags;
+                       unsigned long sckcr;
+                       local_irq_save(flags);
+                       sckcr = __raw_readl((void *)0x00080020);
+                       sckcr &= ~(0x0f << bits);
+                       sckcr |= i << bits;
+                       __raw_writel(sckcr, (void *)0x00080020);
+                       local_irq_restore(flags);
+                       clk->rate = rate;
+                       return 0;
+               }
+       return 1;
+}
+
+
+static int cpu_set_rate(struct clk *clk, unsigned long rate)
+{
+       if (rate > 100 * MHz)
+               return 1;
+       return update_clock(clk, rate, 24);
+}
+
+static int cpu_update(struct clk *clk)
+{
+       return update_clock(clk, clk->rate, 24);
+}
+
+static struct clk cpu = {
+       .name   = "cpu_clk",
+       .parent = &master,
+       .flags  = CLK_ENABLE_ON_INIT,
+       .set_rate = cpu_set_rate,
+};
+
+static int peripheral_set_rate(struct clk *clk, unsigned long rate)
+{
+       if (rate > 50 * MHz)
+               return 1;
+       return update_clock(clk, rate, 8);
+}
+
+static int peripheral_update(struct clk *clk)
+{
+       return update_clock(clk, clk->rate, 8);
+}
+
+static struct clk peripheral = {
+       .name   = "peripheral_clk",
+       .parent = &master,
+       .flags  = CLK_ENABLE_ON_INIT,
+       .set_rate = peripheral_set_rate,
+};
+
+static int bus_set_rate(struct clk *clk, unsigned long rate)
+{
+       if (rate > 50 * MHz)
+               return 1;
+       return update_clock(clk, rate, 16);
+}
+
+static int bus_update(struct clk *clk)
+{
+       return update_clock(clk, clk->rate, 16);
+}
+
+static struct clk bus = {
+       .name   = "bus_clk",
+       .parent = &master,
+       .flags  = CLK_ENABLE_ON_INIT,
+       .set_rate = bus_set_rate,
+};
+
+static void __init set_selectable(struct clk *clk, int limit)
+{
+       int i, nr, max;
+       for(i = 0, nr = 0, max = 0; i < ARRAY_SIZE(div_rate); i++) {
+               int f = (CONFIG_INPUT_CLOCK_FREQ * 8) / div_rate[i];
+               if (f <= limit) {
+                       if (f > max) {
+                               clk->nr_selectable = nr;
+                               max = f;
+                       }
+                       clk->selectable[nr++] = f;
+               }
+       }
+}
+
+static void __init set_clock_nr(struct clk *clk, int freq)
+{
+       int i;
+       for (i = 0; i < DIV_NR; i++)
+               if (clk->selectable[i] == freq) {
+                       clk->nr_selectable = i;
+                       break;
+               }
+}
+
+int __init arch_clk_init(void)
+{
+       int ret;
+       if ((ret = clk_register(&master)))
+               pr_err("%s: CPU clock registration failed.\n", __func__);
+
+       set_selectable(&cpu, 100 * MHz);
+       if ((ret = clk_register(&cpu))) {
+               pr_err("%s: CPU clock registration failed.\n", __func__);
+               goto end;
+       }
+       set_selectable(&peripheral, 50 * MHz);
+       set_clock_nr(&peripheral, CONFIG_INPUT_CLOCK_FREQ * CONFIG_PCLK_MULT);
+       if ((ret = clk_register(&peripheral))) {
+               pr_err("%s: CPU clock registration failed.\n", __func__);
+               goto end;
+       }
+       set_selectable(&bus, 50 * MHz);
+       if ((ret = clk_register(&bus))) {
+               pr_err("%s: CPU clock registration failed.\n", __func__);
+               goto end;
+       }
+end:
+       return ret;
+}
diff --git a/arch/rx/kernel/cpu/rx64m/setup.c b/arch/rx/kernel/cpu/rx64m/setup.c
new file mode 100644 (file)
index 0000000..ec3cea0
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * RX62N Internal peripheral setup
+ *
+ *  Copyright (C) 2011  Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/serial_sci.h>
+
+static struct plat_sci_port sci_platform_data[] = {
+       /* SCIF0 to SCIF3 */
+       {
+               .mapbase        = 0x000d0000,
+               .flags          = UPF_BOOT_AUTOCONF,
+               .type           = PORT_RXSCIF,
+               .scscr          = SCSCR_RE | SCSCR_TE,
+               .scbrr_algo_id  = -1,
+               .irqs           = { 100, 101, 0, 0 },
+       }, {
+               .mapbase        = 0x000d0020,
+               .flags          = UPF_BOOT_AUTOCONF,
+               .type           = PORT_RXSCIF,
+               .scscr          = SCSCR_RE | SCSCR_TE,
+               .scbrr_algo_id  = -1,
+               .irqs           = { 102, 103, 0, 0 },
+       }, {
+               .mapbase        = 0x000d0040,
+               .flags          = UPF_BOOT_AUTOCONF,
+               .type           = PORT_RXSCIF,
+               .scscr          = SCSCR_RE | SCSCR_TE,
+               .scbrr_algo_id  = -1,
+               .irqs           = { 104, 105, 0, 0 },
+       }, {
+               .mapbase        = 0x000d0060,
+               .flags          = UPF_BOOT_AUTOCONF,
+               .type           = PORT_RXSCIF,
+               .scscr          = SCSCR_RE | SCSCR_TE,
+               .scbrr_algo_id  = -1,
+               .irqs           = { 114, 115, 0, 0 },
+       }, {
+               .flags = 0,
+       }
+};
+
+static struct platform_device sci_device[] = {
+       {
+               .name           = "sh-sci",
+               .id             = 0,
+               .dev            = {
+                       .platform_data  = &sci_platform_data[0],
+               },
+       },
+       {
+               .name           = "sh-sci",
+               .id             = 1,
+               .dev            = {
+                       .platform_data  = &sci_platform_data[1],
+               },
+       },
+       {
+               .name           = "sh-sci",
+               .id             = 2,
+               .dev            = {
+                       .platform_data  = &sci_platform_data[2],
+               },
+       },
+       {
+               .name           = "sh-sci",
+               .id             = 3,
+               .dev            = {
+                       .platform_data  = &sci_platform_data[3],
+               },
+       },
+};
+
+static struct platform_device *rx64m_devices[] __initdata = {
+       &sci_device[0],
+       &sci_device[1],
+       &sci_device[2],
+       &sci_device[3],
+};
+
+static int __init devices_register(void)
+{
+       return platform_add_devices(rx64m_devices,
+                                   ARRAY_SIZE(rx64m_devices));
+}
+arch_initcall(devices_register);
+
+void __init early_device_register(void)
+{
+       early_platform_add_devices(rx64m_devices,
+                                  ARRAY_SIZE(rx64m_devices));
+       *(volatile unsigned long *)0x00080010 &= ~0x00008000;
+}
diff --git a/arch/rx/kernel/dma-nommu.c b/arch/rx/kernel/dma-nommu.c
new file mode 100644 (file)
index 0000000..ba83f00
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * DMA mapping support
+ *
+ * Copyright (C) 2011 Yoshinori Sato
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/dma-mapping.h>
+#include <linux/io.h>
+
+struct dma_map_ops *dma_ops;
+EXPORT_SYMBOL(dma_ops);
+
+static void *dma_generic_alloc_coherent(struct device *dev, size_t size,
+                                dma_addr_t *dma_handle, gfp_t gfp)
+{
+       void *ret;
+       int order = get_order(size);
+
+       gfp |= __GFP_ZERO;
+
+       ret = (void *)__get_free_pages(gfp, order);
+       if (!ret)
+               return NULL;
+
+       split_page(pfn_to_page(virt_to_phys(ret) >> PAGE_SHIFT), order);
+
+       *dma_handle = virt_to_phys(ret);
+
+       return ret;
+}
+
+static void dma_generic_free_coherent(struct device *dev, size_t size,
+                              void *vaddr, dma_addr_t dma_handle)
+{
+       int order = get_order(size);
+       unsigned long pfn = dma_handle >> PAGE_SHIFT;
+       int k;
+
+       for (k = 0; k < (1 << order); k++)
+               __free_pages(pfn_to_page(pfn + k), 0);
+
+       iounmap(vaddr);
+}
+
+static dma_addr_t nommu_dma_map_page(struct device *dev, struct page *page,
+                                unsigned long offset, size_t size,
+                                enum dma_data_direction dir,
+                                struct dma_attrs *attrs)
+{
+       WARN_ON(size == 0);
+
+       return page_to_phys(page) + offset;
+}
+
+static int nommu_dma_map_sg(struct device *dev, struct scatterlist *sg,
+                       int nents, enum dma_data_direction dir,
+                       struct dma_attrs *attrs)
+{
+       struct scatterlist *s;
+       int i;
+
+       WARN_ON(nents == 0 || sg[0].length == 0);
+
+       for_each_sg(sg, s, nents, i) {
+               BUG_ON(!sg_page(s));
+
+               s->dma_address = sg_phys(s);
+               s->dma_length = s->length;
+       }
+
+       return nents;
+}
+
+struct dma_map_ops rx_dma_ops = {
+       .alloc_coherent         = dma_generic_alloc_coherent,
+       .free_coherent          = dma_generic_free_coherent,
+       .map_page               = nommu_dma_map_page,
+       .map_sg                 = nommu_dma_map_sg,
+       .is_phys                = 1,
+};
+
+void __init no_iommu_init(void)
+{
+       if (dma_ops)
+               return;
+       dma_ops = &rx_dma_ops;
+}
diff --git a/arch/rx/kernel/early-printk.c b/arch/rx/kernel/early-printk.c
new file mode 100644 (file)
index 0000000..1749270
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * arch/rx/kernel/early-printk.c
+ *
+ *  Copyright (C) 2009 Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/console.h>
+#include <linux/tty.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/delay.h>
+
+#if defined(CONFIG_RX_GDB_SIM)
+static void gdb_write(struct console *co, const char *ptr,
+                                unsigned len)
+{
+       register const int fd __asm__("r1") = 1; /* stdout */
+       register const char *_ptr __asm__("r2") = ptr;
+       register const unsigned _len __asm__("r3") = len;
+       register const unsigned syscall __asm__("r5") = 5; /* sys_write */
+       __asm__("int #255"
+               ::"g"(fd),"g"(_ptr),"g"(_len),"g"(syscall));
+}
+
+static struct console gdb_console = {
+       .name           = "gdb_console",
+       .write          = gdb_write,
+       .setup          = NULL,
+       .flags          = CON_PRINTBUFFER,
+       .index          = -1,
+};
+#endif
+
+static struct console *early_console = NULL;
+
+static int __init setup_early_printk(char *buf)
+{
+       if (!buf)
+               return 0;
+
+#if defined(CONFIG_RX_GDB_SIM)
+       if (!strncmp(buf, "gdb", 3))
+               early_console = &gdb_console;
+#endif
+#if defined(CONFIG_EARLY_SCI_CONSOLE)
+       if (!strncmp(buf, "serial", 6)) {
+               early_console = &sci_console;
+               sci_early_init(buf + 6);
+       }
+#endif
+       if (!early_console)
+               return 0;
+
+       if (strstr(buf, "keep"))
+               early_console->flags &= ~CON_BOOT;
+       else
+               early_console->flags |= CON_BOOT;
+       register_console(early_console);
+
+       return 0;
+}
+early_param("earlyprintk", setup_early_printk);
diff --git a/arch/rx/kernel/entry.S b/arch/rx/kernel/entry.S
new file mode 100644 (file)
index 0000000..6570928
--- /dev/null
@@ -0,0 +1,192 @@
+/*
+ * arch/rx/kernel/entry.S
+ *
+ * The RX exception entry
+ *
+ * Copyright (C) 2009,2010 Yoshinori Sato
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/linkage.h>
+#include <asm/asm-offsets.h>
+#include <asm/thread_info.h>
+#include <asm/unistd.h>
+#include <asm/errno.h>
+#include <asm/page.h>
+#include <asm/ptrace.h>
+       
+#if !defined(CONFIG_PREEMPT)
+#define resume_kernel restore_all
+#endif
+
+#define MIN_IRQ 20
+#define MAX_EXCEPTION (32 + 20)
+#define SYSVEC 8
+       
+.global        rx_int_table
+.global ret_from_fork
+.global rx_exception_handler
+       
+       .section        .text
+       .align  4
+rx_int_table:  
+       .rept   256
+       bsr.a   interrupt_entry
+       .endr
+
+interrupt_entry:
+       sub     #4,r0
+       pushm   r1-r15
+       mov.l   r0,r13
+       add     #-(19*4),r13
+       mov.l   r13,[-r0]
+       mvfc    usp,r13
+       mov.l   r13,OFF_USP[r0]
+       mov.l   OFF_VEC[r0],r13
+       mov.l   #rx_int_table,r14
+       sub     r14,r13
+       shlr    #2,r13
+       sub     #1,r13
+       mov.l   r13,OFF_VEC[r0]
+       cmp     #MIN_IRQ,r13
+       ble     1f
+       mvfc    psw,r1
+       and     #~0x07000000,r1         ; enable nested interrupt
+       mvtc    r1,psw
+       mov.l   r13,r1
+       mov.l   r0,r2
+       bsr     do_IRQ
+       bra     ret_from_interrupt
+1:
+       add     #32,r13
+
+rx_exception_handler:
+       cmp     #32+SYSVEC,r13
+       beq     syscall_entry
+       cmp     #MAX_EXCEPTION,r13
+       bge     1f
+       add     #0x1000,r13,r14
+       mov.l   r13,OFF_VEC[r0]
+       mov.l   r0,r1
+       shll    #2,r13
+       add     #exception_table,r13
+       mov.l   [r13],r13
+       tst     r13,r13
+       beq     1f
+       jsr     r13
+       bra     ret_from_exception
+1:
+       mov.l   r0,r1
+       mov.l   r13,r2
+       bsr     unhandled_exception
+ret_from_exception:    
+#if defined(CONFIG_PREEMPT)
+       clrpsw  i
+#endif
+ret_from_interrupt:    
+       mov.l   OFF_PSW[r0],r1
+       btst    #20,r1
+       beq     resume_kernel
+resume_userspace:
+       clrpsw  i
+       mov.l   #~(THREAD_SIZE - 1),r13
+       and     r0, r13
+       mov.l   TI_FLAGS[r13],r14
+       tst     #_TIF_WORK_MASK,r14
+       beq     restore_all
+work_pending:
+       btst    #TIF_NEED_RESCHED,r14
+       bne     work_resched
+       mov.l   r0,r1                   ; pt_regs
+       mov     r15,r3
+       mov.l   r14,r2
+       bsr     do_notify_resume        ; do_notify_resume(pt_regs *, ti_flags, saved_r1)
+       bra     resume_userspace
+work_resched:
+       bsr     schedule
+       clrpsw  i
+       mov     TI_FLAGS[r13],r14
+       tst     #_TIF_WORK_MASK,r14
+       bne     work_pending
+restore_all:
+       mov.l   OFF_USP[r0],r1
+       mvtc    r1,usp
+       add     #4,r0
+       popm    r1-r15
+       add     #8,r0
+       rte
+#if defined(CONFIG_PREEMPT)
+resume_kernel:
+       clrpsw  i
+       mov.l   #~(THREAD_SIZE - 1),r13
+       and     r0,r13
+       mov.l   TI_PRECOUNT[r13],r14
+       tst     r14,r14
+       bne     restore_all
+1:     
+       mov.l   TI_FLAGS[r13],r14
+       btst    #TIF_NEED_RESCHED,r14
+       beq     restore_all
+       mov.l   OFF_PSW[r0],r2
+       btst    #16,r2          ; I flag check
+       beq     restore_all     ; intterupt disable (exception cause)
+       bsr     preempt_schedule_irq
+       bra     1b
+#endif
+syscall_entry:
+       setpsw  i
+       mov.l   #~(THREAD_SIZE - 1),r13
+       and     r0,r13
+       mov.l   TI_FLAGS[r13],r14
+       tst     #_TIF_WORK_SYSCALL_MASK,r14
+       bnz     4f
+1:     
+       cmp     #NR_syscalls,r15
+       blt     2f
+       mov.l   #-ENOSYS,r1     ; invalid no
+       bra     3f
+2:     
+       shll    #2,r15
+       add     #syscall_table,r15
+       mov.l   [r15],r15
+       mov.l   r7,[-r0]
+       mov.l   r5,[-r0]
+       jsr     r15
+       add     #8,r0
+3:     
+       mov.l   OFF_R1[r0],r15  ; r15 = saved r1
+       mov.l   r1,OFF_R1[r0]
+       clrpsw  i
+       mov.l   #~(THREAD_SIZE - 1),r13
+       and     r0,r13
+       mov.l   TI_FLAGS[r13],r14
+       tst     #_TIF_ALLWORK_MASK,r14
+       bne     5f
+       bra     restore_all
+4:
+       ;; syscall trace enter
+       mov.l   r0,r1
+       bsr     syscall_trace_enter ; syscall_trace_enter(pt_regs *)
+       mov.l   OFF_R1[r0],r1
+       mov.l   OFF_R2[r0],r2
+       mov.l   OFF_R3[r0],r3
+       mov.l   OFF_R4[r0],r4
+       mov.l   OFF_R5[r0],r5
+       bra     1b
+5:
+       ;; syscall trace leave
+       btst    #TIF_SYSCALL_TRACE,r14
+       beq     work_pending
+       setpsw  i
+       mov.l   r0,r1
+       bsr     syscall_trace_leave ; syscall_trace_leave(pt_regs *)
+       bra     resume_userspace
+
+ret_from_fork: 
+       bsr     schedule_tail
+       bra     ret_from_exception
+
+       .end
diff --git a/arch/rx/kernel/head.S b/arch/rx/kernel/head.S
new file mode 100644 (file)
index 0000000..7cd7376
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * arch/rx/kernel/head.S
+ *  Copyright (C) 2009 Yoshinori Sato
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+       
+
+#include <linux/init.h>
+#include <linux/linkage.h>
+#include <asm/thread_info.h>
+#include <asm/vmlinux.lds.h>
+
+       .global startup
+       .section        .head.text,"ax"
+startup:
+       mov.l   #CONFIG_INITIAL_STACK,r0
+#if !defined(CONFIG_RX_GDB_SIM)
+#if defined(CONFIG_ROMKERNEL)
+       mov.l   #setup_bsc,r1
+       jsr     r1
+
+       /* copy rw data for ram */
+       mov.l   #__data_romtop,r2
+       mov.l   #_sdata,r1
+       mov.l   #_edata,r3
+       sub     r1,r3
+       smovf
+#endif
+#else
+       /* setup args */
+       mov.l   #12, r5
+       int     #255
+       mov.l   r1,r2
+       mov.l   #0x400,r1
+       mov.l   #13, r5
+       int     #255
+       /* r1 - argc */
+       /* r2 -length */
+       /* skip argv[0] */
+       mov.l   r1,r4
+       mov.l   r2,r3
+       mov.l   #0x400,r1
+       mov.l   #0,r2
+       suntil.b
+       mov.l   r3,r5
+       mov.l   r1,r2
+       mov.l   #0x400,r1
+       smovf
+       mov.l   #0x400,r1
+       mov.l   #0,r2
+       sub     #1,r4
+       mov.l   r5,r3
+1:     
+       suntil.b
+       sub     #1,r1
+       mov.b   #' ',[r1]
+       add     #1,r1
+       sub     #1,r4
+       bne     1b
+#endif
+       /* clear BSS */
+       mov.l   #_sbss,r1
+       mov.l   #_ebss,r3
+       sub     r1,r3
+       shlr    #2,r3
+       mov.l   #0,r2
+       sstr.l
+       /* exception handler setup */
+#if defined(CONFIG_RAMKERNEL)
+       mov.l   #install_exception_entry,r1
+       jsr     r1
+#endif
+       /* start kernel */
+       mov.l   #init_thread_union, r1
+       add     #PAGE_SIZE, r1, r0
+       mov.l   #start_kernel, r1
+       jmp     r1
+
+       .weak   setup_bsc
+setup_bsc:     
+       rts
+
+       .end
diff --git a/arch/rx/kernel/init_task.c b/arch/rx/kernel/init_task.c
new file mode 100644 (file)
index 0000000..ccb534a
--- /dev/null
@@ -0,0 +1,33 @@
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/init.h>
+#include <linux/init_task.h>
+#include <linux/fs.h>
+#include <linux/mqueue.h>
+
+#include <asm/uaccess.h>
+#include <asm/pgtable.h>
+
+static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
+static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
+/*
+ * Initial task structure.
+ *
+ * All other task structs will be allocated on slabs in fork.c
+ */
+__asm__(".align 4");
+struct task_struct init_task = INIT_TASK(init_task);
+
+EXPORT_SYMBOL(init_task);
+
+/*
+ * Initial thread structure.
+ *
+ * We need to make sure that this is 8192-byte aligned due to the
+ * way process stacks are handled. This is done by having a special
+ * "init_task" linker map entry..
+ */
+union thread_union init_thread_union __init_task_data =
+       { INIT_THREAD_INFO(init_task) };
+
diff --git a/arch/rx/kernel/irq.c b/arch/rx/kernel/irq.c
new file mode 100644 (file)
index 0000000..a67ade4
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * arch/rx/kernel/irq.c
+ *
+ * Copyright (C) 2009 Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ */
+
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/seq_file.h>
+#include <asm/processor.h>
+#include <asm/io.h>
+
+void setup_rx_irq_desc(void);
+
+extern unsigned long rx_int_table[NR_IRQS];
+extern unsigned long rx_exp_table[32];
+static unsigned long *interrupt_vector[NR_IRQS];
+
+#define EXT_IRQ0 64
+#define EXT_IRQS 16
+#define IR (0x00087000)
+#define IER (0x00087200)
+#define IRQER (0x0008c300)
+
+void rx_force_interrupt(unsigned int no)
+{
+       __raw_writeb(1, (void __iomem *)(IR + no));
+}
+
+void __init setup_vector(void)
+{
+       int i;
+       for (i = 0; i < NR_IRQS; i++)
+               interrupt_vector[i] = &rx_int_table[i];
+       __asm__ volatile("mvtc %0,intb"::"i"(interrupt_vector));
+}
+
+
+void __init init_IRQ(void)
+{
+       setup_vector();
+       setup_rx_irq_desc();
+}
+
+asmlinkage int do_IRQ(unsigned int irq, struct pt_regs *regs)
+{
+       struct pt_regs *old_regs = set_irq_regs(regs);
+
+       irq_enter();
+       generic_handle_irq(irq);
+       irq_exit();
+
+       set_irq_regs(old_regs);
+       return 1;
+}
diff --git a/arch/rx/kernel/process.c b/arch/rx/kernel/process.c
new file mode 100644 (file)
index 0000000..2e39f2b
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * arch/rx/kernel/process.c
+ *
+ * This file handles the architecture-dependent parts of process handling..
+ *
+ *  Copyright (C) 1995  Linus Torvalds
+ *
+ *  RX version:  Copyright (C) 2009 Yoshinori Sato
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/elfcore.h>
+#include <linux/kallsyms.h>
+#include <linux/fs.h>
+#include <linux/ftrace.h>
+#include <linux/preempt.h>
+#include <asm/uaccess.h>
+#include <asm/mmu_context.h>
+#include <asm/pgalloc.h>
+#include <asm/system.h>
+
+void (*pm_power_off)(void) = NULL;
+EXPORT_SYMBOL(pm_power_off);
+
+/*
+ * The idle thread. There's no useful work to be
+ * done, so just try to conserve power and have a
+ * low exit latency (ie sit in a loop waiting for
+ * somebody to say that they'd like to reschedule)
+ */
+void cpu_idle(void)
+{
+       while (1) {
+               while (!need_resched())
+                       __asm__ volatile("wait");
+               preempt_enable_no_resched();
+               schedule();
+               preempt_disable();
+       }
+}
+
+void __noreturn machine_restart(char * __unused)
+{
+       unsigned long tmp;
+       local_irq_disable();
+       __asm__ volatile("mov.l #0xfffffffc,%0\n\t"
+                        "mov.l [%0],%0\n\t"
+                        "jmp %0"
+                        :"=r"(tmp));
+       for(;;);
+}
+
+void __noreturn machine_halt(void)
+{
+       local_irq_disable();
+
+       while (1)
+               __asm__ volatile("wait");
+}
+
+void machine_power_off(void)
+{
+       /* Nothing do. */
+}
+
+void show_regs(struct pt_regs * regs)
+{
+       printk("\n");
+       printk("Pid : %d, Comm: \t\t%s\n", task_pid_nr(current), current->comm);
+       print_symbol("PC is at %s\n", instruction_pointer(regs));
+
+       printk("PC  : %08lx SP  : %08lx PSW  : %08lx\n",
+              regs->pc, regs->r[0], regs->psw);
+       printk("R1  : %08lx R2  : %08lx R3  : %08lx\n",
+              regs->r[1],
+              regs->r[2],regs->r[3]);
+       printk("R4  : %08lx R5  : %08lx R6  : %08lx R7  : %08lx\n",
+              regs->r[4],regs->r[5],
+              regs->r[6],regs->r[7]);
+       printk("R8  : %08lx R9  : %08lx R10 : %08lx R11 : %08lx\n",
+              regs->r[8],regs->r[9],
+              regs->r[10],regs->r[11]);
+       printk("R12 : %08lx R13 : %08lx R14 : %08lx R15 : %08lx\n",
+              regs->r[12],regs->r[13],
+              regs->r[14],regs->r[15]);
+}
+
+/*
+ * Create a kernel thread
+ */
+static void __noreturn kernel_thread_helper(int dummy, int (*fn)(void *), void *arg)
+{
+       fn(arg);
+       do_exit(-1);
+}
+
+int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
+{
+       struct pt_regs regs;
+
+       memset(&regs, 0, sizeof(regs));
+       regs.r[2] = (unsigned long)fn;
+       regs.r[3] = (unsigned long)arg;
+
+       regs.pc = (unsigned long)kernel_thread_helper;
+       regs.psw = 0;
+
+       /* Ok, create the new process.. */
+       return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
+                     &regs, 0, NULL, NULL);
+}
+
+asmlinkage void ret_from_fork(void);
+
+int copy_thread(unsigned long clone_flags,
+                unsigned long usp, unsigned long topstk,
+                struct task_struct * p, struct pt_regs * regs)
+{
+       struct pt_regs *childregs = 
+               (struct pt_regs *) (THREAD_SIZE + task_stack_page(p)) - 1;
+
+       *childregs = *regs;
+       childregs->usp  = usp;
+       childregs->r[1] = 0;
+
+       p->thread.sp = (unsigned long)childregs;
+       p->thread.pc = (unsigned long)ret_from_fork;
+
+       return 0;
+}
+
+asmlinkage int sys_fork(void)
+{
+       return -EINVAL;
+}
+
+asmlinkage int rx_clone(struct pt_regs *regs)
+{
+       unsigned long clone_flags = regs->r[1];
+       unsigned long newsp = regs->r[2];
+       unsigned long parent_tidptr = regs->r[3];
+       unsigned long child_tidptr = regs->r[4];
+
+       if (!newsp)
+               newsp = regs->usp;
+       return do_fork(clone_flags, newsp, regs, 0,
+                       (int __user *)parent_tidptr,
+                       (int __user *)child_tidptr);
+}
+
+asmlinkage int rx_vfork(struct pt_regs *regs)
+{
+       return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->usp, regs,
+                      0, NULL, NULL);
+}
+
+/*
+ * sys_execve() executes a new program.
+ */
+asmlinkage int sys_execve(const char __user *ufilename, const char __user * __user *uargv,
+                         const char __user * __user *uenvp, int dummy, ...)
+{
+       struct pt_regs *regs = (struct pt_regs *)
+               ((unsigned char *)&dummy + 8);
+       int error;
+       char *filename;
+
+       filename = getname(ufilename);
+       error = PTR_ERR(filename);
+       if (IS_ERR(filename))
+               goto out;
+
+       error = do_execve(filename, uargv, uenvp, regs);
+       putname(filename);
+out:
+       return error;
+}
+
+unsigned long get_wchan(struct task_struct *p)
+{
+       int count = 0;
+       unsigned long pc;
+       unsigned long fp;
+       unsigned long stack_page;
+
+       if (!p || p == current || p->state == TASK_RUNNING)
+               return 0;
+
+       stack_page = (unsigned long)p;
+       fp = ((struct pt_regs *)p->thread.sp)->r[6];
+       do {
+               if (fp < stack_page+sizeof(struct thread_info) ||
+                   fp >= (THREAD_SIZE - sizeof(struct pt_regs) +stack_page))
+                       return 0;
+               pc = ((unsigned long *)fp)[1];
+               if (!in_sched_functions(pc))
+                       return pc;
+               fp = *(unsigned long *) fp;
+       } while (count++ < 16);
+       return 0;
+}
diff --git a/arch/rx/kernel/ptrace.c b/arch/rx/kernel/ptrace.c
new file mode 100644 (file)
index 0000000..36f9bad
--- /dev/null
@@ -0,0 +1,52 @@
+#include <linux/sched.h>
+#include <linux/errno.h>
+#include <linux/audit.h>
+#include <linux/tracehook.h>
+
+#include <trace/events/syscalls.h>
+
+long arch_ptrace(struct task_struct *child, long request, 
+                unsigned long addr, unsigned long data) {
+       return -ENOSYS;
+}
+
+void ptrace_disable(struct task_struct *child)
+{
+}
+
+asmlinkage long syscall_trace_enter(struct pt_regs *regs)
+{
+       long ret = 0;
+
+       secure_computing(regs->r[8]);
+
+       if (test_thread_flag(TIF_SYSCALL_TRACE) &&
+           tracehook_report_syscall_entry(regs))
+               /*
+                * Tracing decided this syscall should not happen.
+                * We'll return a bogus call number to get an ENOSYS
+                * error, but leave the original number in regs->r[8].
+                */
+               ret = -1L;
+
+       if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
+               trace_sys_enter(regs, regs->r[8]);
+
+       if (unlikely(current->audit_context))
+               audit_syscall_entry(EM_RX|__AUDIT_ARCH_LE, regs->r[8],
+                                   regs->r[1], regs->r[2],
+                                   regs->r[3], regs->r[4]);
+
+       return ret ?: regs->r[8];
+}
+
+asmlinkage void syscall_trace_leave(struct pt_regs *regs)
+{
+       audit_syscall_exit(regs);
+
+       if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
+               trace_sys_exit(regs, regs->r[1]);
+
+       if (test_thread_flag(TIF_SYSCALL_TRACE))
+               tracehook_report_syscall_exit(regs, 0);
+}
diff --git a/arch/rx/kernel/setup.c b/arch/rx/kernel/setup.c
new file mode 100644 (file)
index 0000000..a48a8d9
--- /dev/null
@@ -0,0 +1,196 @@
+/*
+ * arch/rx/kernel/setup.c
+ * This file handles the architecture-dependent parts of system setup
+ *
+ * Copyright (C) 2009 Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/mm.h>
+#include <linux/fs.h>
+#include <linux/fb.h>
+#include <linux/console.h>
+#include <linux/genhd.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/major.h>
+#include <linux/bootmem.h>
+#include <linux/seq_file.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/initrd.h>
+#include <asm/setup.h>
+#include <asm/irq.h>
+#include <asm/pgtable.h>
+
+unsigned long rom_length;
+unsigned long memory_start;
+unsigned long memory_end;
+
+#define COMMAND_LINE ((char *)CONFIG_RAMSTART)
+
+static struct resource code_resource = {
+       .name   = "Kernel code",
+};
+
+static struct resource data_resource = {
+       .name   = "Kernel data",
+};
+
+static struct resource bss_resource = {
+       .name   = "Kernel bss",
+};
+
+extern void *_ramstart, *_ramend;
+extern void *_stext, *_etext;
+extern void *_sdata, *_edata;
+extern void *_sbss, *_ebss;
+extern void *_end;
+
+void early_device_register(void);
+
+void __init setup_arch(char **cmdline_p)
+{
+       int bootmap_size;
+
+#ifdef CONFIG_CMDLINE
+       if (*COMMAND_LINE == 0)
+               memcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+#endif
+       if(*boot_command_line == '\0')
+               memcpy(boot_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
+       *cmdline_p = boot_command_line;
+
+#ifdef DEBUG
+       if (strlen(boot_command_line)) 
+               printk(KERN_DEBUG "Command line: '%s'\n", *cmdline_p);
+#endif
+
+       memory_start = (unsigned long) &_end;
+
+       /* allow for ROMFS on the end of the kernel */
+       if (memcmp((void *)memory_start, "-rom1fs-", 8) == 0) {
+#if defined(CONFIG_BLK_DEV_INITRD)
+               initrd_start = memory_start;
+               initrd_end = memory_start += be32_to_cpu(((unsigned long *) (memory_start))[2]);
+#else
+               memory_start += be32_to_cpu(((unsigned long *) memory_start)[2]);
+#endif
+       }
+       memory_start = PAGE_ALIGN(memory_start);
+#if !defined(CONFIG_BLKDEV_RESERVE)
+       memory_end = (unsigned long) &_ramend; /* by now the stack is part of the init task */
+#else
+       if ((memory_end < CONFIG_BLKDEV_RESERVE_ADDRESS) && 
+           (memory_end > CONFIG_BLKDEV_RESERVE_ADDRESS))
+           /* overlap userarea */
+           memory_end = CONFIG_BLKDEV_RESERVE_ADDRESS; 
+#endif
+
+       init_mm.start_code = (unsigned long) &_stext;
+       init_mm.end_code = (unsigned long) &_etext;
+       init_mm.end_data = (unsigned long) &_edata;
+       init_mm.brk = (unsigned long) &_end; 
+
+       code_resource.start = virt_to_bus(&_stext);
+       code_resource.end = virt_to_bus(&_etext)-1;
+       data_resource.start = virt_to_bus(&_sdata);
+       data_resource.end = virt_to_bus(&_edata)-1;
+       bss_resource.start = virt_to_bus(&_sbss);
+       bss_resource.end = virt_to_bus(&_ebss)-1;
+
+
+#ifdef DEBUG
+       printk(KERN_DEBUG "KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x "
+               "BSS=0x%06x-0x%06x\n", (int) &_stext, (int) &_etext,
+               (int) &_sdata, (int) &_edata,
+               (int) &_sbss, (int) &_ebss);
+       printk(KERN_DEBUG "KERNEL -> ROMFS=0x%06x-0x%06x MEM=0x%06x-0x%06x "
+               "STACK=0x%06x-0x%06x\n",
+              (int) &_ebss, (int) memory_start,
+               (int) memory_start, (int) memory_end,
+               (int) memory_end, (int) &_ramend);
+#endif
+       /*
+        * give all the memory to the bootmap allocator,  tell it to put the
+        * boot mem_map at the start of memory
+        */
+       bootmap_size = init_bootmem_node(
+                       NODE_DATA(0),
+                       memory_start >> PAGE_SHIFT, /* map goes here */
+                       memory_start >> PAGE_SHIFT,
+                       memory_end >> PAGE_SHIFT);
+       /*
+        * free the usable memory,  we have to make sure we do not free
+        * the bootmem bitmap so we then reserve it after freeing it :-)
+        */
+       free_bootmem(memory_start, memory_end - memory_start);
+       reserve_bootmem(memory_start, bootmap_size, BOOTMEM_DEFAULT);
+       /* Let earlyprintk output early console messages */
+       early_device_register();
+       parse_early_param();
+       early_platform_driver_probe("earlyprintk", 1, 1);
+       /*
+        * get kmalloc into gear
+        */
+       paging_init();
+
+       insert_resource(&iomem_resource, &code_resource);
+       insert_resource(&iomem_resource, &data_resource);
+       insert_resource(&iomem_resource, &bss_resource);
+#ifdef DEBUG
+       printk(KERN_DEBUG "Done setup_arch\n");
+#endif
+}
+
+/*
+ *     Get CPU information for use by the procfs.
+ */
+
+static int show_cpuinfo(struct seq_file *m, void *v)
+{
+    char *cpu;
+
+#if defined(CONFIG_CPU_RX610)
+    cpu = "RX610";
+#elif defined(CONFIG_CPU_RX62N)
+    cpu = "RX62N";
+#else
+    cpu = "Unknown";
+#endif
+
+    seq_printf(m,  "CPU:\t\t%s\n"
+                  "BogoMips:\t%lu.%02lu\n"
+                  "Calibration:\t%lu loops\n",
+                  cpu,
+                  (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
+                  (loops_per_jiffy*HZ));
+
+    return 0;
+}
+
+static void *c_start(struct seq_file *m, loff_t *pos)
+{
+       return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
+}
+
+static void *c_next(struct seq_file *m, void *v, loff_t *pos)
+{
+       ++*pos;
+       return c_start(m, pos);
+}
+
+static void c_stop(struct seq_file *m, void *v)
+{
+}
+
+const struct seq_operations cpuinfo_op = {
+       .start  = c_start,
+       .next   = c_next,
+       .stop   = c_stop,
+       .show   = show_cpuinfo,
+};
diff --git a/arch/rx/kernel/signal.c b/arch/rx/kernel/signal.c
new file mode 100644 (file)
index 0000000..95d05d5
--- /dev/null
@@ -0,0 +1,318 @@
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/smp.h>
+#include <linux/kernel.h>
+#include <linux/signal.h>
+#include <linux/errno.h>
+#include <linux/wait.h>
+#include <linux/unistd.h>
+#include <linux/stddef.h>
+#include <linux/personality.h>
+#include <linux/freezer.h>
+#include <linux/tracehook.h>
+#include <asm/cacheflush.h>
+#include <asm/ucontext.h>
+#include <asm/uaccess.h>
+
+#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
+
+struct rt_sigframe
+{
+       u8 __user *pretcode;
+       struct siginfo info;
+       struct ucontext uc;
+       u8 retcode[8];
+};
+
+static int
+restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc,
+                  unsigned long *r1)
+{
+       unsigned int err = 0;
+
+       /* Always make any pending restarted system calls return -EINTR */
+       current_thread_info()->restart_block.fn = do_no_restart_syscall;
+
+#define COPY(x)                err |= __get_user(regs->x, &sc->sc_##x)
+       COPY(r[0]); COPY(r[1]);
+       COPY(r[2]); COPY(r[3]);
+       COPY(r[4]); COPY(r[5]);
+       COPY(r[6]); COPY(r[7]);
+       COPY(r[8]); COPY(r[9]);
+       COPY(r[10]); COPY(r[11]);
+       COPY(r[12]); COPY(r[13]);
+       COPY(r[14]); COPY(r[15]);
+       COPY(psw); COPY(pc);
+       COPY(usp);
+#undef COPY
+       regs->vec = 0;
+       *r1 = regs->r[1];
+       return err;
+}
+
+
+static int
+setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
+                unsigned long mask)
+{
+       int err = 0;
+
+#define COPY(x)        err |= __put_user(regs->x, &sc->sc_##x)
+       COPY(r[0]); COPY(r[1]);
+       COPY(r[2]); COPY(r[3]);
+       COPY(r[4]); COPY(r[5]);
+       COPY(r[6]); COPY(r[7]);
+       COPY(r[8]); COPY(r[9]);
+       COPY(r[10]); COPY(r[11]);
+       COPY(r[12]); COPY(r[13]);
+       COPY(r[14]); COPY(r[15]);
+       COPY(psw); COPY(pc);
+       COPY(usp);
+#undef COPY
+
+       err |= __put_user(mask, &sc->sc_mask);
+
+       return err;
+}
+
+asmlinkage long rx_rt_sigreturn(struct pt_regs *regs)
+{
+       struct rt_sigframe __user *frame;
+       unsigned long result;
+       sigset_t set;
+
+       frame = (struct rt_sigframe __user *)(regs->usp - 4);
+       if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
+               goto badframe;
+       if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
+               goto badframe;
+
+       sigdelsetmask(&set, ~_BLOCKABLE);
+       spin_lock_irq(&current->sighand->siglock);
+       current->blocked = set;
+       recalc_sigpending();
+       spin_unlock_irq(&current->sighand->siglock);
+
+       if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &result))
+               goto badframe;
+
+       if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->usp) == -EFAULT)
+               goto badframe;
+
+       return result;
+
+badframe:
+       force_sig(SIGSEGV, current);
+       return 0;
+}
+
+asmlinkage int rx_sigaltstack(const stack_t *uss, stack_t *uoss, 
+                             struct pt_regs *regs)
+{
+       return do_sigaltstack(uss, uoss, regs->usp);
+}
+
+/*
+ * Determine which stack to use..
+ */
+static inline void __user *
+get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size)
+{
+       /* This is the X/Open sanctioned signal stack switching.  */
+       if (ka->sa.sa_flags & SA_ONSTACK) {
+               if (sas_ss_flags(sp) == 0)
+                       sp = current->sas_ss_sp + current->sas_ss_size;
+       }
+
+       return (void __user *)((sp - frame_size) & -8ul);
+}
+
+#define SIMM16(n) (n) & 0x00ff, ((n) >> 8) & 0x00ff
+static const u8 __rt_retcode[8] = {
+       0xfb, 0xfa, SIMM16(__NR_rt_sigreturn),  /* mov.l #__NR_rt_sigreturn,r15 */
+       0x75, 0x60, 0x08,                       /* int #0x08 */
+       0x03};                                  /* nop (padding) */
+
+static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
+                          sigset_t *set, struct pt_regs *regs)
+{
+       struct rt_sigframe __user *frame;
+       int err = 0;
+       int signal;
+
+       frame = get_sigframe(ka, regs->usp, sizeof(*frame));
+
+       if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
+               goto give_sigsegv;
+
+       signal = current_thread_info()->exec_domain
+               && current_thread_info()->exec_domain->signal_invmap
+               && sig < 32
+               ? current_thread_info()->exec_domain->signal_invmap[sig]
+               : sig;
+
+       err |= copy_siginfo_to_user(&frame->info, info);
+       if (err)
+               goto give_sigsegv;
+
+       /* Create the ucontext.  */
+       err |= __put_user(0, &frame->uc.uc_flags);
+       err |= __put_user(0, &frame->uc.uc_link);
+       err |= __put_user(current->sas_ss_sp, (u8 *)&frame->uc.uc_stack.ss_sp);
+       err |= __put_user(sas_ss_flags(regs->usp),
+                         &frame->uc.uc_stack.ss_flags);
+       err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
+       err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0]);
+       err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
+       if (err)
+               goto give_sigsegv;
+
+       /* setup retcode */
+       err |= __put_user(*((u64 *)&__rt_retcode), (u64 *)frame->retcode);
+       err |= __put_user(frame->retcode, &(frame->pretcode));
+       if (err)
+               goto give_sigsegv;
+
+       /* Set up registers for signal handler */
+       regs->usp = (unsigned long)frame;
+       regs->r[1] = signal;    /* Arg for signal handler */
+       regs->r[2] = (unsigned long)&frame->info;
+       regs->r[3] = (unsigned long)&frame->uc;
+       regs->pc = (unsigned long)ka->sa.sa_handler;
+
+       set_fs(USER_DS);
+
+#if 0
+       printk("SIG deliver (%s:%d): sp=%p pc=%p\n",
+               current->comm, current->pid, frame, regs->pc);
+#endif
+
+       return;
+
+give_sigsegv:
+       force_sigsegv(sig, current);
+}
+
+/*
+ * OK, we're invoking a handler
+ */
+
+static int 
+handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
+             sigset_t *oldset, struct pt_regs *regs, unsigned long saved_r1)
+{
+       /* Are we from a system call? */
+       if (regs->vec >= 0x1000) {
+               /* check for system call restart.. */
+               switch (regs->r[1]) {
+               case -ERESTART_RESTARTBLOCK:
+               case -ERESTARTNOHAND:
+                       regs->r[1] = -EINTR;
+                       break;
+                       
+               case -ERESTARTSYS:
+                       if (!(ka->sa.sa_flags & SA_RESTART)) {
+                               regs->r[1] = -EINTR;
+                               break;
+                       }
+                       /* fallthrough */
+               case -ERESTARTNOINTR:
+                       regs->r[1] = saved_r1;
+                       regs->pc -= 3;
+                       break;
+               }
+       }
+       /* Set up the stack frame */
+       setup_rt_frame(sig, ka, info, oldset, regs);
+
+       if (ka->sa.sa_flags & SA_ONESHOT)
+               ka->sa.sa_handler = SIG_DFL;
+
+       spin_lock_irq(&current->sighand->siglock);
+       sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
+       if (!(ka->sa.sa_flags & SA_NODEFER))
+               sigaddset(&current->blocked,sig);
+       recalc_sigpending();
+       spin_unlock_irq(&current->sighand->siglock);
+       return 0;
+}
+
+/*
+ * Note that 'init' is a special process: it doesn't get signals it doesn't
+ * want to handle. Thus you cannot kill init even with a SIGKILL even by
+ * mistake.
+ */
+static int do_signal(struct pt_regs *regs, unsigned long saved_r1)
+{
+       siginfo_t info;
+       int signr;
+       sigset_t *oldset;
+       struct k_sigaction ka;
+
+       /*
+        * We want the common case to go fast, which
+        * is why we may in certain cases get here from
+        * kernel mode. Just return without doing anything
+        * if so.
+        */
+       if (!user_mode(regs))
+               return 1;
+
+       if (try_to_freeze()) 
+               goto no_signal;
+
+       if (test_thread_flag(TIF_RESTORE_SIGMASK))
+               oldset = &current->saved_sigmask;
+       else
+               oldset = &current->blocked;
+
+       signr = get_signal_to_deliver(&info, &ka, regs, NULL);
+       if (signr > 0) {
+               /* Re-enable any watchpoints before delivering the
+                * signal to user space. The processor register will
+                * have been cleared if the watchpoint triggered
+                * inside the kernel.
+                */
+
+               /* Whee!  Actually deliver the signal.  */
+               handle_signal(signr, &ka, &info, oldset, regs, saved_r1);
+               return 1;
+       }
+
+ no_signal:
+       /* Did we come from a system call? */
+       if (regs->vec >= 0x1000) {
+               /* Restart the system call - no handlers present */
+               if (regs->r[1] == -ERESTARTNOHAND ||
+                   regs->r[1] == -ERESTARTSYS ||
+                   regs->r[1] == -ERESTARTNOINTR) {
+                       regs->r[1] = saved_r1;
+                       regs->pc -= 3;
+               }
+               if (regs->r[1] == -ERESTART_RESTARTBLOCK){
+                       regs->r[1] = saved_r1;
+                       regs->r[8] = __NR_restart_syscall;
+                       regs->pc -=3;
+               }
+       }
+       return 0;
+}
+
+/*
+ * notification of userspace execution resumption
+ * - triggered by current->work.notify_resume
+ */
+void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags,
+                     unsigned long saved_r1)
+{
+       /* deal with pending signal delivery */
+       if (thread_info_flags & _TIF_SIGPENDING)
+               do_signal(regs, saved_r1);
+
+       if (thread_info_flags & _TIF_NOTIFY_RESUME) {
+               clear_thread_flag(TIF_NOTIFY_RESUME);
+               tracehook_notify_resume(regs);
+               if (current->replacement_session_keyring)
+                       key_replace_session_keyring();
+       }
+}
diff --git a/arch/rx/kernel/sys_rx.c b/arch/rx/kernel/sys_rx.c
new file mode 100644 (file)
index 0000000..1087dc7
--- /dev/null
@@ -0,0 +1,83 @@
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/fs.h>
+#include <linux/smp.h>
+#include <linux/sem.h>
+#include <linux/msg.h>
+#include <linux/shm.h>
+#include <linux/stat.h>
+#include <linux/syscalls.h>
+#include <linux/mman.h>
+#include <linux/file.h>
+#include <linux/utsname.h>
+#include <linux/ipc.h>
+#include <linux/linkage.h>
+#include <asm/unistd.h>
+#include <asm/uaccess.h>
+
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, const char *const argv[], const char *const envp[])
+{
+       register long __r15 __asm__ ("r15") = __NR_execve;
+       register long __r1 __asm__ ("r1") = (long) filename;
+       register long __r2 __asm__ ("r2") = (long) argv;
+       register long __r3 __asm__ ("r3") = (long) envp;
+       __asm__ __volatile__ ("int #0x08" : "=r" (__r1)
+                       : "r" (__r15), "r" (__r1), "r" (__r2), "r" (__r3)
+                       : "memory");
+       return __r1;
+}
+
+asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, int op)
+{
+       /* Not affected and always success */
+       return 0;
+}
+
+asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
+                         unsigned long prot, unsigned long flags,
+                         unsigned long fd, unsigned long pgoff)
+{
+       if (pgoff & ~PAGE_MASK)
+               return -EINVAL;
+
+       return do_mmap_pgoff(NULL, addr, len, prot, flags, pgoff >> PAGE_SHIFT);
+}
+
+asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
+                         unsigned long prot, unsigned long flags,
+                         unsigned long fd, unsigned long pgoff)
+{
+       int error = -EBADF;
+       struct file * file = NULL;
+
+       /*
+        * The shift for mmap2 is constant, regardless of PAGE_SIZE
+        * setting.
+        */
+       if (pgoff & ((1 << (PAGE_SHIFT - 12)) - 1))
+               return -EINVAL;
+
+       pgoff >>= PAGE_SHIFT - 12;
+
+       flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
+       if (!(flags & MAP_ANONYMOUS)) {
+               file = fget(fd);
+               if (!file)
+                       goto out;
+       }
+
+       down_write(&current->mm->mmap_sem);
+       error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
+       up_write(&current->mm->mmap_sem);
+
+       if (file)
+               fput(file);
+out:
+       return error;
+}
+
diff --git a/arch/rx/kernel/syscalls.S b/arch/rx/kernel/syscalls.S
new file mode 100644 (file)
index 0000000..0135f18
--- /dev/null
@@ -0,0 +1,364 @@
+#include <linux/sys.h>
+#include <linux/linkage.h>
+
+.globl syscall_table
+       .section .text
+       .align  2
+
+syscall_table:
+       .long   sys_restart_syscall             ;0
+       .long   sys_exit
+       .long   sys_fork
+       .long   sys_read
+       .long   sys_write
+       .long   sys_open
+       .long   sys_close
+       .long   sys_waitpid
+       .long   sys_creat
+       .long   sys_link
+       .long   sys_unlink              ;10
+       .long   sys_execve
+       .long   sys_chdir
+       .long   sys_time
+       .long   sys_mknod
+       .long   sys_chmod
+       .long   sys_lchown
+       .long   sys_ni_syscall
+       .long   sys_ni_syscall
+       .long   sys_lseek
+       .long   sys_getpid              ;20
+       .long   sys_mount
+       .long   sys_umount
+       .long   sys_setuid
+       .long   sys_getuid
+       .long   sys_stime
+       .long   sys_ptrace
+       .long   sys_alarm
+       .long   sys_ni_syscall
+       .long   sys_pause
+       .long   sys_utime               ;30
+       .long   sys_ni_syscall
+       .long   sys_ni_syscall
+       .long   sys_access
+       .long   sys_nice
+       .long   sys_ni_syscall
+       .long   sys_sync
+       .long   sys_kill
+       .long   sys_rename
+       .long   sys_mkdir
+       .long   sys_rmdir               ;40
+       .long   sys_dup
+       .long   sys_pipe
+       .long   sys_times
+       .long   sys_ni_syscall
+       .long   sys_brk
+       .long   sys_setgid
+       .long   sys_getgid
+       .long   sys_signal
+       .long   sys_geteuid
+       .long   sys_getegid             ;50
+       .long   sys_acct
+       .long   sys_umount
+       .long   sys_ni_syscall
+       .long   sys_ioctl
+       .long   sys_fcntl
+       .long   sys_ni_syscall
+       .long   sys_setpgid
+       .long   sys_ni_syscall
+       .long   sys_ni_syscall
+       .long   sys_umask               ;60
+       .long   sys_chroot
+       .long   sys_ustat
+       .long   sys_dup2
+       .long   sys_getppid
+       .long   sys_getpgrp
+       .long   sys_setsid
+       .long   sys_ni_syscall
+       .long   sys_ni_syscall
+       .long   sys_ni_syscall
+       .long   sys_ni_syscall          ;70
+       .long   sys_ni_syscall
+       .long   sys_ni_syscall
+       .long   sys_ni_syscall
+       .long   sys_ni_syscall
+       .long   sys_setrlimit
+       .long   sys_getrlimit
+       .long   sys_getrusage
+       .long   sys_gettimeofday
+       .long   sys_settimeofday
+       .long   sys_getgroups           ;80
+       .long   sys_setgroups
+       .long   sys_ni_syscall
+       .long   sys_symlink
+       .long   sys_ni_syscall
+       .long   sys_readlink
+       .long   sys_uselib
+       .long   sys_swapon
+       .long   sys_reboot
+       .long   sys_ni_syscall
+       .long   sys_mmap                ;90
+       .long   sys_munmap
+       .long   sys_truncate
+       .long   sys_ftruncate
+       .long   sys_fchmod
+       .long   sys_fchown
+       .long   sys_getpriority
+       .long   sys_setpriority
+       .long   sys_ni_syscall
+       .long   sys_statfs
+       .long   sys_fstatfs             ;100
+       .long   sys_ni_syscall
+       .long   sys_socketcall
+       .long   sys_syslog
+       .long   sys_setitimer
+       .long   sys_getitimer
+       .long   sys_newstat
+       .long   sys_newlstat
+       .long   sys_newfstat
+       .long   sys_ni_syscall
+       .long   sys_ni_syscall          ;110
+       .long   sys_vhangup
+       .long   sys_ni_syscall
+       .long   sys_ni_syscall
+       .long   sys_wait4
+       .long   sys_swapoff
+       .long   sys_sysinfo
+       .long   sys_ipc
+       .long   sys_fsync
+       .long   sys_ni_syscall
+       .long   sys_clone               ;120
+       .long   sys_setdomainname
+       .long   sys_ni_syscall
+       .long   sys_cacheflush
+       .long   sys_adjtimex
+       .long   sys_mprotect
+       .long   sys_sigprocmask
+       .long   sys_ni_syscall
+       .long   sys_init_module
+       .long   sys_delete_module
+       .long   sys_ni_syscall          ;130
+       .long   sys_quotactl
+       .long   sys_getpgid
+       .long   sys_fchdir
+       .long   sys_bdflush
+       .long   sys_sysfs
+       .long   sys_personality
+       .long   sys_ni_syscall
+       .long   sys_setfsuid
+       .long   sys_setfsgid
+       .long   sys_llseek              ;140
+       .long   sys_getdents
+       .long   sys_select
+       .long   sys_flock
+       .long   sys_msync
+       .long   sys_readv
+       .long   sys_writev
+       .long   sys_getsid
+       .long   sys_fdatasync
+       .long   sys_sysctl
+       .long   sys_mlock               ;150
+       .long   sys_munlock
+       .long   sys_mlockall
+       .long   sys_munlockall
+       .long   sys_sched_setparam
+       .long   sys_sched_getparam
+       .long   sys_sched_setscheduler
+       .long   sys_sched_getscheduler
+       .long   sys_sched_yield
+       .long   sys_sched_get_priority_max
+       .long   sys_sched_get_priority_min              ;160
+       .long   sys_sched_rr_get_interval
+       .long   sys_nanosleep
+       .long   sys_mremap
+       .long   sys_setresuid
+       .long   sys_getresuid
+       .long   sys_ni_syscall
+       .long   sys_ni_syscall
+       .long   sys_poll
+       .long   sys_ni_syscall
+       .long   sys_setresgid           ;170
+       .long   sys_getresgid
+       .long   sys_prctl
+       .long   sys_rt_sigreturn
+       .long   sys_rt_sigaction
+       .long   sys_rt_sigprocmask
+       .long   sys_rt_sigpending
+       .long   sys_rt_sigtimedwait
+       .long   sys_rt_sigqueueinfo
+       .long   sys_rt_sigsuspend
+       .long   sys_pread64             ;180
+       .long   sys_pwrite64
+       .long   sys_chown
+       .long   sys_getcwd
+       .long   sys_capget
+       .long   sys_capset
+       .long   sys_sigaltstack
+       .long   sys_sendfile
+       .long   sys_ni_syscall
+       .long   sys_ni_syscall
+       .long   sys_vfork               ;190
+       .long   sys_getrlimit
+       .long   sys_mmap2
+       .long   sys_truncate64
+       .long   sys_ftruncate64
+       .long   sys_stat64
+       .long   sys_lstat64
+       .long   sys_fstat64
+       .long   sys_lchown
+       .long   sys_getuid
+       .long   sys_getgid              ;200
+       .long   sys_geteuid
+       .long   sys_getegid
+       .long   sys_setreuid
+       .long   sys_setregid
+       .long   sys_getgroups
+       .long   sys_setgroups
+       .long   sys_fchown
+       .long   sys_setresuid
+       .long   sys_getresuid
+       .long   sys_setresgid           ;210
+       .long   sys_getresgid
+       .long   sys_chown
+       .long   sys_setuid
+       .long   sys_setgid
+       .long   sys_setfsuid
+       .long   sys_setfsgid
+       .long   sys_pivot_root
+       .long   sys_mincore
+       .long   sys_madvise
+; skip madvise1
+       .long   sys_getdents64          ;220
+       .long   sys_fcntl64
+       .long   sys_ni_syscall
+       .long   sys_ni_syscall
+       .long   sys_gettid
+       .long   sys_readahead
+       .long   sys_setxattr
+       .long   sys_lsetxattr
+       .long   sys_fsetxattr
+       .long   sys_getxattr
+       .long   sys_lgetxattr           ;230
+       .long   sys_fgetxattr
+       .long   sys_listxattr
+       .long   sys_llistxattr
+       .long   sys_flistxattr
+       .long   sys_removexattr
+       .long   sys_lremovexattr
+       .long   sys_fremovexattr
+       .long   sys_tkill
+       .long   sys_sendfile64
+       .long   sys_futex               ;240
+       .long   sys_sched_setaffinity
+       .long   sys_sched_getaffinity
+       .long   sys_ni_syscall
+       .long   sys_ni_syscall
+       .long   sys_io_setup
+       .long   sys_io_destroy
+       .long   sys_io_getevents
+       .long   sys_io_submit
+       .long   sys_io_cancel
+       .long   sys_fadvise64           ;250
+       .long   sys_ni_syscall
+       .long   sys_exit_group
+       .long   sys_lookup_dcookie
+       .long   sys_epoll_create
+       .long   sys_epoll_ctl
+       .long   sys_epoll_wait
+       .long   sys_remap_file_pages
+       .long   sys_set_tid_address
+       .long   sys_timer_create
+       .long   sys_timer_settime               ;260
+       .long   sys_timer_gettime
+       .long   sys_timer_getoverrun
+       .long   sys_timer_delete
+       .long   sys_clock_settime
+       .long   sys_clock_gettime
+       .long   sys_clock_getres
+       .long   sys_clock_nanosleep
+       .long   sys_statfs64
+       .long   sys_fstatfs64
+       .long   sys_tgkill              ;270
+       .long   sys_utimes
+       .long   sys_fadvise64_64
+       .long   sys_ni_syscall
+       .long   sys_mbind
+       .long   sys_get_mempolicy
+       .long   sys_set_mempolicy
+       .long   sys_mq_open
+       .long   sys_mq_unlink
+       .long   sys_mq_timedsend
+       .long   sys_mq_timedreceive             ;280
+       .long   sys_mq_notify
+       .long   sys_mq_getsetattr
+       .long   sys_kexec_load
+       .long   sys_waitid
+       .long   sys_ni_syscall
+       .long   sys_add_key
+       .long   sys_request_key
+       .long   sys_keyctl
+       .long   sys_ioprio_set
+       .long   sys_ioprio_get          ;290
+       .long   sys_inotify_init
+       .long   sys_inotify_add_watch
+       .long   sys_inotify_rm_watch
+       .long   sys_migrate_pages
+       .long   sys_openat
+       .long   sys_mkdirat
+       .long   sys_mknodat
+       .long   sys_fchownat
+       .long   sys_futimesat
+       .long   sys_fstatat64           ;300
+       .long   sys_unlinkat
+       .long   sys_renameat
+       .long   sys_linkat
+       .long   sys_symlinkat
+       .long   sys_readlinkat
+       .long   sys_fchmodat
+       .long   sys_faccessat
+       .long   sys_pselect6
+       .long   sys_ppoll
+       .long   sys_unshare             ;310
+       .long   sys_set_robust_list
+       .long   sys_get_robust_list
+       .long   sys_splice
+       .long   sys_sync_file_range
+       .long   sys_tee
+       .long   sys_vmsplice
+       .long   sys_move_pages
+       .long   sys_getcpu
+       .long   sys_epoll_pwait
+       .long   sys_utimensat           ;320
+       .long   sys_signalfd
+       .long   sys_timerfd_create
+       .long   sys_eventfd
+       .long   sys_fallocate
+       .long   sys_timerfd_settime
+       .long   sys_timerfd_gettime
+       .long   sys_signalfd4
+       .long   sys_eventfd2
+       .long   sys_epoll_create1
+       .long   sys_dup3                ;330
+       .long   sys_pipe2
+       .long   sys_inotify_init1
+       .long   sys_preadv
+       .long   sys_pwritev
+       .long   sys_rt_tgsigqueueinfo
+       .long   sys_perf_event_open
+
+sys_vfork:
+       add     #12,r0,r1
+       bra     rx_vfork
+
+sys_clone:
+       add     #12,r0,r1
+       bra     rx_clone
+
+sys_sigaltstack:
+       add     #12,r0,r3
+       bra     rx_sigaltstack
+
+sys_rt_sigreturn:      
+       add     #12,r0,r1
+       bra     rx_rt_sigreturn
+
+       .end
diff --git a/arch/rx/kernel/time.c b/arch/rx/kernel/time.c
new file mode 100644 (file)
index 0000000..fdd2261
--- /dev/null
@@ -0,0 +1,40 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/profile.h>
+#include <linux/timex.h>
+#include <linux/sched.h>
+#include <linux/clockchips.h>
+#include <linux/platform_device.h>
+#include <linux/rtc.h>
+#include <asm/clock.h>
+
+void __init rx_clk_init(void (*tick)(void));
+
+/* common tick interrupt handler */
+void rx_timer_tick(void)
+{
+       if (current->pid)
+               profile_tick(CPU_PROFILING);
+       update_process_times(user_mode(get_irq_regs()));
+       xtime_update(1);
+       update_process_times(user_mode(get_irq_regs()));
+}
+
+/* dummy RTC access */
+void read_persistent_clock(struct timespec *tv)
+{
+       tv->tv_sec = mktime(2000, 1, 1, 0, 0, 0);
+       tv->tv_nsec = 0;
+}
+
+int update_persistent_clock(struct timespec now)
+{
+       return 0;
+}
+
+void __init time_init(void)
+{
+       rx_clk_init(rx_timer_tick);
+       clk_init();
+}
diff --git a/arch/rx/kernel/timer/Makefile b/arch/rx/kernel/timer/Makefile
new file mode 100644 (file)
index 0000000..5299e38
--- /dev/null
@@ -0,0 +1 @@
+obj-$(CONFIG_RX_CMT) = cmt.o
\ No newline at end of file
diff --git a/arch/rx/kernel/timer/cmt.c b/arch/rx/kernel/timer/cmt.c
new file mode 100644 (file)
index 0000000..1e6de0b
--- /dev/null
@@ -0,0 +1,69 @@
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/param.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/profile.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+
+static const u32 base[] = {0x00088002, 0x00088008, 0x00088012, 0x00088018};
+static const u32 str[] = {0x00088000, 0x00088010};
+static const int irqno[] = {28, 29, 30, 31};
+
+enum {CMCR = 0, CMCNT = 2, CMCOR = 4};
+
+/*
+ * timer_interrupt() needs to keep up the real-time clock,
+ * as well as call the "do_timer()" routine every clocktick
+ */
+
+static void (*tick_handler)(void);
+
+static irqreturn_t timer_interrupt(int irq, void *dev_id)
+{
+       tick_handler();
+       return IRQ_HANDLED;
+}
+
+static struct irqaction cmt_irq = {
+       .name           = "rx-cmt",
+       .handler        = timer_interrupt,
+       .flags          = IRQF_TIMER,
+};
+
+static const int __initdata divide_rate[] = {8, 32, 128, 512};
+
+void __init rx_clk_init(void (*tick)(void))
+{
+       unsigned int div;
+       unsigned int cnt;
+       unsigned long p_freq;
+       u16 str_r;
+
+       tick_handler = tick;
+
+       p_freq = CONFIG_INPUT_CLOCK_FREQ * CONFIG_PCLK_MULT;
+       for (div = 0; div < 4; div++) {
+               cnt = p_freq / HZ / divide_rate[div];
+               if (cnt < 0x00010000)
+                       break;
+       }
+
+       /* stop all timer (it enable u-boot)*/
+       __raw_writew(0, (void __iomem *)str[0]);
+       __raw_writew(0, (void __iomem *)str[1]);
+
+       /* initalize timer */
+       __raw_writew(0x0000, (void __iomem *)(base[CONFIG_RX_CMT_CH] + CMCNT));
+       __raw_writew(cnt, (void __iomem *)(base[CONFIG_RX_CMT_CH] + CMCOR));
+       __raw_writew(0x00c0 | div, (void __iomem *)(base[CONFIG_RX_CMT_CH] + CMCR));
+       setup_irq(irqno[CONFIG_RX_CMT_CH], &cmt_irq);
+       str_r = __raw_readw((void __iomem *)str[CONFIG_RX_CMT_CH/2]);
+       str_r |= 1 << (CONFIG_RX_CMT_CH % 2);
+       __raw_writew(str_r, (void __iomem *)str[CONFIG_RX_CMT_CH/2]);
+}
diff --git a/arch/rx/kernel/traps.c b/arch/rx/kernel/traps.c
new file mode 100644 (file)
index 0000000..1fe1d7d
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+ * arch/rx/kernel/traps.c
+ * handles hardware traps and faults.
+ * 
+ * Copyright (C) 2009 Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/ptrace.h>
+#include <linux/hardirq.h>
+#include <linux/irqflags.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+#include <linux/module.h>
+#include <linux/kallsyms.h>
+#include <linux/io.h>
+#include <linux/bug.h>
+#include <linux/limits.h>
+#include <linux/proc_fs.h>
+#include <linux/sysfs.h>
+#include <linux/kdebug.h>
+#include <asm/system.h>
+#include <asm/uaccess.h>
+
+unsigned long __nmi_count = 0;
+
+void do_privileged_op(struct pt_regs *regs);
+void do_eaccess(struct pt_regs *regs);
+void do_invalid_op(struct pt_regs *regs);
+void do_fpuerror(struct pt_regs *regs);
+void do_nmi(struct pt_regs *regs);
+void do_breakpoint(struct pt_regs *regs);
+void do_buserr(struct pt_regs *regs);
+
+void (*exception_table[32 + 20])(struct pt_regs *regs);
+struct installed_exception {
+       int no;
+       void (*handler)(struct pt_regs *regs);
+} exceptions_list[] __initdata = {
+       {20, do_privileged_op},
+       {21, do_eaccess},
+       {23, do_invalid_op},
+       {25, do_fpuerror},
+       {30, do_nmi},
+       {32, do_breakpoint},
+       {48, do_buserr},
+};
+
+static void do_trap(int signr, char *str, struct pt_regs *regs, 
+                   siginfo_t *info)
+{
+       struct task_struct *tsk = current;
+
+       if (user_mode(regs)) {
+               if (info)
+                       force_sig_info(signr, info, tsk);
+               else
+                       force_sig(signr, tsk);
+       } else {
+               die(str, regs);
+       }
+       return;
+}
+
+static inline void conditional_sti(struct pt_regs *regs)
+{
+       if (regs->psw & 0x00010000)
+               local_irq_enable();
+}
+
+#define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr)                \
+asmlinkage void do_##name(struct pt_regs *regs)                        \
+{                                                                      \
+       siginfo_t info;                                                 \
+       info.si_signo = signr;                                          \
+       info.si_errno = 0;                                              \
+       info.si_code = sicode;                                          \
+       info.si_addr = (void __user *)siaddr;                           \
+       if (notify_die(DIE_TRAP, str, regs, 0, trapnr, signr)           \
+                                                       == NOTIFY_STOP) \
+               return;                                                 \
+       conditional_sti(regs);                                          \
+       do_trap(signr, str, regs, &info);                               \
+}
+
+DO_ERROR_INFO(20, SIGILL, "privileged exception", privileged_op, ILL_PRVOPC, regs->pc)
+DO_ERROR_INFO(21, SIGSEGV, "access exception", eaccess, SEGV_ACCERR, regs->pc)
+DO_ERROR_INFO(23, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPC, regs->pc)
+DO_ERROR_INFO(48, SIGBUS, "BUS error", buserr, BUS_ADRERR, regs->pc)
+
+static inline int fpsw_decode(void)
+{
+       static const int vector_fpsw[] = { FPE_FLTINV, FPE_FLTOVF, FPE_FLTDIV, 
+                                          FPE_FLTUND, FPE_FLTRES};
+       int bit;
+       unsigned int fpsw;
+       __asm__ volatile("mvfc fpsw,%0":"=r"(fpsw));
+       for (bit = 26; bit < 32; bit++)
+               if (fpsw & (1 << bit)) {
+                       fpsw &= ~(1 << bit);
+                       __asm__ volatile("mvtc %0,fpsw"::"r"(fpsw));
+                       return vector_fpsw[bit - 26];
+               }
+       return 0;
+}
+
+asmlinkage void do_fpuerror(struct pt_regs *regs)
+{
+       siginfo_t info;
+       info.si_signo = fpsw_decode();
+       info.si_errno = 0;
+       info.si_addr = (void __user *)regs->pc;
+       if (notify_die(DIE_TRAP, "Floating point exceprion", 
+                      regs, 0, 25, SIGFPE) == NOTIFY_STOP)
+               return;
+       conditional_sti(regs);
+       do_trap(SIGFPE, "Floating point exceprion", regs, &info);
+}
+
+asmlinkage void do_nmi(struct pt_regs *regs)
+{
+       nmi_enter();
+
+       __nmi_count++;
+       notify_die(DIE_NMI, "nmi", regs, 0, 31, SIGINT);
+
+       nmi_exit();
+}
+
+asmlinkage void do_breakpoint(struct pt_regs *regs)
+{
+       /* TBD */
+}
+
+static void dump(struct pt_regs *regs)
+{
+       unsigned long   *sp;
+       unsigned char   *tp;
+       int             i;
+
+       printk("\nCURRENT PROCESS:\n\n");
+       printk("COMM=%s PID=%d\n", current->comm, current->pid);
+       if (current->mm) {
+               printk("TEXT=%08x-%08x DATA=%08x-%08x BSS=%08x-%08x\n",
+                       (int) current->mm->start_code,
+                       (int) current->mm->end_code,
+                       (int) current->mm->start_data,
+                       (int) current->mm->end_data,
+                       (int) current->mm->end_data,
+                       (int) current->mm->brk);
+               printk("USER-STACK=%08x  KERNEL-STACK=%08lx\n\n",
+                       (int) current->mm->start_stack,
+                       (int) PAGE_SIZE+(unsigned long)current);
+       }
+
+       show_regs(regs);
+       printk("\nCODE:");
+       tp = ((unsigned char *) regs->pc) - 0x20;
+       for (sp = (unsigned long *) tp, i = 0; (i < 0x40);  i += 4) {
+               if ((i % 0x10) == 0)
+                       printk("\n%08x: ", (int) (tp + i));
+               printk("%08x ", (int) *sp++);
+       }
+       printk("\n");
+
+       printk("\nKERNEL STACK:");
+       tp = ((unsigned char *) regs) - 0x40;
+       for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) {
+               if ((i % 0x10) == 0)
+                       printk("\n%08x: ", (int) (tp + i));
+               printk("%08x ", (int) *sp++);
+       }
+       printk("\n");
+       if (STACK_MAGIC != *(unsigned long *)((unsigned long)current+PAGE_SIZE))
+                printk("(Possibly corrupted stack page??)\n");
+
+       printk("\n\n");
+}
+
+static DEFINE_SPINLOCK(die_lock);
+
+void die(const char *str, struct pt_regs *regs)
+{
+       static int diecount;
+
+       oops_enter();
+
+       console_verbose();
+       spin_lock_irq(&die_lock);
+       report_bug(regs->pc, regs);
+       printk(KERN_EMERG "%s: [#%d] ", str,  ++diecount);
+       dump(regs);
+
+       spin_unlock_irq(&die_lock);
+       do_exit(SIGSEGV);
+}
+
+extern char _stext, _etext;
+#define check_kernel_text(addr) \
+        ((addr >= (unsigned long)(&_stext)) && \
+         (addr <  (unsigned long)(&_etext))) 
+
+static int kstack_depth_to_print = 24;
+
+void show_stack(struct task_struct *task, unsigned long *esp)
+{
+       unsigned long *stack,  addr;
+       int i;
+
+       if (esp == NULL)
+               esp = (unsigned long *) &esp;
+
+       stack = esp;
+
+       printk("Stack from %08lx:", (unsigned long)stack);
+       for (i = 0; i < kstack_depth_to_print; i++) {
+               if (((unsigned long)stack & (THREAD_SIZE - 1)) == 0)
+                       break;
+               if (i % 8 == 0)
+                       printk("\n       ");
+               printk(" %08lx", *stack++);
+       }
+
+       printk("\nCall Trace:");
+       i = 0;
+       stack = esp;
+       while (((unsigned long)stack & (THREAD_SIZE - 1)) != 0) {
+               addr = *stack++;
+               /*
+                * If the address is either in the text segment of the
+                * kernel, or in the region which contains vmalloc'ed
+                * memory, it *may* be the address of a calling
+                * routine; if so, print it so that someone tracing
+                * down the cause of the crash will be able to figure
+                * out the call path that was taken.
+                */
+               if (check_kernel_text(addr)) {
+                       if (i % 4 == 0)
+                               printk("\n       ");
+                       printk(" [<%08lx>]", addr);
+                       i++;
+               }
+       }
+       printk("\n");
+}
+
+void show_trace_task(struct task_struct *tsk)
+{
+       show_stack(tsk,(unsigned long *)tsk->thread.esp0);
+}
+
+void dump_stack(void)
+{
+       show_stack(NULL,NULL);
+}
+
+EXPORT_SYMBOL(dump_stack);
+
+asmlinkage void unhandled_exception(struct pt_regs *regs, unsigned int ex)
+{
+       if (!user_mode(regs))
+               die("exception", regs);
+}
+
+
+
+#define IER (0x00087200)
+
+void __init trap_init(void)
+{
+       u8 ier;
+       int i;
+       struct installed_exception *e = exceptions_list;
+       /* BUS error enabled */
+       ier = __raw_readb((void __iomem*)(IER + 2));
+       ier |= 0x01;
+       __raw_writeb(ier, (void __iomem*)(IER + 2));
+       /* exception handler install */
+       for (i = 0; i < sizeof(exceptions_list) / sizeof(*e); i++, e++)
+               exception_table[e->no] = e->handler;
+}
+
diff --git a/arch/rx/kernel/vmlinux.lds.S b/arch/rx/kernel/vmlinux.lds.S
new file mode 100644 (file)
index 0000000..4cf2213
--- /dev/null
@@ -0,0 +1,91 @@
+#define        LOAD_OFFSET 0
+#include <asm-generic/vmlinux.lds.h>
+#include <asm/page.h>
+#include <asm/thread_info.h>
+
+#define EXCEPTION_FIXED 0xffffff80
+
+#if defined(CONFIG_ROMKERNEL)
+ROMTOP = CONFIG_ROMSTART;
+#endif
+RAMTOP = CONFIG_RAMSTART;
+RAMSIZE = CONFIG_RAMEND - CONFIG_RAMSTART;
+
+#if defined(CONFIG_RX_GDB_SIM)
+/*INPUT(romfs.o)*/
+#endif
+
+jiffies = jiffies_64;
+
+ENTRY(startup)
+
+SECTIONS
+{
+#if defined(CONFIG_ROMKERNEL)
+       . = ROMTOP;
+       _text = .;
+       _stext = . ;
+#else
+       . = RAMTOP + 0x1000;
+       _text = .;
+       _stext = . ;
+#endif
+        .text :
+       {
+       HEAD_TEXT
+       TEXT_TEXT
+       SCHED_TEXT
+       LOCK_TEXT
+       _etext = . ;
+       }
+       EXCEPTION_TABLE(16)
+#if defined(CONFIG_ROMKERNEL)
+       INIT_TEXT_SECTION(PAGE_SIZE)
+       ROEND = .; 
+       __data_romtop = .;
+       . = RAMTOP;
+       _sdata = .;
+       RODATA
+       RW_DATA_SECTION(0, PAGE_SIZE, THREAD_SIZE)
+       _edata = .;
+#else
+       _sdata = .;
+       RODATA
+       RW_DATA_SECTION(0, PAGE_SIZE, THREAD_SIZE)
+       _edata = .;
+#endif
+
+       . = ALIGN(PAGE_SIZE);           /* Init code and data */
+#if defined(CONFIG_RAMKERNEL)
+       __init_begin = .;
+       INIT_TEXT_SECTION(PAGE_SIZE)
+#else
+       __init_begin = .;
+#endif
+       INIT_DATA_SECTION(16)
+       .rx.exception : {
+       ram_exception_handler = .;
+       *(.rx.exception);
+       }
+       sizeof_ram_exception_handler = SIZEOF(.rx.exception);
+       __init_end = .;
+       _sbss = .;
+       BSS_SECTION(0, PAGE_SIZE, 4)
+       _ebss = .;              /* uClinux MTD sucks */
+       _end = . ;
+       _ramstart = .;
+        .romfs :       
+       {
+               *(.romfs*)
+       }
+       . = RAMTOP + RAMSIZE;
+       _ramend = .;
+#if defined(CONFIG_ROMKERNEL)
+       . = EXCEPTION_FIXED;
+       .vector :
+       {
+               *(.vector*)
+       }
+#endif
+       DISCARDS
+}
diff --git a/arch/rx/lib/Makefile b/arch/rx/lib/Makefile
new file mode 100644 (file)
index 0000000..2d65664
--- /dev/null
@@ -0,0 +1 @@
+obj-y=delay.o
diff --git a/arch/rx/lib/delay.c b/arch/rx/lib/delay.c
new file mode 100644 (file)
index 0000000..9ded581
--- /dev/null
@@ -0,0 +1,32 @@
+#include <linux/delay.h>
+
+void __delay(unsigned long loops)
+{
+       if (loops == 0)
+               return;
+       __asm__ volatile("1: sub #1,%0\n\t"
+                        "bne 1b"
+                        :"=r"(loops)
+                        :"0"(loops));
+}
+
+void __const_udelay(unsigned long xloops)
+{
+       __asm__("mov.l %1,r2\n\t"
+               "emul %2,r2\n\t"
+               "mov.l r3,%0"
+               :"=r"(xloops)
+               :"0"(xloops),"r"(loops_per_jiffy)
+               :"r2","r3");
+       __delay(xloops);
+}
+
+void __udelay(unsigned long usecs)
+{
+       __const_udelay(usecs * 0x000010c6);  /* 2**32 / 1000000 */
+}
+
+void __ndelay(unsigned long nsecs)
+{
+       __const_udelay(nsecs * 0x00000005);
+}
diff --git a/arch/rx/mm/Makefile b/arch/rx/mm/Makefile
new file mode 100644 (file)
index 0000000..c4721c8
--- /dev/null
@@ -0,0 +1,2 @@
+obj-y   := init.o fault.o
+
diff --git a/arch/rx/mm/fault.c b/arch/rx/mm/fault.c
new file mode 100644 (file)
index 0000000..93e2967
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * arch/rx/mm/fault.c
+ */
+
+#include <linux/mman.h>
+#include <linux/mm.h>
+#include <linux/kernel.h>
+#include <linux/ptrace.h>
+
+#include <asm/system.h>
+#include <asm/pgtable.h>
+#include <asm/kdebug.h>
+
+asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address)
+{
+       if ((unsigned long) address < PAGE_SIZE) {
+               printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
+       } else
+               printk(KERN_ALERT "Unable to handle kernel access");
+       printk(" at virtual address %08lx\n",address);
+       if (!user_mode(regs))
+               die("Oops", regs);
+       do_exit(SIGKILL);
+
+       return 1;
+}
+
diff --git a/arch/rx/mm/init.c b/arch/rx/mm/init.c
new file mode 100644 (file)
index 0000000..3bace72
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ *  arch/rx/mm/init.c
+ * Copyright (C) 2009 Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *  
+ */
+
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/ptrace.h>
+#include <linux/mman.h>
+#include <linux/mm.h>
+#include <linux/swap.h>
+#include <linux/init.h>
+#include <linux/highmem.h>
+#include <linux/pagemap.h>
+#include <linux/bootmem.h>
+#include <linux/slab.h>
+#include <linux/dma-mapping.h>
+
+#include <asm/setup.h>
+#include <asm/segment.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/system.h>
+
+#undef DEBUG
+
+/*
+ * BAD_PAGE is the page that is used for page faults when linux
+ * is out-of-memory. Older versions of linux just did a
+ * do_exit(), but using this instead means there is less risk
+ * for a process dying in kernel mode, possibly leaving a inode
+ * unused etc..
+ *
+ * BAD_PAGETABLE is the accompanying page-table: it is initialized
+ * to point to BAD_PAGE entries.
+ *
+ * ZERO_PAGE is a special page that is used for zero-initialized
+ * data and COW.
+ */
+static unsigned long empty_bad_page_table;
+
+static unsigned long empty_bad_page;
+
+unsigned long empty_zero_page;
+
+extern unsigned long rom_length;
+
+extern unsigned long memory_start;
+extern unsigned long memory_end;
+
+/*
+ * paging_init() continues the virtual memory environment setup which
+ * was begun by the code in arch/head.S.
+ * The parameters are pointers to where to stick the starting and ending
+ * addresses of available kernel virtual memory.
+ */
+void __init paging_init(void)
+{
+       /*
+        * Make sure start_mem is page aligned,  otherwise bootmem and
+        * page_alloc get different views og the world.
+        */
+#ifdef DEBUG
+       unsigned long start_mem = PAGE_ALIGN(memory_start);
+#endif
+       unsigned long end_mem   = memory_end & PAGE_MASK;
+
+#ifdef DEBUG
+       printk ("start_mem is %#lx\nvirtual_end is %#lx\n",
+               start_mem, end_mem);
+#endif
+
+       /*
+        * Initialize the bad page table and bad page to point
+        * to a couple of allocated pages.
+        */
+       empty_bad_page_table = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
+       empty_bad_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
+       empty_zero_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
+       memset((void *)empty_zero_page, 0, PAGE_SIZE);
+
+       /*
+        * Set up SFC/DFC registers (user data space).
+        */
+       set_fs (USER_DS);
+
+#ifdef DEBUG
+       printk ("before free_area_init\n");
+
+       printk ("free_area_init -> start_mem is %#lx\nvirtual_end is %#lx\n",
+               start_mem, end_mem);
+#endif
+
+       {
+               unsigned long zones_size[MAX_NR_ZONES] = {0, };
+
+               zones_size[ZONE_NORMAL]  = (end_mem - PAGE_OFFSET) >> PAGE_SHIFT;
+#ifdef CONFIG_HIGHMEM
+               zones_size[ZONE_HIGHMEM] = 0;
+#endif
+               free_area_init(zones_size);
+       }
+}
+
+void __init mem_init(void)
+{
+       unsigned long tmp;
+       extern char _etext, _stext, _sdata, _ebss, __init_begin, __init_end;
+       extern unsigned long  _ramend, _ramstart;
+       unsigned long len;
+       unsigned long end_mem = (unsigned long)&_ramend;
+       unsigned int codek, datak, initk;
+
+#ifdef DEBUG
+       printk(KERN_DEBUG "Mem_init: start=%lx, end=%lx\n", 
+              (unsigned long)&_ram_start, end_mem);
+#endif
+#ifdef CONFIG_ROMKERNEL
+       len = &_ramend - &_ramstart;
+#else
+       len = memory_end - memory_start;
+#endif
+       end_mem &= PAGE_MASK;
+       high_memory = (void *) end_mem;
+
+       max_mapnr = num_physpages = len >> PAGE_SHIFT;
+
+       totalram_pages = free_all_bootmem();
+
+       codek = (&_etext - &_stext) >> 10;
+       datak = (&_ebss - &_sdata) >> 10;
+       initk = (&__init_begin - &__init_end) >> 10;
+
+       tmp = nr_free_pages() << PAGE_SHIFT;
+       printk(KERN_INFO "Memory available: %luk/%luk RAM, %luk/%luk ROM (%dk kernel code, %dk data)\n",
+              tmp >> 10,
+              len >> 10,
+              (rom_length > 0) ? ((rom_length >> 10) - codek) : 0,
+              rom_length >> 10,
+              codek,
+              datak
+              );
+       no_iommu_init();
+}
+
+
+#ifdef CONFIG_BLK_DEV_INITRD
+void free_initrd_mem(unsigned long start, unsigned long end)
+{
+       int pages = 0;
+       for (; start < end; start += PAGE_SIZE) {
+               ClearPageReserved(virt_to_page(start));
+               init_page_count(virt_to_page(start));
+               free_page(start);
+               totalram_pages++;
+               pages++;
+       }
+       printk ("Freeing initrd memory: %dk freed\n", pages);
+}
+#endif
+
+void free_initmem(void)
+{
+       unsigned long addr;
+       extern char __init_begin, __init_end;
+
+       addr = PAGE_ALIGN((unsigned long)(&__init_begin));
+       /* next to check that the page we free is not a partial page */
+       for (; addr + PAGE_SIZE < (unsigned long)(&__init_end); addr +=PAGE_SIZE) {
+               ClearPageReserved(virt_to_page(addr));
+               init_page_count(virt_to_page(addr));
+               free_page(addr);
+               totalram_pages++;
+       }
+       printk(KERN_INFO "Freeing unused kernel memory: %ldk freed (0x%x - 0x%x)\n",
+                       (addr - PAGE_ALIGN((long) &__init_begin)) >> 10,
+                       (int)(PAGE_ALIGN((unsigned long)(&__init_begin))),
+                       (int)(addr - PAGE_SIZE));
+}
+
diff --git a/arch/rx/mm/memory.c b/arch/rx/mm/memory.c
new file mode 100644 (file)
index 0000000..ccd6ade
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ *  linux/arch/h8300/mm/memory.c
+ *
+ *  Copyright (C) 2002  Yoshinori Sato <ysato@users.sourceforge.jp>,
+ *
+ *  Based on:
+ *
+ *  linux/arch/m68knommu/mm/memory.c
+ *
+ *  Copyright (C) 1998  Kenneth Albanowski <kjahds@kjahds.com>,
+ *  Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
+ *
+ *  Based on:
+ *
+ *  linux/arch/m68k/mm/memory.c
+ *
+ *  Copyright (C) 1995  Hamish Macdonald
+ */
+
+#include <linux/mm.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/slab.h>
+
+#include <asm/setup.h>
+#include <asm/segment.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/system.h>
+#include <asm/traps.h>
+#include <asm/io.h>
+
+void cache_clear (unsigned long paddr, int len)
+{
+}
+
+
+void cache_push (unsigned long paddr, int len)
+{
+}
+
+void cache_push_v (unsigned long vaddr, int len)
+{
+}
+
+/* Map some physical address range into the kernel address space. The
+ * code is copied and adapted from map_chunk().
+ */
+
+unsigned long kernel_map(unsigned long paddr, unsigned long size,
+                        int nocacheflag, unsigned long *memavailp )
+{
+       return paddr;
+}
+
index fc543ac..0e21bd4 100644 (file)
@@ -653,7 +653,7 @@ config SERIAL_IP22_ZILOG_CONSOLE
 
 config SERIAL_SH_SCI
        tristate "SuperH SCI(F) serial port support"
-       depends on SUPERH || ARCH_RENESAS || H8300 || COMPILE_TEST
+       depends on SUPERH || ARCH_SHMOBILE || H8300 || RX || COMPILE_TEST
        select SERIAL_CORE
        select SERIAL_MCTRL_GPIO if GPIOLIB