diff options
author | Petr Stehlik <pstehlik@sophics.cz> | 2008-11-18 15:02:18 -0500 |
---|---|---|
committer | Geert Uytterhoeven <geert@linux-m68k.org> | 2011-03-16 14:10:41 -0400 |
commit | 65cd577d5e61043d1c1aec5812dea8a5c834652d (patch) | |
tree | 7823e6b01e354717dc5340e6231f48a357a6de9e /arch/m68k/emu | |
parent | 93ff9542462ba5074fb6b6cd9e27c4fb04d452ec (diff) |
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 <pstehlik@sophics.cz>
Signed-off-by: Michael Schmitz <schmitz@debian.org>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Diffstat (limited to 'arch/m68k/emu')
-rw-r--r-- | arch/m68k/emu/Makefile | 5 | ||||
-rw-r--r-- | arch/m68k/emu/natfeat.c | 116 |
2 files changed, 121 insertions, 0 deletions
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 @@ | |||
1 | # | ||
2 | # Makefile for Linux arch/m68k/emu source directory | ||
3 | # | ||
4 | |||
5 | 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 @@ | |||
1 | /* | ||
2 | * natfeat.c - ARAnyM hardware support via Native Features (natfeats) | ||
3 | * | ||
4 | * Copyright (c) 2005 Petr Stehlik of ARAnyM dev team | ||
5 | * | ||
6 | * Reworked for Linux by Roman Zippel <zippel@linux-m68k.org> | ||
7 | * | ||
8 | * This software may be used and distributed according to the terms of | ||
9 | * the GNU General Public License (GPL), incorporated herein by reference. | ||
10 | */ | ||
11 | |||
12 | #include <linux/types.h> | ||
13 | #include <linux/console.h> | ||
14 | #include <linux/string.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <asm/machdep.h> | ||
19 | #include <asm/natfeat.h> | ||
20 | |||
21 | asm("\n" | ||
22 | " .global nf_get_id,nf_call\n" | ||
23 | "nf_get_id:\n" | ||
24 | " .short 0x7300\n" | ||
25 | " rts\n" | ||
26 | "nf_call:\n" | ||
27 | " .short 0x7301\n" | ||
28 | " rts\n" | ||
29 | "1: moveq.l #0,%d0\n" | ||
30 | " rts\n" | ||
31 | " .section __ex_table,\"a\"\n" | ||
32 | " .long nf_get_id,1b\n" | ||
33 | " .long nf_call,1b\n" | ||
34 | " .previous"); | ||
35 | EXPORT_SYMBOL_GPL(nf_get_id); | ||
36 | EXPORT_SYMBOL_GPL(nf_call); | ||
37 | |||
38 | static int stderr_id; | ||
39 | |||
40 | static void nf_write(struct console *co, const char *str, unsigned int count) | ||
41 | { | ||
42 | char buf[68]; | ||
43 | |||
44 | buf[64] = 0; | ||
45 | while (count > 64) { | ||
46 | memcpy(buf, str, 64); | ||
47 | nf_call(stderr_id, buf); | ||
48 | str += 64; | ||
49 | count -= 64; | ||
50 | } | ||
51 | memcpy(buf, str, count); | ||
52 | buf[count] = 0; | ||
53 | nf_call(stderr_id, buf); | ||
54 | } | ||
55 | |||
56 | void nfprint(const char *fmt, ...) | ||
57 | { | ||
58 | static char buf[256]; | ||
59 | va_list ap; | ||
60 | int n; | ||
61 | |||
62 | va_start(ap, fmt); | ||
63 | n = vsnprintf(buf, 256, fmt, ap); | ||
64 | nf_call(nf_get_id("NF_STDERR"), buf); | ||
65 | va_end(ap); | ||
66 | } | ||
67 | |||
68 | static struct console nf_console_driver = { | ||
69 | .name = "debug", | ||
70 | .write = nf_write, | ||
71 | .flags = CON_PRINTBUFFER, | ||
72 | .index = -1, | ||
73 | }; | ||
74 | |||
75 | static int __init nf_debug_setup(char *arg) | ||
76 | { | ||
77 | if (strcmp(arg, "emu")) | ||
78 | return 0; | ||
79 | |||
80 | stderr_id = nf_get_id("NF_STDERR"); | ||
81 | if (stderr_id) | ||
82 | register_console(&nf_console_driver); | ||
83 | return 0; | ||
84 | } | ||
85 | |||
86 | early_param("debug", nf_debug_setup); | ||
87 | |||
88 | static void nf_poweroff(void) | ||
89 | { | ||
90 | long id = nf_get_id("NF_SHUTDOWN"); | ||
91 | |||
92 | if (id) | ||
93 | nf_call(id); | ||
94 | } | ||
95 | |||
96 | void nf_init(void) | ||
97 | { | ||
98 | unsigned long id, version; | ||
99 | char buf[256]; | ||
100 | |||
101 | id = nf_get_id("NF_VERSION"); | ||
102 | if (!id) | ||
103 | return; | ||
104 | version = nf_call(id); | ||
105 | |||
106 | id = nf_get_id("NF_NAME"); | ||
107 | if (!id) | ||
108 | return; | ||
109 | nf_call(id, buf, 256); | ||
110 | buf[255] = 0; | ||
111 | |||
112 | pr_info("NatFeats found (%s, %lu.%lu)\n", buf, version >> 16, | ||
113 | version & 0xffff); | ||
114 | |||
115 | mach_power_off = nf_poweroff; | ||
116 | } | ||