call.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include <lib.h>
  2. PUBLIC int _callm1(proc, syscallnr, int1, int2, int3, ptr1, ptr2, ptr3)
  3. int proc; /* FS or MM */
  4. int syscallnr; /* which system call */
  5. int int1; /* first integer parameter */
  6. int int2; /* second integer parameter */
  7. int int3; /* third integer parameter */
  8. char *ptr1; /* pointer parameter */
  9. char *ptr2; /* pointer parameter */
  10. char *ptr3; /* pointer parameter */
  11. {
  12. /* Send a message and get the response. The '_M.m_type' field of the
  13. * reply contains a value (>= 0) or an error code (<0). Use message format m1.
  14. */
  15. _M.m1_i1 = int1;
  16. _M.m1_i2 = int2;
  17. _M.m1_i3 = int3;
  18. _M.m1_p1 = ptr1;
  19. _M.m1_p2 = ptr2;
  20. _M.m1_p3 = ptr3;
  21. return _callx(proc, syscallnr);
  22. }
  23. PUBLIC int _callm3(proc, syscallnr, int1, name)
  24. int proc; /* FS or MM */
  25. int syscallnr; /* which system call */
  26. int int1; /* integer parameter */
  27. _CONST char *name; /* string */
  28. {
  29. /* This form of system call is used for those calls that contain at most
  30. * one integer parameter along with a string. If the string fits in the
  31. * message, it is copied there. If not, a pointer to it is passed.
  32. */
  33. register int k;
  34. register char *rp;
  35. k = _len(name);
  36. _M.m3_i1 = k;
  37. _M.m3_i2 = int1;
  38. _M.m3_p1 = (char *) name;
  39. rp = &_M.m3_ca1[0];
  40. if (k <= M3_STRING) while (k--)
  41. *rp++ = *name++;
  42. return _callx(proc, syscallnr);
  43. }
  44. PUBLIC int _callx(proc, syscallnr)
  45. int proc; /* FS or MM */
  46. int syscallnr; /* which system call */
  47. {
  48. /* Send a message and get the response. The '_M.m_type' field of the
  49. * reply contains a value (>= 0) or an error code (<0).
  50. */
  51. int k;
  52. _M.m_type = syscallnr;
  53. k = _sendrec(proc, &_M);
  54. if (k != 0) return(k); /* _send() itself failed */
  55. if (_M.m_type < 0) {
  56. errno = -_M.m_type;
  57. return(-1);
  58. }
  59. return(_M.m_type);
  60. }
  61. PUBLIC int _len(s)
  62. _CONST register char *s; /* character string whose length is needed */
  63. {
  64. /* Return the length of a character string, including the 0 at the end. */
  65. register int k;
  66. k = 0;
  67. while (*s++ != 0) k++;
  68. return(k + 1); /* return length including the 0-byte at end */
  69. }