arthur.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * linux/arch/arm/kernel/arthur.c
  3. *
  4. * Copyright (C) 1998, 1999, 2000, 2001 Philip Blundell
  5. *
  6. * Arthur personality
  7. */
  8. /*
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #include <linux/module.h>
  15. #include <linux/personality.h>
  16. #include <linux/stddef.h>
  17. #include <linux/signal.h>
  18. #include <linux/init.h>
  19. #include <asm/ptrace.h>
  20. /* Arthur doesn't have many signals, and a lot of those that it does
  21. have don't map easily to any Linux equivalent. Never mind. */
  22. #define ARTHUR_SIGABRT 1
  23. #define ARTHUR_SIGFPE 2
  24. #define ARTHUR_SIGILL 3
  25. #define ARTHUR_SIGINT 4
  26. #define ARTHUR_SIGSEGV 5
  27. #define ARTHUR_SIGTERM 6
  28. #define ARTHUR_SIGSTAK 7
  29. #define ARTHUR_SIGUSR1 8
  30. #define ARTHUR_SIGUSR2 9
  31. #define ARTHUR_SIGOSERROR 10
  32. static unsigned long arthur_to_linux_signals[32] = {
  33. 0, 1, 2, 3, 4, 5, 6, 7,
  34. 8, 9, 10, 11, 12, 13, 14, 15,
  35. 16, 17, 18, 19, 20, 21, 22, 23,
  36. 24, 25, 26, 27, 28, 29, 30, 31
  37. };
  38. static unsigned long linux_to_arthur_signals[32] = {
  39. 0, -1, ARTHUR_SIGINT, -1,
  40. ARTHUR_SIGILL, 5, ARTHUR_SIGABRT, 7,
  41. ARTHUR_SIGFPE, 9, ARTHUR_SIGUSR1, ARTHUR_SIGSEGV,
  42. ARTHUR_SIGUSR2, 13, 14, ARTHUR_SIGTERM,
  43. 16, 17, 18, 19,
  44. 20, 21, 22, 23,
  45. 24, 25, 26, 27,
  46. 28, 29, 30, 31
  47. };
  48. static void arthur_lcall7(int nr, struct pt_regs *regs)
  49. {
  50. struct siginfo info;
  51. info.si_signo = SIGSWI;
  52. info.si_errno = nr;
  53. /* Bounce it to the emulator */
  54. send_sig_info(SIGSWI, &info, current);
  55. }
  56. static struct exec_domain arthur_exec_domain = {
  57. .name = "Arthur",
  58. .handler = arthur_lcall7,
  59. .pers_low = PER_RISCOS,
  60. .pers_high = PER_RISCOS,
  61. .signal_map = arthur_to_linux_signals,
  62. .signal_invmap = linux_to_arthur_signals,
  63. .module = THIS_MODULE,
  64. };
  65. /*
  66. * We could do with some locking to stop Arthur being removed while
  67. * processes are using it.
  68. */
  69. static int __init arthur_init(void)
  70. {
  71. return register_exec_domain(&arthur_exec_domain);
  72. }
  73. static void __exit arthur_exit(void)
  74. {
  75. unregister_exec_domain(&arthur_exec_domain);
  76. }
  77. module_init(arthur_init);
  78. module_exit(arthur_exit);