From dcdf3a293522e6ef09d8b3650ac1ceec56438e5d Mon Sep 17 00:00:00 2001 From: Roman Zippel Date: Tue, 18 Nov 2008 21:25:17 +0100 Subject: m68k: Add helper function handle_kernel_fault() Add helper function handle_kernel_fault() in signal.c, so frame_extra_sizes can become static, and to avoid future code duplication. Signed-off-by: Roman Zippel Signed-off-by: Geert Uytterhoeven --- arch/m68k/kernel/signal.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'arch/m68k/kernel') diff --git a/arch/m68k/kernel/signal.c b/arch/m68k/kernel/signal.c index d12c3b0d9e4f..a0afc239304e 100644 --- a/arch/m68k/kernel/signal.c +++ b/arch/m68k/kernel/signal.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -51,7 +52,7 @@ #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) -const int frame_extra_sizes[16] = { +static const int frame_extra_sizes[16] = { [1] = -1, /* sizeof(((struct frame *)0)->un.fmt1), */ [2] = sizeof(((struct frame *)0)->un.fmt2), [3] = sizeof(((struct frame *)0)->un.fmt3), @@ -69,6 +70,27 @@ const int frame_extra_sizes[16] = { [15] = -1, /* sizeof(((struct frame *)0)->un.fmtf), */ }; +int handle_kernel_fault(struct pt_regs *regs) +{ + const struct exception_table_entry *fixup; + struct pt_regs *tregs; + + /* Are we prepared to handle this kernel fault? */ + fixup = search_exception_tables(regs->pc); + if (!fixup) + return 0; + + /* Create a new four word stack frame, discarding the old one. */ + regs->stkadj = frame_extra_sizes[regs->format]; + tregs = (struct pt_regs *)((long)regs + regs->stkadj); + tregs->vector = regs->vector; + tregs->format = 0; + tregs->pc = fixup->fixup; + tregs->sr = regs->sr; + + return 1; +} + /* * Atomically swap in the new signal mask, and wait for a signal. */ -- cgit v1.2.3 From f67080884a81f58cf95e25c284e30cbed21122a3 Mon Sep 17 00:00:00 2001 From: Roman Zippel Date: Tue, 18 Nov 2008 21:25:17 +0100 Subject: m68k: Use base_trap_init() to initialize vectors So basic initialization is all in one place. Signed-off-by: Roman Zippel Signed-off-by: Geert Uytterhoeven --- arch/m68k/kernel/traps.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'arch/m68k/kernel') diff --git a/arch/m68k/kernel/traps.c b/arch/m68k/kernel/traps.c index ada4f4cca811..cd802d49f7e9 100644 --- a/arch/m68k/kernel/traps.c +++ b/arch/m68k/kernel/traps.c @@ -48,10 +48,7 @@ asmlinkage void nmihandler(void); asmlinkage void fpu_emu(void); #endif -e_vector vectors[256] = { - [VEC_BUSERR] = buserr, - [VEC_SYS] = system_call, -}; +e_vector vectors[256]; /* nmi handler for the Amiga */ asm(".text\n" @@ -64,7 +61,7 @@ asm(".text\n" */ void __init base_trap_init(void) { - if(MACH_IS_SUN3X) { + if (MACH_IS_SUN3X) { extern e_vector *sun3x_prom_vbr; __asm__ volatile ("movec %%vbr, %0" : "=r" (sun3x_prom_vbr)); @@ -79,6 +76,9 @@ void __init base_trap_init(void) vectors[VEC_UNIMPII] = unimp_vec; } + + vectors[VEC_BUSERR] = buserr; + vectors[VEC_SYS] = system_call; } void __init trap_init (void) -- cgit v1.2.3 From cf6da575ad8d86afa591dd78114067bbff448c36 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 18 Nov 2008 21:25:17 +0100 Subject: m68k: Allow all kernel traps to be handled via exception fixups This will be needed by the ARAnyM Native Feature initialization code. Also document that the VEC_TRACE check is needed for 68020/30. Signed-off-by: Andreas Schwab Signed-off-by: Geert Uytterhoeven --- arch/m68k/kernel/traps.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'arch/m68k/kernel') diff --git a/arch/m68k/kernel/traps.c b/arch/m68k/kernel/traps.c index cd802d49f7e9..4022bbc28878 100644 --- a/arch/m68k/kernel/traps.c +++ b/arch/m68k/kernel/traps.c @@ -58,6 +58,7 @@ asm(".text\n" /* * this must be called very early as the kernel might * use some instruction that are emulated on the 060 + * and so we're prepared for early probe attempts (e.g. nf_init). */ void __init base_trap_init(void) { @@ -78,6 +79,7 @@ void __init base_trap_init(void) } vectors[VEC_BUSERR] = buserr; + vectors[VEC_ILLEGAL] = trap; vectors[VEC_SYS] = system_call; } @@ -1055,9 +1057,11 @@ asmlinkage void trap_c(struct frame *fp) siginfo_t info; if (fp->ptregs.sr & PS_S) { - if ((fp->ptregs.vector >> 2) == VEC_TRACE) { - /* traced a trapping instruction */ - } else + if (fp->ptregs.vector == VEC_TRACE << 2) { + /* traced a trapping instruction on a 68020/30, + * real exception will be executed afterwards. + */ + } else if (!handle_kernel_fault(&fp->ptregs)) bad_super_trap(fp); return; } -- cgit v1.2.3 From 65cd577d5e61043d1c1aec5812dea8a5c834652d Mon Sep 17 00:00:00 2001 From: Petr Stehlik Date: Tue, 18 Nov 2008 21:02:18 +0100 Subject: m68k/atari: Initial ARAnyM support Add improved support for running under the ARAnyM emulator (Atari Running on Any Machine - http://aranym.org/). [michael, geert: Cleanups and updates] Signed-off-by: Petr Stehlik Signed-off-by: Michael Schmitz Signed-off-by: Geert Uytterhoeven --- arch/m68k/Kconfig | 7 +++ arch/m68k/Makefile | 1 + arch/m68k/emu/Makefile | 5 ++ arch/m68k/emu/natfeat.c | 116 ++++++++++++++++++++++++++++++++++++++++ arch/m68k/include/asm/natfeat.h | 22 ++++++++ arch/m68k/kernel/setup.c | 5 ++ 6 files changed, 156 insertions(+) create mode 100644 arch/m68k/emu/Makefile create mode 100644 arch/m68k/emu/natfeat.c create mode 100644 arch/m68k/include/asm/natfeat.h (limited to 'arch/m68k/kernel') diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index cbe8b18e808b..f668a5802a4a 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -240,6 +240,13 @@ config SUN3 If you don't want to compile a kernel exclusively for a Sun 3, say N. +config NATFEAT + bool "ARAnyM emulator support" + depends on ATARI + help + This option enables support for ARAnyM native features, such as + access to a disk image as /dev/hda. + comment "Processor type" config M68020 diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile index b06a7e3cbcd6..b793163abc61 100644 --- a/arch/m68k/Makefile +++ b/arch/m68k/Makefile @@ -76,6 +76,7 @@ core-$(CONFIG_MVME16x) += arch/m68k/mvme16x/ core-$(CONFIG_BVME6000) += arch/m68k/bvme6000/ core-$(CONFIG_SUN3X) += arch/m68k/sun3x/ arch/m68k/sun3/ core-$(CONFIG_SUN3) += arch/m68k/sun3/ arch/m68k/sun3/prom/ +core-$(CONFIG_NATFEAT) += arch/m68k/emu/ core-$(CONFIG_M68040) += arch/m68k/fpsp040/ core-$(CONFIG_M68060) += arch/m68k/ifpsp060/ core-$(CONFIG_M68KFPU_EMU) += arch/m68k/math-emu/ diff --git a/arch/m68k/emu/Makefile b/arch/m68k/emu/Makefile new file mode 100644 index 000000000000..34cfa348ca2b --- /dev/null +++ b/arch/m68k/emu/Makefile @@ -0,0 +1,5 @@ +# +# Makefile for Linux arch/m68k/emu source directory +# + +obj-y += natfeat.o diff --git a/arch/m68k/emu/natfeat.c b/arch/m68k/emu/natfeat.c new file mode 100644 index 000000000000..987d77322178 --- /dev/null +++ b/arch/m68k/emu/natfeat.c @@ -0,0 +1,116 @@ +/* + * natfeat.c - ARAnyM hardware support via Native Features (natfeats) + * + * Copyright (c) 2005 Petr Stehlik of ARAnyM dev team + * + * Reworked for Linux by Roman Zippel + * + * This software may be used and distributed according to the terms of + * the GNU General Public License (GPL), incorporated herein by reference. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +asm("\n" +" .global nf_get_id,nf_call\n" +"nf_get_id:\n" +" .short 0x7300\n" +" rts\n" +"nf_call:\n" +" .short 0x7301\n" +" rts\n" +"1: moveq.l #0,%d0\n" +" rts\n" +" .section __ex_table,\"a\"\n" +" .long nf_get_id,1b\n" +" .long nf_call,1b\n" +" .previous"); +EXPORT_SYMBOL_GPL(nf_get_id); +EXPORT_SYMBOL_GPL(nf_call); + +static int stderr_id; + +static void nf_write(struct console *co, const char *str, unsigned int count) +{ + char buf[68]; + + buf[64] = 0; + while (count > 64) { + memcpy(buf, str, 64); + nf_call(stderr_id, buf); + str += 64; + count -= 64; + } + memcpy(buf, str, count); + buf[count] = 0; + nf_call(stderr_id, buf); +} + +void nfprint(const char *fmt, ...) +{ + static char buf[256]; + va_list ap; + int n; + + va_start(ap, fmt); + n = vsnprintf(buf, 256, fmt, ap); + nf_call(nf_get_id("NF_STDERR"), buf); + va_end(ap); +} + +static struct console nf_console_driver = { + .name = "debug", + .write = nf_write, + .flags = CON_PRINTBUFFER, + .index = -1, +}; + +static int __init nf_debug_setup(char *arg) +{ + if (strcmp(arg, "emu")) + return 0; + + stderr_id = nf_get_id("NF_STDERR"); + if (stderr_id) + register_console(&nf_console_driver); + return 0; +} + +early_param("debug", nf_debug_setup); + +static void nf_poweroff(void) +{ + long id = nf_get_id("NF_SHUTDOWN"); + + if (id) + nf_call(id); +} + +void nf_init(void) +{ + unsigned long id, version; + char buf[256]; + + id = nf_get_id("NF_VERSION"); + if (!id) + return; + version = nf_call(id); + + id = nf_get_id("NF_NAME"); + if (!id) + return; + nf_call(id, buf, 256); + buf[255] = 0; + + pr_info("NatFeats found (%s, %lu.%lu)\n", buf, version >> 16, + version & 0xffff); + + mach_power_off = nf_poweroff; +} diff --git a/arch/m68k/include/asm/natfeat.h b/arch/m68k/include/asm/natfeat.h new file mode 100644 index 000000000000..a3521b80c3b9 --- /dev/null +++ b/arch/m68k/include/asm/natfeat.h @@ -0,0 +1,22 @@ +/* + * ARAnyM hardware support via Native Features (natfeats) + * + * Copyright (c) 2005 Petr Stehlik of ARAnyM dev team + * + * This software may be used and distributed according to the terms of + * the GNU General Public License (GPL), incorporated herein by reference. + */ + +#ifndef _NATFEAT_H +#define _NATFEAT_H + +long nf_get_id(const char *feature_name); +long nf_call(long id, ...); + +void nf_init(void); +void nf_shutdown(void); + +void nfprint(const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + +# endif /* _NATFEAT_H */ diff --git a/arch/m68k/kernel/setup.c b/arch/m68k/kernel/setup.c index b3963ab3d149..334d83640376 100644 --- a/arch/m68k/kernel/setup.c +++ b/arch/m68k/kernel/setup.c @@ -42,6 +42,7 @@ #ifdef CONFIG_SUN3X #include #endif +#include #if !FPSTATESIZE || !NR_IRQS #warning No CPU/platform type selected, your kernel will not work! @@ -324,6 +325,10 @@ void __init setup_arch(char **cmdline_p) panic("No configuration setup"); } +#ifdef CONFIG_NATFEAT + nf_init(); +#endif + paging_init(); #ifndef CONFIG_SUN3 -- cgit v1.2.3