2 * natfeat.c - ARAnyM hardware support via Native Features (natfeats)
4 * Copyright (c) 2005 Petr Stehlik of ARAnyM dev team
6 * Reworked for Linux by Roman Zippel <zippel@linux-m68k.org>
8 * This software may be used and distributed according to the terms of
9 * the GNU General Public License (GPL), incorporated herein by reference.
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>
18 #include <asm/machdep.h>
19 #include <asm/natfeat.h>
21 extern long nf_get_id_phys(unsigned long feature_name);
24 " .global nf_get_id_phys,nf_call\n"
33 " .section __ex_table,\"a\"\n"
34 " .long nf_get_id_phys,1b\n"
37 EXPORT_SYMBOL_GPL(nf_call);
39 long nf_get_id(const char *feature_name)
41 /* feature_name may be in vmalloc()ed memory, so make a copy */
45 n = strlcpy(name_copy, feature_name, sizeof(name_copy));
46 if (n >= sizeof(name_copy))
49 return nf_get_id_phys(virt_to_phys(name_copy));
51 EXPORT_SYMBOL_GPL(nf_get_id);
53 void nfprint(const char *fmt, ...)
60 n = vsnprintf(buf, 256, fmt, ap);
61 nf_call(nf_get_id("NF_STDERR"), virt_to_phys(buf));
65 static void nf_poweroff(void)
67 long id = nf_get_id("NF_SHUTDOWN");
75 unsigned long id, version;
78 id = nf_get_id("NF_VERSION");
81 version = nf_call(id);
83 id = nf_get_id("NF_NAME");
86 nf_call(id, virt_to_phys(buf), 256);
89 pr_info("NatFeats found (%s, %lu.%lu)\n", buf, version >> 16,
92 mach_power_off = nf_poweroff;