minix.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <unistd.h>
  5. #include <fcntl.h>
  6. #include <sys/stat.h>
  7. #include <sys/vm86.h>
  8. #include <sys/times.h>
  9. #include <utime.h>
  10. #include <termios.h>
  11. #include <time.h>
  12. #include <signal.h>
  13. #include <errno.h>
  14. #include <sys/types.h>
  15. #include <sys/resource.h>
  16. #include <sys/wait.h>
  17. #include <sys/ioctl.h>
  18. #include <dirent.h>
  19. #include "elks.h"
  20. #ifdef DEBUG
  21. #define dbprintf(x) db_printf x
  22. #else
  23. #define dbprintf(x)
  24. #endif
  25. static char * minix_names[] = {
  26. "0", "EXIT", "FORK", "READ", "WRITE", "OPEN", "CLOSE", "WAIT",
  27. "CREAT", "LINK", "UNLINK", "WAITPID", "CHDIR", "TIME", "MKNOD",
  28. "CHMOD", "CHOWN", "BRK", "STAT", "LSEEK", "GETPID", "MOUNT",
  29. "UMOUNT", "SETUID", "GETUID", "STIME", "PTRACE", "ALARM", "FSTAT",
  30. "PAUSE", "UTIME", "31", "32", "ACCESS", "34", "35", "SYNC", "KILL",
  31. "RENAME", "MKDIR", "RMDIR", "DUP", "PIPE", "TIMES", "44", "45",
  32. "SETGID", "GETGID", "SIGNAL", "49", "50", "51", "52", "53", "IOCTL",
  33. "FCNTL", "56", "57", "58", "EXEC", "UMASK", "CHROOT", "SETSID",
  34. "GETPGRP", "KSIG", "UNPAUSE", "66", "REVIVE", "TASK_REPLY", "69",
  35. "70", "SIGACTION", "SIGSUSPEND", "SIGPENDING", "SIGPROCMASK",
  36. "SIGRETURN", "REBOOT", "77"
  37. };
  38. void
  39. minix_syscall()
  40. {
  41. static char *nm[4] = {"?", "send", "receive", "sendrec"};
  42. char tsks[10], syss[10];
  43. int sr = (unsigned short) elks_cpu.regs.ecx;
  44. int tsk = (unsigned short) elks_cpu.regs.eax;
  45. int sys = ELKS_PEEK(short, (unsigned short) elks_cpu.regs.ebx + 2);
  46. if (sr < 0 || sr > 3) sr = 0;
  47. switch(tsk)
  48. {
  49. case 0: strcpy(tsks, "MM"); break;
  50. case 1: strcpy(tsks, "FS"); break;
  51. default: sprintf(tsks, "task(%d)", tsk);
  52. }
  53. if( sys > 0 && sys < 77 )
  54. strcpy(syss, minix_names[sys]);
  55. else
  56. sprintf(syss, "%d", sys);
  57. fprintf(stderr, "Minix syscall %s(%s,&{%d,%s,...})\n", nm[sr], tsks, getpid(), syss);
  58. exit(99);
  59. }