arthur.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 <linux/sched.h>
  20. #include <asm/ptrace.h>
  21. /* Arthur doesn't have many signals, and a lot of those that it does
  22. have don't map easily to any Linux equivalent. Never mind. */
  23. #define ARTHUR_SIGABRT 1
  24. #define ARTHUR_SIGFPE 2
  25. #define ARTHUR_SIGILL 3
  26. #define ARTHUR_SIGINT 4
  27. #define ARTHUR_SIGSEGV 5
  28. #define ARTHUR_SIGTERM 6
  29. #define ARTHUR_SIGSTAK 7
  30. #define ARTHUR_SIGUSR1 8
  31. #define ARTHUR_SIGUSR2 9
  32. #define ARTHUR_SIGOSERROR 10
  33. static unsigned long arthur_to_linux_signals[32] = {
  34. 0, 1, 2, 3, 4, 5, 6, 7,
  35. 8, 9, 10, 11, 12, 13, 14, 15,
  36. 16, 17, 18, 19, 20, 21, 22, 23,
  37. 24, 25, 26, 27, 28, 29, 30, 31
  38. };
  39. static unsigned long linux_to_arthur_signals[32] = {
  40. 0, -1, ARTHUR_SIGINT, -1,
  41. ARTHUR_SIGILL, 5, ARTHUR_SIGABRT, 7,
  42. ARTHUR_SIGFPE, 9, ARTHUR_SIGUSR1, ARTHUR_SIGSEGV,
  43. ARTHUR_SIGUSR2, 13, 14, ARTHUR_SIGTERM,
  44. 16, 17, 18, 19,
  45. 20, 21, 22, 23,
  46. 24, 25, 26, 27,
  47. 28, 29, 30, 31
  48. };
  49. static void arthur_lcall7(int nr, struct pt_regs *regs)
  50. {
  51. struct siginfo info;
  52. info.si_signo = SIGSWI;
  53. info.si_errno = nr;
  54. /* Bounce it to the emulator */
  55. send_sig_info(SIGSWI, &info, current);
  56. }
  57. static struct exec_domain arthur_exec_domain = {
  58. .name = "Arthur",
  59. .handler = arthur_lcall7,
  60. .pers_low = PER_RISCOS,
  61. .pers_high = PER_RISCOS,
  62. .signal_map = arthur_to_linux_signals,
  63. .signal_invmap = linux_to_arthur_signals,
  64. .module = THIS_MODULE,
  65. };
  66. /*
  67. * We could do with some locking to stop Arthur being removed while
  68. * processes are using it.
  69. */
  70. static int __init arthur_init(void)
  71. {
  72. return register_exec_domain(&arthur_exec_domain);
  73. }
  74. static void __exit arthur_exit(void)
  75. {
  76. unregister_exec_domain(&arthur_exec_domain);
  77. }
  78. module_init(arthur_init);
  79. module_exit(arthur_exit);