dragonos.rs 2.0 KB

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