dragonos.rs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. use core::arch::global_asm;
  2. // Needs to be defined in assembly because it can't have a function prologue
  3. // rax is register, 25 is RT_SIGRETURN
  4. #[cfg(target_arch = "x86_64")]
  5. global_asm!(
  6. "
  7. .global __restore_rt
  8. __restore_rt:
  9. push rbp
  10. mov rbp,rsp
  11. mov eax, 25
  12. int 0x80
  13. nop
  14. pop rbp
  15. ret
  16. "
  17. );
  18. // x8 is register, 139 is RT_SIGRETURN
  19. #[cfg(target_arch = "aarch64")]
  20. global_asm!(
  21. "
  22. .global __restore_rt
  23. __restore_rt:
  24. mov x8, #139
  25. svc 0
  26. "
  27. );
  28. pub const SIGHUP: usize = 1;
  29. pub const SIGINT: usize = 2;
  30. pub const SIGQUIT: usize = 3;
  31. pub const SIGILL: usize = 4;
  32. pub const SIGTRAP: usize = 5;
  33. pub const SIGABRT: usize = 6;
  34. pub const SIGIOT: usize = SIGABRT;
  35. pub const SIGBUS: usize = 7;
  36. pub const SIGFPE: usize = 8;
  37. pub const SIGKILL: usize = 9;
  38. pub const SIGUSR1: usize = 10;
  39. pub const SIGSEGV: usize = 11;
  40. pub const SIGUSR2: usize = 12;
  41. pub const SIGPIPE: usize = 13;
  42. pub const SIGALRM: usize = 14;
  43. pub const SIGTERM: usize = 15;
  44. pub const SIGSTKFLT: usize = 16;
  45. pub const SIGCHLD: usize = 17;
  46. pub const SIGCONT: usize = 18;
  47. pub const SIGSTOP: usize = 19;
  48. pub const SIGTSTP: usize = 20;
  49. pub const SIGTTIN: usize = 21;
  50. pub const SIGTTOU: usize = 22;
  51. pub const SIGURG: usize = 23;
  52. pub const SIGXCPU: usize = 24;
  53. pub const SIGXFSZ: usize = 25;
  54. pub const SIGVTALRM: usize = 26;
  55. pub const SIGPROF: usize = 27;
  56. pub const SIGWINCH: usize = 28;
  57. pub const SIGIO: usize = 29;
  58. pub const SIGPOLL: usize = SIGIO;
  59. pub const SIGPWR: usize = 30;
  60. pub const SIGSYS: usize = 31;
  61. pub const SIGUNUSED: usize = SIGSYS;
  62. pub const NSIG: usize = 32;
  63. pub const SA_NOCLDSTOP: usize = 1;
  64. pub const SA_NOCLDWAIT: usize = 2;
  65. pub const SA_SIGINFO: usize = 4;
  66. pub const SA_ONSTACK: usize = 0x0800_0000;
  67. pub const SA_RESTART: usize = 0x1000_0000;
  68. pub const SA_NODEFER: usize = 0x4000_0000;
  69. pub const SA_RESETHAND: usize = 0x8000_0000;
  70. pub const SA_RESTORER: usize = 0x0400_0000;
  71. pub const SS_ONSTACK: usize = 1;
  72. pub const SS_DISABLE: usize = 2;
  73. // Those two should be updated from kernel headers
  74. pub const MINSIGSTKSZ: usize = 2048;
  75. pub const SIGSTKSZ: usize = 8096;