natfeat.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. #include <linux/types.h>
  12. #include <linux/console.h>
  13. #include <linux/string.h>
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/io.h>
  17. #include <asm/machdep.h>
  18. #include <asm/natfeat.h>
  19. asm("\n"
  20. " .global nf_get_id,nf_call\n"
  21. "nf_get_id:\n"
  22. " .short 0x7300\n"
  23. " rts\n"
  24. "nf_call:\n"
  25. " .short 0x7301\n"
  26. " rts\n"
  27. "1: moveq.l #0,%d0\n"
  28. " rts\n"
  29. " .section __ex_table,\"a\"\n"
  30. " .long nf_get_id,1b\n"
  31. " .long nf_call,1b\n"
  32. " .previous");
  33. EXPORT_SYMBOL_GPL(nf_get_id);
  34. EXPORT_SYMBOL_GPL(nf_call);
  35. void nfprint(const char *fmt, ...)
  36. {
  37. static char buf[256];
  38. va_list ap;
  39. int n;
  40. va_start(ap, fmt);
  41. n = vsnprintf(buf, 256, fmt, ap);
  42. nf_call(nf_get_id("NF_STDERR"), buf);
  43. va_end(ap);
  44. }
  45. static void nf_poweroff(void)
  46. {
  47. long id = nf_get_id("NF_SHUTDOWN");
  48. if (id)
  49. nf_call(id);
  50. }
  51. void nf_init(void)
  52. {
  53. unsigned long id, version;
  54. char buf[256];
  55. id = nf_get_id("NF_VERSION");
  56. if (!id)
  57. return;
  58. version = nf_call(id);
  59. id = nf_get_id("NF_NAME");
  60. if (!id)
  61. return;
  62. nf_call(id, buf, 256);
  63. buf[255] = 0;
  64. pr_info("NatFeats found (%s, %lu.%lu)\n", buf, version >> 16,
  65. version & 0xffff);
  66. mach_power_off = nf_poweroff;
  67. }