syscall.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Syscall interface (int 0x80), shared by the kernel and ring-3 commands. */
  2. #ifndef SYSCALL_H
  3. #define SYSCALL_H
  4. #define SYS_PUTSTR 1
  5. #define SYS_GET_TICKS_MS 2
  6. #define SYS_SLEEP_MS 3
  7. #define SYS_EXIT 4
  8. /* File service (see sys_fs.c). Paths are absolute VFS paths; buffers live in
  9. * the calling process's address space (the kernel runs on its CR3, so no copy
  10. * in/out is needed). */
  11. #define SYS_READ_FILE 5 /* (const char *path, void *buf, unsigned int max)
  12. -> bytes read, or <0 (SYS_E*) */
  13. #define SYS_WRITE_FILE 6 /* (const char *path, const void *buf, unsigned int len)
  14. -> 0, or <0 */
  15. #define SYS_LIST_DIR 7 /* (const char *path, unsigned int index,
  16. struct sys_dirent *out) -> 1 entry, 0 end, <0 */
  17. #define SYS_UNLINK 8 /* (const char *path) -> 0, or <0 */
  18. #define SYS_MKDIR 9 /* (const char *path) -> 0, or <0 */
  19. #define SYS_RMDIR 10 /* (const char *path) -> 0, or <0 */
  20. #define SYS_LIST_MOUNTS 11 /* (unsigned int index, struct sys_mount *out)
  21. -> 1 mount, 0 end */
  22. /* Error codes returned by the file syscalls. */
  23. #define SYS_EIO (-1) /* disk I/O error */
  24. #define SYS_ENODEV (-2) /* no such device / unusable path prefix */
  25. #define SYS_ENOFS (-3) /* device exists but has no mounted filesystem */
  26. #define SYS_ENOENT (-4) /* file/directory not found */
  27. #define SYS_EINVAL (-5) /* path is not valid for this operation */
  28. #define SYS_EWRITE (-6) /* write refused (full, or FAT rejected it) */
  29. /* One directory entry, raw 8.3 name exactly as stored (space padded). */
  30. struct sys_dirent {
  31. char name[12];
  32. unsigned int size;
  33. unsigned int is_dir;
  34. };
  35. /* One mounted filesystem (for `ls /`). */
  36. struct sys_mount {
  37. char name[16];
  38. char type[8]; /* "FAT12", "FAT16", "FAT32" */
  39. unsigned int total_sectors;
  40. char label[12];
  41. };
  42. int syscall_dispatch(int num, int a1, int a2, int a3);
  43. #endif