Skip to contentSkip to conversation

Re-introduce h8300 architecture

PATCH Superseded Yoshinori Sato 4 participants 26 messages Apr 20, 2015 – Apr 21, 2015

Subsystems (11)

v8 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

v8 cover Re-introduce h8300 architecture

Hello.
I will re-introducing h8300.

Changes for v8
- rebase to v4.0

Changes for v7
- Add MAINTAINERS

Changes for v6
- rebase to v4.0-rc3
- remove unused headers
- optimized atomic operation
- System.map cleanup

Changes for v5
- Signal handling fix
- LD script cleanup

Changes for v4
- Remove signal mapping
- Organize Kconfig
- Coding style fix

Changes for v3
- Fix clone
- Add dma functions
- Add missing library
- Fix various errors

Changes for v2
- Use Common Clock Framework
- Use common unistd.h
- Use common ptrace function
- clocksource driver move to drivers/clocksource
- some cleanup

Changes for latest relase (v3.12)
- standard ELF toolchain (h8300-linux)
- use common driver support
- exception handling fix
- too many cleanup

git repository
git://git.sourceforge.jp/gitroot/uclinux-h8/linux.git h8300

Yoshinori Sato (17):
h8300: Assembly headers.
h8300: UAPI headers
h8300: Exception and Interrupt handling
h8300: kernel booting
h8300: process and signals
h8300: CPU depend helpers
h8300: miscellaneous functions
h8300: Memory management
h8300: library functions
h8300: Build scripts
h8300: clock driver
h8300: clocksource
h8300: configs
serial: Add H8300.
Add ELF machine
mksysmap: Add h8300 local symbol pattern
Add H8/300 entry

 CREDITS                                    |   5 -
 MAINTAINERS                                |  11 +
 arch/h8300/Kconfig                         |  73 +++++
 arch/h8300/Kconfig.cpu                     | 111 ++++++++
 arch/h8300/Makefile                        |  45 ++++
 arch/h8300/boot/Makefile                   |  26 ++
 arch/h8300/boot/compressed/Makefile        |  37 +++
 arch/h8300/boot/compressed/head.S          |  48 ++++
 arch/h8300/boot/compressed/misc.c          |  74 ++++++
 arch/h8300/boot/compressed/vmlinux.lds     |  32 +++
 arch/h8300/boot/compressed/vmlinux.scr     |   9 +
 arch/h8300/configs/h8300h-sim_defconfig    |  53 ++++
 arch/h8300/configs/h8s-sim_defconfig       |  53 ++++
 arch/h8300/include/asm/Kbuild              |  66 +++++
 arch/h8300/include/asm/asm-offsets.h       |   1 +
 arch/h8300/include/asm/atomic.h            | 159 +++++++++++
 arch/h8300/include/asm/bitops.h            | 185 +++++++++++++
 arch/h8300/include/asm/bootparams.h        |  17 ++
 arch/h8300/include/asm/bug.h               |  12 +
 arch/h8300/include/asm/cache.h             |  11 +
 arch/h8300/include/asm/checksum.h          | 102 +++++++
 arch/h8300/include/asm/cmpxchg.h           |  65 +++++
 arch/h8300/include/asm/delay.h             |  38 +++
 arch/h8300/include/asm/device.h            |   6 +
 arch/h8300/include/asm/dma-mapping.h       | 124 +++++++++
 arch/h8300/include/asm/elf.h               | 101 +++++++
 arch/h8300/include/asm/emergency-restart.h |   6 +
 arch/h8300/include/asm/flat.h              |  27 ++
 arch/h8300/include/asm/io.h                | 314 ++++++++++++++++++++++
 arch/h8300/include/asm/irq.h               |  26 ++
 arch/h8300/include/asm/irqflags.h          |  96 +++++++
 arch/h8300/include/asm/mc146818rtc.h       |   9 +
 arch/h8300/include/asm/mutex.h             |   9 +
 arch/h8300/include/asm/page.h              |  18 ++
 arch/h8300/include/asm/page_offset.h       |   2 +
 arch/h8300/include/asm/pci.h               |  19 ++
 arch/h8300/include/asm/pgtable.h           |  49 ++++
 arch/h8300/include/asm/processor.h         | 144 ++++++++++
 arch/h8300/include/asm/ptrace.h            |  36 +++
 arch/h8300/include/asm/segment.h           |  49 ++++
 arch/h8300/include/asm/sh_bios.h           |   4 +
 arch/h8300/include/asm/signal.h            |  22 ++
 arch/h8300/include/asm/smp.h               |   1 +
 arch/h8300/include/asm/spinlock.h          |   6 +
 arch/h8300/include/asm/string.h            |  17 ++
 arch/h8300/include/asm/switch_to.h         |  51 ++++
 arch/h8300/include/asm/syscall.h           |  56 ++++
 arch/h8300/include/asm/thread_info.h       | 119 +++++++++
 arch/h8300/include/asm/timer.h             |  31 +++
 arch/h8300/include/asm/tlb.h               |   8 +
 arch/h8300/include/asm/topology.h          |   6 +
 arch/h8300/include/asm/traps.h             |  41 +++
 arch/h8300/include/asm/uaccess.h           | 136 ++++++++++
 arch/h8300/include/asm/unaligned.h         |  11 +
 arch/h8300/include/asm/user.h              |  74 ++++++
 arch/h8300/include/uapi/asm/Kbuild         |  29 ++
 arch/h8300/include/uapi/asm/auxvec.h       |   4 +
 arch/h8300/include/uapi/asm/byteorder.h    |   6 +
 arch/h8300/include/uapi/asm/ptrace.h       |  42 +++
 arch/h8300/include/uapi/asm/sigcontext.h   |  18 ++
 arch/h8300/include/uapi/asm/signal.h       | 115 ++++++++
 arch/h8300/include/uapi/asm/swab.h         |   1 +
 arch/h8300/include/uapi/asm/unistd.h       |   3 +
 arch/h8300/kernel/Makefile                 |  16 ++
 arch/h8300/kernel/asm-offsets.c            |  60 +++++
 arch/h8300/kernel/cpu/Makefile             |   4 +
 arch/h8300/kernel/cpu/h83069/Makefile      |   1 +
 arch/h8300/kernel/cpu/h83069/setup.c       | 202 ++++++++++++++
 arch/h8300/kernel/cpu/h8s2678/Makefile     |   1 +
 arch/h8300/kernel/cpu/h8s2678/setup.c      | 161 +++++++++++
 arch/h8300/kernel/cpu/irq_h.c              |  62 +++++
 arch/h8300/kernel/cpu/irq_s.c              |  70 +++++
 arch/h8300/kernel/cpu/ptrace_h.c           | 256 ++++++++++++++++++
 arch/h8300/kernel/cpu/ptrace_s.c           |  44 +++
 arch/h8300/kernel/dma.c                    |  95 +++++++
 arch/h8300/kernel/entry.S                  | 414 +++++++++++++++++++++++++++++
 arch/h8300/kernel/h8300_ksyms.c            |  34 +++
 arch/h8300/kernel/head_ram.S               |  60 +++++
 arch/h8300/kernel/head_rom.S               | 108 ++++++++
 arch/h8300/kernel/irq.c                    | 100 +++++++
 arch/h8300/kernel/module.c                 |  70 +++++
 arch/h8300/kernel/process.c                | 171 ++++++++++++
 arch/h8300/kernel/ptrace.c                 | 203 ++++++++++++++
 arch/h8300/kernel/setup.c                  | 174 ++++++++++++
 arch/h8300/kernel/signal.c                 | 289 ++++++++++++++++++++
 arch/h8300/kernel/sim-console.c            |  79 ++++++
 arch/h8300/kernel/syscalls.c               |  14 +
 arch/h8300/kernel/traps.c                  | 161 +++++++++++
 arch/h8300/kernel/vmlinux.lds.S            |  67 +++++
 arch/h8300/lib/Makefile                    |   7 +
 arch/h8300/lib/abs.S                       |  20 ++
 arch/h8300/lib/ashldi3.c                   |  24 ++
 arch/h8300/lib/ashrdi3.c                   |  24 ++
 arch/h8300/lib/checksum.c                  | 167 ++++++++++++
 arch/h8300/lib/libgcc.h                    |  77 ++++++
 arch/h8300/lib/lshrdi3.c                   |  23 ++
 arch/h8300/lib/memcpy.S                    |  85 ++++++
 arch/h8300/lib/memset.S                    |  69 +++++
 arch/h8300/lib/moddivsi3.S                 |  72 +++++
 arch/h8300/lib/modsi3.S                    |  72 +++++
 arch/h8300/lib/muldi3.c                    |  44 +++
 arch/h8300/lib/mulsi3.S                    |  38 +++
 arch/h8300/lib/strncpy.S                   |  34 +++
 arch/h8300/lib/ucmpdi2.c                   |  17 ++
 arch/h8300/lib/udivsi3.S                   |  76 ++++++
 arch/h8300/mm/Makefile                     |   5 +
 arch/h8300/mm/fault.c                      |  57 ++++
 arch/h8300/mm/init.c                       | 133 +++++++++
 arch/h8300/mm/kmap.c                       |  61 +++++
 arch/h8300/mm/memory.c                     |  53 ++++
 drivers/clk/Makefile                       |   1 +
 drivers/clk/h8300/Makefile                 |   2 +
 drivers/clk/h8300/clk-h83069.c             |  80 ++++++
 drivers/clk/h8300/clk-h8s2678.c            | 171 ++++++++++++
 drivers/clocksource/Kconfig                |   6 +
 drivers/clocksource/Makefile               |   3 +
 drivers/clocksource/h8300_timer16.c        | 332 +++++++++++++++++++++++
 drivers/clocksource/h8300_timer8.c         | 398 +++++++++++++++++++++++++++
 drivers/clocksource/h8300_tpu.c            | 203 ++++++++++++++
 drivers/tty/serial/Kconfig                 |   2 +-
 include/linux/clk-provider.h               |  12 +
 include/uapi/linux/elf-em.h                |   1 +
 scripts/mksysmap                           |   2 +-
 123 files changed, 8349 insertions(+), 7 deletions(-)
 create mode 100644 arch/h8300/Kconfig
 create mode 100644 arch/h8300/Kconfig.cpu
 create mode 100644 arch/h8300/Makefile
 create mode 100644 arch/h8300/boot/Makefile
 create mode 100644 arch/h8300/boot/compressed/Makefile
 create mode 100644 arch/h8300/boot/compressed/head.S
 create mode 100644 arch/h8300/boot/compressed/misc.c
 create mode 100644 arch/h8300/boot/compressed/vmlinux.lds
 create mode 100644 arch/h8300/boot/compressed/vmlinux.scr
 create mode 100644 arch/h8300/configs/h8300h-sim_defconfig
 create mode 100644 arch/h8300/configs/h8s-sim_defconfig
 create mode 100644 arch/h8300/include/asm/Kbuild
 create mode 100644 arch/h8300/include/asm/asm-offsets.h
 create mode 100644 arch/h8300/include/asm/atomic.h
 create mode 100644 arch/h8300/include/asm/bitops.h
 create mode 100644 arch/h8300/include/asm/bootparams.h
 create mode 100644 arch/h8300/include/asm/bug.h
 create mode 100644 arch/h8300/include/asm/cache.h
 create mode 100644 arch/h8300/include/asm/checksum.h
 create mode 100644 arch/h8300/include/asm/cmpxchg.h
 create mode 100644 arch/h8300/include/asm/delay.h
 create mode 100644 arch/h8300/include/asm/device.h
 create mode 100644 arch/h8300/include/asm/dma-mapping.h
 create mode 100644 arch/h8300/include/asm/elf.h
 create mode 100644 arch/h8300/include/asm/emergency-restart.h
 create mode 100644 arch/h8300/include/asm/flat.h
 create mode 100644 arch/h8300/include/asm/io.h
 create mode 100644 arch/h8300/include/asm/irq.h
 create mode 100644 arch/h8300/include/asm/irqflags.h
 create mode 100644 arch/h8300/include/asm/mc146818rtc.h
 create mode 100644 arch/h8300/include/asm/mutex.h
 create mode 100644 arch/h8300/include/asm/page.h
 create mode 100644 arch/h8300/include/asm/page_offset.h
 create mode 100644 arch/h8300/include/asm/pci.h
 create mode 100644 arch/h8300/include/asm/pgtable.h
 create mode 100644 arch/h8300/include/asm/processor.h
 create mode 100644 arch/h8300/include/asm/ptrace.h
 create mode 100644 arch/h8300/include/asm/segment.h
 create mode 100644 arch/h8300/include/asm/sh_bios.h
 create mode 100644 arch/h8300/include/asm/signal.h
 create mode 100644 arch/h8300/include/asm/smp.h
 create mode 100644 arch/h8300/include/asm/spinlock.h
 create mode 100644 arch/h8300/include/asm/string.h
 create mode 100644 arch/h8300/include/asm/switch_to.h
 create mode 100644 arch/h8300/include/asm/syscall.h
 create mode 100644 arch/h8300/include/asm/thread_info.h
 create mode 100644 arch/h8300/include/asm/timer.h
 create mode 100644 arch/h8300/include/asm/tlb.h
 create mode 100644 arch/h8300/include/asm/topology.h
 create mode 100644 arch/h8300/include/asm/traps.h
 create mode 100644 arch/h8300/include/asm/uaccess.h
 create mode 100644 arch/h8300/include/asm/unaligned.h
 create mode 100644 arch/h8300/include/asm/user.h
 create mode 100644 arch/h8300/include/uapi/asm/Kbuild
 create mode 100644 arch/h8300/include/uapi/asm/auxvec.h
 create mode 100644 arch/h8300/include/uapi/asm/byteorder.h
 create mode 100644 arch/h8300/include/uapi/asm/ptrace.h
 create mode 100644 arch/h8300/include/uapi/asm/sigcontext.h
 create mode 100644 arch/h8300/include/uapi/asm/signal.h
 create mode 100644 arch/h8300/include/uapi/asm/swab.h
 create mode 100644 arch/h8300/include/uapi/asm/unistd.h
 create mode 100644 arch/h8300/kernel/Makefile
 create mode 100644 arch/h8300/kernel/asm-offsets.c
 create mode 100644 arch/h8300/kernel/cpu/Makefile
 create mode 100644 arch/h8300/kernel/cpu/h83069/Makefile
 create mode 100644 arch/h8300/kernel/cpu/h83069/setup.c
 create mode 100644 arch/h8300/kernel/cpu/h8s2678/Makefile
 create mode 100644 arch/h8300/kernel/cpu/h8s2678/setup.c
 create mode 100644 arch/h8300/kernel/cpu/irq_h.c
 create mode 100644 arch/h8300/kernel/cpu/irq_s.c
 create mode 100644 arch/h8300/kernel/cpu/ptrace_h.c
 create mode 100644 arch/h8300/kernel/cpu/ptrace_s.c
 create mode 100644 arch/h8300/kernel/dma.c
 create mode 100644 arch/h8300/kernel/entry.S
 create mode 100644 arch/h8300/kernel/h8300_ksyms.c
 create mode 100644 arch/h8300/kernel/head_ram.S
 create mode 100644 arch/h8300/kernel/head_rom.S
 create mode 100644 arch/h8300/kernel/irq.c
 create mode 100644 arch/h8300/kernel/module.c
 create mode 100644 arch/h8300/kernel/process.c
 create mode 100644 arch/h8300/kernel/ptrace.c
 create mode 100644 arch/h8300/kernel/setup.c
 create mode 100644 arch/h8300/kernel/signal.c
 create mode 100644 arch/h8300/kernel/sim-console.c
 create mode 100644 arch/h8300/kernel/syscalls.c
 create mode 100644 arch/h8300/kernel/traps.c
 create mode 100644 arch/h8300/kernel/vmlinux.lds.S
 create mode 100644 arch/h8300/lib/Makefile
 create mode 100644 arch/h8300/lib/abs.S
 create mode 100644 arch/h8300/lib/ashldi3.c
 create mode 100644 arch/h8300/lib/ashrdi3.c
 create mode 100644 arch/h8300/lib/checksum.c
 create mode 100644 arch/h8300/lib/libgcc.h
 create mode 100644 arch/h8300/lib/lshrdi3.c
 create mode 100644 arch/h8300/lib/memcpy.S
 create mode 100644 arch/h8300/lib/memset.S
 create mode 100644 arch/h8300/lib/moddivsi3.S
 create mode 100644 arch/h8300/lib/modsi3.S
 create mode 100644 arch/h8300/lib/muldi3.c
 create mode 100644 arch/h8300/lib/mulsi3.S
 create mode 100644 arch/h8300/lib/strncpy.S
 create mode 100644 arch/h8300/lib/ucmpdi2.c
 create mode 100644 arch/h8300/lib/udivsi3.S
 create mode 100644 arch/h8300/mm/Makefile
 create mode 100644 arch/h8300/mm/fault.c
 create mode 100644 arch/h8300/mm/init.c
 create mode 100644 arch/h8300/mm/kmap.c
 create mode 100644 arch/h8300/mm/memory.c
 create mode 100644 drivers/clk/h8300/Makefile
 create mode 100644 drivers/clk/h8300/clk-h83069.c
 create mode 100644 drivers/clk/h8300/clk-h8s2678.c
 create mode 100644 drivers/clocksource/h8300_timer16.c
 create mode 100644 drivers/clocksource/h8300_timer8.c
 create mode 100644 drivers/clocksource/h8300_tpu.c
Signature · 1 line
2.1.4
#11 lore raw

PATCH v8 3/17 h8300: Exception and Interrupt handling

h8300 exception entry and exception / interrupt handling

---
 arch/h8300/kernel/entry.S | 414 ++++++++++++++++++++++++++++++++++++++++++++++
 arch/h8300/kernel/irq.c   | 100 +++++++++++
 arch/h8300/kernel/traps.c | 161 ++++++++++++++++++
 3 files changed, 675 insertions(+)
 create mode 100644 arch/h8300/kernel/entry.S
 create mode 100644 arch/h8300/kernel/irq.c
 create mode 100644 arch/h8300/kernel/traps.c
arch/h8300/kernel/entry.S new file +414 -0
new file mode 100644
index 0000000..797dfa8
@@ -0,0 +1,414 @@
+/*
+ *
+ *  linux/arch/h8300/kernel/entry.S
+ *
+ *  Yoshinori Sato <[email protected]>
+ *  David McCullough <[email protected]>
+ *
+ */
+
+/*
+ *  entry.S
+ *  include exception/interrupt gateway
+ *          system call entry
+ */
+
+#include <linux/sys.h>
+#include <asm/unistd.h>
+#include <asm/setup.h>
+#include <asm/segment.h>
+#include <asm/linkage.h>
+#include <asm/asm-offsets.h>
+#include <asm/thread_info.h>
+#include <asm/errno.h>
+
+#if defined(CONFIG_CPU_H8300H)
+#define USERRET 8
+INTERRUPTS = 64
+	.h8300h
+	.macro	SHLL2 reg
+	shll.l	\reg
+	shll.l	\reg
+	.endm
+	.macro	SHLR2 reg
+	shlr.l	\reg
+	shlr.l	\reg
+	.endm
+	.macro	SAVEREGS
+	mov.l	er0,@-sp
+	mov.l	er1,@-sp
+	mov.l	er2,@-sp
+	mov.l	er3,@-sp
+	.endm
+	.macro	RESTOREREGS
+	mov.l	@sp+,er3
+	mov.l	@sp+,er2
+	.endm
+	.macro	SAVEEXR
+	.endm
+	.macro	RESTOREEXR
+	.endm
+#endif
+#if defined(CONFIG_CPU_H8S)
+#define USERRET 10
+#define USEREXR 8
+INTERRUPTS = 128
+	.h8300s
+	.macro	SHLL2 reg
+	shll.l	#2,\reg
+	.endm
+	.macro	SHLR2 reg
+	shlr.l	#2,\reg
+	.endm
+	.macro	SAVEREGS
+	stm.l	er0-er3,@-sp
+	.endm
+	.macro	RESTOREREGS
+	ldm.l	@sp+,er2-er3
+	.endm
+	.macro	SAVEEXR
+	mov.w	@(USEREXR:16,er0),r1
+	mov.w	r1,@(LEXR-LER3:16,sp)		/* copy EXR */
+	.endm
+	.macro	RESTOREEXR
+	mov.w	@(LEXR-LER1:16,sp),r1		/* restore EXR */
+	mov.b	r1l,r1h
+	mov.w	r1,@(USEREXR:16,er0)
+	.endm
+#endif
+
+
+/* CPU context save/restore macros. */
+
+	.macro	SAVE_ALL
+	mov.l	er0,@-sp
+	stc	ccr,r0l				/* check kernel mode */
+	btst	#4,r0l
+	bne	5f
+
+	/* user mode */
+	mov.l	sp,@_sw_usp
+	mov.l	@sp,er0				/* restore saved er0 */
+	orc	#0x10,ccr			/* switch kernel stack */
+	mov.l	@_sw_ksp,sp
+	sub.l	#(LRET-LORIG),sp		/* allocate LORIG - LRET */
+	SAVEREGS
+	mov.l   @_sw_usp,er0
+	mov.l   @(USERRET:16,er0),er1           /* copy the RET addr */
+	mov.l   er1,@(LRET-LER3:16,sp)
+	SAVEEXR
+
+	mov.l	@(LORIG-LER3:16,sp),er0
+	mov.l	er0,@(LER0-LER3:16,sp)		/* copy ER0 */
+	mov.w	e1,r1				/* e1 highbyte = ccr */
+	and	#0xef,r1h			/* mask mode? flag */
+	bra	6f
+5:
+	/* kernel mode */
+	mov.l	@sp,er0				/* restore saved er0 */
+	subs	#2,sp				/* set dummy ccr */
+	subs	#4,sp				/* set dummp sp */
+	SAVEREGS
+	mov.w	@(LRET-LER3:16,sp),r1		/* copy old ccr */
+6:
+	mov.b	r1h,r1l
+	mov.b	#0,r1h
+	mov.w	r1,@(LCCR-LER3:16,sp)		/* set ccr */
+	mov.l	@_sw_usp,er2
+	mov.l	er2,@(LSP-LER3:16,sp)		/* set usp */
+	mov.l	er6,@-sp			/* syscall arg #6 */
+	mov.l	er5,@-sp			/* syscall arg #5 */
+	mov.l	er4,@-sp			/* syscall arg #4 */
+	.endm					/* r1 = ccr */
+
+	.macro	RESTORE_ALL
+	mov.l	@sp+,er4
+	mov.l	@sp+,er5
+	mov.l	@sp+,er6
+	RESTOREREGS
+	mov.w	@(LCCR-LER1:16,sp),r0		/* check kernel mode */
+	btst	#4,r0l
+	bne	7f
+
+	orc	#0xc0,ccr
+	mov.l	@(LSP-LER1:16,sp),er0
+	mov.l	@(LER0-LER1:16,sp),er1		/* restore ER0 */
+	mov.l	er1,@er0
+	RESTOREEXR
+	mov.w	@(LCCR-LER1:16,sp),r1		/* restore the RET addr */
+	mov.b	r1l,r1h
+	mov.b	@(LRET+1-LER1:16,sp),r1l
+	mov.w	r1,e1
+	mov.w	@(LRET+2-LER1:16,sp),r1
+	mov.l	er1,@(USERRET:16,er0)
+
+	mov.l	@sp+,er1
+	add.l	#(LRET-LER1),sp			/* remove LORIG - LRET */
+	mov.l	sp,@_sw_ksp
+	andc	#0xef,ccr			/* switch to user mode */
+	mov.l	er0,sp
+	bra	8f
+7:
+	mov.l	@sp+,er1
+	add.l	#10,sp
+8:
+	mov.l	@sp+,er0
+	adds	#4,sp				/* remove the sw created LVEC */
+	rte
+	.endm
+
+.globl _system_call
+.globl ret_from_exception
+.globl ret_from_fork
+.globl ret_from_kernel_thread
+.globl ret_from_interrupt
+.globl _interrupt_redirect_table
+.globl _sw_ksp,_sw_usp
+.globl _resume
+.globl _interrupt_entry
+.globl _trace_break
+.globl _nmi
+
+#if defined(CONFIG_ROMKERNEL)
+	.section .int_redirect,"ax"
+_interrupt_redirect_table:
+#if defined(CONFIG_CPU_H8300H)
+	.rept	7
+	.long	0
+	.endr
+#endif
+#if defined(CONFIG_CPU_H8S)
+	.rept	5
+	.long	0
+	.endr
+	jmp	@_trace_break
+	.long	0
+#endif
+
+	jsr	@_interrupt_entry		/* NMI */
+	jmp	@_system_call			/* TRAPA #0 (System call) */
+	.long	0
+	.long	0
+	jmp	@_trace_break			/* TRAPA #3 (breakpoint) */
+	.rept	INTERRUPTS-12
+	jsr	@_interrupt_entry
+	.endr
+#endif
+#if defined(CONFIG_RAMKERNEL)
+.globl _interrupt_redirect_table
+	.section .bss
+_interrupt_redirect_table:
+	.space	4
+#endif
+
+	.section .text
+	.align	2
+_interrupt_entry:
+	SAVE_ALL
+/* r1l is saved ccr */
+	mov.l	sp,er0
+	add.l	#LVEC,er0
+	btst	#4,r1l
+	bne	1f
+	/* user LVEC */
+	mov.l	@_sw_usp,er0
+	adds	#4,er0
+1:
+	mov.l	@er0,er0			/* LVEC address */
+#if defined(CONFIG_ROMKERNEL)
+	sub.l	#_interrupt_redirect_table,er0
+#endif
+#if defined(CONFIG_RAMKERNEL)
+	mov.l	@_interrupt_redirect_table,er1
+	sub.l	er1,er0
+#endif
+	SHLR2	er0
+	dec.l	#1,er0
+	mov.l	sp,er1
+	subs	#4,er1				/* adjust ret_pc */
+#if defined(CONFIG_CPU_H8S)
+	orc	#7,exr
+#endif
+	jsr	@do_IRQ
+	jmp	@ret_from_interrupt
+
+_system_call:
+	subs	#4,sp				/* dummy LVEC */
+	SAVE_ALL
+	/* er0: syscall nr */
+	andc	#0xbf,ccr
+	mov.l	er0,er4
+
+	/* save top of frame */
+	mov.l	sp,er0
+	jsr	@set_esp0
+	mov.l	sp,er2
+	and.w	#0xe000,r2
+	mov.l	@(TI_FLAGS:16,er2),er2
+	and.w	#_TIF_WORK_SYSCALL_MASK,r2
+	beq	1f
+	mov.l	sp,er0
+	jsr	@do_syscall_trace_enter
+1:
+	cmp.l	#__NR_syscalls,er4
+	bcc	badsys
+	SHLL2	er4
+	mov.l	#_sys_call_table,er0
+	add.l	er4,er0
+	mov.l	@er0,er4
+	beq	ret_from_exception:16
+	mov.l	@(LER1:16,sp),er0
+	mov.l	@(LER2:16,sp),er1
+	mov.l	@(LER3:16,sp),er2
+	jsr	@er4
+	mov.l	er0,@(LER0:16,sp)		/* save the return value */
+	mov.l	sp,er2
+	and.w	#0xe000,r2
+	mov.l	@(TI_FLAGS:16,er2),er2
+	and.w	#_TIF_WORK_SYSCALL_MASK,r2
+	beq	2f
+	mov.l	sp,er0
+	jsr	@do_syscall_trace_leave
+2:
+	orc	#0xc0,ccr
+	bra	resume_userspace
+
+badsys:
+	mov.l	#-ENOSYS,er0
+	mov.l	er0,@(LER0:16,sp)
+	bra	resume_userspace
+
+#if !defined(CONFIG_PREEMPT)
+#define resume_kernel restore_all
+#endif
+
+ret_from_exception:
+#if defined(CONFIG_PREEMPT)
+	orc	#0xc0,ccr
+#endif
+ret_from_interrupt:
+	mov.b	@(LCCR+1:16,sp),r0l
+	btst	#4,r0l
+	bne	resume_kernel:16	/* return from kernel */
+resume_userspace:
+	andc	#0xbf,ccr
+	mov.l	sp,er4
+	and.w	#0xe000,r4		/* er4 <- current thread info */
+	mov.l	@(TI_FLAGS:16,er4),er1
+	and.l	#_TIF_WORK_MASK,er1
+	beq	restore_all:8
+work_pending:
+	btst	#TIF_NEED_RESCHED,r1l
+	bne	work_resched:8
+	/* work notifysig */
+	mov.l	sp,er0
+	subs	#4,er0			/* er0: pt_regs */
+	jsr	@do_notify_resume
+	bra	resume_userspace:8
+work_resched:
+	mov.l	sp,er0
+	jsr	@set_esp0
+	jsr	@schedule
+	bra	resume_userspace:8
+restore_all:
+	RESTORE_ALL			/* Does RTE */
+
+#if defined(CONFIG_PREEMPT)
+resume_kernel:
+	mov.l	@(TI_PRE_COUNT:16,er4),er0
+	bne	restore_all:8
+need_resched:
+	mov.l	@(TI_FLAGS:16,er4),er0
+	btst	#TIF_NEED_RESCHED,r0l
+	beq	restore_all:8
+	mov.b	@(LCCR+1:16,sp),r0l	/* Interrupt Enabled? */
+	bmi	restore_all:8
+	mov.l	sp,er0
+	jsr	@set_esp0
+	jsr	@preempt_schedule_irq
+	bra	need_resched:8
+#endif
+
+ret_from_fork:
+	mov.l	er2,er0
+	jsr	@schedule_tail
+	jmp	@ret_from_exception
+
+ret_from_kernel_thread:
+	mov.l	er2,er0
+	jsr	@schedule_tail
+	mov.l	@(LER4:16,sp),er0
+	mov.l	@(LER5:16,sp),er1
+	jsr	@er1
+	jmp	@ret_from_exception
+
+_resume:
+	/*
+	 * Beware - when entering resume, offset of tss is in d1,
+	 * prev (the current task) is in a0, next (the new task)
+	 * is in a1 and d2.b is non-zero if the mm structure is
+	 * shared between the tasks, so don't change these
+	 * registers until their contents are no longer needed.
+	 */
+
+	/* save sr */
+	sub.w	r3,r3
+	stc	ccr,r3l
+	mov.w	r3,@(THREAD_CCR+2:16,er0)
+
+	/* disable interrupts */
+	orc	#0xc0,ccr
+	mov.l	@_sw_usp,er3
+	mov.l	er3,@(THREAD_USP:16,er0)
+	mov.l	sp,@(THREAD_KSP:16,er0)
+
+	/* Skip address space switching if they are the same. */
+	/* FIXME: what did we hack out of here, this does nothing! */
+
+	mov.l	@(THREAD_USP:16,er1),er0
+	mov.l	er0,@_sw_usp
+	mov.l	@(THREAD_KSP:16,er1),sp
+
+	/* restore status register */
+	mov.w	@(THREAD_CCR+2:16,er1),r3
+
+	ldc	r3l,ccr
+	rts
+
+_trace_break:
+	subs	#4,sp
+	SAVE_ALL
+	sub.l	er1,er1
+	dec.l	#1,er1
+	mov.l	er1,@(LORIG,sp)
+	mov.l	sp,er0
+	jsr	@set_esp0
+	mov.l	@_sw_usp,er0
+	mov.l	@er0,er1
+	mov.w	@(-2:16,er1),r2
+	cmp.w	#0x5730,r2
+	beq	1f
+	subs	#2,er1
+	mov.l	er1,@er0
+1:
+	and.w	#0xff,e1
+	mov.l	er1,er0
+	jsr	@trace_trap
+	jmp	@ret_from_exception
+
+_nmi:
+	subs	#4, sp
+	mov.l	er0, @-sp
+	mov.l	@_interrupt_redirect_table, er0
+	add.l	#8*4, er0
+	mov.l	er0, @(4,sp)
+	mov.l	@sp+, er0
+	jmp	@_interrupt_entry
+
+	.section	.bss
+_sw_ksp:
+	.space	4
+_sw_usp:
+	.space	4
+
+	.end
arch/h8300/kernel/irq.c new file +100 -0

100 lines not on this page · raw message

arch/h8300/kernel/traps.c new file +161 -0

161 lines not on this page · raw message

Signature · 1 line
2.1.4
#13 lore raw

PATCH v8 5/17 h8300: process and signals

In reply to Yoshinori Sato

process management helper and signal handling

---
 arch/h8300/kernel/process.c | 171 ++++++++++++++++++++++++++
 arch/h8300/kernel/ptrace.c  | 203 +++++++++++++++++++++++++++++++
 arch/h8300/kernel/signal.c  | 289 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 663 insertions(+)
 create mode 100644 arch/h8300/kernel/process.c
 create mode 100644 arch/h8300/kernel/ptrace.c
 create mode 100644 arch/h8300/kernel/signal.c
arch/h8300/kernel/process.c new file +171 -0
new file mode 100644
index 0000000..dee4125
@@ -0,0 +1,171 @@
+/*
+ *  linux/arch/h8300/kernel/process.c
+ *
+ * Yoshinori Sato <[email protected]>
+ *
+ *  Based on:
+ *
+ *  linux/arch/m68knommu/kernel/process.c
+ *
+ *  Copyright (C) 1998  D. Jeff Dionne <[email protected]>,
+ *                      Kenneth Albanowski <[email protected]>,
+ *                      The Silver Hammer Group, Ltd.
+ *
+ *  linux/arch/m68k/kernel/process.c
+ *
+ *  Copyright (C) 1995  Hamish Macdonald
+ *
+ *  68060 fixes by Jesper Skov
+ */
+
+/*
+ * This file handles the architecture-dependent parts of process handling..
+ */
+
+#include <linux/errno.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/smp.h>
+#include <linux/stddef.h>
+#include <linux/unistd.h>
+#include <linux/ptrace.h>
+#include <linux/user.h>
+#include <linux/interrupt.h>
+#include <linux/reboot.h>
+#include <linux/fs.h>
+#include <linux/slab.h>
+#include <linux/rcupdate.h>
+
+#include <asm/uaccess.h>
+#include <asm/traps.h>
+#include <asm/setup.h>
+#include <asm/pgtable.h>
+
+void (*pm_power_off)(void) = NULL;
+EXPORT_SYMBOL(pm_power_off);
+
+asmlinkage void ret_from_fork(void);
+asmlinkage void ret_from_kernel_thread(void);
+
+/*
+ * The idle loop on an H8/300..
+ */
+void arch_cpu_idle(void)
+{
+	local_irq_enable();
+	__asm__("sleep");
+}
+
+void machine_restart(char *__unused)
+{
+	local_irq_disable();
+	__asm__("jmp @@0");
+}
+
+void machine_halt(void)
+{
+	local_irq_disable();
+	__asm__("sleep");
+	for (;;)
+		;
+}
+
+void machine_power_off(void)
+{
+	local_irq_disable();
+	__asm__("sleep");
+	for (;;)
+		;
+}
+
+void show_regs(struct pt_regs *regs)
+{
+	show_regs_print_info(KERN_DEFAULT);
+
+	pr_notice("\n");
+	pr_notice("PC: %08lx  Status: %02x\n",
+	       regs->pc, regs->ccr);
+	pr_notice("ORIG_ER0: %08lx ER0: %08lx ER1: %08lx\n",
+	       regs->orig_er0, regs->er0, regs->er1);
+	pr_notice("ER2: %08lx ER3: %08lx ER4: %08lx ER5: %08lx\n",
+	       regs->er2, regs->er3, regs->er4, regs->er5);
+	pr_notice("ER6' %08lx ", regs->er6);
+	if (user_mode(regs))
+		printk("USP: %08lx\n", rdusp());
+	else
+		printk("\n");
+}
+
+void flush_thread(void)
+{
+}
+
+int copy_thread(unsigned long clone_flags,
+		unsigned long usp, unsigned long topstk,
+		struct task_struct *p)
+{
+	struct pt_regs *childregs;
+
+	childregs = (struct pt_regs *) (THREAD_SIZE + task_stack_page(p)) - 1;
+
+	if (unlikely(p->flags & PF_KTHREAD)) {
+		memset(childregs, 0, sizeof(struct pt_regs));
+		childregs->retpc = (unsigned long) ret_from_kernel_thread;
+		childregs->er4 = topstk; /* arg */
+		childregs->er5 = usp; /* fn */
+	}  else {
+		*childregs = *current_pt_regs();
+		childregs->er0 = 0;
+		childregs->retpc = (unsigned long) ret_from_fork;
+		p->thread.usp = usp ?: rdusp();
+	}
+	p->thread.ksp = (unsigned long)childregs;
+
+	return 0;
+}
+
+unsigned long thread_saved_pc(struct task_struct *tsk)
+{
+	return ((struct pt_regs *)tsk->thread.esp0)->pc;
+}
+
+unsigned long get_wchan(struct task_struct *p)
+{
+	unsigned long fp, pc;
+	unsigned long stack_page;
+	int count = 0;
+
+	if (!p || p == current || p->state == TASK_RUNNING)
+		return 0;
+
+	stack_page = (unsigned long)p;
+	fp = ((struct pt_regs *)p->thread.ksp)->er6;
+	do {
+		if (fp < stack_page+sizeof(struct thread_info) ||
+		    fp >= 8184+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;
+}
+
+/* generic sys_clone is not enough registers */
+asmlinkage int sys_clone(unsigned long __user *args)
+{
+	unsigned long clone_flags;
+	unsigned long  newsp;
+	uintptr_t parent_tidptr;
+	uintptr_t child_tidptr;
+
+	get_user(clone_flags, &args[0]);
+	get_user(newsp, &args[1]);
+	get_user(parent_tidptr, &args[2]);
+	get_user(child_tidptr, &args[3]);
+	return do_fork(clone_flags, newsp, 0,
+		       (int __user *)parent_tidptr, (int __user *)child_tidptr);
+}
arch/h8300/kernel/ptrace.c new file +203 -0

203 lines not on this page · raw message

arch/h8300/kernel/signal.c new file +289 -0

289 lines not on this page · raw message

Signature · 1 line
2.1.4
#15 lore raw

PATCH v8 7/17 h8300: miscellaneous functions

In reply to Yoshinori Sato
---
 arch/h8300/kernel/asm-offsets.c | 60 ++++++++++++++++++++++++++
 arch/h8300/kernel/dma.c         | 95 +++++++++++++++++++++++++++++++++++++++++
 arch/h8300/kernel/h8300_ksyms.c | 34 +++++++++++++++
 arch/h8300/kernel/module.c      | 70 ++++++++++++++++++++++++++++++
 arch/h8300/kernel/sim-console.c | 79 ++++++++++++++++++++++++++++++++++
 arch/h8300/kernel/syscalls.c    | 14 ++++++
 6 files changed, 352 insertions(+)
 create mode 100644 arch/h8300/kernel/asm-offsets.c
 create mode 100644 arch/h8300/kernel/dma.c
 create mode 100644 arch/h8300/kernel/h8300_ksyms.c
 create mode 100644 arch/h8300/kernel/module.c
 create mode 100644 arch/h8300/kernel/sim-console.c
 create mode 100644 arch/h8300/kernel/syscalls.c
arch/h8300/kernel/asm-offsets.c new file +60 -0
new file mode 100644
index 0000000..9fb9d49
@@ -0,0 +1,60 @@
+/*
+ * 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));
+
+	/* offsets into the thread struct */
+	DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp));
+	DEFINE(THREAD_USP, offsetof(struct thread_struct, usp));
+	DEFINE(THREAD_CCR, offsetof(struct thread_struct, ccr));
+
+	/* offsets into the pt_regs struct */
+	DEFINE(LER0,  offsetof(struct pt_regs, er0)      - sizeof(long));
+	DEFINE(LER1,  offsetof(struct pt_regs, er1)      - sizeof(long));
+	DEFINE(LER2,  offsetof(struct pt_regs, er2)      - sizeof(long));
+	DEFINE(LER3,  offsetof(struct pt_regs, er3)      - sizeof(long));
+	DEFINE(LER4,  offsetof(struct pt_regs, er4)      - sizeof(long));
+	DEFINE(LER5,  offsetof(struct pt_regs, er5)      - sizeof(long));
+	DEFINE(LER6,  offsetof(struct pt_regs, er6)      - sizeof(long));
+	DEFINE(LORIG, offsetof(struct pt_regs, orig_er0) - sizeof(long));
+	DEFINE(LSP,  offsetof(struct pt_regs, sp)        - sizeof(long));
+	DEFINE(LCCR,  offsetof(struct pt_regs, ccr)      - sizeof(long));
+	DEFINE(LVEC,  offsetof(struct pt_regs, vector)   - sizeof(long));
+#if defined(CONFIG_CPU_H8S)
+	DEFINE(LEXR,  offsetof(struct pt_regs, exr)      - sizeof(long));
+#endif
+	DEFINE(LRET,  offsetof(struct pt_regs, pc)       - sizeof(long));
+
+	DEFINE(PT_PTRACED, PT_PTRACED);
+
+	return 0;
+}
arch/h8300/kernel/dma.c new file +95 -0

95 lines not on this page · raw message

arch/h8300/kernel/h8300_ksyms.c new file +34 -0
new file mode 100644
index 0000000..33bf96a
@@ -0,0 +1,34 @@
+#include <linux/module.h>
+#include <linux/linkage.h>
+
+/*
+ * libgcc functions - functions that are used internally by the
+ * compiler...  (prototypes are not correct though, but that
+ * doesn't really matter since they're not versioned).
+ */
+asmlinkage long long __ashldi3(long long, int);
+asmlinkage long long __ashrdi3(long long, int);
+asmlinkage long long __lshrdi3(long long, int);
+asmlinkage long __divsi3(long, long);
+asmlinkage long __modsi3(long, long);
+asmlinkage unsigned long __umodsi3(unsigned long, unsigned long);
+asmlinkage long long __muldi3(long long, long long);
+asmlinkage long __mulsi3(long, long);
+asmlinkage long __udivsi3(long, long);
+asmlinkage void *memcpy(void *, const void *, size_t);
+asmlinkage void *memset(void *, int, size_t);
+asmlinkage long strncpy_from_user(void *to, void *from, size_t n);
+
+	/* gcc lib functions */
+EXPORT_SYMBOL(__ashldi3);
+EXPORT_SYMBOL(__ashrdi3);
+EXPORT_SYMBOL(__lshrdi3);
+EXPORT_SYMBOL(__divsi3);
+EXPORT_SYMBOL(__modsi3);
+EXPORT_SYMBOL(__umodsi3);
+EXPORT_SYMBOL(__muldi3);
+EXPORT_SYMBOL(__mulsi3);
+EXPORT_SYMBOL(__udivsi3);
+EXPORT_SYMBOL(memcpy);
+EXPORT_SYMBOL(memset);
+EXPORT_SYMBOL(strncpy_from_user);
arch/h8300/kernel/module.c new file +70 -0

70 lines not on this page · raw message

arch/h8300/kernel/sim-console.c new file +79 -0

79 lines not on this page · raw message

arch/h8300/kernel/syscalls.c new file +14 -0
new file mode 100644
index 0000000..1f9123a
@@ -0,0 +1,14 @@
+#include <linux/syscalls.h>
+#include <linux/signal.h>
+#include <linux/unistd.h>
+
+#undef __SYSCALL
+#define __SYSCALL(nr, call) [nr] = (call),
+
+#define sys_mmap2 sys_mmap_pgoff
+
+asmlinkage int sys_rt_sigreturn(void);
+
+void *_sys_call_table[__NR_syscalls] = {
+#include <asm/unistd.h>
+};
Signature · 1 line
2.1.4
#16 lore raw

PATCH v8 8/17 h8300: Memory management

In reply to Yoshinori Sato
---
 arch/h8300/mm/Makefile |   5 ++
 arch/h8300/mm/fault.c  |  57 +++++++++++++++++++++
 arch/h8300/mm/init.c   | 133 +++++++++++++++++++++++++++++++++++++++++++++++++
 arch/h8300/mm/kmap.c   |  61 +++++++++++++++++++++++
 arch/h8300/mm/memory.c |  53 ++++++++++++++++++++
 5 files changed, 309 insertions(+)
 create mode 100644 arch/h8300/mm/Makefile
 create mode 100644 arch/h8300/mm/fault.c
 create mode 100644 arch/h8300/mm/init.c
 create mode 100644 arch/h8300/mm/kmap.c
 create mode 100644 arch/h8300/mm/memory.c
arch/h8300/mm/Makefile new file +5 -0
new file mode 100644
index 0000000..117d71f
@@ -0,0 +1,5 @@
+#
+# Makefile for the linux h8300-specific parts of the memory manager.
+#
+
+obj-y	 := init.o fault.o memory.o kmap.o
arch/h8300/mm/fault.c new file +57 -0

57 lines not on this page · raw message

arch/h8300/mm/init.c new file +133 -0

133 lines not on this page · raw message

arch/h8300/mm/kmap.c new file +61 -0

61 lines not on this page · raw message

arch/h8300/mm/memory.c new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.1.4
#17 lore raw

PATCH v8 9/17 h8300: library functions

In reply to Yoshinori Sato

h8300 assembly functions and private libgcc.

---
 arch/h8300/lib/Makefile    |   7 ++
 arch/h8300/lib/abs.S       |  20 ++++++
 arch/h8300/lib/ashldi3.c   |  24 +++++++
 arch/h8300/lib/ashrdi3.c   |  24 +++++++
 arch/h8300/lib/checksum.c  | 167 +++++++++++++++++++++++++++++++++++++++++++++
 arch/h8300/lib/libgcc.h    |  77 +++++++++++++++++++++
 arch/h8300/lib/lshrdi3.c   |  23 +++++++
 arch/h8300/lib/memcpy.S    |  85 +++++++++++++++++++++++
 arch/h8300/lib/memset.S    |  69 +++++++++++++++++++
 arch/h8300/lib/moddivsi3.S |  72 +++++++++++++++++++
 arch/h8300/lib/modsi3.S    |  72 +++++++++++++++++++
 arch/h8300/lib/muldi3.c    |  44 ++++++++++++
 arch/h8300/lib/mulsi3.S    |  38 +++++++++++
 arch/h8300/lib/strncpy.S   |  34 +++++++++
 arch/h8300/lib/ucmpdi2.c   |  17 +++++
 arch/h8300/lib/udivsi3.S   |  76 +++++++++++++++++++++
 16 files changed, 849 insertions(+)
 create mode 100644 arch/h8300/lib/Makefile
 create mode 100644 arch/h8300/lib/abs.S
 create mode 100644 arch/h8300/lib/ashldi3.c
 create mode 100644 arch/h8300/lib/ashrdi3.c
 create mode 100644 arch/h8300/lib/checksum.c
 create mode 100644 arch/h8300/lib/libgcc.h
 create mode 100644 arch/h8300/lib/lshrdi3.c
 create mode 100644 arch/h8300/lib/memcpy.S
 create mode 100644 arch/h8300/lib/memset.S
 create mode 100644 arch/h8300/lib/moddivsi3.S
 create mode 100644 arch/h8300/lib/modsi3.S
 create mode 100644 arch/h8300/lib/muldi3.c
 create mode 100644 arch/h8300/lib/mulsi3.S
 create mode 100644 arch/h8300/lib/strncpy.S
 create mode 100644 arch/h8300/lib/ucmpdi2.c
 create mode 100644 arch/h8300/lib/udivsi3.S
arch/h8300/lib/Makefile new file +7 -0
new file mode 100644
index 0000000..8311a9f
@@ -0,0 +1,7 @@
+#
+# Makefile for H8/300-specific library files..
+#
+
+lib-y  = checksum.o memcpy.o memset.o abs.o strncpy.o \
+	 mulsi3.o udivsi3.o muldi3.o moddivsi3.o \
+	 ashldi3.o lshrdi3.o ashrdi3.o ucmpdi2.o
arch/h8300/lib/abs.S new file +20 -0
new file mode 100644
index 0000000..efda749
@@ -0,0 +1,20 @@
+;;; abs.S
+
+#include <asm/linkage.h>
+
+#if defined(CONFIG_CPU_H8300H)
+	.h8300h
+#endif
+#if defined(CONFIG_CPU_H8S)
+	.h8300s
+#endif
+	.text
+.global _abs
+
+;;; int abs(int n)
+_abs:
+	mov.l	er0,er0
+	bpl	1f
+	neg.l	er0
+1:
+	rts
arch/h8300/lib/ashldi3.c new file +24 -0
new file mode 100644
index 0000000..c6aa8ea
@@ -0,0 +1,24 @@
+#include "libgcc.h"
+
+DWtype
+__ashldi3(DWtype u, word_type b)
+{
+	const DWunion uu = {.ll = u};
+	const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
+	DWunion w;
+
+	if (b == 0)
+		return u;
+
+	if (bm <= 0) {
+		w.s.low = 0;
+		w.s.high = (UWtype) uu.s.low << -bm;
+	} else {
+		const UWtype carries = (UWtype) uu.s.low >> bm;
+
+		w.s.low = (UWtype) uu.s.low << b;
+		w.s.high = ((UWtype) uu.s.high << b) | carries;
+	}
+
+	return w.ll;
+}
arch/h8300/lib/ashrdi3.c new file +24 -0
new file mode 100644
index 0000000..070adf9
@@ -0,0 +1,24 @@
+#include "libgcc.h"
+
+DWtype __ashrdi3(DWtype u, word_type b)
+{
+	const DWunion uu = {.ll = u};
+	const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
+	DWunion w;
+
+	if (b == 0)
+		return u;
+
+	if (bm <= 0) {
+		/* w.s.high = 1..1 or 0..0 */
+		w.s.high = uu.s.high >> (sizeof (Wtype) * BITS_PER_UNIT - 1);
+		w.s.low = uu.s.high >> -bm;
+	} else {
+		const UWtype carries = (UWtype) uu.s.high << bm;
+
+		w.s.high = uu.s.high >> b;
+		w.s.low = ((UWtype) uu.s.low >> b) | carries;
+	}
+
+	return w.ll;
+}
arch/h8300/lib/checksum.c new file +167 -0

167 lines not on this page · raw message

arch/h8300/lib/libgcc.h new file +77 -0

77 lines not on this page · raw message

arch/h8300/lib/lshrdi3.c new file +23 -0
new file mode 100644
index 0000000..a86bbe3
@@ -0,0 +1,23 @@
+#include "libgcc.h"
+
+DWtype __lshrdi3(DWtype u, word_type b)
+{
+	const DWunion uu = {.ll = u};
+	const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
+	DWunion w;
+
+	if (b == 0)
+		return u;
+
+	if (bm <= 0) {
+		w.s.high = 0;
+		w.s.low = (UWtype) uu.s.high >> -bm;
+	} else {
+		const UWtype carries = (UWtype) uu.s.high << bm;
+
+		w.s.high = (UWtype) uu.s.high >> b;
+		w.s.low = ((UWtype) uu.s.low >> b) | carries;
+	}
+
+	return w.ll;
+}
arch/h8300/lib/memcpy.S new file +85 -0

85 lines not on this page · raw message

arch/h8300/lib/memset.S new file +69 -0

69 lines not on this page · raw message

arch/h8300/lib/moddivsi3.S new file +72 -0

72 lines not on this page · raw message

arch/h8300/lib/modsi3.S new file +72 -0

72 lines not on this page · raw message

arch/h8300/lib/muldi3.c new file +44 -0

44 lines not on this page · raw message

arch/h8300/lib/mulsi3.S new file +38 -0
new file mode 100644
index 0000000..451f0e0
@@ -0,0 +1,38 @@
+;
+; mulsi3 for H8/300H - based on Renesas SH implementation
+;
+; by Toshiyasu Morita
+;
+; Old code:
+;
+; 16b * 16b = 372 states (worst case)
+; 32b * 32b = 724 states (worst case)
+;
+; New code:
+;
+; 16b * 16b =  48 states
+; 16b * 32b =  72 states
+; 32b * 32b =  92 states
+;
+
+	.global __mulsi3
+__mulsi3:
+	mov.w	r1,r2   ; ( 2 states) b * d
+	mulxu	r0,er2  ; (22 states)
+
+	mov.w	e0,r3   ; ( 2 states) a * d
+	beq	L_skip1 ; ( 4 states)
+	mulxu	r1,er3  ; (22 states)
+	add.w	r3,e2   ; ( 2 states)
+
+L_skip1:
+	mov.w	e1,r3   ; ( 2 states) c * b
+	beq	L_skip2 ; ( 4 states)
+	mulxu	r0,er3  ; (22 states)
+	add.w	r3,e2   ; ( 2 states)
+
+L_skip2:
+	mov.l	er2,er0	; ( 2 states)
+	rts		; (10 states)
+
+	.end
arch/h8300/lib/strncpy.S new file +34 -0
new file mode 100644
index 0000000..d00396a
@@ -0,0 +1,34 @@
+;;; strncpy.S
+
+#include <asm/linkage.h>
+
+	.text
+.global strncpy_from_user
+
+;;; long strncpy_from_user(void *to, void *from, size_t n)
+strncpy_from_user:
+	mov.l	er2,er2
+	bne	1f
+	sub.l	er0,er0
+	rts
+1:
+	mov.l	er4,@-sp
+	sub.l	er3,er3
+2:
+	mov.b	@er1+,r4l
+	mov.b	r4l,@er0
+	adds	#1,er0
+	beq	3f
+	inc.l	#1,er3
+	dec.l	#1,er2
+	bne	2b
+3:
+	dec.l	#1,er2
+4:
+	mov.b	r4l,@er0
+	adds	#1,er0
+	dec.l	#1,er2
+	bne	4b
+	mov.l	er3,er0
+	mov.l	@sp+,er4
+	rts
arch/h8300/lib/ucmpdi2.c new file +17 -0
new file mode 100644
index 0000000..772399d
@@ -0,0 +1,17 @@
+#include "libgcc.h"
+
+word_type __ucmpdi2(DWtype a, DWtype b)
+{
+	const DWunion au = {.ll = a};
+	const DWunion bu = {.ll = b};
+
+	if ((UWtype) au.s.high < (UWtype) bu.s.high)
+		return 0;
+	else if ((UWtype) au.s.high > (UWtype) bu.s.high)
+		return 2;
+	if ((UWtype) au.s.low < (UWtype) bu.s.low)
+		return 0;
+	else if ((UWtype) au.s.low > (UWtype) bu.s.low)
+		return 2;
+	return 1;
+}
arch/h8300/lib/udivsi3.S new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
2.1.4
#20 lore raw

PATCH v8 12/17 h8300: clocksource

In reply to Yoshinori Sato

H8/300 internal timer driver.
h8300_timer8 - 8bit Timer driver. h8300_timer16 - 16bit Timer driver (only H8/3069).
h8300_tpu - Timer Pulse Unit driver (only H8S2678).

---
 drivers/clocksource/Kconfig         |   6 +
 drivers/clocksource/Makefile        |   3 +
 drivers/clocksource/h8300_timer16.c | 332 ++++++++++++++++++++++++++++++
 drivers/clocksource/h8300_timer8.c  | 398 ++++++++++++++++++++++++++++++++++++
 drivers/clocksource/h8300_tpu.c     | 203 ++++++++++++++++++
 5 files changed, 942 insertions(+)
 create mode 100644 drivers/clocksource/h8300_timer16.c
 create mode 100644 drivers/clocksource/h8300_timer8.c
 create mode 100644 drivers/clocksource/h8300_tpu.c
drivers/clocksource/Kconfig +6 -0
index a0b036c..fef959a 100644
@@ -253,4 +253,10 @@ config CLKSRC_PXA
 	help
 	  This enables OST0 support available on PXA and SA-11x0
 	  platforms.
+config H8300_TMR16
+        bool
+
+config H8300_TPU
+        bool
+
 endmenu
drivers/clocksource/Makefile +3 -0
index 752d5c7..99b45f7 100644
@@ -51,3 +51,6 @@ obj-$(CONFIG_ARCH_INTEGRATOR_AP)	+= timer-integrator-ap.o
 obj-$(CONFIG_CLKSRC_VERSATILE)		+= versatile.o
 obj-$(CONFIG_CLKSRC_MIPS_GIC)		+= mips-gic-timer.o
 obj-$(CONFIG_ASM9260_TIMER)		+= asm9260_timer.o
+obj-$(CONFIG_H8300)			+= h8300_timer8.o
+obj-$(CONFIG_H8300_TMR16)		+= h8300_timer16.o
+obj-$(CONFIG_H8300_TPU)			+= h8300_tpu.o
drivers/clocksource/h8300_timer16.c new file +332 -0

332 lines not on this page · raw message

drivers/clocksource/h8300_timer8.c new file +398 -0

398 lines not on this page · raw message

drivers/clocksource/h8300_tpu.c new file +203 -0

203 lines not on this page · raw message

Signature · 1 line
2.1.4
#21 lore raw

PATCH v8 13/17 h8300: configs

In reply to Yoshinori Sato
h8300h-sim_defconfig: H8/300H simulator config.
h8s-sim_defconfig:    H8S simulator config.
edosk2674_defconfig:  EDOSK2674R evalution board config.
---
 arch/h8300/configs/h8300h-sim_defconfig | 53 +++++++++++++++++++++++++++++++++
 arch/h8300/configs/h8s-sim_defconfig    | 53 +++++++++++++++++++++++++++++++++
 2 files changed, 106 insertions(+)
 create mode 100644 arch/h8300/configs/h8300h-sim_defconfig
 create mode 100644 arch/h8300/configs/h8s-sim_defconfig
arch/h8300/configs/h8300h-sim_defconfig new file +53 -0
new file mode 100644
index 0000000..bad1a1e
@@ -0,0 +1,53 @@
+# CONFIG_LOCALVERSION_AUTO is not set
+# CONFIG_USELIB is not set
+# CONFIG_INIT_FALLBACK is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+# CONFIG_UID16 is not set
+# CONFIG_SYSFS_SYSCALL is not set
+# CONFIG_KALLSYMS 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_ADVISE_SYSCALLS is not set
+CONFIG_EMBEDDED=y
+# CONFIG_VM_EVENT_COUNTERS is not set
+# CONFIG_COMPAT_BRK is not set
+CONFIG_SLOB=y
+# CONFIG_BLOCK is not set
+CONFIG_H8300H_SIM=y
+CONFIG_CPU_CLOCK=20000000
+CONFIG_RAMSIZE=0x200000
+# CONFIG_BINFMT_SCRIPT is not set
+CONFIG_BINFMT_FLAT=y
+# CONFIG_COREDUMP is not set
+# CONFIG_UEVENT_HELPER is not set
+# CONFIG_STANDALONE is not set
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+# CONFIG_FW_LOADER is not set
+# CONFIG_ALLOW_DEV_COREDUMP is not set
+# CONFIG_INPUT is not set
+# CONFIG_SERIO is not set
+# CONFIG_VT is not set
+# CONFIG_UNIX98_PTYS is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_DEVKMEM is not set
+CONFIG_SERIAL_SH_SCI=y
+CONFIG_SERIAL_SH_SCI_CONSOLE=y
+# CONFIG_HW_RANDOM is not set
+# CONFIG_HWMON is not set
+# CONFIG_USB_SUPPORT is not set
+# CONFIG_IOMMU_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_DEBUG_INFO=y
+# CONFIG_ENABLE_WARN_DEPRECATED is not set
+# CONFIG_ENABLE_MUST_CHECK is not set
+# CONFIG_CRC32 is not set
arch/h8300/configs/h8s-sim_defconfig new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.1.4
#23 lore raw

PATCH v8 15/17 Add ELF machine

In reply to Yoshinori Sato
---
 include/uapi/linux/elf-em.h | 1 +
 1 file changed, 1 insertion(+)
include/uapi/linux/elf-em.h +1 -0
index ae99f77..b088296 100644
@@ -25,6 +25,7 @@
 #define EM_ARM		40	/* ARM 32 bit */
 #define EM_SH		42	/* SuperH */
 #define EM_SPARCV9	43	/* SPARC v9 64-bit */
+#define EM_H8_300	46	/* Renesas H8/300 */
 #define EM_IA_64	50	/* HP/Intel IA-64 */
 #define EM_X86_64	62	/* AMD x86-64 */
 #define EM_S390		22	/* IBM S/390 */
Signature · 1 line
2.1.4
#24 lore raw

PATCH v8 16/17 mksysmap: Add h8300 local symbol pattern

In reply to Yoshinori Sato

h8300's nm output have a lot of local symbols.
ex)
00000000 N .Lframe0
00000013 N .LLST1
00000026 N .LLST2
00000039 N .LLST3
0000004c N .LLST4
Added new pattern " .L" to filter rule.

---
 scripts/mksysmap | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mksysmap +1 -1
index 7ada35a..a35acc0 100755
@@ -41,4 +41,4 @@
 # so we just ignore them to let readprofile continue to work.
 # (At least sparc64 has __crc_ in the middle).
 
-$NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)' > $2
+$NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( .L\)' > $2
Signature · 1 line
2.1.4
#25 lore raw

PATCH v8 17/17 Add H8/300 entry

In reply to Yoshinori Sato
---
 CREDITS     |  5 -----
 MAINTAINERS | 11 +++++++++++
 2 files changed, 11 insertions(+), 5 deletions(-)
CREDITS +0 -5
index 96935df..3bea091 100644
@@ -3194,11 +3194,6 @@ N: Dipankar Sarma
 E: [email protected]
 D: RCU
 
-N: Yoshinori Sato
-E: [email protected]
-D: uClinux for Renesas H8/300 (H8300)
-D: http://uclinux-h8.sourceforge.jp/
-
 N: Hannu Savolainen
 E: [email protected]
 D: Maintainer of the sound drivers until 2.1.x days.
MAINTAINERS +11 -0
index efbcb50..14a2c51 100644
@@ -4444,6 +4444,17 @@ T:	git git://linuxtv.org/media_tree.git
 S:	Maintained
 F:	drivers/media/usb/stk1160/
 
+H8/300 ARCHITECTURE
+M:	Yoshinori Sato <[email protected]>
+L:	[email protected]
+W:	http://uclinux-h8.sourceforge.jp
+T:	git git://git.sourceforge.jp/gitroot/uclinux-h8/linux.git
+S:	Maintained
+F:	arch/h8300/
+F:	drivers/clocksource/h8300/
+F:	drivers/clk/clk-h83069.c
+F:	drivers/clk/clk-h8s2678.c
+
 HARD DRIVE ACTIVE PROTECTION SYSTEM (HDAPS) DRIVER
 M:	Frank Seidel <[email protected]>
 L:	[email protected]
Signature · 1 line
2.1.4
#10 lore raw

PATCH v8 2/17 h8300: UAPI headers

In reply to Yoshinori Sato
---
 arch/h8300/include/uapi/asm/Kbuild       |  29 ++++++++
 arch/h8300/include/uapi/asm/auxvec.h     |   4 ++
 arch/h8300/include/uapi/asm/byteorder.h  |   6 ++
 arch/h8300/include/uapi/asm/ptrace.h     |  42 +++++++++++
 arch/h8300/include/uapi/asm/sigcontext.h |  18 +++++
 arch/h8300/include/uapi/asm/signal.h     | 115 +++++++++++++++++++++++++++++++
 arch/h8300/include/uapi/asm/swab.h       |   1 +
 arch/h8300/include/uapi/asm/unistd.h     |   3 +
 8 files changed, 218 insertions(+)
 create mode 100644 arch/h8300/include/uapi/asm/Kbuild
 create mode 100644 arch/h8300/include/uapi/asm/auxvec.h
 create mode 100644 arch/h8300/include/uapi/asm/byteorder.h
 create mode 100644 arch/h8300/include/uapi/asm/ptrace.h
 create mode 100644 arch/h8300/include/uapi/asm/sigcontext.h
 create mode 100644 arch/h8300/include/uapi/asm/signal.h
 create mode 100644 arch/h8300/include/uapi/asm/swab.h
 create mode 100644 arch/h8300/include/uapi/asm/unistd.h
arch/h8300/include/uapi/asm/Kbuild new file +29 -0
new file mode 100644
index 0000000..077e720
@@ -0,0 +1,29 @@
+# UAPI Header export list
+include include/uapi/asm-generic/Kbuild.asm
+
+header-y += auxvec.h
+header-y += bitsperlong.h
+header-y += errno.h
+header-y += fcntl.h
+header-y += ioctl.h
+header-y += ioctls.h
+header-y += ipcbuf.h
+header-y += kvm_para.h
+header-y += mman.h
+header-y += msgbuf.h
+header-y += param.h
+header-y += poll.h
+header-y += posix_types.h
+header-y += resource.h
+header-y += sembuf.h
+header-y += setup.h
+header-y += shmbuf.h
+header-y += siginfo.h
+header-y += socket.h
+header-y += sockios.h
+header-y += stat.h
+header-y += statfs.h
+header-y += termbits.h
+header-y += termios.h
+header-y += types.h
+header-y += unistd.h
arch/h8300/include/uapi/asm/auxvec.h new file +4 -0
new file mode 100644
index 0000000..1d36fe38
@@ -0,0 +1,4 @@
+#ifndef __ASMH8300_AUXVEC_H
+#define __ASMH8300_AUXVEC_H
+
+#endif
arch/h8300/include/uapi/asm/byteorder.h new file +6 -0
new file mode 100644
index 0000000..13539da
@@ -0,0 +1,6 @@
+#ifndef _H8300_BYTEORDER_H
+#define _H8300_BYTEORDER_H
+
+#include <linux/byteorder/big_endian.h>
+
+#endif /* _H8300_BYTEORDER_H */
arch/h8300/include/uapi/asm/ptrace.h new file +42 -0

42 lines not on this page · raw message

arch/h8300/include/uapi/asm/sigcontext.h new file +18 -0
new file mode 100644
index 0000000..c41fdaa
@@ -0,0 +1,18 @@
+#ifndef _ASM_H8300_SIGCONTEXT_H
+#define _ASM_H8300_SIGCONTEXT_H
+
+struct sigcontext {
+	unsigned long  sc_mask;		/* old sigmask */
+	unsigned long  sc_usp;		/* old user stack pointer */
+	unsigned long  sc_er0;
+	unsigned long  sc_er1;
+	unsigned long  sc_er2;
+	unsigned long  sc_er3;
+	unsigned long  sc_er4;
+	unsigned long  sc_er5;
+	unsigned long  sc_er6;
+	unsigned short sc_ccr;
+	unsigned long  sc_pc;
+};
+
+#endif
arch/h8300/include/uapi/asm/signal.h new file +115 -0

115 lines not on this page · raw message

arch/h8300/include/uapi/asm/swab.h new file +1 -0
new file mode 100644
index 0000000..7847e56
@@ -0,0 +1 @@
+#include <asm-generic/swab.h>
arch/h8300/include/uapi/asm/unistd.h new file +3 -0
new file mode 100644
index 0000000..7a2eb69
@@ -0,0 +1,3 @@
+#define __ARCH_NOMMU
+
+#include <asm-generic/unistd.h>
Signature · 1 line
2.1.4
#19 lore raw

PATCH v8 11/17 h8300: clock driver

In reply to Yoshinori Sato

h8300 clock generator drivers.
H8/3069 is simple oscillator.
H8S2678 is PLL multiplier support.

---
 drivers/clk/Makefile            |   1 +
 drivers/clk/h8300/Makefile      |   2 +
 drivers/clk/h8300/clk-h83069.c  |  80 +++++++++++++++++++
 drivers/clk/h8300/clk-h8s2678.c | 171 ++++++++++++++++++++++++++++++++++++++++
 include/linux/clk-provider.h    |  12 +++
 5 files changed, 266 insertions(+)
 create mode 100644 drivers/clk/h8300/Makefile
 create mode 100644 drivers/clk/h8300/clk-h83069.c
 create mode 100644 drivers/clk/h8300/clk-h8s2678.c
drivers/clk/Makefile +1 -0
index d478ceb..593b09c 100644
@@ -70,3 +70,4 @@ obj-$(CONFIG_ARCH_U8500)		+= ux500/
 obj-$(CONFIG_COMMON_CLK_VERSATILE)	+= versatile/
 obj-$(CONFIG_X86)			+= x86/
 obj-$(CONFIG_ARCH_ZYNQ)			+= zynq/
+obj-$(CONFIG_H8300)		+= h8300/
drivers/clk/h8300/Makefile new file +2 -0
new file mode 100644
index 0000000..82eab42
@@ -0,0 +1,2 @@
+obj-$(CONFIG_H83069) += clk-h83069.o
+obj-$(CONFIG_H8S2678) += clk-h8s2678.o
drivers/clk/h8300/clk-h83069.c new file +80 -0

80 lines not on this page · raw message

drivers/clk/h8300/clk-h8s2678.c new file +171 -0

171 lines not on this page · raw message

include/linux/clk-provider.h +12 -0
index 5591ea7..6059414 100644
@@ -675,6 +675,18 @@ static inline void clk_writel(u32 val, u32 __iomem *reg)
 	iowrite32be(val, reg);
 }
 
+#elif IS_ENABLED(CONFIG_H8300)
+
+static inline u32 clk_readl(u32 __iomem *reg)
+{
+	return __raw_readb(reg);
+}
+
+static inline void clk_writel(u32 val, u32 __iomem *reg)
+{
+	__raw_writeb(val, reg);
+}
+
 #else	/* platform dependent I/O accessors */
 
 static inline u32 clk_readl(u32 __iomem *reg)
Signature · 1 line
2.1.4
#22 lore raw

PATCH v8 14/17 serial: Add H8300.

In reply to Yoshinori Sato

h8300 internal serial controller of same as sh-sci. So h8300 use SH_SCI.

---
 drivers/tty/serial/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/Kconfig +1 -1
index d2501f0..77d77d4 100644
@@ -738,7 +738,7 @@ config SERIAL_IP22_ZILOG_CONSOLE
 
 config SERIAL_SH_SCI
 	tristate "SuperH SCI(F) serial port support"
-	depends on SUPERH || ARCH_SHMOBILE || COMPILE_TEST
+	depends on SUPERH || ARCH_SHMOBILE || H8300 || COMPILE_TEST 
 	select SERIAL_CORE
 
 config SERIAL_SH_SCI_NR_UARTS
Signature · 1 line
2.1.4
#18 lore raw

PATCH v8 10/17 h8300: Build scripts

In reply to Yoshinori Sato

h8300's Makefile, Kconfig and memory layout.

---
 arch/h8300/Kconfig              |  73 ++++++++++++++++++++++++++
 arch/h8300/Kconfig.cpu          | 111 ++++++++++++++++++++++++++++++++++++++++
 arch/h8300/Makefile             |  45 ++++++++++++++++
 arch/h8300/kernel/Makefile      |  16 ++++++
 arch/h8300/kernel/vmlinux.lds.S |  67 ++++++++++++++++++++++++
 5 files changed, 312 insertions(+)
 create mode 100644 arch/h8300/Kconfig
 create mode 100644 arch/h8300/Kconfig.cpu
 create mode 100644 arch/h8300/Makefile
 create mode 100644 arch/h8300/kernel/Makefile
 create mode 100644 arch/h8300/kernel/vmlinux.lds.S
arch/h8300/Kconfig new file +73 -0
new file mode 100644
index 0000000..9e352e6
@@ -0,0 +1,73 @@
+config H8300
+	bool
+	default y
+	select GENERIC_ATOMIC64
+	select HAVE_UID16
+	select VIRT_TO_BUS
+	select ARCH_WANT_IPC_PARSE_VERSION
+	select GENERIC_IRQ_SHOW
+	select FRAME_POINTER
+	select GENERIC_CPU_DEVICES
+	select MODULES_USE_ELF_RELA
+	select GENERIC_CLOCKEVENTS
+	select CLKDEV_LOOKUP
+	select COMMON_CLK
+	select ARCH_WANT_FRAME_POINTERS
+
+config RWSEM_GENERIC_SPINLOCK
+	def_bool y
+
+config GENERIC_HWEIGHT
+	def_bool y
+
+config GENERIC_CALIBRATE_DELAY
+	def_bool y
+
+config NO_IOPORT_MAP
+	def_bool y
+
+config HZ
+	int
+	default 100
+
+config NR_CPUS
+	int
+	default 1
+
+source "init/Kconfig"
+
+source "kernel/Kconfig.freezer"
+
+source "arch/h8300/Kconfig.cpu"
+
+menu "Kernel Features"
+
+source "kernel/Kconfig.preempt"
+
+source "mm/Kconfig"
+
+endmenu
+
+menu "Executable file formats"
+
+source "fs/Kconfig.binfmt"
+
+endmenu
+
+source "net/Kconfig"
+
+source "drivers/Kconfig"
+
+source "fs/Kconfig"
+
+menu "Kernel hacking"
+
+source "lib/Kconfig.debug"
+
+endmenu
+
+source "security/Kconfig"
+
+source "crypto/Kconfig"
+
+source "lib/Kconfig"
arch/h8300/Kconfig.cpu new file +111 -0

111 lines not on this page · raw message

arch/h8300/Makefile new file +45 -0

45 lines not on this page · raw message

arch/h8300/kernel/Makefile new file +16 -0
new file mode 100644
index 0000000..0b5fe00
@@ -0,0 +1,16 @@
+#
+# Makefile for the linux kernel.
+#
+
+extra-y := vmlinux.lds
+
+obj-y := process.o traps.o ptrace.o \
+	 signal.o setup.o syscalls.o \
+	 irq.o entry.o dma.o cpu/
+
+obj-$(CONFIG_ROMKERNEL) += head_rom.o
+obj-$(CONFIG_RAMKERNEL) += head_ram.o
+
+obj-$(CONFIG_MODULES) += module.o h8300_ksyms.o
+obj-$(CONFIG_H8300H_SIM) += sim-console.o
+obj-$(CONFIG_H8S_SIM) += sim-console.o
arch/h8300/kernel/vmlinux.lds.S new file +67 -0

67 lines not on this page · raw message

Signature · 1 line
2.1.4
#14 lore raw

PATCH v8 6/17 h8300: CPU depend helpers

In reply to Yoshinori Sato

H8/3069 and H8S2678 have little different specification (peripheral, interrupt and trace).
Its difference is absorbed here.

---
 arch/h8300/kernel/cpu/Makefile         |   4 +
 arch/h8300/kernel/cpu/h83069/Makefile  |   1 +
 arch/h8300/kernel/cpu/h83069/setup.c   | 202 ++++++++++++++++++++++++++
 arch/h8300/kernel/cpu/h8s2678/Makefile |   1 +
 arch/h8300/kernel/cpu/h8s2678/setup.c  | 161 +++++++++++++++++++++
 arch/h8300/kernel/cpu/irq_h.c          |  62 ++++++++
 arch/h8300/kernel/cpu/irq_s.c          |  70 +++++++++
 arch/h8300/kernel/cpu/ptrace_h.c       | 256 +++++++++++++++++++++++++++++++++
 arch/h8300/kernel/cpu/ptrace_s.c       |  44 ++++++
 9 files changed, 801 insertions(+)
 create mode 100644 arch/h8300/kernel/cpu/Makefile
 create mode 100644 arch/h8300/kernel/cpu/h83069/Makefile
 create mode 100644 arch/h8300/kernel/cpu/h83069/setup.c
 create mode 100644 arch/h8300/kernel/cpu/h8s2678/Makefile
 create mode 100644 arch/h8300/kernel/cpu/h8s2678/setup.c
 create mode 100644 arch/h8300/kernel/cpu/irq_h.c
 create mode 100644 arch/h8300/kernel/cpu/irq_s.c
 create mode 100644 arch/h8300/kernel/cpu/ptrace_h.c
 create mode 100644 arch/h8300/kernel/cpu/ptrace_s.c
arch/h8300/kernel/cpu/Makefile new file +4 -0
new file mode 100644
index 0000000..684475c
@@ -0,0 +1,4 @@
+obj-$(CONFIG_CPU_H8300H) += ptrace_h.o irq_h.o
+obj-$(CONFIG_CPU_H8S) += ptrace_s.o irq_s.o
+obj-$(CONFIG_H83069) += h83069/
+obj-$(CONFIG_H8S2678) += h8s2678/
arch/h8300/kernel/cpu/h83069/Makefile new file +1 -0
new file mode 100644
index 0000000..49d283e
@@ -0,0 +1 @@
+obj-y = setup.o
arch/h8300/kernel/cpu/h83069/setup.c new file +202 -0

202 lines not on this page · raw message

arch/h8300/kernel/cpu/h8s2678/Makefile new file +1 -0
new file mode 100644
index 0000000..49d283e
@@ -0,0 +1 @@
+obj-y = setup.o
arch/h8300/kernel/cpu/h8s2678/setup.c new file +161 -0

161 lines not on this page · raw message

arch/h8300/kernel/cpu/irq_h.c new file +62 -0

62 lines not on this page · raw message

arch/h8300/kernel/cpu/irq_s.c new file +70 -0

70 lines not on this page · raw message

arch/h8300/kernel/cpu/ptrace_h.c new file +256 -0

256 lines not on this page · raw message

arch/h8300/kernel/cpu/ptrace_s.c new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
2.1.4
#1 lore raw

PATCH v8 1/17 h8300: Assembly headers.

In reply to Yoshinori Sato
---
 arch/h8300/include/asm/Kbuild              |  66 ++++++
 arch/h8300/include/asm/asm-offsets.h       |   1 +
 arch/h8300/include/asm/atomic.h            | 159 +++++++++++++++
 arch/h8300/include/asm/bitops.h            | 185 +++++++++++++++++
 arch/h8300/include/asm/bootparams.h        |  17 ++
 arch/h8300/include/asm/bug.h               |  12 ++
 arch/h8300/include/asm/cache.h             |  11 +
 arch/h8300/include/asm/checksum.h          | 102 ++++++++++
 arch/h8300/include/asm/cmpxchg.h           |  65 ++++++
 arch/h8300/include/asm/delay.h             |  38 ++++
 arch/h8300/include/asm/device.h            |   6 +
 arch/h8300/include/asm/dma-mapping.h       | 124 ++++++++++++
 arch/h8300/include/asm/elf.h               | 101 ++++++++++
 arch/h8300/include/asm/emergency-restart.h |   6 +
 arch/h8300/include/asm/flat.h              |  27 +++
 arch/h8300/include/asm/io.h                | 314 +++++++++++++++++++++++++++++
 arch/h8300/include/asm/irq.h               |  26 +++
 arch/h8300/include/asm/irqflags.h          |  96 +++++++++
 arch/h8300/include/asm/mc146818rtc.h       |   9 +
 arch/h8300/include/asm/mutex.h             |   9 +
 arch/h8300/include/asm/page.h              |  18 ++
 arch/h8300/include/asm/page_offset.h       |   2 +
 arch/h8300/include/asm/pci.h               |  19 ++
 arch/h8300/include/asm/pgtable.h           |  49 +++++
 arch/h8300/include/asm/processor.h         | 144 +++++++++++++
 arch/h8300/include/asm/ptrace.h            |  36 ++++
 arch/h8300/include/asm/segment.h           |  49 +++++
 arch/h8300/include/asm/sh_bios.h           |   4 +
 arch/h8300/include/asm/signal.h            |  22 ++
 arch/h8300/include/asm/smp.h               |   1 +
 arch/h8300/include/asm/spinlock.h          |   6 +
 arch/h8300/include/asm/string.h            |  17 ++
 arch/h8300/include/asm/switch_to.h         |  51 +++++
 arch/h8300/include/asm/syscall.h           |  56 +++++
 arch/h8300/include/asm/thread_info.h       | 119 +++++++++++
 arch/h8300/include/asm/timer.h             |  31 +++
 arch/h8300/include/asm/tlb.h               |   8 +
 arch/h8300/include/asm/topology.h          |   6 +
 arch/h8300/include/asm/traps.h             |  41 ++++
 arch/h8300/include/asm/uaccess.h           | 136 +++++++++++++
 arch/h8300/include/asm/unaligned.h         |  11 +
 arch/h8300/include/asm/user.h              |  74 +++++++
 42 files changed, 2274 insertions(+)
 create mode 100644 arch/h8300/include/asm/Kbuild
 create mode 100644 arch/h8300/include/asm/asm-offsets.h
 create mode 100644 arch/h8300/include/asm/atomic.h
 create mode 100644 arch/h8300/include/asm/bitops.h
 create mode 100644 arch/h8300/include/asm/bootparams.h
 create mode 100644 arch/h8300/include/asm/bug.h
 create mode 100644 arch/h8300/include/asm/cache.h
 create mode 100644 arch/h8300/include/asm/checksum.h
 create mode 100644 arch/h8300/include/asm/cmpxchg.h
 create mode 100644 arch/h8300/include/asm/delay.h
 create mode 100644 arch/h8300/include/asm/device.h
 create mode 100644 arch/h8300/include/asm/dma-mapping.h
 create mode 100644 arch/h8300/include/asm/elf.h
 create mode 100644 arch/h8300/include/asm/emergency-restart.h
 create mode 100644 arch/h8300/include/asm/flat.h
 create mode 100644 arch/h8300/include/asm/io.h
 create mode 100644 arch/h8300/include/asm/irq.h
 create mode 100644 arch/h8300/include/asm/irqflags.h
 create mode 100644 arch/h8300/include/asm/mc146818rtc.h
 create mode 100644 arch/h8300/include/asm/mutex.h
 create mode 100644 arch/h8300/include/asm/page.h
 create mode 100644 arch/h8300/include/asm/page_offset.h
 create mode 100644 arch/h8300/include/asm/pci.h
 create mode 100644 arch/h8300/include/asm/pgtable.h
 create mode 100644 arch/h8300/include/asm/processor.h
 create mode 100644 arch/h8300/include/asm/ptrace.h
 create mode 100644 arch/h8300/include/asm/segment.h
 create mode 100644 arch/h8300/include/asm/sh_bios.h
 create mode 100644 arch/h8300/include/asm/signal.h
 create mode 100644 arch/h8300/include/asm/smp.h
 create mode 100644 arch/h8300/include/asm/spinlock.h
 create mode 100644 arch/h8300/include/asm/string.h
 create mode 100644 arch/h8300/include/asm/switch_to.h
 create mode 100644 arch/h8300/include/asm/syscall.h
 create mode 100644 arch/h8300/include/asm/thread_info.h
 create mode 100644 arch/h8300/include/asm/timer.h
 create mode 100644 arch/h8300/include/asm/tlb.h
 create mode 100644 arch/h8300/include/asm/topology.h
 create mode 100644 arch/h8300/include/asm/traps.h
 create mode 100644 arch/h8300/include/asm/uaccess.h
 create mode 100644 arch/h8300/include/asm/unaligned.h
 create mode 100644 arch/h8300/include/asm/user.h
arch/h8300/include/asm/Kbuild new file +66 -0
new file mode 100644
index 0000000..9e9f4f3
@@ -0,0 +1,66 @@
+generic-y += barrier.h
+generic-y += bitsperlong.h
+generic-y += bugs.h
+generic-y += cacheflush.h
+generic-y += clkdev.h
+generic-y += cputime.h
+generic-y += current.h
+generic-y += div64.h
+generic-y += dma.h
+generic-y += emergency-restart.h
+generic-y += errno.h
+generic-y += exec.h
+generic-y += fb.h
+generic-y += fcntl.h
+generic-y += ftrace.h
+generic-y += futex.h
+generic-y += hardirq.h
+generic-y += hash.h
+generic-y += hw_irq.h
+generic-y += ioctl.h
+generic-y += ioctls.h
+generic-y += ipcbuf.h
+generic-y += irq_regs.h
+generic-y += irq_work.h
+generic-y += kdebug.h
+generic-y += kmap_types.h
+generic-y += kvm_para.h
+generic-y += linkage.h
+generic-y += local.h
+generic-y += local64.h
+generic-y += mcs_spinlock.h
+generic-y += mman.h
+generic-y += mmu.h
+generic-y += mmu_context.h
+generic-y += module.h
+generic-y += msgbuf.h
+generic-y += param.h
+generic-y += parport.h
+generic-y += percpu.h
+generic-y += pgalloc.h
+generic-y += poll.h
+generic-y += posix_types.h
+generic-y += preempt.h
+generic-y += resource.h
+generic-y += scatterlist.h
+generic-y += sections.h
+generic-y += sembuf.h
+generic-y += serial.h
+generic-y += setup.h
+generic-y += shmbuf.h
+generic-y += shmparam.h
+generic-y += siginfo.h
+generic-y += sizes.h
+generic-y += socket.h
+generic-y += sockios.h
+generic-y += stat.h
+generic-y += statfs.h
+generic-y += termbits.h
+generic-y += termios.h
+generic-y += timex.h
+generic-y += tlbflush.h
+generic-y += trace_clock.h
+generic-y += types.h
+generic-y += ucontext.h
+generic-y += vga.h
+generic-y += xor.h
arch/h8300/include/asm/asm-offsets.h new file +1 -0
new file mode 100644
index 0000000..d370ee3
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
arch/h8300/include/asm/atomic.h new file +159 -0

159 lines not on this page · raw message

arch/h8300/include/asm/bitops.h new file +185 -0

185 lines not on this page · raw message

arch/h8300/include/asm/bootparams.h new file +17 -0
new file mode 100644
index 0000000..6c0b145
@@ -0,0 +1,17 @@
+/*
+H8/300 kernel boot parameters
+*/
+
+#ifndef __ASM_H8300_BOOTPARAMS__
+#define __ASM_H8300_BOOTPARAMS__
+
+struct bootparams {
+	short size;
+	unsigned char gpio_ddr[24];
+	unsigned char gpio_use[24];
+	unsigned int clock_freq;
+	unsigned int ram_end;
+	unsigned char *command_line;
+} __packed __aligned(2);
+
+#endif
arch/h8300/include/asm/bug.h new file +12 -0
new file mode 100644
index 0000000..1e1be81
@@ -0,0 +1,12 @@
+#ifndef _H8300_BUG_H
+#define _H8300_BUG_H
+
+/* always true */
+#define is_valid_bugaddr(addr) (1)
+
+#include <asm-generic/bug.h>
+
+struct pt_regs;
+extern void die(const char *str, struct pt_regs *fp, unsigned long err);
+
+#endif
arch/h8300/include/asm/cache.h new file +11 -0
new file mode 100644
index 0000000..0ef1edc
@@ -0,0 +1,11 @@
+#ifndef __ARCH_H8300_CACHE_H
+#define __ARCH_H8300_CACHE_H
+
+/* bytes per L1 cache line */
+#define        L1_CACHE_SHIFT  2
+#define        L1_CACHE_BYTES  (1 << L1_CACHE_SHIFT)
+
+#define __cacheline_aligned
+#define ____cacheline_aligned
+
+#endif
arch/h8300/include/asm/checksum.h new file +102 -0

102 lines not on this page · raw message

arch/h8300/include/asm/cmpxchg.h new file +65 -0

65 lines not on this page · raw message

arch/h8300/include/asm/delay.h new file +38 -0
new file mode 100644
index 0000000..2bdde59
@@ -0,0 +1,38 @@
+#ifndef _H8300_DELAY_H
+#define _H8300_DELAY_H
+
+#include <asm/param.h>
+
+/*
+ * Copyright (C) 2002 Yoshinori Sato <[email protected]>
+ *
+ * Delay routines, using a pre-computed "loops_per_second" value.
+ */
+
+static inline void __delay(unsigned long loops)
+{
+	__asm__ __volatile__ ("1:\n\t"
+			      "dec.l #1,%0\n\t"
+			      "bne 1b"
+			      : "=r" (loops) : "0"(loops));
+}
+
+/*
+ * Use only for very small delays ( < 1 msec).  Should probably use a
+ * lookup table, really, as the multiplications take much too long with
+ * short delays.  This is a "reasonable" implementation, though (and the
+ * first constant multiplications gets optimized away if the delay is
+ * a constant)
+ */
+
+extern unsigned long loops_per_jiffy;
+
+static inline void udelay(unsigned long usecs)
+{
+	usecs *= 4295;		/* 2**32 / 1000000 */
+	usecs /= (loops_per_jiffy*HZ);
+	if (usecs)
+		__delay(usecs);
+}
+
+#endif /* _H8300_DELAY_H */
arch/h8300/include/asm/device.h new file +6 -0
new file mode 100644
index 0000000..06746c5
@@ -0,0 +1,6 @@
+/*
+ * Arch specific extensions to struct device
+ *
+ * This file is released under the GPLv2
+ */
+#include <asm-generic/device.h>
arch/h8300/include/asm/dma-mapping.h new file +124 -0

124 lines not on this page · raw message

arch/h8300/include/asm/elf.h new file +101 -0

101 lines not on this page · raw message

arch/h8300/include/asm/emergency-restart.h new file +6 -0
new file mode 100644
index 0000000..108d8c4
@@ -0,0 +1,6 @@
+#ifndef _ASM_EMERGENCY_RESTART_H
+#define _ASM_EMERGENCY_RESTART_H
+
+#include <asm-generic/emergency-restart.h>
+
+#endif /* _ASM_EMERGENCY_RESTART_H */
arch/h8300/include/asm/flat.h new file +27 -0
new file mode 100644
index 0000000..9ff092e
@@ -0,0 +1,27 @@
+/*
+ * arch/h8300/asm/include/flat.h -- uClinux flat-format executables
+ */
+
+#ifndef __H8300_FLAT_H__
+#define __H8300_FLAT_H__
+
+#define	flat_argvp_envp_on_stack()		1
+#define	flat_old_ram_flag(flags)		1
+#define	flat_reloc_valid(reloc, size)		((reloc) <= (size))
+#define	flat_set_persistent(relval, p)		0
+
+/*
+ * on the H8 a couple of the relocations have an instruction in the
+ * top byte.  As there can only be 24bits of address space,  we just
+ * always preserve that 8bits at the top,  when it isn't an instruction
+ * is is 0 ([email protected])
+ */
+
+#define	flat_get_relocate_addr(rel)		(rel & ~0x00000001)
+#define flat_get_addr_from_rp(rp, relval, flags, persistent) \
+	(get_unaligned(rp) & (((flags) & FLAT_FLAG_GOTPIC) ? \
+			      0xffffffff : 0x00ffffff))
+#define flat_put_addr_at_rp(rp, addr, rel) \
+	put_unaligned(((*(char *)(rp)) << 24) | ((addr) & 0x00ffffff), (rp))
+
+#endif /* __H8300_FLAT_H__ */
arch/h8300/include/asm/io.h new file +314 -0

314 lines not on this page · raw message

arch/h8300/include/asm/irq.h new file +26 -0
new file mode 100644
index 0000000..69f23f0
@@ -0,0 +1,26 @@
+#ifndef _H8300_IRQ_H_
+#define _H8300_IRQ_H_
+
+#include <linux/irqchip.h>
+
+#if defined(CONFIG_CPU_H8300H)
+#define NR_IRQS 64
+#define IRQ_CHIP h8300h_irq_chip
+#define EXT_IRQ0 12
+#define EXT_IRQS 6
+#elif defined(CONFIG_CPU_H8S)
+#define NR_IRQS 128
+#define IRQ_CHIP h8s_irq_chip
+#define EXT_IRQ0 16
+#define EXT_IRQS 16
+#endif
+
+static inline int irq_canonicalize(int irq)
+{
+	return irq;
+}
+
+void h8300_init_ipr(void);
+extern struct irq_chip h8300h_irq_chip;
+extern struct irq_chip h8s_irq_chip;
+#endif /* _H8300_IRQ_H_ */
arch/h8300/include/asm/irqflags.h new file +96 -0

96 lines not on this page · raw message

arch/h8300/include/asm/mc146818rtc.h new file +9 -0
new file mode 100644
index 0000000..ab9d964
@@ -0,0 +1,9 @@
+/*
+ * Machine dependent access functions for RTC registers.
+ */
+#ifndef _H8300_MC146818RTC_H
+#define _H8300_MC146818RTC_H
+
+/* empty include file to satisfy the include in genrtc.c/ide-geometry.c */
+
+#endif /* _H8300_MC146818RTC_H */
arch/h8300/include/asm/mutex.h new file +9 -0
new file mode 100644
index 0000000..458c1f7
@@ -0,0 +1,9 @@
+/*
+ * Pull in the generic implementation for the mutex fastpath.
+ *
+ * TODO: implement optimized primitives instead, or leave the generic
+ * implementation in place, or pick the atomic_xchg() based generic
+ * implementation. (see asm-generic/mutex-xchg.h for details)
+ */
+
+#include <asm-generic/mutex-dec.h>
arch/h8300/include/asm/page.h new file +18 -0
new file mode 100644
index 0000000..3a987a5
@@ -0,0 +1,18 @@
+#ifndef _H8300_PAGE_H
+#define _H8300_PAGE_H
+
+#include <asm-generic/page.h>
+#include <linux/types.h>
+
+#define MAP_NR(addr) (((uintptr_t)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
+#define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
+				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
+
+#ifndef __ASSEMBLY__
+extern unsigned long rom_length;
+extern unsigned long memory_start;
+extern unsigned long memory_end;
+extern unsigned long _ramend;
+#endif
+
+#endif
arch/h8300/include/asm/page_offset.h new file +2 -0
new file mode 100644
index 0000000..888576d
@@ -0,0 +1,2 @@
+
+#define PAGE_OFFSET_RAW		0x00000000
arch/h8300/include/asm/pci.h new file +19 -0
new file mode 100644
index 0000000..0b2acaa
@@ -0,0 +1,19 @@
+#ifndef _ASM_H8300_PCI_H
+#define _ASM_H8300_PCI_H
+
+/*
+ * asm-h8300/pci.h - H8/300 specific PCI declarations.
+ *
+ * Yoshinori Sato <[email protected]>
+ */
+
+#define pcibios_assign_all_busses()	0
+
+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_H8300_PCI_H */
arch/h8300/include/asm/pgtable.h new file +49 -0

49 lines not on this page · raw message

arch/h8300/include/asm/processor.h new file +144 -0

144 lines not on this page · raw message

arch/h8300/include/asm/ptrace.h new file +36 -0
new file mode 100644
index 0000000..e693fb4
@@ -0,0 +1,36 @@
+#ifndef _H8300_PTRACE_H
+#define _H8300_PTRACE_H
+
+#include <uapi/asm/ptrace.h>
+
+#ifndef __ASSEMBLY__
+#ifndef PS_S
+#define PS_S  (0x10)
+#endif
+
+#if defined(CONFIG_CPU_H8300H)
+#define H8300_REGS_NO 11
+#endif
+#if defined(CONFIG_CPU_H8S)
+#define H8300_REGS_NO 12
+#endif
+
+#define arch_has_single_step()	(1)
+
+#define user_mode(regs) (!((regs)->ccr & PS_S))
+#define instruction_pointer(regs) ((regs)->pc)
+#define profile_pc(regs) instruction_pointer(regs)
+#define user_stack_pointer(regs) ((regs)->sp)
+#define current_pt_regs() ((struct pt_regs *) \
+	(THREAD_SIZE + (unsigned long)current_thread_info()) - 1)
+#define signal_pt_regs() ((struct pt_regs *)current->thread.esp0)
+#define current_user_stack_pointer() rdusp()
+#define task_pt_regs(task) \
+	((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE) - 1)
+
+extern long h8300_get_reg(struct task_struct *task, int regno);
+extern int h8300_put_reg(struct task_struct *task, int regno,
+			 unsigned long data);
+
+#endif /* __ASSEMBLY__ */
+#endif /* _H8300_PTRACE_H */
arch/h8300/include/asm/segment.h new file +49 -0

49 lines not on this page · raw message

arch/h8300/include/asm/sh_bios.h new file +4 -0
new file mode 100644
index 0000000..9ce513c
@@ -0,0 +1,4 @@
+#ifndef SH_BIOS_H
+#define SH_BIOS_H
+
+#endif
arch/h8300/include/asm/signal.h new file +22 -0
new file mode 100644
index 0000000..5870835
@@ -0,0 +1,22 @@
+#ifndef _H8300_SIGNAL_H
+#define _H8300_SIGNAL_H
+
+#include <uapi/asm/signal.h>
+
+/* Most things should be clean enough to redefine this at will, if care
+   is taken to make libc match.  */
+
+#define _NSIG		64
+#define _NSIG_BPW	32
+#define _NSIG_WORDS	(_NSIG / _NSIG_BPW)
+
+typedef unsigned long old_sigset_t;		/* at least 32 bits */
+
+typedef struct {
+	unsigned long sig[_NSIG_WORDS];
+} sigset_t;
+
+#define __ARCH_HAS_SA_RESTORER
+#include <asm/sigcontext.h>
+
+#endif /* _H8300_SIGNAL_H */
arch/h8300/include/asm/smp.h new file +1 -0
new file mode 100644
index 0000000..9e9bd7e
@@ -0,0 +1 @@
+/* nothing required here yet */
arch/h8300/include/asm/spinlock.h new file +6 -0
new file mode 100644
index 0000000..d5407fa
@@ -0,0 +1,6 @@
+#ifndef __H8300_SPINLOCK_H
+#define __H8300_SPINLOCK_H
+
+#error "H8/300 doesn't do SMP yet"
+
+#endif
arch/h8300/include/asm/string.h new file +17 -0
new file mode 100644
index 0000000..5dc5a8a
@@ -0,0 +1,17 @@
+#ifndef _H8300_STRING_H_
+#define _H8300_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);
+
+#endif /* KERNEL */
+
+#endif
arch/h8300/include/asm/switch_to.h new file +51 -0

51 lines not on this page · raw message

arch/h8300/include/asm/syscall.h new file +56 -0

56 lines not on this page · raw message

arch/h8300/include/asm/thread_info.h new file +119 -0

119 lines not on this page · raw message

arch/h8300/include/asm/timer.h new file +31 -0
new file mode 100644
index 0000000..c905f4e
@@ -0,0 +1,31 @@
+#ifndef __H8300_TIMER_H
+#define __H8300_TIMER_H
+
+unsigned long get_cpu_clock(void);
+
+#define H8300_TIMER_FREQ get_cpu_clock() /* Timer input freq. */
+
+#define H8300_TMR8_CLKSRC    0
+#define H8300_TMR8_CLKEVTDEV 1
+
+#define H8300_TMR8_DIV_8 0
+#define H8300_TMR8_DIV_64 1
+#define H8300_TMR8_DIV_8192 2
+
+struct h8300_timer8_config {
+	int mode;
+	int div;
+	int rating;
+};
+
+struct h8300_timer16_config {
+	int rating;
+	__u8 enb;
+	__u8 imfa;
+	__u8 imiea;
+};
+
+struct h8300_tpu_config {
+	int rating;
+};
+#endif
arch/h8300/include/asm/tlb.h new file +8 -0
new file mode 100644
index 0000000..2c6fa4ee
@@ -0,0 +1,8 @@
+#ifndef __H8300_TLB_H__
+#define __H8300_TLB_H__
+
+#define tlb_flush(tlb)	do { } while (0)
+
+#include <asm-generic/tlb.h>
+
+#endif
arch/h8300/include/asm/topology.h new file +6 -0
new file mode 100644
index 0000000..fdc1219
@@ -0,0 +1,6 @@
+#ifndef _ASM_H8300_TOPOLOGY_H
+#define _ASM_H8300_TOPOLOGY_H
+
+#include <asm-generic/topology.h>
+
+#endif /* _ASM_H8300_TOPOLOGY_H */
arch/h8300/include/asm/traps.h new file +41 -0

41 lines not on this page · raw message

arch/h8300/include/asm/uaccess.h new file +136 -0

136 lines not on this page · raw message

arch/h8300/include/asm/unaligned.h new file +11 -0
new file mode 100644
index 0000000..b8d06c7
@@ -0,0 +1,11 @@
+#ifndef _ASM_H8300_UNALIGNED_H
+#define _ASM_H8300_UNALIGNED_H
+
+#include <linux/unaligned/be_memmove.h>
+#include <linux/unaligned/le_byteshift.h>
+#include <linux/unaligned/generic.h>
+
+#define get_unaligned	__get_unaligned_be
+#define put_unaligned	__put_unaligned_be
+
+#endif /* _ASM_H8300_UNALIGNED_H */
arch/h8300/include/asm/user.h new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
2.1.4
#12 lore raw

PATCH v8 4/17 h8300: kernel booting

In reply to Yoshinori Sato

zImage startup / kernel entry point / arch depend startup

---
 arch/h8300/boot/Makefile               |  26 +++++
 arch/h8300/boot/compressed/Makefile    |  37 +++++++
 arch/h8300/boot/compressed/head.S      |  48 +++++++++
 arch/h8300/boot/compressed/misc.c      |  74 ++++++++++++++
 arch/h8300/boot/compressed/vmlinux.lds |  32 ++++++
 arch/h8300/boot/compressed/vmlinux.scr |   9 ++
 arch/h8300/kernel/head_ram.S           |  60 ++++++++++++
 arch/h8300/kernel/head_rom.S           | 108 ++++++++++++++++++++
 arch/h8300/kernel/setup.c              | 174 +++++++++++++++++++++++++++++++++
 9 files changed, 568 insertions(+)
 create mode 100644 arch/h8300/boot/Makefile
 create mode 100644 arch/h8300/boot/compressed/Makefile
 create mode 100644 arch/h8300/boot/compressed/head.S
 create mode 100644 arch/h8300/boot/compressed/misc.c
 create mode 100644 arch/h8300/boot/compressed/vmlinux.lds
 create mode 100644 arch/h8300/boot/compressed/vmlinux.scr
 create mode 100644 arch/h8300/kernel/head_ram.S
 create mode 100644 arch/h8300/kernel/head_rom.S
 create mode 100644 arch/h8300/kernel/setup.c
arch/h8300/boot/Makefile new file +26 -0
new file mode 100644
index 0000000..2f6393a
@@ -0,0 +1,26 @@
+# arch/h8300/boot/Makefile
+
+targets := vmlinux.srec vmlinux.bin zImage
+subdir- := compressed
+
+OBJCOPYFLAGS_vmlinux.srec := -Osrec
+OBJCOPYFLAGS_vmlinux.bin  := -Obinary
+OBJCOPYFLAGS_zImage := -O binary -R .note -R .comment -R .stab -R .stabstr -S
+
+UIMAGE_LOADADDR = $(CONFIG_RAMBASE)
+UIMAGE_ENTRYADDR = $(shell /bin/bash -c 'printf "0x%08x" \
+	$$[$(CONFIG_RAMBASE) + $(CONFIG_OFFSET)]')
+
+$(obj)/vmlinux.srec $(obj)/vmlinux.bin:  vmlinux FORCE
+	$(call if_changed,objcopy)
+
+$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
+	$(call if_changed,objcopy)
+
+$(obj)/compressed/vmlinux: FORCE
+	$(Q)$(MAKE) $(build)=$(obj)/compressed $@
+
+$(obj)/uImage.bin: $(obj)/vmlinux.bin
+	$(call if_changed,uimage,none)
+
+CLEAN_FILES += arch/$(ARCH)/vmlinux.bin arch/$(ARCH)/vmlinux.srec arch/$(ARCH)/uImage.bin
arch/h8300/boot/compressed/Makefile new file +37 -0
new file mode 100644
index 0000000..87d03b7
@@ -0,0 +1,37 @@
+#
+# linux/arch/sh/boot/compressed/Makefile
+#
+# create a compressed vmlinux image from the original vmlinux
+#
+
+targets		:= vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
+
+OBJECTS = $(obj)/head.o $(obj)/misc.o
+
+#
+# IMAGE_OFFSET is the load offset of the compression loader
+# Assign dummy values if these 2 variables are not defined,
+# in order to suppress error message.
+#
+CONFIG_MEMORY_START     ?= 0x00400000
+CONFIG_BOOT_LINK_OFFSET ?= 0x00140000
+IMAGE_OFFSET := $(shell printf "0x%08x" $$(($(CONFIG_MEMORY_START)+$(CONFIG_BOOT_LINK_OFFSET))))
+
+LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
+LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -estartup $(obj)/vmlinux.lds
+
+$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(LIBGCC) FORCE
+	$(call if_changed,ld)
+	@:
+
+$(obj)/vmlinux.bin: vmlinux FORCE
+	$(call if_changed,objcopy)
+
+$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
+	$(call if_changed,gzip)
+
+LDFLAGS_piggy.o := -r --format binary --oformat elf32-h8300-linux -T
+OBJCOPYFLAGS := -O binary
+
+$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
+	$(call if_changed,ld)
arch/h8300/boot/compressed/head.S new file +48 -0

48 lines not on this page · raw message

arch/h8300/boot/compressed/misc.c new file +74 -0

74 lines not on this page · raw message

arch/h8300/boot/compressed/vmlinux.lds new file +32 -0
new file mode 100644
index 0000000..a0a3a0e
@@ -0,0 +1,32 @@
+SECTIONS
+{
+        .text :
+        {
+        __stext = . ;
+	__text = .;
+	       *(.text..startup)
+	       *(.text)
+        __etext = . ;
+        }
+
+	.rodata :
+	{
+		*(.rodata)
+	}
+        .data :
+
+        {
+        __sdata = . ;
+        ___data_start = . ;
+                *(.data.*)
+	}
+        .bss :
+        {
+        . = ALIGN(0x4) ;
+        __sbss = . ;
+                *(.bss*)
+        . = ALIGN(0x4) ;
+        __ebss = . ;
+        __end = . ;
+        }
+}
arch/h8300/boot/compressed/vmlinux.scr new file +9 -0
new file mode 100644
index 0000000..a0849036
@@ -0,0 +1,9 @@
+SECTIONS
+{
+  .data : {
+	input_len = .;
+	LONG(input_data_end - input_data) input_data = .;
+	*(.data)
+	input_data_end = .;
+	}
+}
arch/h8300/kernel/head_ram.S new file +60 -0

60 lines not on this page · raw message

arch/h8300/kernel/head_rom.S new file +108 -0

108 lines not on this page · raw message

arch/h8300/kernel/setup.c new file +174 -0

174 lines not on this page · raw message

Signature · 1 line
2.1.4
#2 lore raw

Re: [PATCH v8 01/17] h8300: Assembly headers.

In reply to Yoshinori Sato

dOn Mon, Apr 20, 2015 at 8:13 AM, Yoshinori Sato

Quoted 2,159 lines · <[email protected]> wrote:
---
 arch/h8300/include/asm/Kbuild              |  66 ++++++
 arch/h8300/include/asm/asm-offsets.h       |   1 +
 arch/h8300/include/asm/atomic.h            | 159 +++++++++++++++
 arch/h8300/include/asm/bitops.h            | 185 +++++++++++++++++
 arch/h8300/include/asm/bootparams.h        |  17 ++
 arch/h8300/include/asm/bug.h               |  12 ++
 arch/h8300/include/asm/cache.h             |  11 +
 arch/h8300/include/asm/checksum.h          | 102 ++++++++++
 arch/h8300/include/asm/cmpxchg.h           |  65 ++++++
 arch/h8300/include/asm/delay.h             |  38 ++++
 arch/h8300/include/asm/device.h            |   6 +
 arch/h8300/include/asm/dma-mapping.h       | 124 ++++++++++++
 arch/h8300/include/asm/elf.h               | 101 ++++++++++
 arch/h8300/include/asm/emergency-restart.h |   6 +
 arch/h8300/include/asm/flat.h              |  27 +++
 arch/h8300/include/asm/io.h                | 314 +++++++++++++++++++++++++++++
 arch/h8300/include/asm/irq.h               |  26 +++
 arch/h8300/include/asm/irqflags.h          |  96 +++++++++
 arch/h8300/include/asm/mc146818rtc.h       |   9 +
 arch/h8300/include/asm/mutex.h             |   9 +
 arch/h8300/include/asm/page.h              |  18 ++
 arch/h8300/include/asm/page_offset.h       |   2 +
 arch/h8300/include/asm/pci.h               |  19 ++
 arch/h8300/include/asm/pgtable.h           |  49 +++++
 arch/h8300/include/asm/processor.h         | 144 +++++++++++++
 arch/h8300/include/asm/ptrace.h            |  36 ++++
 arch/h8300/include/asm/segment.h           |  49 +++++
 arch/h8300/include/asm/sh_bios.h           |   4 +
 arch/h8300/include/asm/signal.h            |  22 ++
 arch/h8300/include/asm/smp.h               |   1 +
 arch/h8300/include/asm/spinlock.h          |   6 +
 arch/h8300/include/asm/string.h            |  17 ++
 arch/h8300/include/asm/switch_to.h         |  51 +++++
 arch/h8300/include/asm/syscall.h           |  56 +++++
 arch/h8300/include/asm/thread_info.h       | 119 +++++++++++
 arch/h8300/include/asm/timer.h             |  31 +++
 arch/h8300/include/asm/tlb.h               |   8 +
 arch/h8300/include/asm/topology.h          |   6 +
 arch/h8300/include/asm/traps.h             |  41 ++++
 arch/h8300/include/asm/uaccess.h           | 136 +++++++++++++
 arch/h8300/include/asm/unaligned.h         |  11 +
 arch/h8300/include/asm/user.h              |  74 +++++++
 42 files changed, 2274 insertions(+)
 create mode 100644 arch/h8300/include/asm/Kbuild
 create mode 100644 arch/h8300/include/asm/asm-offsets.h
 create mode 100644 arch/h8300/include/asm/atomic.h
 create mode 100644 arch/h8300/include/asm/bitops.h
 create mode 100644 arch/h8300/include/asm/bootparams.h
 create mode 100644 arch/h8300/include/asm/bug.h
 create mode 100644 arch/h8300/include/asm/cache.h
 create mode 100644 arch/h8300/include/asm/checksum.h
 create mode 100644 arch/h8300/include/asm/cmpxchg.h
 create mode 100644 arch/h8300/include/asm/delay.h
 create mode 100644 arch/h8300/include/asm/device.h
 create mode 100644 arch/h8300/include/asm/dma-mapping.h
 create mode 100644 arch/h8300/include/asm/elf.h
 create mode 100644 arch/h8300/include/asm/emergency-restart.h
 create mode 100644 arch/h8300/include/asm/flat.h
 create mode 100644 arch/h8300/include/asm/io.h
 create mode 100644 arch/h8300/include/asm/irq.h
 create mode 100644 arch/h8300/include/asm/irqflags.h
 create mode 100644 arch/h8300/include/asm/mc146818rtc.h
 create mode 100644 arch/h8300/include/asm/mutex.h
 create mode 100644 arch/h8300/include/asm/page.h
 create mode 100644 arch/h8300/include/asm/page_offset.h
 create mode 100644 arch/h8300/include/asm/pci.h
 create mode 100644 arch/h8300/include/asm/pgtable.h
 create mode 100644 arch/h8300/include/asm/processor.h
 create mode 100644 arch/h8300/include/asm/ptrace.h
 create mode 100644 arch/h8300/include/asm/segment.h
 create mode 100644 arch/h8300/include/asm/sh_bios.h
 create mode 100644 arch/h8300/include/asm/signal.h
 create mode 100644 arch/h8300/include/asm/smp.h
 create mode 100644 arch/h8300/include/asm/spinlock.h
 create mode 100644 arch/h8300/include/asm/string.h
 create mode 100644 arch/h8300/include/asm/switch_to.h
 create mode 100644 arch/h8300/include/asm/syscall.h
 create mode 100644 arch/h8300/include/asm/thread_info.h
 create mode 100644 arch/h8300/include/asm/timer.h
 create mode 100644 arch/h8300/include/asm/tlb.h
 create mode 100644 arch/h8300/include/asm/topology.h
 create mode 100644 arch/h8300/include/asm/traps.h
 create mode 100644 arch/h8300/include/asm/uaccess.h
 create mode 100644 arch/h8300/include/asm/unaligned.h
 create mode 100644 arch/h8300/include/asm/user.h
arch/h8300/include/asm/Kbuild new file +66 -0
new file mode 100644
index 0000000..9e9f4f3
@@ -0,0 +1,66 @@
+generic-y += barrier.h
+generic-y += bitsperlong.h
+generic-y += bugs.h
+generic-y += cacheflush.h
+generic-y += clkdev.h
+generic-y += cputime.h
+generic-y += current.h
+generic-y += div64.h
+generic-y += dma.h
+generic-y += emergency-restart.h
+generic-y += errno.h
+generic-y += exec.h
+generic-y += fb.h
+generic-y += fcntl.h
+generic-y += ftrace.h
+generic-y += futex.h
+generic-y += hardirq.h
+generic-y += hash.h
+generic-y += hw_irq.h
+generic-y += ioctl.h
+generic-y += ioctls.h
+generic-y += ipcbuf.h
+generic-y += irq_regs.h
+generic-y += irq_work.h
+generic-y += kdebug.h
+generic-y += kmap_types.h
+generic-y += kvm_para.h
+generic-y += linkage.h
+generic-y += local.h
+generic-y += local64.h
+generic-y += mcs_spinlock.h
+generic-y += mman.h
+generic-y += mmu.h
+generic-y += mmu_context.h
+generic-y += module.h
+generic-y += msgbuf.h
+generic-y += param.h
+generic-y += parport.h
+generic-y += percpu.h
+generic-y += pgalloc.h
+generic-y += poll.h
+generic-y += posix_types.h
+generic-y += preempt.h
+generic-y += resource.h
+generic-y += scatterlist.h
+generic-y += sections.h
+generic-y += sembuf.h
+generic-y += serial.h
+generic-y += setup.h
+generic-y += shmbuf.h
+generic-y += shmparam.h
+generic-y += siginfo.h
+generic-y += sizes.h
+generic-y += socket.h
+generic-y += sockios.h
+generic-y += stat.h
+generic-y += statfs.h
+generic-y += termbits.h
+generic-y += termios.h
+generic-y += timex.h
+generic-y += tlbflush.h
+generic-y += trace_clock.h
+generic-y += types.h
+generic-y += ucontext.h
+generic-y += vga.h
+generic-y += xor.h
arch/h8300/include/asm/asm-offsets.h new file +1 -0
new file mode 100644
index 0000000..d370ee3
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
arch/h8300/include/asm/atomic.h new file +159 -0
new file mode 100644
index 0000000..7ca73f8
@@ -0,0 +1,159 @@
+#ifndef __ARCH_H8300_ATOMIC__
+#define __ARCH_H8300_ATOMIC__
+
+#include <linux/types.h>
+#include <asm/cmpxchg.h>
+
+/*
+ * Atomic operations that C can't guarantee us.  Useful for
+ * resource counting etc..
+ */
+
+#define ATOMIC_INIT(i) { (i) }
+
+#define atomic_read(v)         ACCESS_ONCE((v)->counter)
+#define atomic_set(v, i)       (((v)->counter) = i)
+
+#include <linux/kernel.h>
+
+static inline int atomic_add_return(int i, atomic_t *v)
+{
+       h8300flags flags;
+       int ret;
+
+       flags = arch_local_irq_save();
+       ret = v->counter += i;
+       arch_local_irq_restore(flags);
+       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)
+{
+       h8300flags flags;
+       int ret;
+
+       flags = arch_local_irq_save();
+       ret = v->counter -= i;
+       arch_local_irq_restore(flags);
+       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)
+{
+       h8300flags flags;
+       int ret;
+
+       flags = arch_local_irq_save();
+       v->counter++;
+       ret = v->counter;
+       arch_local_irq_restore(flags);
+       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)
+{
+       h8300flags flags;
+       int ret;
+
+       flags = arch_local_irq_save();
+       --v->counter;
+       ret = v->counter;
+       arch_local_irq_restore(flags);
+       return ret;
+}
+
+#define atomic_dec(v) atomic_dec_return(v)
+
+static inline int atomic_dec_and_test(atomic_t *v)
+{
+       h8300flags flags;
+       int ret;
+
+       flags = arch_local_irq_save();
+       --v->counter;
+       ret = v->counter;
+       arch_local_irq_restore(flags);
+       return ret == 0;
+}
+
+static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
+{
+       int ret;
+       h8300flags flags;
+
+       flags = arch_local_irq_save();
+       ret = v->counter;
+       if (likely(ret == old))
+               v->counter = new;
+       arch_local_irq_restore(flags);
+       return ret;
+}
+
+static inline int __atomic_add_unless(atomic_t *v, int a, int u)
+{
+       int ret;
+       h8300flags flags;
+
+       flags = arch_local_irq_save();
+       ret = v->counter;
+       if (ret != u)
+               v->counter += a;
+       arch_local_irq_restore(flags);
+       return ret;
+}
+
+static inline void atomic_clear_mask(unsigned long mask, unsigned long *v)
+{
+       unsigned char ccr;
+       unsigned long tmp;
+
+       __asm__ __volatile__("stc ccr,%w3\n\t"
+                            "orc #0x80,ccr\n\t"
+                            "mov.l %0,%1\n\t"
+                            "and.l %2,%1\n\t"
+                            "mov.l %1,%0\n\t"
+                            "ldc %w3,ccr"
+                            : "=m"(*v), "=r"(tmp)
+                            : "g"(~(mask)), "r"(ccr));
+}
+
+static inline void atomic_set_mask(unsigned long mask, unsigned long *v)
+{
+       unsigned char ccr;
+       unsigned long tmp;
+
+       __asm__ __volatile__("stc ccr,%w3\n\t"
+                            "orc #0x80,ccr\n\t"
+                            "mov.l %0,%1\n\t"
+                            "or.l %2,%1\n\t"
+                            "mov.l %1,%0\n\t"
+                            "ldc %w3,ccr"
+                            : "=m"(*v), "=r"(tmp)
+                            : "g"(~(mask)), "r"(ccr));
+}
+
+/* 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 /* __ARCH_H8300_ATOMIC __ */
arch/h8300/include/asm/bitops.h new file +185 -0
new file mode 100644
index 0000000..05999ab
@@ -0,0 +1,185 @@
+#ifndef _H8300_BITOPS_H
+#define _H8300_BITOPS_H
+
+/*
+ * Copyright 1992, Linus Torvalds.
+ * Copyright 2002, Yoshinori Sato
+ */
+
+#include <linux/compiler.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;
+
+       result = -1;
+       __asm__("1:\n\t"
+               "shlr.l %2\n\t"
+               "adds #1,%0\n\t"
+               "bcs 1b"
+               : "=r"(result)
+               : "0"(result), "r"(word));
+       return result;
+}
+
+#define H8300_GEN_BITOP(FNAME, OP)                             \
+static inline void FNAME(int nr, volatile unsigned long *addr) \
+{                                                              \
+       unsigned char *b_addr;                                  \
+       unsigned char bit = nr & 7;                             \
+                                                               \
+       b_addr = (unsigned char *)addr + ((nr >> 3) ^ 3);       \
+       if (__builtin_constant_p(nr)) {                         \
+               __asm__(OP " %1,%0" : "+WU"(*b_addr) : "i"(nr & 7));    \
+       } else {                                                \
+               __asm__(OP " %s1,%0" : "+WU"(*b_addr) : "r"(bit));      \
+       }                                                       \
+}
+
+/*
+ * clear_bit() doesn't provide any barrier for the compiler.
+ */
+#define smp_mb__before_clear_bit()     barrier()
+#define smp_mb__after_clear_bit()      barrier()
+
+H8300_GEN_BITOP(set_bit,    "bset")
+H8300_GEN_BITOP(clear_bit,  "bclr")
+H8300_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 H8300_GEN_BITOP
+
+static inline int test_bit(int nr, const unsigned long *addr)
+{
+       int ret = 0;
+       unsigned char *b_addr;
+       unsigned char bit = nr & 7;
+
+       b_addr = (unsigned char *)addr + ((nr >> 3) ^ 3);
+       if (__builtin_constant_p(nr)) {
+               __asm__("bld %Z2,%1\n\t"
+                       "rotxl %0\n\t"
+                       : "=r"(ret)
+                       : "WU"(*b_addr), "i"(nr & 7), "0"(ret) : "cc");
+       } else {
+               __asm__("btst %w2,%1\n\t"
+                       "beq 1f\n\t"
+                       "inc.l #1,%0\n"
+                       "1:"
+                       : "=r"(ret)
+                       : "WU"(*b_addr), "r"(bit), "0"(ret) : "cc");
+       }
+       return ret;
+}
+
+#define __test_bit(nr, addr) test_bit(nr, addr)
+
+#define H8300_GEN_TEST_BITOP(FNNAME, OP)                               \
+static inline int FNNAME(int nr, void *addr)                           \
+{                                                                      \
+       int retval = 0;                                                 \
+       char ccrsave;                                                   \
+       unsigned char *b_addr;                                          \
+       unsigned char bit = nr & 7;                                     \
+                                                                       \
+       b_addr = (unsigned char *)addr + ((nr >> 3) ^ 3);               \
+       if (__builtin_constant_p(nr)) {                                 \
+               __asm__("stc ccr,%s2\n\t"                               \
+                       "orc #0x80,ccr\n\t"                             \
+                       "bld %4,%1\n\t"                                 \
+                       OP " %4,%1\n\t"                                 \
+                       "rotxl.l %0\n\t"                                \
+                       "ldc %s2,ccr"                                   \
+                       : "=r"(retval), "+WU" (*b_addr), "=&r"(ccrsave) \
+                       : "0"(retval), "i"(nr & 7) : "cc");             \
+       } else {                                                        \
+               __asm__("stc ccr,%t3\n\t"                               \
+                       "orc #0x80,ccr\n\t"                             \
+                       "btst %s3,%1\n\t"                               \
+                       OP " %s3,%1\n\t"                                \
+                       "beq 1f\n\t"                                    \
+                       "inc.l #1,%0\n\t"                               \
+                       "1:\n"                                          \
+                       "ldc %t3,ccr"                                   \
+                       : "=r"(retval), "+WU" (*b_addr)                 \
+                       : "0" (retval), "r"(bit) : "cc");               \
+       }                                                               \
+       return retval;                                                  \
+}                                                                      \
+                                                                       \
+static inline int __ ## FNNAME(int nr, void *addr)                     \
+{                                                                      \
+       int retval = 0;                                                 \
+       unsigned char *b_addr;                                          \
+       unsigned char bit = nr & 7;                                     \
+                                                                       \
+       b_addr = (unsigned char *)addr + ((nr >> 3) ^ 3);               \
+       if (__builtin_constant_p(nr)) {                                 \
+               __asm__("bld %3,%1\n\t"                                 \
+                       OP " %3,%1\n\t"                                 \
+                       "rotxl.l %0\n\t"                                \
+                       : "=r"(retval), "+WU"(*b_addr)                  \
+                       : "0" (retval), "i"(nr & 7));                   \
+       } else {                                                        \
+               __asm__("btst %s3,%1\n\t"                               \
+                       OP " %s3,%1\n\t"                                \
+                       "beq 1f\n\t"                                    \
+                       "inc.l #1,%0\n\t"                               \
+                       "1:"                                            \
+                       : "=r"(retval), "+WU"(*b_addr)                  \
+                       : "0" (retval), "r"(bit));                      \
+       }                                                               \
+       return retval;                                                  \
+}
+
+H8300_GEN_TEST_BITOP(test_and_set_bit,   "bset")
+H8300_GEN_TEST_BITOP(test_and_clear_bit,  "bclr")
+H8300_GEN_TEST_BITOP(test_and_change_bit, "bnot")
+#undef H8300_GEN_TEST_BITOP
+
+#include <asm-generic/bitops/ffs.h>
+
+static inline unsigned long __ffs(unsigned long word)
+{
+       unsigned long result;
+
+       result = -1;
+       __asm__("1:\n\t"
+               "shlr.l %2\n\t"
+               "adds #1,%0\n\t"
+               "bcc 1b"
+               : "=r" (result)
+               : "0"(result), "r"(word));
+       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/le.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 /* _H8300_BITOPS_H */
arch/h8300/include/asm/bootparams.h new file +17 -0
new file mode 100644
index 0000000..6c0b145
@@ -0,0 +1,17 @@
+/*
+H8/300 kernel boot parameters
+*/
+
+#ifndef __ASM_H8300_BOOTPARAMS__
+#define __ASM_H8300_BOOTPARAMS__
+
+struct bootparams {
+       short size;
+       unsigned char gpio_ddr[24];
+       unsigned char gpio_use[24];
+       unsigned int clock_freq;
+       unsigned int ram_end;
+       unsigned char *command_line;
+} __packed __aligned(2);
+
+#endif
arch/h8300/include/asm/bug.h new file +12 -0
new file mode 100644
index 0000000..1e1be81
@@ -0,0 +1,12 @@
+#ifndef _H8300_BUG_H
+#define _H8300_BUG_H
+
+/* always true */
+#define is_valid_bugaddr(addr) (1)
+
+#include <asm-generic/bug.h>
+
+struct pt_regs;
+extern void die(const char *str, struct pt_regs *fp, unsigned long err);
+
+#endif
arch/h8300/include/asm/cache.h new file +11 -0
new file mode 100644
index 0000000..0ef1edc
@@ -0,0 +1,11 @@
+#ifndef __ARCH_H8300_CACHE_H
+#define __ARCH_H8300_CACHE_H
+
+/* bytes per L1 cache line */
+#define        L1_CACHE_SHIFT  2
+#define        L1_CACHE_BYTES  (1 << L1_CACHE_SHIFT)
+
+#define __cacheline_aligned
+#define ____cacheline_aligned
+
+#endif
arch/h8300/include/asm/checksum.h new file +102 -0
new file mode 100644
index 0000000..59e2adc9
@@ -0,0 +1,102 @@
+#ifndef _H8300_CHECKSUM_H
+#define _H8300_CHECKSUM_H
+
+/*
+ * computes the checksum of a memory block at buff, length len,
+ * and adds in "sum" (32-bit)
+ *
+ * returns a 32-bit number suitable for feeding into itself
+ * or csum_tcpudp_magic
+ *
+ * this function must be called with even lengths, except
+ * for the last fragment, which may be odd
+ *
+ * it's best to have buff aligned on a 32-bit boundary
+ */
+__wsum csum_partial(const void *buff, int len, __wsum sum);
+
+/*
+ * the same as csum_partial, but copies from src while it
+ * checksums
+ *
+ * here even more important to align src and dst on a 32-bit (or even
+ * better 64-bit) boundary
+ */
+
+__wsum csum_partial_copy_nocheck(const void *src, void *dst,
+                                int len, __wsum sum);
+
+
+/*
+ * the same as csum_partial_copy, but copies from user space.
+ *
+ * here even more important to align src and dst on a 32-bit (or even
+ * better 64-bit) boundary
+ */
+
+extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
+                                         int len, __wsum sum, int *csum_err);
+
+__sum16 ip_fast_csum(const void *iph, unsigned int ihl);
+
+
+/*
+ *     Fold a partial checksum
+ */
+
+static inline __sum16 csum_fold(__wsum sum)
+{
+       __asm__("add.w %e0,%f0\n\t"
+               "xor.w %e0,%e0\n\t"
+               "rotxl.w %e0\n\t"
+               "add.w %e0,%f0\n\t"
+               "sub.w %e0,%e0\n\t"
+               : "=r"(sum)
+               : "0"(sum));
+       return (__force __sum16)~sum;
+}
+
+
+/*
+ * computes the checksum of the TCP/UDP pseudo-header
+ * returns a 16-bit checksum, already complemented
+ */
+
+static inline __wsum
+csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
+                 unsigned short proto, __wsum sum)
+{
+       int tmp;
+
+       __asm__ ("sub.l %1,%1\n\t"
+                "add.l %3,%0\n\t"
+                "addx  #0,%w1\n\t"
+                "add.l %4,%0\n\t"
+                "addx  #0,%w1\n\t"
+                "add.l %5,%0\n\t"
+                "addx  #0,%w1\n\t"
+                "add.l %1,%0\n\t"
+                "bcc   1f\n\t"
+                "inc.l #1,%0\n"
+                "1:"
+                : "=&r" (sum), "=&r"(tmp)
+                : "0" (sum), "1" (daddr),
+                  "r" (saddr), "r" (len + proto));
+       return sum;
+}
+
+static inline __sum16
+csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
+                 unsigned short proto, __wsum sum)
+{
+       return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
+}
+
+/*
+ * this routine is used for miscellaneous IP-like checksums, mainly
+ * in icmp.c
+ */
+
+extern __sum16 ip_compute_csum(const void *buff, int len);
+
+#endif /* _H8300_CHECKSUM_H */
arch/h8300/include/asm/cmpxchg.h new file +65 -0
new file mode 100644
index 0000000..95fec4c
@@ -0,0 +1,65 @@
+#ifndef __ARCH_H8300_CMPXCHG__
+#define __ARCH_H8300_CMPXCHG__
+
+#include <linux/irqflags.h>
+
+#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;
+
+       local_irq_save(flags);
+
+       switch (size) {
+       case 1:
+               __asm__ __volatile__
+                       ("mov.b %2,%0\n\t"
+                        "mov.b %1,%2"
+                        : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)));
+               break;
+       case 2:
+               __asm__ __volatile__
+                       ("mov.w %2,%0\n\t"
+                        "mov.w %1,%2"
+                        : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)));
+               break;
+       case 4:
+               __asm__ __volatile__
+                       ("mov.l %2,%0\n\t"
+                        "mov.l %1,%2"
+                        : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)));
+               break;
+       default:
+               tmp = 0;
+       }
+       local_irq_restore(flags);
+       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 atomic_xchg(v, new) (xchg(&((v)->counter), new))
+
+#endif /* __ARCH_H8300_CMPXCHG__ */
arch/h8300/include/asm/delay.h new file +38 -0
new file mode 100644
index 0000000..2bdde59
@@ -0,0 +1,38 @@
+#ifndef _H8300_DELAY_H
+#define _H8300_DELAY_H
+
+#include <asm/param.h>
+
+/*
+ * Copyright (C) 2002 Yoshinori Sato <[email protected]>
+ *
+ * Delay routines, using a pre-computed "loops_per_second" value.
+ */
+
+static inline void __delay(unsigned long loops)
+{
+       __asm__ __volatile__ ("1:\n\t"
+                             "dec.l #1,%0\n\t"
+                             "bne 1b"
+                             : "=r" (loops) : "0"(loops));
+}
+
+/*
+ * Use only for very small delays ( < 1 msec).  Should probably use a
+ * lookup table, really, as the multiplications take much too long with
+ * short delays.  This is a "reasonable" implementation, though (and the
+ * first constant multiplications gets optimized away if the delay is
+ * a constant)
+ */
+
+extern unsigned long loops_per_jiffy;
+
+static inline void udelay(unsigned long usecs)
+{
+       usecs *= 4295;          /* 2**32 / 1000000 */
+       usecs /= (loops_per_jiffy*HZ);
+       if (usecs)
+               __delay(usecs);
+}
+
+#endif /* _H8300_DELAY_H */
arch/h8300/include/asm/device.h new file +6 -0
new file mode 100644
index 0000000..06746c5
@@ -0,0 +1,6 @@
+/*
+ * Arch specific extensions to struct device
+ *
+ * This file is released under the GPLv2
+ */
+#include <asm-generic/device.h>
arch/h8300/include/asm/dma-mapping.h new file +124 -0
new file mode 100644
index 0000000..f6f4716
@@ -0,0 +1,124 @@
+#ifndef _H8300_DMA_MAPPING_H
+#define _H8300_DMA_MAPPING_H
+
+struct scatterlist;
+
+static inline int dma_supported(struct device *dev, u64 mask)
+{
+       return 1;
+}
+
+static inline int dma_set_mask(struct device *dev, u64 mask)
+{
+       return 0;
+}
+
+extern void *dma_alloc_coherent(struct device *, size_t,
+                               dma_addr_t *, gfp_t);
+extern void dma_free_coherent(struct device *, size_t,
+                             void *, dma_addr_t);
+
+static inline void *dma_alloc_attrs(struct device *dev, size_t size,
+                                   dma_addr_t *dma_handle, gfp_t flag,
+                                   struct dma_attrs *attrs)
+{
+       /* attrs is not supported and ignored */
+       return dma_alloc_coherent(dev, size, dma_handle, flag);
+}
+
+static inline void dma_free_attrs(struct device *dev, size_t size,
+                                 void *cpu_addr, dma_addr_t dma_handle,
+                                 struct dma_attrs *attrs)
+{
+       /* attrs is not supported and ignored */
+       dma_free_coherent(dev, size, cpu_addr, dma_handle);
+}
+
+static inline void *dma_alloc_noncoherent(struct device *dev, size_t size,
+                                         dma_addr_t *handle, gfp_t flag)
+{
+       return dma_alloc_coherent(dev, size, handle, flag);
+}
+static inline void dma_free_noncoherent(struct device *dev, size_t size,
+                                       void *addr, dma_addr_t handle)
+{
+       dma_free_coherent(dev, size, addr, handle);
+}
+static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
+                                 enum dma_data_direction dir)
+{
+       /* we use coherent allocation, so not much to do here. */
+}
+
+extern dma_addr_t dma_map_single(struct device *, void *, size_t,
+                                enum dma_data_direction);
+static inline void dma_unmap_single(struct device *dev, dma_addr_t addr,
+                                   size_t size, enum dma_data_direction dir)
+{
+}
+
+extern dma_addr_t dma_map_page(struct device *, struct page *,
+                              unsigned long, size_t size,
+                              enum dma_data_direction);
+static inline void dma_unmap_page(struct device *dev, dma_addr_t address,
+                                 size_t size, enum dma_data_direction dir)
+{
+}
+
+extern int dma_map_sg(struct device *, struct scatterlist *, int,
+                     enum dma_data_direction);
+static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
+                               int nhwentries, enum dma_data_direction dir)
+{
+}
+
+extern void dma_sync_single_for_device(struct device *, dma_addr_t, size_t,
+                                      enum dma_data_direction);
+extern void dma_sync_sg_for_device(struct device *, struct scatterlist *, int,
+                                  enum dma_data_direction);
+
+static inline void dma_sync_single_range_for_device(struct device *dev,
+               dma_addr_t dma_handle, unsigned long offset, size_t size,
+               enum dma_data_direction direction)
+{
+       /* just sync everything for now */
+       dma_sync_single_for_device(dev, dma_handle, offset + size, direction);
+}
+
+static inline void dma_sync_single_for_cpu(struct device *dev,
+                                          dma_addr_t handle,
+                                          size_t size,
+                                          enum dma_data_direction dir)
+{
+}
+
+static inline void dma_sync_sg_for_cpu(struct device *dev,
+                                      struct scatterlist *sg,
+                                      int nents, enum dma_data_direction dir)
+{
+}
+
+static inline void dma_sync_single_range_for_cpu(struct device *dev,
+               dma_addr_t dma_handle, unsigned long offset, size_t size,
+               enum dma_data_direction direction)
+{
+       /* just sync everything for now */
+       dma_sync_single_for_cpu(dev, dma_handle, offset + size, direction);
+}
+
+static inline int dma_mapping_error(struct device *dev, dma_addr_t handle)
+{
+       return 0;
+}
+
+/* drivers/base/dma-mapping.c */
+extern int dma_common_mmap(struct device *dev, struct vm_area_struct *vma,
+                          void *cpu_addr, dma_addr_t dma_addr, size_t size);
+extern int dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
+                                 void *cpu_addr, dma_addr_t dma_addr,
+                                 size_t size);
+
+#define dma_mmap_coherent(d, v, c, h, s) dma_common_mmap(d, v, c, h, s)
+#define dma_get_sgtable(d, t, v, h, s) dma_common_get_sgtable(d, t, v, h, s)
+
+#endif
arch/h8300/include/asm/elf.h new file +101 -0
new file mode 100644
index 0000000..09031d0
@@ -0,0 +1,101 @@
+#ifndef __ASM_H8300_ELF_H
+#define __ASM_H8300_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_H8_300)
+
+/*
+ * These are used to set parameters in the core dumps.
+ */
+#define ELF_CLASS      ELFCLASS32
+#define ELF_DATA       ELFDATA2MSB
+#define ELF_ARCH       EM_H8_300
+#if defined(CONFIG_CPU_H8300H)
+#define ELF_CORE_EFLAGS 0x810000
+#endif
+#if defined(CONFIG_CPU_H8S)
+#define ELF_CORE_EFLAGS 0x820000
+#endif
+
+#define ELF_PLAT_INIT(_r) do { (_r)->er1 = 0; } while (0)
+
+#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 R_H8_NONE       0
+#define R_H8_DIR32      1
+#define R_H8_DIR32_28   2
+#define R_H8_DIR32_24   3
+#define R_H8_DIR32_16   4
+#define R_H8_DIR32U     6
+#define R_H8_DIR32U_28  7
+#define R_H8_DIR32U_24  8
+#define R_H8_DIR32U_20  9
+#define R_H8_DIR32U_16 10
+#define R_H8_DIR24     11
+#define R_H8_DIR24_20  12
+#define R_H8_DIR24_16  13
+#define R_H8_DIR24U    14
+#define R_H8_DIR24U_20 15
+#define R_H8_DIR24U_16 16
+#define R_H8_DIR16     17
+#define R_H8_DIR16U    18
+#define R_H8_DIR16S_32 19
+#define R_H8_DIR16S_28 20
+#define R_H8_DIR16S_24 21
+#define R_H8_DIR16S_20 22
+#define R_H8_DIR16S    23
+#define R_H8_DIR8      24
+#define R_H8_DIR8U     25
+#define R_H8_DIR8Z_32  26
+#define R_H8_DIR8Z_28  27
+#define R_H8_DIR8Z_24  28
+#define R_H8_DIR8Z_20  29
+#define R_H8_DIR8Z_16  30
+#define R_H8_PCREL16   31
+#define R_H8_PCREL8    32
+#define R_H8_BPOS      33
+#define R_H8_PCREL32   34
+#define R_H8_GOT32O    35
+#define R_H8_GOT16O    36
+#define R_H8_DIR16A8   59
+#define R_H8_DIR16R8   60
+#define R_H8_DIR24A8   61
+#define R_H8_DIR24R8   62
+#define R_H8_DIR32A16  63
+#define R_H8_ABS32     65
+#define R_H8_ABS32A16 127
+
+#endif
arch/h8300/include/asm/emergency-restart.h new file +6 -0
new file mode 100644
index 0000000..108d8c4
@@ -0,0 +1,6 @@
+#ifndef _ASM_EMERGENCY_RESTART_H
+#define _ASM_EMERGENCY_RESTART_H
+
+#include <asm-generic/emergency-restart.h>
+
+#endif /* _ASM_EMERGENCY_RESTART_H */
arch/h8300/include/asm/flat.h new file +27 -0
new file mode 100644
index 0000000..9ff092e
@@ -0,0 +1,27 @@
+/*
+ * arch/h8300/asm/include/flat.h -- uClinux flat-format executables
+ */
+
+#ifndef __H8300_FLAT_H__
+#define __H8300_FLAT_H__
+
+#define        flat_argvp_envp_on_stack()              1
+#define        flat_old_ram_flag(flags)                1
+#define        flat_reloc_valid(reloc, size)           ((reloc) <= (size))
+#define        flat_set_persistent(relval, p)          0
+
+/*
+ * on the H8 a couple of the relocations have an instruction in the
+ * top byte.  As there can only be 24bits of address space,  we just
+ * always preserve that 8bits at the top,  when it isn't an instruction
+ * is is 0 ([email protected])
+ */
+
+#define        flat_get_relocate_addr(rel)             (rel & ~0x00000001)
+#define flat_get_addr_from_rp(rp, relval, flags, persistent) \
+       (get_unaligned(rp) & (((flags) & FLAT_FLAG_GOTPIC) ? \
+                             0xffffffff : 0x00ffffff))
+#define flat_put_addr_at_rp(rp, addr, rel) \
+       put_unaligned(((*(char *)(rp)) << 24) | ((addr) & 0x00ffffff), (rp))
+
+#endif /* __H8300_FLAT_H__ */
arch/h8300/include/asm/io.h new file +314 -0
new file mode 100644
index 0000000..51ee096
@@ -0,0 +1,314 @@
+#ifndef _H8300_IO_H
+#define _H8300_IO_H
+
+#ifdef __KERNEL__
+
+#include <linux/types.h>
+
+#define __raw_readb(addr) ({ u8 __v = *(volatile u8 *)(addr); __v; })
+
+#define __raw_readw(addr) ({ u16 __v = *(volatile u16 *)(addr); __v; })
+
+#define __raw_readl(addr) ({ u32 __v = *(volatile u32 *)(addr); __v; })
+
+#define __raw_writeb(b, addr) (void)((*(volatile u8 *)(addr)) = (b))
+
+#define __raw_writew(b, addr) (void)((*(volatile u16 *)(addr)) = (b))
+
+#define __raw_writel(b, addr) (void)((*(volatile u32 *)(addr)) = (b))
+
+#define readb __raw_readb
+#define readw __raw_readw
+#define readl __raw_readl
+#define writeb __raw_writeb
+#define writew __raw_writew
+#define writel __raw_writel
+
+#if defined(CONFIG_H83069)
+#define ABWCR  0xFEE020
+#elif defined(CONFIG_H8S2678)
+#define ABWCR  0xFFFEC0
+#endif
+
+#ifdef CONFIG_H8300_BUBSSWAP
+#define _swapw(x) __builtin_bswap16(x)
+#define _swapl(x) __builtin_bswap32(x)
+#else
+#define _swapw(x) (x)
+#define _swapl(x) (x)
+#endif
+
+static inline int h8300_buswidth(unsigned int addr)
+{
+       return (*(volatile u8 *)ABWCR & (1 << ((addr >> 21) & 7))) == 0;
+}
+
+static inline void io_outsb(unsigned int addr, const void *buf, int len)
+{
+       volatile unsigned char  *ap_b = (volatile unsigned char *) addr;
+       volatile unsigned short *ap_w = (volatile unsigned short *) addr;
+       unsigned char *bp = (unsigned char *) buf;
+
+       if (h8300_buswidth(addr) && (addr & 1)) {
+               while (len--)
+                       *ap_w = *bp++;
+       } else {
+               while (len--)
+                       *ap_b = *bp++;
+       }
+}
+
+static inline void io_outsw(unsigned int addr, const void *buf, int len)
+{
+       volatile unsigned short *ap = (volatile unsigned short *) addr;
+       unsigned short *bp = (unsigned short *) buf;
+
+       while (len--)
+               *ap = _swapw(*bp++);
+}
+
+static inline void io_outsl(unsigned int addr, const void *buf, int len)
+{
+       volatile unsigned short *ap = (volatile unsigned short *) addr;
+       unsigned short *bp = (unsigned short *) buf;
+
+       while (len--) {
+               *(ap + 1) = _swapw(*(bp + 0));
+               *(ap + 0) = _swapw(*(bp + 1));
+               bp += 2;
+       }
+}
+
+static inline void io_outsw_noswap(unsigned int addr, const void *buf, int len)
+{
+       volatile unsigned short *ap = (volatile unsigned short *) addr;
+       unsigned short *bp = (unsigned short *) buf;
+
+       while (len--)
+               *ap = *bp++;
+}
+
+static inline void io_outsl_noswap(unsigned int addr, const void *buf, int len)
+{
+       volatile unsigned long *ap = (volatile unsigned long *) addr;
+       unsigned long *bp = (unsigned long *) buf;
+
+       while (len--)
+               *ap = *bp++;
+}
+
+static inline void io_insb(unsigned int addr, void *buf, int len)
+{
+       volatile unsigned char  *ap_b;
+       volatile unsigned short *ap_w;
+       unsigned char *bp = (unsigned char *) buf;
+
+       if (h8300_buswidth(addr)) {
+               ap_w = (volatile unsigned short *)(addr & ~1);
+               while (len--)
+                       *bp++ = *ap_w & 0xff;
+       } else {
+               ap_b = (volatile unsigned char *)addr;
+               while (len--)
+                       *bp++ = *ap_b;
+       }
+}
+
+static inline void io_insw(unsigned int addr, void *buf, int len)
+{
+       volatile unsigned short *ap = (volatile unsigned short *) addr;
+       unsigned short *bp = (unsigned short *) buf;
+
+       while (len--)
+               *bp++ = _swapw(*ap);
+}
+
+static inline void io_insl(unsigned int addr, void *buf, int len)
+{
+       volatile unsigned short *ap = (volatile unsigned short *) addr;
+       unsigned short *bp = (unsigned short *) buf;
+
+       while (len--) {
+               *(bp + 0) = _swapw(*(ap + 1));
+               *(bp + 1) = _swapw(*(ap + 0));
+               bp += 2;
+       }
+}
+
+static inline void io_insw_noswap(unsigned int addr, void *buf, int len)
+{
+       volatile unsigned short *ap = (volatile unsigned short *) addr;
+       unsigned short *bp = (unsigned short *) buf;
+
+       while (len--)
+               *bp++ = *ap;
+}
+
+static inline void io_insl_noswap(unsigned int addr, void *buf, int len)
+{
+       volatile unsigned long *ap = (volatile unsigned long *) addr;
+       unsigned long *bp = (unsigned long *) buf;
+
+       while (len--)
+               *bp++ = *ap;
+}
+
+/*
+ *     make the short names macros so specific devices
+ *     can override them as required
+ */
+
+#define memset_io(a, b, c)     memset((void *)(a), (b), (c))
+#define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c))
+#define memcpy_toio(a, b, c)   memcpy((void *)(a), (b), (c))
+
+#define mmiowb()
+
+#define inb(addr)    ((h8300_buswidth(addr)) ? \
+                     __raw_readw((addr) & ~1) & 0xff:__raw_readb(addr))
+#define inw(addr)    _swapw(__raw_readw(addr))
+#define inl(addr)    (_swapw(__raw_readw(addr) << 16 | \
+                            _swapw(__raw_readw(addr + 2))))
+#define outb(x, addr) ((void)((h8300_buswidth(addr) && ((addr) & 1)) ? \
+                             __raw_writeb(x, (addr) & ~1) : \
+                             __raw_writeb(x, addr)))
+#define outw(x, addr) ((void) __raw_writew(_swapw(x), addr))
+#define outl(x, addr) \
+               ((void) __raw_writel(_swapw(x & 0xffff) | \
+                                     _swapw(x >> 16) << 16, addr))
+
+#define inb_p(addr)    inb(addr)
+#define inw_p(addr)    inw(addr)
+#define inl_p(addr)    inl(addr)
+#define outb_p(x, addr) outb(x, addr)
+#define outw_p(x, addr) outw(x, addr)
+#define outl_p(x, addr) outl(x, addr)
+
+#define outsb(a, b, l) io_outsb(a, b, l)
+#define outsw(a, b, l) io_outsw(a, b, l)
+#define outsl(a, b, l) io_outsl(a, b, l)
+
+#define insb(a, b, l) io_insb(a, b, l)
+#define insw(a, b, l) io_insw(a, b, l)
+#define insl(a, b, l) io_insl(a, b, l)
+
+#define ioread8(a)             __raw_readb(a)
+#define ioread16(a)            __raw_readw(a)
+#define ioread32(a)            __raw_readl(a)
+
+#define iowrite8(v, a)         __raw_writeb((v), (a))
+#define iowrite16(v, a)                __raw_writew((v), (a))
+#define iowrite32(v, a)                __raw_writel((v), (a))
+
+#define ioread8_rep(p, d, c)   insb(p, d, c)
+#define ioread16_rep(p, d, c)  insw(p, d, c)
+#define ioread32_rep(p, d, c)  insl(p, d, c)
+#define iowrite8_rep(p, s, c)  outsb(p, s, c)
+#define iowrite16_rep(p, s, c) outsw(p, s, c)
+#define iowrite32_rep(p, s, c) outsl(p, s, c)
+
+#define IO_SPACE_LIMIT 0xffffff
+
+/* Values for nocacheflag and cmode */
+#define IOMAP_FULL_CACHING             0
+#define IOMAP_NOCACHE_SER              1
+#define IOMAP_NOCACHE_NONSER           2
+#define IOMAP_WRITETHROUGH             3
+
+extern void *__ioremap(unsigned long physaddr, unsigned long size,
+                      int cacheflag);
+extern void __iounmap(void *addr, unsigned long size);
+
+static inline void *ioremap(unsigned long physaddr, unsigned long size)
+{
+       return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
+}
+static inline void *ioremap_nocache(unsigned long physaddr,
+                                   unsigned long size)
+{
+       return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
+}
+static inline void *ioremap_writethrough(unsigned long physaddr,
+                                        unsigned long size)
+{
+       return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
+}
+static inline void *ioremap_fullcache(unsigned long physaddr,
+                                     unsigned long size)
+{
+       return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
+}
+
+extern void iounmap(void *addr);
+
+#define ioremap_wc ioremap_nocache
+
+/* H8/300 internal I/O functions */
+static inline unsigned char ctrl_inb(unsigned long addr)
+{
+       return *(volatile unsigned char *)addr;
+}
+
+static inline unsigned short ctrl_inw(unsigned long addr)
+{
+       return *(volatile unsigned short *)addr;
+}
+
+static inline unsigned long ctrl_inl(unsigned long addr)
+{
+       return *(volatile unsigned long *)addr;
+}
+
+static inline void ctrl_outb(unsigned char b, unsigned long addr)
+{
+       *(volatile unsigned char *)addr = b;
+}
+
+static inline void ctrl_outw(unsigned short b, unsigned long addr)
+{
+       *(volatile unsigned short *)addr = b;
+}
+
+static inline void ctrl_outl(unsigned long b, unsigned long addr)
+{
+       *(volatile unsigned long *)addr = b;
+}
+
+static inline void ctrl_bclr(int b, unsigned long addr)
+{
+       if (__builtin_constant_p(b))
+               __asm__("bclr %1,%0" : : "WU"(addr), "i"(b));
+       else
+               __asm__("bclr %w1,%0" : : "WU"(addr), "r"(b));
+}
+
+static inline void ctrl_bset(int b, unsigned long addr)
+{
+       if (__builtin_constant_p(b))
+               __asm__("bset %1,%0" : : "WU"(addr), "i"(b));
+       else
+               __asm__("bset %w1,%0" : : "WU"(addr), "r"(b));
+}
+
+/*
+ * Macros used for converting between virtual and physical mappings.
+ */
+#define phys_to_virt(vaddr)    ((void *) (vaddr))
+#define virt_to_phys(vaddr)    ((unsigned long) (vaddr))
+
+#define virt_to_bus virt_to_phys
+#define bus_to_virt phys_to_virt
+/*
+ * Convert a physical pointer to a virtual kernel pointer for /dev/mem
+ * access
+ */
+#define xlate_dev_mem_ptr(p)   __va(p)
+
+/*
+ * Convert a virtual cached pointer to an uncached pointer
+ */
+#define xlate_dev_kmem_ptr(p)  (p)
+
+#endif /* __KERNEL__ */
+
+#endif /* _H8300_IO_H */
arch/h8300/include/asm/irq.h new file +26 -0
new file mode 100644
index 0000000..69f23f0
@@ -0,0 +1,26 @@
+#ifndef _H8300_IRQ_H_
+#define _H8300_IRQ_H_
+
+#include <linux/irqchip.h>
+
+#if defined(CONFIG_CPU_H8300H)
+#define NR_IRQS 64
+#define IRQ_CHIP h8300h_irq_chip
+#define EXT_IRQ0 12
+#define EXT_IRQS 6
+#elif defined(CONFIG_CPU_H8S)
+#define NR_IRQS 128
+#define IRQ_CHIP h8s_irq_chip
+#define EXT_IRQ0 16
+#define EXT_IRQS 16
+#endif
+
+static inline int irq_canonicalize(int irq)
+{
+       return irq;
+}
+
+void h8300_init_ipr(void);
+extern struct irq_chip h8300h_irq_chip;
+extern struct irq_chip h8s_irq_chip;
+#endif /* _H8300_IRQ_H_ */
arch/h8300/include/asm/irqflags.h new file +96 -0
new file mode 100644
index 0000000..5e1e324
@@ -0,0 +1,96 @@
+#ifndef _H8300_IRQFLAGS_H
+#define _H8300_IRQFLAGS_H
+
+#ifdef CONFIG_CPU_H8300H
+typedef unsigned char h8300flags;
+
+static inline h8300flags arch_local_save_flags(void)
+{
+       h8300flags flags;
+
+       __asm__ volatile ("stc ccr,%w0" : "=r" (flags));
+       return flags;
+}
+
+static inline void arch_local_irq_disable(void)
+{
+       __asm__ volatile ("orc  #0xc0,ccr");
+}
+
+static inline void arch_local_irq_enable(void)
+{
+       __asm__ volatile ("andc #0x3f,ccr");
+}
+
+static inline h8300flags arch_local_irq_save(void)
+{
+       h8300flags flags;
+
+       __asm__ volatile ("stc ccr,%w0\n\t"
+                     "orc  #0xc0,ccr" : "=r" (flags));
+       return flags;
+}
+
+static inline void arch_local_irq_restore(h8300flags flags)
+{
+       __asm__ volatile ("ldc %w0,ccr" : : "r" (flags) : "cc");
+}
+
+static inline int arch_irqs_disabled_flags(unsigned long flags)
+{
+       return (flags & 0xc0) == 0xc0;
+}
+#endif
+#ifdef CONFIG_CPU_H8S
+typedef unsigned short h8300flags;
+
+static inline h8300flags arch_local_save_flags(void)
+{
+       h8300flags flags;
+
+       __asm__ volatile ("stc ccr,%w0\n\tstc exr,%x0" : "=r" (flags));
+       return flags;
+}
+
+static inline void arch_local_irq_disable(void)
+{
+       __asm__ volatile ("orc #0x80,ccr\n\t");
+}
+
+static inline void arch_local_irq_enable(void)
+{
+       __asm__ volatile ("andc #0x7f,ccr\n\t"
+                     "andc #0xf0,exr\n\t");
+}
+
+static inline h8300flags arch_local_irq_save(void)
+{
+       h8300flags flags;
+
+       __asm__ volatile ("stc ccr,%w0\n\t"
+                     "stc exr,%x0\n\t"
+                     "orc  #0x80,ccr\n\t"
+                     : "=r" (flags));
+       return flags;
+}
+
+static inline void arch_local_irq_restore(h8300flags flags)
+{
+       __asm__ volatile ("ldc %w0,ccr\n\t"
+                     "ldc %x0,exr"
+                     : : "r" (flags) : "cc");
+}
+
+static inline int arch_irqs_disabled_flags(h8300flags flags)
+{
+       return (flags & 0x0080) == 0x0080;
+}
+
+#endif
+
+static inline int arch_irqs_disabled(void)
+{
+       return arch_irqs_disabled_flags(arch_local_save_flags());
+}
+
+#endif /* _H8300_IRQFLAGS_H */
arch/h8300/include/asm/mc146818rtc.h new file +9 -0
new file mode 100644
index 0000000..ab9d964
@@ -0,0 +1,9 @@
+/*
+ * Machine dependent access functions for RTC registers.
+ */
+#ifndef _H8300_MC146818RTC_H
+#define _H8300_MC146818RTC_H
+
+/* empty include file to satisfy the include in genrtc.c/ide-geometry.c */
+
+#endif /* _H8300_MC146818RTC_H */
arch/h8300/include/asm/mutex.h new file +9 -0
new file mode 100644
index 0000000..458c1f7
@@ -0,0 +1,9 @@
+/*
+ * Pull in the generic implementation for the mutex fastpath.
+ *
+ * TODO: implement optimized primitives instead, or leave the generic
+ * implementation in place, or pick the atomic_xchg() based generic
+ * implementation. (see asm-generic/mutex-xchg.h for details)
+ */
+
+#include <asm-generic/mutex-dec.h>
arch/h8300/include/asm/page.h new file +18 -0
new file mode 100644
index 0000000..3a987a5
@@ -0,0 +1,18 @@
+#ifndef _H8300_PAGE_H
+#define _H8300_PAGE_H
+
+#include <asm-generic/page.h>
+#include <linux/types.h>
+
+#define MAP_NR(addr) (((uintptr_t)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
+#define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
+                                VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
+
+#ifndef __ASSEMBLY__
+extern unsigned long rom_length;
+extern unsigned long memory_start;
+extern unsigned long memory_end;
+extern unsigned long _ramend;
+#endif
+
+#endif
arch/h8300/include/asm/page_offset.h new file +2 -0
new file mode 100644
index 0000000..888576d
@@ -0,0 +1,2 @@
+
+#define PAGE_OFFSET_RAW                0x00000000
arch/h8300/include/asm/pci.h new file +19 -0
new file mode 100644
index 0000000..0b2acaa
@@ -0,0 +1,19 @@
+#ifndef _ASM_H8300_PCI_H
+#define _ASM_H8300_PCI_H
+
+/*
+ * asm-h8300/pci.h - H8/300 specific PCI declarations.
+ *
+ * Yoshinori Sato <[email protected]>
+ */
+
+#define pcibios_assign_all_busses()    0
+
+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_H8300_PCI_H */
arch/h8300/include/asm/pgtable.h new file +49 -0
new file mode 100644
index 0000000..8341db6
@@ -0,0 +1,49 @@
+#ifndef _H8300_PGTABLE_H
+#define _H8300_PGTABLE_H
+#include <asm-generic/pgtable-nopud.h>
+#include <asm-generic/pgtable.h>
+#define pgtable_cache_init()   do { } while (0)
+extern 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 __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 })
+#define kern_addr_valid(addr)  (1)
+#define pgprot_writecombine(prot)  (prot)
+#define pgprot_noncached pgprot_writecombine
+
+static inline int pte_file(pte_t pte) { return 0; }
+#define swapper_pg_dir ((pgd_t *) 0)
+/*
+ * ZERO_PAGE is a global shared page that is always zero: used
+ * for zero-mapped memory areas etc..
+ */
+#define ZERO_PAGE(vaddr)       (virt_to_page(0))
+
+/*
+ * These would be in other places but having them here reduces the diffs.
+ */
+extern unsigned int kobjsize(const void *objp);
+extern int is_in_rom(unsigned long);
+
+/*
+ * No page table caches to initialise
+ */
+#define pgtable_cache_init()   do { } while (0)
+
+/*
+ * All 32bit addresses are effectively valid for vmalloc...
+ * Sort of meaningless for non-VM targets.
+ */
+#define        VMALLOC_START   0
+#define        VMALLOC_END     0xffffffff
+
+#define arch_enter_lazy_cpu_mode()    do {} while (0)
+
+#endif /* _H8300_PGTABLE_H */
arch/h8300/include/asm/processor.h new file +144 -0
new file mode 100644
index 0000000..54e3fd8
@@ -0,0 +1,144 @@
+/*
+ * include/asm-h8300/processor.h
+ *
+ * Copyright (C) 2002 Yoshinori Sato
+ *
+ * Based on: linux/asm-m68nommu/processor.h
+ *
+ * Copyright (C) 1995 Hamish Macdonald
+ */
+
+#ifndef __ASM_H8300_PROCESSOR_H
+#define __ASM_H8300_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>
+
+static inline unsigned long rdusp(void)
+{
+       extern unsigned int     _sw_usp;
+
+       return _sw_usp;
+}
+
+static inline void wrusp(unsigned long usp)
+{
+       extern unsigned int     _sw_usp;
+
+       _sw_usp = usp;
+}
+
+/*
+ * 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  ksp;             /* kernel stack pointer */
+       unsigned long  usp;             /* user stack pointer */
+       unsigned long  ccr;             /* saved status register */
+       unsigned long  esp0;            /* points to SR of stack frame */
+       struct {
+               unsigned short *addr;
+               unsigned short inst;
+       } breakinfo;
+};
+
+#define INIT_THREAD  {                                         \
+       .ksp  = sizeof(init_stack) + (unsigned long)init_stack, \
+       .usp  = 0,                                              \
+       .ccr  = PS_S,                                           \
+       .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
+ */
+#if defined(CONFIG_CPU_H8300H)
+#define start_thread(_regs, _pc, _usp)                         \
+do {                                                           \
+       (_regs)->pc = (_pc);                                    \
+       (_regs)->ccr = 0x00;       /* clear all flags */        \
+       (_regs)->er5 = current->mm->start_data; /* GOT base */  \
+       (_regs)->sp = ((unsigned long)(_usp)) - sizeof(unsigned long) * 3; \
+} while (0)
+#endif
+#if defined(CONFIG_CPU_H8S)
+#define start_thread(_regs, _pc, _usp)                         \
+do {                                                           \
+       (_regs)->pc = (_pc);                                    \
+       (_regs)->ccr = 0x00;       /* clear kernel flag */      \
+       (_regs)->exr = 0x78;       /* enable all interrupts */  \
+       (_regs)->er5 = current->mm->start_data; /* GOT base */  \
+       /* 14 = space for retaddr(4), vector(4), er0(4) and exr(2) on stack */ \
+       (_regs)->sp = ((unsigned long)(_usp)) - 14;             \
+} while (0)
+#endif
+
+/* 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)
+{
+}
+
+/*
+ * Free current thread data structures etc..
+ */
+static inline void exit_thread(void)
+{
+}
+
+/*
+ * Return saved PC of a blocked thread.
+ */
+unsigned long thread_saved_pc(struct task_struct *tsk);
+unsigned long get_wchan(struct task_struct *p);
+
+#define        KSTK_EIP(tsk)   \
+       ({                       \
+               unsigned long eip = 0;        \
+               if ((tsk)->thread.esp0 > PAGE_SIZE &&   \
+                   MAP_NR((tsk)->thread.esp0) < max_mapnr)      \
+                       eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
+               eip; })
+
+#define        KSTK_ESP(tsk)   ((tsk) == current ? rdusp() : (tsk)->thread.usp)
+
+#define cpu_relax()    barrier()
+#define cpu_relax_lowlatency() cpu_relax()
+
+#define HARD_RESET_NOW() ({            \
+       local_irq_disable();            \
+       asm("jmp @@0");                 \
+})
+
+#endif
arch/h8300/include/asm/ptrace.h new file +36 -0
new file mode 100644
index 0000000..e693fb4
@@ -0,0 +1,36 @@
+#ifndef _H8300_PTRACE_H
+#define _H8300_PTRACE_H
+
+#include <uapi/asm/ptrace.h>
+
+#ifndef __ASSEMBLY__
+#ifndef PS_S
+#define PS_S  (0x10)
+#endif
+
+#if defined(CONFIG_CPU_H8300H)
+#define H8300_REGS_NO 11
+#endif
+#if defined(CONFIG_CPU_H8S)
+#define H8300_REGS_NO 12
+#endif
+
+#define arch_has_single_step() (1)
+
+#define user_mode(regs) (!((regs)->ccr & PS_S))
+#define instruction_pointer(regs) ((regs)->pc)
+#define profile_pc(regs) instruction_pointer(regs)
+#define user_stack_pointer(regs) ((regs)->sp)
+#define current_pt_regs() ((struct pt_regs *) \
+       (THREAD_SIZE + (unsigned long)current_thread_info()) - 1)
+#define signal_pt_regs() ((struct pt_regs *)current->thread.esp0)
+#define current_user_stack_pointer() rdusp()
+#define task_pt_regs(task) \
+       ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE) - 1)
+
+extern long h8300_get_reg(struct task_struct *task, int regno);
+extern int h8300_put_reg(struct task_struct *task, int regno,
+                        unsigned long data);
+
+#endif /* __ASSEMBLY__ */
+#endif /* _H8300_PTRACE_H */
arch/h8300/include/asm/segment.h new file +49 -0
new file mode 100644
index 0000000..c8bc68e
@@ -0,0 +1,49 @@
+#ifndef _H8300_SEGMENT_H
+#define _H8300_SEGMENT_H
+
+/* define constants */
+#define USER_DATA     (1)
+#ifndef __USER_DS
+#define __USER_DS     (USER_DATA)
+#endif
+#define USER_PROGRAM  (2)
+#define SUPER_DATA    (3)
+#ifndef __KERNEL_DS
+#define __KERNEL_DS   (SUPER_DATA)
+#endif
+#define SUPER_PROGRAM (4)
+
+#ifndef __ASSEMBLY__
+
+typedef struct {
+       unsigned long seg;
+} mm_segment_t;
+
+#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
+#define USER_DS                MAKE_MM_SEG(__USER_DS)
+#define KERNEL_DS      MAKE_MM_SEG(__KERNEL_DS)
+
+/*
+ * Get/set the SFC/DFC registers for MOVES instructions
+ */
+
+static inline mm_segment_t get_fs(void)
+{
+       return USER_DS;
+}
+
+static inline mm_segment_t get_ds(void)
+{
+       /* return the supervisor data space code */
+       return KERNEL_DS;
+}
+
+static inline void set_fs(mm_segment_t val)
+{
+}
+
+#define segment_eq(a, b)       ((a).seg == (b).seg)
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* _H8300_SEGMENT_H */
arch/h8300/include/asm/sh_bios.h new file +4 -0
new file mode 100644
index 0000000..9ce513c
@@ -0,0 +1,4 @@
+#ifndef SH_BIOS_H
+#define SH_BIOS_H
+
+#endif
arch/h8300/include/asm/signal.h new file +22 -0
new file mode 100644
index 0000000..5870835
@@ -0,0 +1,22 @@
+#ifndef _H8300_SIGNAL_H
+#define _H8300_SIGNAL_H
+
+#include <uapi/asm/signal.h>
+
+/* Most things should be clean enough to redefine this at will, if care
+   is taken to make libc match.  */
+
+#define _NSIG          64
+#define _NSIG_BPW      32
+#define _NSIG_WORDS    (_NSIG / _NSIG_BPW)
+
+typedef unsigned long old_sigset_t;            /* at least 32 bits */
+
+typedef struct {
+       unsigned long sig[_NSIG_WORDS];
+} sigset_t;
+
+#define __ARCH_HAS_SA_RESTORER
+#include <asm/sigcontext.h>
+
+#endif /* _H8300_SIGNAL_H */
arch/h8300/include/asm/smp.h new file +1 -0
new file mode 100644
index 0000000..9e9bd7e
@@ -0,0 +1 @@
+/* nothing required here yet */
arch/h8300/include/asm/spinlock.h new file +6 -0
new file mode 100644
index 0000000..d5407fa
@@ -0,0 +1,6 @@
+#ifndef __H8300_SPINLOCK_H
+#define __H8300_SPINLOCK_H
+
+#error "H8/300 doesn't do SMP yet"
+
+#endif
arch/h8300/include/asm/string.h new file +17 -0
new file mode 100644
index 0000000..5dc5a8a
@@ -0,0 +1,17 @@
+#ifndef _H8300_STRING_H_
+#define _H8300_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);
+
+#endif /* KERNEL */
+
+#endif
arch/h8300/include/asm/switch_to.h new file +51 -0
new file mode 100644
index 0000000..7ad1bf9
@@ -0,0 +1,51 @@
+#ifndef _H8300_SWITCH_TO_H
+#define _H8300_SWITCH_TO_H
+
+/*
+ * switch_to(n) should switch tasks to task ptr, first checking that
+ * ptr isn't the current task, in which case it does nothing.  This
+ * also clears the TS-flag if the task we switched to has used the
+ * math co-processor latest.
+ */
+/*
+ * switch_to() saves the extra registers, that are not saved
+ * automatically by SAVE_SWITCH_STACK in resume(), ie. d0-d5 and
+ * a0-a1. Some of these are used by schedule() and its predecessors
+ * and so we might get see unexpected behaviors when a task returns
+ * with unexpected register values.
+ *
+ * syscall stores these registers itself and none of them are used
+ * by syscall after the function in the syscall has been called.
+ *
+ * Beware that resume now expects *next to be in d1 and the offset of
+ * tss to be in a1. This saves a few instructions as we no longer have
+ * to push them onto the stack and read them back right after.
+ *
+ * 02/17/96 - Jes Sorensen ([email protected])
+ *
+ * Changed 96/09/19 by Andreas Schwab
+ * pass prev in a0, next in a1, offset of tss in d1, and whether
+ * the mm structures are shared in d2 (to avoid atc flushing).
+ *
+ * H8/300 Porting 2002/09/04 Yoshinori Sato
+ */
+
+asmlinkage void resume(void);
+#define switch_to(prev, next, last) \
+do {                        \
+       void *_last;                                        \
+       __asm__ __volatile__(                               \
+               "mov.l  %1, er0\n\t"                        \
+               "mov.l  %2, er1\n\t"                        \
+               "mov.l  %3, er2\n\t"                        \
+               "jsr @_resume\n\t"                          \
+               "mov.l  er2,%0\n\t"                         \
+               : "=r" (_last)                              \
+               : "r" (&(prev->thread)),                    \
+                 "r" (&(next->thread)),                    \
+                 "g" (prev)                                \
+               : "cc", "er0", "er1", "er2", "er3");        \
+       (last) = _last;                                     \
+} while (0)
+
+#endif /* _H8300_SWITCH_TO_H */
arch/h8300/include/asm/syscall.h new file +56 -0
new file mode 100644
index 0000000..b41f688
@@ -0,0 +1,56 @@
+#ifndef __ASM_H8300_SYSCALLS_32_H
+#define __ASM_H8300_SYSCALLS_32_H
+
+#ifdef __KERNEL__
+
+#include <linux/compiler.h>
+#include <linux/linkage.h>
+#include <linux/types.h>
+#include <linux/ptrace.h>
+
+static inline int
+syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
+{
+       return regs->orig_er0;
+}
+
+static inline void
+syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
+                     unsigned int i, unsigned int n, unsigned long *args)
+{
+       BUG_ON(i + n > 6);
+
+       while (n > 0) {
+               switch (i) {
+               case 0:
+                       *args++ = regs->er1;
+                       break;
+               case 1:
+                       *args++ = regs->er2;
+                       break;
+               case 2:
+                       *args++ = regs->er3;
+                       break;
+               case 3:
+                       *args++ = regs->er4;
+                       break;
+               case 4:
+                       *args++ = regs->er5;
+                       break;
+               case 5:
+                       *args++ = regs->er6;
+                       break;
+               }
+               i++;
+               n--;
+       }
+}
+
+
+
+/* Misc syscall related bits */
+asmlinkage long do_syscall_trace_enter(struct pt_regs *regs);
+asmlinkage void do_syscall_trace_leave(struct pt_regs *regs);
+
+#endif /* __KERNEL__ */
+#endif /* __ASM_H8300_SYSCALLS_32_H */
arch/h8300/include/asm/thread_info.h new file +13 -0
new file mode 100644
index 0000000..eded1ee
@@ -0,0 +1,119 @@
+/* thread_info.h: h8300 low-level thread information
+ * adapted from the i386 and PPC versions by Yoshinori Sato <[email protected]>
+ *
+ * Copyright (C) 2002  David Howells ([email protected])
+ * - Incorporating suggestions made by Linus Torvalds and Dave Miller
+ */
+
+#ifndef _ASM_THREAD_INFO_H
+#define _ASM_THREAD_INFO_H
+
+#include <asm/page.h>
+
+#ifdef __KERNEL__

arch/h8300/include/asm/thread_info.h line 23

Quoted 10 lines
arch/h8300/include/asm/thread_info.h new file +10 -0
+
+#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 */

Same here, remove exec_domain.

Quoted 45 lines
arch/h8300/include/asm/thread_info.h new file +44 -0
+       unsigned long      flags;               /* low level flags */
+       int                cpu;                 /* cpu we're on */
+       int                preempt_count;       /* 0 => preemptable, <0 => BUG */
+       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,    \
+       .restart_block  = {                     \
+               .fn = do_no_restart_syscall,    \
+       },                                      \
+}
+
+#define init_thread_info       (init_thread_union.thread_info)
+#define init_stack             (init_thread_union.stack)
+
+
+/*
+ * 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 */
+
+
+/* how to get the thread information struct from C */
+static inline struct thread_info *current_thread_info(void)
+{
+       struct thread_info *ti;
+
+       __asm__("mov.l  sp, %0\n\t"
+               "and.w  %1, %T0"
+               : "=&r"(ti)
+               : "i" (~(THREAD_SIZE-1) & 0xffff));
+       return ti;
+}
+

arch/h8300/include/asm/thread_info.h line 77

Quoted 10 lines
arch/h8300/include/asm/thread_info.h new file +10 -0
+#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

You can kill TI_EXECDOMAIN, execution domain support is gone.
It would be also nice if the TI_* constants would be created using asm-offsets.c.
See git.kernel.org/linus/37f078ff4c97ad143a6dc2adae31e20a3f780ca7 as an example.

Quoted 397 lines
arch/h8300/include/asm/thread_info.h new file +41 -0
+/*
+ * 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_SINGLESTEP         3       /* singlestepping active */
+#define TIF_MEMDIE             4       /* is terminating due to OOM killer */
+#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_SYSCALL_TRACEPOINT 8       /* for ftrace syscall instrumentation */
+#define TIF_POLLING_NRFLAG     9       /* true if poll_idle() is polling TIF_NEED_RESCHED */
+
+/* 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_NOTIFY_RESUME     (1 << TIF_NOTIFY_RESUME)
+#define _TIF_SINGLESTEP                (1 << TIF_SINGLESTEP)
+#define _TIF_SYSCALL_AUDIT     (1 << TIF_SYSCALL_AUDIT)
+#define _TIF_SYSCALL_TRACEPOINT        (1 << TIF_SYSCALL_TRACEPOINT)
+#define _TIF_POLLING_NRFLAG    (1 << TIF_POLLING_NRFLAG)
+
+/* work to do in syscall trace */
+#define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
+                                _TIF_SYSCALL_AUDIT | _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_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_THREAD_INFO_H */
arch/h8300/include/asm/timer.h new file +31 -0
new file mode 100644
index 0000000..c905f4e
@@ -0,0 +1,31 @@
+#ifndef __H8300_TIMER_H
+#define __H8300_TIMER_H
+
+unsigned long get_cpu_clock(void);
+
+#define H8300_TIMER_FREQ get_cpu_clock() /* Timer input freq. */
+
+#define H8300_TMR8_CLKSRC    0
+#define H8300_TMR8_CLKEVTDEV 1
+
+#define H8300_TMR8_DIV_8 0
+#define H8300_TMR8_DIV_64 1
+#define H8300_TMR8_DIV_8192 2
+
+struct h8300_timer8_config {
+       int mode;
+       int div;
+       int rating;
+};
+
+struct h8300_timer16_config {
+       int rating;
+       __u8 enb;
+       __u8 imfa;
+       __u8 imiea;
+};
+
+struct h8300_tpu_config {
+       int rating;
+};
+#endif
arch/h8300/include/asm/tlb.h new file +8 -0
new file mode 100644
index 0000000..2c6fa4ee
@@ -0,0 +1,8 @@
+#ifndef __H8300_TLB_H__
+#define __H8300_TLB_H__
+
+#define tlb_flush(tlb) do { } while (0)
+
+#include <asm-generic/tlb.h>
+
+#endif
arch/h8300/include/asm/topology.h new file +6 -0
new file mode 100644
index 0000000..fdc1219
@@ -0,0 +1,6 @@
+#ifndef _ASM_H8300_TOPOLOGY_H
+#define _ASM_H8300_TOPOLOGY_H
+
+#include <asm-generic/topology.h>
+
+#endif /* _ASM_H8300_TOPOLOGY_H */
arch/h8300/include/asm/traps.h new file +41 -0
new file mode 100644
index 0000000..aa34e75
@@ -0,0 +1,41 @@
+/*
+ *  linux/include/asm-h8300/traps.h
+ *
+ *  Copyright (C) 2003 Yoshinori Sato <[email protected]>
+ *
+ * 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.
+ */
+
+#ifndef _H8300_TRAPS_H
+#define _H8300_TRAPS_H
+
+extern void _system_call(void);
+extern void _interrupt_entry(void);
+extern void _trace_break(void);
+extern void _nmi(void);
+extern void _interrupt_entry(void);
+
+extern unsigned long *_interrupt_redirect_table;
+
+#define JMP_OP 0x5a000000
+#define JSR_OP 0x5e000000
+#define VECTOR(address) ((JMP_OP)|((unsigned long)address))
+#define REDIRECT(address) ((JSR_OP)|((unsigned long)address))
+#define CPU_VECTOR ((unsigned long *)0x000000)
+#define ADDR_MASK (0xffffff)
+
+#define TRACE_VEC 5
+
+#define TRAP0_VEC 8
+#define TRAP1_VEC 9
+#define TRAP2_VEC 10
+#define TRAP3_VEC 11
+
+extern char _start, _etext;
+#define check_kernel_text(addr) \
+       ((addr >= (unsigned long)(&_start)) && \
+        (addr <  (unsigned long)(&_etext)))
+
+#endif /* _H8300_TRAPS_H */
arch/h8300/include/asm/uaccess.h new file +136 -0
new file mode 100644
index 0000000..a3b6b18
@@ -0,0 +1,136 @@
+#ifndef __H8300_UACCESS_H
+#define __H8300_UACCESS_H
+
+/*
+ * User space memory access functions
+ */
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+
+#include <asm/segment.h>
+
+#define VERIFY_READ    0
+#define VERIFY_WRITE   1
+
+/* We let the MMU do all checking */
+#define access_ok(type, addr, size) __access_ok((unsigned long)addr, size)
+static inline int __access_ok(unsigned long addr, unsigned long size)
+{
+#define        RANGE_CHECK_OK(addr, size, lower, upper) \
+       (((addr) >= (lower)) && (((addr) + (size)) < (upper)))
+
+       extern unsigned long  memory_end;
+
+       return RANGE_CHECK_OK(addr, size, 0L, memory_end);
+}
+
+/*
+ * The exception table consists of pairs of addresses: the first is the
+ * address of an instruction that is allowed to fault, and the second is
+ * the address at which the program should continue.  No registers are
+ * modified, so it is entirely up to the continuation code to figure out
+ * what to do.
+ *
+ * All the routines below use bits of fixup code that are out of line
+ * with the main instruction path.  This means when everything is well,
+ * we don't even have to jump over them.  Further, they do not intrude
+ * on our cache or tlb entries.
+ */
+
+struct exception_table_entry {
+       unsigned long insn, fixup;
+};
+
+/* Returns 0 if exception not found and fixup otherwise.  */
+extern unsigned long search_exception_table(unsigned long);
+
+
+/*
+ * These are the main single-value transfer routines.  They automatically
+ * use the right size if we just have the right pointer type.
+ */
+
+#define put_user(x, ptr)                               \
+({                                                     \
+       int __pu_err = 0;                               \
+       typeof(*(ptr)) __pu_val = (x);                  \
+       switch (sizeof(*(ptr))) {                       \
+       case 1:                                         \
+       /* falll through */ \
+       case 2:                                         \
+       /* fall through */ \
+       case 4:                                         \
+               *(ptr) = x;                             \
+               break;                                  \
+       case 8:                                         \
+               memcpy(ptr, &__pu_val, sizeof(*(ptr))); \
+               break;                                  \
+       default:                                        \
+               __pu_err = __put_user_bad();            \
+               break;                                  \
+       }                                               \
+       __pu_err;                                       \
+})
+
+#define __put_user(x, ptr) put_user(x, ptr)
+
+extern int __put_user_bad(void);
+
+/*
+ * Tell gcc we read from memory instead of writing: this is because
+ * we do not write to any memory gcc knows about, so there are no
+ * aliasing issues.
+ */
+
+#define __ptr(x) ((unsigned long *)(x))
+
+/*
+ * Tell gcc we read from memory instead of writing: this is because
+ * we do not write to any memory gcc knows about, so there are no
+ * aliasing issues.
+ */
+
+#define get_user(x, ptr)                                       \
+({                                                             \
+       typeof(*(ptr)) __gu_val;                                \
+       int __gu_err = 0;                                       \
+       switch (sizeof(*(ptr))) {                               \
+       case 1:                                                 \
+               *(u8 *)&__gu_val = *((u8 *)(ptr));              \
+               break;                                          \
+       case 2:                                                 \
+               *(u16 *)&__gu_val = *((u16 *)ptr);              \
+               break;                                          \
+       case 4:                                                 \
+               *(u32 *)&__gu_val = *((u32 *)ptr);              \
+               break;                                          \
+       case 8:                                                 \
+               memcpy((void *)&__gu_val, ptr, sizeof(*(ptr))); \
+               break;                                          \
+       default:                                                \
+               __gu_err = __get_user_bad();                    \
+               break;                                          \
+       }                                                       \
+       (x) = (typeof(*(ptr)))__gu_val;                         \
+       __gu_err;                                               \
+})
+#define __get_user(x, ptr) get_user(x, ptr)
+
+extern int __get_user_bad(void);
+
+#define copy_from_user(to, from, n)            (memcpy(to, from, n), 0)
+#define copy_to_user(to, from, n)              (memcpy(to, from, n), 0)
+
+#define __copy_from_user(to, from, n) copy_from_user(to, from, n)
+#define __copy_to_user(to, from, n) copy_to_user(to, from, n)
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
+unsigned long clear_user(void __user *addr, unsigned long size);
+#define strnlen_user(s, n) (strnlen(s, n) + 1)
+long strncpy_from_user(char *d, const char *s, long n);
+
+#define __clear_user   clear_user
+
+#endif /* _H8300_UACCESS_H */
arch/h8300/include/asm/unaligned.h new file +11 -0
new file mode 100644
index 0000000..b8d06c7
@@ -0,0 +1,11 @@
+#ifndef _ASM_H8300_UNALIGNED_H
+#define _ASM_H8300_UNALIGNED_H
+
+#include <linux/unaligned/be_memmove.h>
+#include <linux/unaligned/le_byteshift.h>
+#include <linux/unaligned/generic.h>
+
+#define get_unaligned  __get_unaligned_be
+#define put_unaligned  __put_unaligned_be
+
+#endif /* _ASM_H8300_UNALIGNED_H */
arch/h8300/include/asm/user.h new file +74 -1
new file mode 100644
index 0000000..2e3555f
@@ -0,0 +1,74 @@
+#ifndef _H8300_USER_H
+#define _H8300_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 er1, er2, er3, er4, er5, er6;
+       long er0;
+       long usp;
+       long orig_er0;
+       long ccr;
+       long pc;
+};
+
+/* 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
--

2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Thanks,
//richard
#6 lore raw

Re: [PATCH v8 01/17] h8300: Assembly headers.

In reply to Yoshinori Sato

On 2015-04-20 at 08:13:17 +0200, Yoshinori Sato <[email protected]> wrote:
[...]

Quoted 16 lines
arch/h8300/include/asm/elf.h new file +10 -0
new file mode 100644
index 0000000..09031d0
@@ -0,0 +1,101 @@
+#ifndef __ASM_H8300_ELF_H
+#define __ASM_H8300_ELF_H
+
+/*
+ * ELF register definitions..
+ */
+
+#include <asm/ptrace.h>
+#include <asm/user.h>
+

arch/h8300/include/asm/elf.h line 20

Quoted 10 lines
arch/h8300/include/asm/elf.h new file +10 -0
+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_H8_300)

EM_H8_300 is used here but only introduced in patch 15/17. Please change the order of the patches such that the patch adding EM_H8_300 comes before the ones using it.

arch/h8300/include/asm/elf.h line 27

Quoted 7 lines
arch/h8300/include/asm/elf.h new file +7 -0
+
+/*
+ * These are used to set parameters in the core dumps.
+ */
+#define ELF_CLASS	ELFCLASS32
+#define ELF_DATA	ELFDATA2MSB
+#define ELF_ARCH	EM_H8_300

It's used here again.

Quoted 74 lines
arch/h8300/include/asm/elf.h new file +74 -0
+#if defined(CONFIG_CPU_H8300H)
+#define ELF_CORE_EFLAGS 0x810000
+#endif
+#if defined(CONFIG_CPU_H8S)
+#define ELF_CORE_EFLAGS 0x820000
+#endif
+
+#define ELF_PLAT_INIT(_r) do { (_r)->er1 = 0; } while (0)
+
+#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 R_H8_NONE       0
+#define R_H8_DIR32      1
+#define R_H8_DIR32_28   2
+#define R_H8_DIR32_24   3
+#define R_H8_DIR32_16   4
+#define R_H8_DIR32U     6
+#define R_H8_DIR32U_28  7
+#define R_H8_DIR32U_24  8
+#define R_H8_DIR32U_20  9
+#define R_H8_DIR32U_16 10
+#define R_H8_DIR24     11
+#define R_H8_DIR24_20  12
+#define R_H8_DIR24_16  13
+#define R_H8_DIR24U    14
+#define R_H8_DIR24U_20 15
+#define R_H8_DIR24U_16 16
+#define R_H8_DIR16     17
+#define R_H8_DIR16U    18
+#define R_H8_DIR16S_32 19
+#define R_H8_DIR16S_28 20
+#define R_H8_DIR16S_24 21
+#define R_H8_DIR16S_20 22
+#define R_H8_DIR16S    23
+#define R_H8_DIR8      24
+#define R_H8_DIR8U     25
+#define R_H8_DIR8Z_32  26
+#define R_H8_DIR8Z_28  27
+#define R_H8_DIR8Z_24  28
+#define R_H8_DIR8Z_20  29
+#define R_H8_DIR8Z_16  30
+#define R_H8_PCREL16   31
+#define R_H8_PCREL8    32
+#define R_H8_BPOS      33
+#define R_H8_PCREL32   34
+#define R_H8_GOT32O    35
+#define R_H8_GOT16O    36
+#define R_H8_DIR16A8   59
+#define R_H8_DIR16R8   60
+#define R_H8_DIR24A8   61
+#define R_H8_DIR24R8   62
+#define R_H8_DIR32A16  63
+#define R_H8_ABS32     65
+#define R_H8_ABS32A16 127
+
+#endif
#3 lore raw

Re: [PATCH v8 01/17] h8300: Assembly headers.

In reply to Richard Weinberger

Hi Richard,

Quoted 1 line · On Mon, 20 Apr 2015 09:17:30 +0200 Richard Weinberger…

*tons removed*

Please edit quoted text in your replies down to the essentials. That one was so large that I could not even find what you had commented on. :-(

Signature · 2 lines
Cheers,
Stephen Rothwell                    [email protected]
#4 lore raw

Re: [PATCH v8 01/17] h8300: Assembly headers.

Quoted 10 lines · Stephen Rothwell

Hi Richard,

Quoted 1 line · On Mon, 20 Apr 2015 09:17:30 +0200 Richard Weinberger…

*tons removed*

Please edit quoted text in your replies down to the essentials. That one was so large that I could not even find what you had commented on. :-(

I'm sorry Stephen. Gmail hides such stuff from me. I'll take more care next time.

Signature · 2 lines
Thanks,
//richard
#8 lore raw

Re: [PATCH v8 01/17] h8300: Assembly headers.

In reply to Yoshinori Sato

On 2015-04-20 at 08:13:17 +0200, Yoshinori Sato <[email protected]> wrote:
[...]

Quoted 17 lines
arch/h8300/include/asm/pgtable.h new file +11 -0
new file mode 100644
index 0000000..8341db6
@@ -0,0 +1,49 @@
+#ifndef _H8300_PGTABLE_H
+#define _H8300_PGTABLE_H
+#include <asm-generic/pgtable-nopud.h>
+#include <asm-generic/pgtable.h>
+#define pgtable_cache_init()   do { } while (0)
+extern 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 */

arch/h8300/include/asm/pgtable.h line 21

Quoted 10 lines
arch/h8300/include/asm/pgtable.h new file +10 -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 })
+#define kern_addr_valid(addr)	(1)
+#define pgprot_writecombine(prot)  (prot)
+#define pgprot_noncached pgprot_writecombine
+
+static inline int pte_file(pte_t pte) { return 0; }

No need to define pte_file() anymore, remap_file_pages(2) implementation was replaced by emulation.

arch/h8300/include/asm/pgtable.h line 32

Quoted 11 lines
arch/h8300/include/asm/pgtable.h new file +11 -0
+#define swapper_pg_dir ((pgd_t *) 0)
+/*
+ * ZERO_PAGE is a global shared page that is always zero: used
+ * for zero-mapped memory areas etc..
+ */
+#define ZERO_PAGE(vaddr)	(virt_to_page(0))
+
+/*
+ * These would be in other places but having them here reduces the diffs.
+ */
+extern unsigned int kobjsize(const void *objp);

This prototypes doesn't need to be defined here, it's already in linux/mm.h which is included where kobjsize is used.

arch/h8300/include/asm/pgtable.h line 33

Quoted 1 line
arch/h8300/include/asm/pgtable.h new file +1 -0
+extern int is_in_rom(unsigned long);

This function is no longer defined nor used in the rest of the tree, no need for this prototype as well.

[...]

arch/h8300/include/asm/sh_bios.h line 4

Quoted 10 lines
arch/h8300/include/asm/sh_bios.h new file +4 -0
new file mode 100644
index 0000000..9ce513c
@@ -0,0 +1,4 @@
+#ifndef SH_BIOS_H
+#define SH_BIOS_H
+
+#endif

Why this empty header? Can it be removed?

#5 lore raw

Re: [PATCH v8 01/17] h8300: Assembly headers.

In reply to Richard Weinberger

At Mon, 20 Apr 2015 09:17:30 +0200,

Quoted 2 lines · Richard Weinberger

dOn Mon, Apr 20, 2015 at 8:13 AM, Yoshinori Sato

(snip)

Quoted 5 lines

You can kill TI_EXECDOMAIN, execution domain support is gone.
It would be also nice if the TI_* constants would be created using asm-offsets.c.
See git.kernel.org/linus/37f078ff4c97ad143a6dc2adae31e20a3f780ca7 as an example.

OK.
Removed.

Thanks.

Quoted 8 lines
Signature · 6 lines
Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Yoshinori Sato
<[email protected]>
#7 lore raw

Re: [PATCH v8 01/17] h8300: Assembly headers.

In reply to Tobias Klauser

At Mon, 20 Apr 2015 09:44:46 +0200,

Quoted 25 lines · Tobias Klauser

On 2015-04-20 at 08:13:17 +0200, Yoshinori Sato <[email protected]> wrote:
[...]

Quoted 22 lines
arch/h8300/include/asm/elf.h new file +16 -0
new file mode 100644
index 0000000..09031d0
@@ -0,0 +1,101 @@
+#ifndef __ASM_H8300_ELF_H
+#define __ASM_H8300_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;
+
Quoted 8 lines

arch/h8300/include/asm/elf.h line 20

Quoted 4 lines
arch/h8300/include/asm/elf.h new file +4 -0
+/*
+ * This is used to ensure we don't load something for the wrong architecture.
+ */
+#define elf_check_arch(x) ((x)->e_machine == EM_H8_300)

EM_H8_300 is used here but only introduced in patch 15/17. Please change the order of the patches such that the patch adding EM_H8_300 comes before the ones using it.

OK.
I will changes order next time.

Quoted 88 lines

arch/h8300/include/asm/elf.h line 27

Quoted 7 lines
arch/h8300/include/asm/elf.h new file +7 -0
+
+/*
+ * These are used to set parameters in the core dumps.
+ */
+#define ELF_CLASS	ELFCLASS32
+#define ELF_DATA	ELFDATA2MSB
+#define ELF_ARCH	EM_H8_300

It's used here again.

Quoted 64 lines
arch/h8300/include/asm/elf.h new file +64 -0
+#if defined(CONFIG_CPU_H8300H)
+#define ELF_CORE_EFLAGS 0x810000
+#endif
+#if defined(CONFIG_CPU_H8S)
+#define ELF_CORE_EFLAGS 0x820000
+#endif
+
+#define ELF_PLAT_INIT(_r) do { (_r)->er1 = 0; } while (0)
+
+#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 R_H8_NONE       0
+#define R_H8_DIR32      1
+#define R_H8_DIR32_28   2
+#define R_H8_DIR32_24   3
+#define R_H8_DIR32_16   4
+#define R_H8_DIR32U     6
+#define R_H8_DIR32U_28  7
+#define R_H8_DIR32U_24  8
+#define R_H8_DIR32U_20  9
+#define R_H8_DIR32U_16 10
+#define R_H8_DIR24     11
+#define R_H8_DIR24_20  12
+#define R_H8_DIR24_16  13
+#define R_H8_DIR24U    14
+#define R_H8_DIR24U_20 15
+#define R_H8_DIR24U_16 16
+#define R_H8_DIR16     17
+#define R_H8_DIR16U    18
+#define R_H8_DIR16S_32 19
+#define R_H8_DIR16S_28 20
+#define R_H8_DIR16S_24 21
+#define R_H8_DIR16S_20 22
+#define R_H8_DIR16S    23
+#define R_H8_DIR8      24
+#define R_H8_DIR8U     25
+#define R_H8_DIR8Z_32  26
+#define R_H8_DIR8Z_28  27
+#define R_H8_DIR8Z_24  28
+#define R_H8_DIR8Z_20  29
+#define R_H8_DIR8Z_16  30
+#define R_H8_PCREL16   31
+#define R_H8_PCREL8    32
+#define R_H8_BPOS      33
+#define R_H8_PCREL32   34
+#define R_H8_GOT32O    35

arch/h8300/include/asm/elf.h line 101

Quoted 10 lines
arch/h8300/include/asm/elf.h new file +10 -0
+#define R_H8_GOT16O    36
+#define R_H8_DIR16A8   59
+#define R_H8_DIR16R8   60
+#define R_H8_DIR24A8   61
+#define R_H8_DIR24R8   62
+#define R_H8_DIR32A16  63
+#define R_H8_ABS32     65
+#define R_H8_ABS32A16 127
+
+#endif

--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Yoshinori Sato
<[email protected]>
#9 lore raw

Re: [PATCH v8 01/17] h8300: Assembly headers.

In reply to Tobias Klauser

At Mon, 20 Apr 2015 16:00:34 +0200,

Quoted 25 lines · Tobias Klauser

On 2015-04-20 at 08:13:17 +0200, Yoshinori Sato <[email protected]> wrote:
[...]

Quoted 22 lines
arch/h8300/include/asm/pgtable.h new file +16 -0
new file mode 100644
index 0000000..8341db6
@@ -0,0 +1,49 @@
+#ifndef _H8300_PGTABLE_H
+#define _H8300_PGTABLE_H
+#include <asm-generic/pgtable-nopud.h>
+#include <asm-generic/pgtable.h>
+#define pgtable_cache_init()   do { } while (0)
+extern 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 __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 })
Quoted 8 lines

arch/h8300/include/asm/pgtable.h line 21

Quoted 5 lines
arch/h8300/include/asm/pgtable.h new file +5 -0
+#define kern_addr_valid(addr)	(1)
+#define pgprot_writecombine(prot)  (prot)
+#define pgprot_noncached pgprot_writecombine
+
+static inline int pte_file(pte_t pte) { return 0; }

No need to define pte_file() anymore, remap_file_pages(2) implementation was replaced by emulation.

OK.
Remove it.

Quoted 6 lines
Quoted 6 lines
arch/h8300/include/asm/pgtable.h new file +6 -0
+#define swapper_pg_dir ((pgd_t *) 0)
+/*
+ * ZERO_PAGE is a global shared page that is always zero: used
+ * for zero-mapped memory areas etc..
+ */
+#define ZERO_PAGE(vaddr)	(virt_to_page(0))
Quoted 8 lines

arch/h8300/include/asm/pgtable.h line 32

Quoted 5 lines
arch/h8300/include/asm/pgtable.h new file +5 -0
+
+/*
+ * These would be in other places but having them here reduces the diffs.
+ */
+extern unsigned int kobjsize(const void *objp);

This prototypes doesn't need to be defined here, it's already in linux/mm.h which is included where kobjsize is used.

OK.

Quoted 5 lines

arch/h8300/include/asm/pgtable.h line 33

Quoted 1 line
arch/h8300/include/asm/pgtable.h new file +1 -0
+extern int is_in_rom(unsigned long);

This function is no longer defined nor used in the rest of the tree, no need for this prototype as well.

OK.
Remove.

Quoted 13 lines

[...]

arch/h8300/include/asm/sh_bios.h line 4

Quoted 10 lines
arch/h8300/include/asm/sh_bios.h new file +4 -0
new file mode 100644
index 0000000..9ce513c
@@ -0,0 +1,4 @@
+#ifndef SH_BIOS_H
+#define SH_BIOS_H
+
+#endif

Why this empty header? Can it be removed?

It was necessary before, it's already unnecessary. Removed.

Thanks.

Signature · 2 lines
Yoshinori Sato
<[email protected]>