m68k/atari: Initial ARAnyM support
authorPetr Stehlik <pstehlik@sophics.cz>
Tue, 18 Nov 2008 20:02:18 +0000 (21:02 +0100)
committerGeert Uytterhoeven <geert@linux-m68k.org>
Wed, 16 Mar 2011 18:10:41 +0000 (19:10 +0100)
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 <pstehlik@sophics.cz>
Signed-off-by: Michael Schmitz <schmitz@debian.org>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
arch/m68k/Kconfig
arch/m68k/Makefile
arch/m68k/emu/Makefile [new file with mode: 0644]
arch/m68k/emu/natfeat.c [new file with mode: 0644]
arch/m68k/include/asm/natfeat.h [new file with mode: 0644]
arch/m68k/kernel/setup.c

index cbe8b18e808b02050b2a1a884974a990deed96aa..f668a5802a4ab2209315b0532fec046e59e17ccc 100644 (file)
@@ -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
index b06a7e3cbcd6491de55c409e9516a1d68d6ed527..b793163abc610212618f38a2c1680d6048b41322 100644 (file)
@@ -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 (file)
index 0000000..34cfa34
--- /dev/null
@@ -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 (file)
index 0000000..987d773
--- /dev/null
@@ -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 <zippel@linux-m68k.org>
+ *
+ * This software may be used and distributed according to the terms of
+ * the GNU General Public License (GPL), incorporated herein by reference.
+ */
+
+#include <linux/types.h>
+#include <linux/console.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/io.h>
+#include <asm/machdep.h>
+#include <asm/natfeat.h>
+
+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 (file)
index 0000000..a3521b8
--- /dev/null
@@ -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 */
index b3963ab3d1493fb7a443e2834744f1b9281ac37e..334d83640376762b058a7a4010e2878fffe21439 100644 (file)
@@ -42,6 +42,7 @@
 #ifdef CONFIG_SUN3X
 #include <asm/dvma.h>
 #endif
+#include <asm/natfeat.h>
 
 #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