syscall.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #pragma once
  2. #include <stdint.h>
  3. // 系统调用号
  4. #define SYS_NOT_EXISTS 0
  5. #define SYS_PUT_STRING 1
  6. #define SYS_OPEN 2
  7. #define SYS_CLOSE 3
  8. #define SYS_READ 4
  9. #define SYS_WRITE 5
  10. #define SYS_LSEEK 6
  11. #define SYS_FORK 7
  12. #define SYS_VFORK 8
  13. #define SYS_BRK 9
  14. #define SYS_SBRK 10
  15. #define SYS_REBOOT 11 // 重启
  16. #define SYS_CHDIR 12 // 切换工作目录
  17. #define SYS_GET_DENTS 13 // 获取目录中的数据
  18. #define SYS_EXECVE 14 // 执行新的应用程序
  19. #define SYS_WAIT4 15 // 等待进程退出
  20. #define SYS_EXIT 16 // 进程退出
  21. #define SYS_MKDIR 17 // 创建文件夹
  22. #define SYS_NANOSLEEP 18 // 纳秒级休眠
  23. #define SYS_CLOCK 19 // 获取当前cpu时间
  24. #define SYS_PIPE 20
  25. // 现在已经废弃
  26. // #define SYS_MSTAT 21 // 获取系统的内存状态信息
  27. #define SYS_UNLINK_AT 22 // 删除文件夹/删除文件链接
  28. #define SYS_KILL 23 // kill一个进程(向这个进程发出信号)
  29. #define SYS_SIGACTION 24 // 设置进程的信号处理动作
  30. #define SYS_RT_SIGRETURN 25 // 从信号处理函数返回
  31. #define SYS_GETPID 26 // 获取当前进程的pid(进程标识符)
  32. #define SYS_DUP 28
  33. #define SYS_DUP2 29
  34. #define SYS_SOCKET 30 // 创建一个socket
  35. #define SYS_SETSOCKOPT 31 // 设置socket的选项
  36. #define SYS_GETSOCKOPT 32 // 获取socket的选项
  37. #define SYS_CONNECT 33 // 连接到一个socket
  38. #define SYS_BIND 34 // 绑定一个socket
  39. #define SYS_SENDTO 35 // 向一个socket发送数据
  40. #define SYS_RECVFROM 36 // 从一个socket接收数据
  41. #define SYS_RECVMSG 37 // 从一个socket接收消息
  42. #define SYS_LISTEN 38 // 监听一个socket
  43. #define SYS_SHUTDOWN 39 // 关闭socket
  44. #define SYS_ACCEPT 40 // 接受一个socket连接
  45. #define SYS_GETSOCKNAME 41 // 获取socket的名字
  46. #define SYS_GETPEERNAME 42 // 获取socket的对端名字
  47. #define SYS_IOCTL 54
  48. #define SYS_GETCWD 48
  49. /**
  50. * @brief 用户态系统调用函数
  51. *
  52. * @param syscall_id
  53. * @param arg0
  54. * @param arg1
  55. * @param arg2
  56. * @param arg3
  57. * @param arg4
  58. * @param arg5
  59. * @param arg6
  60. * @param arg7
  61. * @return long
  62. */
  63. long syscall_invoke(uint64_t syscall_id, uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4,
  64. uint64_t arg5, uint64_t arg6, uint64_t arg7);