syscall.c 541 B

1234567891011121314151617181920212223242526272829
  1. /* Syscall dispatcher: services int 0x80 requests from ring-3. */
  2. #include "syscall.h"
  3. #include "io.h"
  4. #include "process.h"
  5. #include "serial.h"
  6. #include "timer.h"
  7. int syscall_dispatch(int num, int a1, int a2, int a3)
  8. {
  9. (void)a2;
  10. (void)a3;
  11. switch (num) {
  12. case SYS_PUTSTR:
  13. io_putstr((const char *)a1);
  14. return 0;
  15. case SYS_GET_TICKS_MS:
  16. return (int)get_ticks_ms();
  17. case SYS_SLEEP_MS:
  18. process_sleep_ms((unsigned int)a1);
  19. return 0;
  20. case SYS_EXIT:
  21. process_exit(); /* never returns */
  22. return 0;
  23. default:
  24. return -1;
  25. }
  26. }