Syscall.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #pragma once
  2. #include <AK/Types.h>
  3. #define DO_SYSCALL_A0(function) Syscall::invoke((dword)(function))
  4. #define DO_SYSCALL_A1(function, arg1) Syscall::invoke((dword)(function), (dword)(arg1))
  5. #define DO_SYSCALL_A2(function, arg1, arg2) Syscall::invoke((dword)(function), (dword)(arg1), (dword)(arg2))
  6. #define DO_SYSCALL_A3(function, arg1, arg2, arg3) Syscall::invoke((dword)(function), (dword)(arg1), (dword)(arg2), (dword)arg3)
  7. namespace Syscall {
  8. enum Function {
  9. Spawn = 0x1981,
  10. Sleep = 0x1982,
  11. Yield = 0x1983,
  12. PutCharacter = 0x1984,
  13. PosixOpen = 0x1985,
  14. PosixClose = 0x1986,
  15. PosixRead = 0x1987,
  16. PosixLseek = 0x1988,
  17. PosixKill = 0x1989,
  18. PosixGetuid = 0x1990,
  19. PosixExit = 0x1991,
  20. PosixGetgid = 0x1992,
  21. PosixGetpid = 0x1993,
  22. PosixWaitpid = 0x1994,
  23. PosixMmap = 0x1995,
  24. PosixMunmap = 0x1996,
  25. GetDirEntries = 0x1997,
  26. PosixLstat = 0x1998,
  27. PosixGetcwd = 0x1999,
  28. PosixGettimeofday = 0x2000,
  29. PosixGethostname = 0x2001,
  30. GetArguments = 0x2002,
  31. PosixChdir = 0x2003,
  32. PosixUname = 0x2004,
  33. SetMmapName = 0x2005,
  34. PosixReadlink = 0x2006,
  35. PosixWrite = 0x2007,
  36. PosixTtynameR = 0x2008,
  37. PosixStat = 0x2009,
  38. GetEnvironment = 0x2010,
  39. PosixGetsid = 0x2011,
  40. PosixSetsid = 0x2012,
  41. PosixGetpgid = 0x2013,
  42. PosixSetpgid = 0x2014,
  43. PosixGetpgrp = 0x2015,
  44. };
  45. void initialize();
  46. inline dword invoke(dword function)
  47. {
  48. dword result;
  49. asm volatile("int $0x80":"=a"(result):"a"(function));
  50. return result;
  51. }
  52. inline dword invoke(dword function, dword arg1)
  53. {
  54. dword result;
  55. asm volatile("int $0x80":"=a"(result):"a"(function),"d"(arg1));
  56. return result;
  57. }
  58. inline dword invoke(dword function, dword arg1, dword arg2)
  59. {
  60. dword result;
  61. asm volatile("int $0x80":"=a"(result):"a"(function),"d"(arg1),"c"(arg2));
  62. return result;
  63. }
  64. inline dword invoke(dword function, dword arg1, dword arg2, dword arg3)
  65. {
  66. dword result;
  67. asm volatile("int $0x80":"=a"(result):"a"(function),"d"(arg1),"c"(arg2),"b"(arg3));
  68. return result;
  69. }
  70. }