Initial revision
authorceriel <none@none>
Tue, 19 Apr 1988 09:34:37 +0000 (09:34 +0000)
committerceriel <none@none>
Tue, 19 Apr 1988 09:34:37 +0000 (09:34 +0000)
113 files changed:
mach/minix/libsys/access.c [new file with mode: 0644]
mach/minix/libsys/alarm.c [new file with mode: 0644]
mach/minix/libsys/brk.c [new file with mode: 0644]
mach/minix/libsys/call.c [new file with mode: 0644]
mach/minix/libsys/chdir.c [new file with mode: 0644]
mach/minix/libsys/chmod.c [new file with mode: 0644]
mach/minix/libsys/chown.c [new file with mode: 0644]
mach/minix/libsys/chroot.c [new file with mode: 0644]
mach/minix/libsys/close.c [new file with mode: 0644]
mach/minix/libsys/creat.c [new file with mode: 0644]
mach/minix/libsys/dup.c [new file with mode: 0644]
mach/minix/libsys/dup2.c [new file with mode: 0644]
mach/minix/libsys/exec.c [new file with mode: 0644]
mach/minix/libsys/exit.c [new file with mode: 0644]
mach/minix/libsys/fork.c [new file with mode: 0644]
mach/minix/libsys/fstat.c [new file with mode: 0644]
mach/minix/libsys/getegid.c [new file with mode: 0644]
mach/minix/libsys/geteuid.c [new file with mode: 0644]
mach/minix/libsys/getgid.c [new file with mode: 0644]
mach/minix/libsys/getpid.c [new file with mode: 0644]
mach/minix/libsys/getuid.c [new file with mode: 0644]
mach/minix/libsys/gtty.c [new file with mode: 0644]
mach/minix/libsys/ioctl.c [new file with mode: 0644]
mach/minix/libsys/kill.c [new file with mode: 0644]
mach/minix/libsys/lib.h [new file with mode: 0644]
mach/minix/libsys/link.c [new file with mode: 0644]
mach/minix/libsys/lseek.c [new file with mode: 0644]
mach/minix/libsys/message.c [new file with mode: 0644]
mach/minix/libsys/mknod.c [new file with mode: 0644]
mach/minix/libsys/mktemp.c [new file with mode: 0644]
mach/minix/libsys/mount.c [new file with mode: 0644]
mach/minix/libsys/open.c [new file with mode: 0644]
mach/minix/libsys/pause.c [new file with mode: 0644]
mach/minix/libsys/pipe.c [new file with mode: 0644]
mach/minix/libsys/read.c [new file with mode: 0644]
mach/minix/libsys/setgid.c [new file with mode: 0644]
mach/minix/libsys/setuid.c [new file with mode: 0644]
mach/minix/libsys/signal.c [new file with mode: 0644]
mach/minix/libsys/stat.c [new file with mode: 0644]
mach/minix/libsys/stderr.c [new file with mode: 0644]
mach/minix/libsys/stime.c [new file with mode: 0644]
mach/minix/libsys/stty.c [new file with mode: 0644]
mach/minix/libsys/sync.c [new file with mode: 0644]
mach/minix/libsys/syslib.c [new file with mode: 0644]
mach/minix/libsys/time.c [new file with mode: 0644]
mach/minix/libsys/times.c [new file with mode: 0644]
mach/minix/libsys/umask.c [new file with mode: 0644]
mach/minix/libsys/umount.c [new file with mode: 0644]
mach/minix/libsys/unlink.c [new file with mode: 0644]
mach/minix/libsys/utime.c [new file with mode: 0644]
mach/minix/libsys/wait.c [new file with mode: 0644]
mach/minix/libsys/write.c [new file with mode: 0644]
mach/minixST/libsys/.distr [new file with mode: 0644]
mach/minixST/libsys/LIST [new file with mode: 0644]
mach/minixST/libsys/Makefile [new file with mode: 0644]
mach/minixST/libsys/access.c [new file with mode: 0644]
mach/minixST/libsys/alarm.c [new file with mode: 0644]
mach/minixST/libsys/brk.c [new file with mode: 0644]
mach/minixST/libsys/call.c [new file with mode: 0644]
mach/minixST/libsys/chdir.c [new file with mode: 0644]
mach/minixST/libsys/chmod.c [new file with mode: 0644]
mach/minixST/libsys/chown.c [new file with mode: 0644]
mach/minixST/libsys/chroot.c [new file with mode: 0644]
mach/minixST/libsys/close.c [new file with mode: 0644]
mach/minixST/libsys/compmodule [new file with mode: 0755]
mach/minixST/libsys/creat.c [new file with mode: 0644]
mach/minixST/libsys/dup.c [new file with mode: 0644]
mach/minixST/libsys/dup2.c [new file with mode: 0644]
mach/minixST/libsys/end.s [new file with mode: 0644]
mach/minixST/libsys/exec.c [new file with mode: 0644]
mach/minixST/libsys/exit.c [new file with mode: 0644]
mach/minixST/libsys/fork.c [new file with mode: 0644]
mach/minixST/libsys/fstat.c [new file with mode: 0644]
mach/minixST/libsys/getegid.c [new file with mode: 0644]
mach/minixST/libsys/geteuid.c [new file with mode: 0644]
mach/minixST/libsys/getgid.c [new file with mode: 0644]
mach/minixST/libsys/getpid.c [new file with mode: 0644]
mach/minixST/libsys/getuid.c [new file with mode: 0644]
mach/minixST/libsys/gtty.c [new file with mode: 0644]
mach/minixST/libsys/head_em.s [new file with mode: 0644]
mach/minixST/libsys/ioctl.c [new file with mode: 0644]
mach/minixST/libsys/kill.c [new file with mode: 0644]
mach/minixST/libsys/lib.h [new file with mode: 0644]
mach/minixST/libsys/link.c [new file with mode: 0644]
mach/minixST/libsys/lseek.c [new file with mode: 0644]
mach/minixST/libsys/message.c [new file with mode: 0644]
mach/minixST/libsys/mknod.c [new file with mode: 0644]
mach/minixST/libsys/mktemp.c [new file with mode: 0644]
mach/minixST/libsys/mount.c [new file with mode: 0644]
mach/minixST/libsys/open.c [new file with mode: 0644]
mach/minixST/libsys/pause.c [new file with mode: 0644]
mach/minixST/libsys/pipe.c [new file with mode: 0644]
mach/minixST/libsys/read.c [new file with mode: 0644]
mach/minixST/libsys/setgid.c [new file with mode: 0644]
mach/minixST/libsys/setuid.c [new file with mode: 0644]
mach/minixST/libsys/signal.c [new file with mode: 0644]
mach/minixST/libsys/stat.c [new file with mode: 0644]
mach/minixST/libsys/stbrksz.s [new file with mode: 0644]
mach/minixST/libsys/stcatch.s [new file with mode: 0644]
mach/minixST/libsys/stderr.c [new file with mode: 0644]
mach/minixST/libsys/stime.c [new file with mode: 0644]
mach/minixST/libsys/stsndrec.s [new file with mode: 0644]
mach/minixST/libsys/stty.c [new file with mode: 0644]
mach/minixST/libsys/sync.c [new file with mode: 0644]
mach/minixST/libsys/syslib.c [new file with mode: 0644]
mach/minixST/libsys/time.c [new file with mode: 0644]
mach/minixST/libsys/times.c [new file with mode: 0644]
mach/minixST/libsys/umask.c [new file with mode: 0644]
mach/minixST/libsys/umount.c [new file with mode: 0644]
mach/minixST/libsys/unlink.c [new file with mode: 0644]
mach/minixST/libsys/utime.c [new file with mode: 0644]
mach/minixST/libsys/wait.c [new file with mode: 0644]
mach/minixST/libsys/write.c [new file with mode: 0644]

diff --git a/mach/minix/libsys/access.c b/mach/minix/libsys/access.c
new file mode 100644 (file)
index 0000000..23a22dd
--- /dev/null
@@ -0,0 +1,9 @@
+#include "lib.h"
+
+PUBLIC int access(name, mode)
+char *name;
+int mode;
+{
+  return callm3(FS, ACCESS, mode, name);
+
+}
diff --git a/mach/minix/libsys/alarm.c b/mach/minix/libsys/alarm.c
new file mode 100644 (file)
index 0000000..9be91a8
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int alarm(sec)
+unsigned sec;
+{
+  return callm1(MM, ALARM, (int) sec, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minix/libsys/brk.c b/mach/minix/libsys/brk.c
new file mode 100644 (file)
index 0000000..dac238a
--- /dev/null
@@ -0,0 +1,34 @@
+#include "lib.h"
+
+extern char *brksize;
+
+PUBLIC char *brk(addr)
+char *addr;
+{
+  int k;
+
+  k = callm1(MM, BRK, 0, 0, 0, addr, NIL_PTR, NIL_PTR);
+  if (k == OK) {
+       brksize = M.m2_p1;
+       return(NIL_PTR);
+  } else {
+       return( (char*) -1 );
+  }
+}
+
+
+PUBLIC char *sbrk(incr)
+int incr;
+{
+  char *newsize, *oldsize;
+  extern int endv, dorgv;
+
+  oldsize = brksize;
+  newsize = brksize + incr;
+  if (incr > 0 && newsize < oldsize) return( (char *) -1);
+  if (brk(newsize) == 0)
+       return(oldsize);
+  else
+       return( (char *) -1 );
+}
+
diff --git a/mach/minix/libsys/call.c b/mach/minix/libsys/call.c
new file mode 100644 (file)
index 0000000..141620c
--- /dev/null
@@ -0,0 +1,85 @@
+#include "lib.h"
+
+PUBLIC int errno;              /* place where error numbers go */
+
+PUBLIC int callm1(proc, syscallnr, int1, int2, int3, ptr1, ptr2, ptr3)
+int proc;                      /* FS or MM */
+int syscallnr;                 /* which system call */
+int int1;                      /* first integer parameter */
+int int2;                      /* second integer parameter */
+int int3;                      /* third integer parameter */
+char *ptr1;                    /* pointer parameter */
+char *ptr2;                    /* pointer parameter */
+char *ptr3;                    /* pointer parameter */
+{
+/* Send a message and get the response.  The 'M.m_type' field of the
+ * reply contains a value (>= 0) or an error code (<0). Use message format m1.
+ */
+  M.m1_i1 = int1;
+  M.m1_i2 = int2;
+  M.m1_i3 = int3;
+  M.m1_p1 = ptr1;
+  M.m1_p2 = ptr2;
+  M.m1_p3 = ptr3;
+  return callx(proc, syscallnr);
+}
+
+
+
+
+
+PUBLIC int callm3(proc, syscallnr, int1, name)
+int proc;                      /* FS or MM */
+int syscallnr;                 /* which system call */
+int int1;                      /* integer parameter */
+char *name;                    /* string */
+{
+/* This form of system call is used for those calls that contain at most
+ * one integer parameter along with a string.  If the string fits in the
+ * message, it is copied there.  If not, a pointer to it is passed.
+ */
+  register int k;
+  register char *rp;
+  k = len(name);
+  M.m3_i1 = k;
+  M.m3_i2 = int1;
+  M.m3_p1 = name;
+  rp = &M.m3_ca1[0];
+  if (k <= M3_STRING) while (k--) *rp++ = *name++;
+  return callx(proc, syscallnr);
+}
+
+
+
+
+
+PUBLIC int callx(proc, syscallnr)
+int proc;                      /* FS or MM */
+int syscallnr;                 /* which system call */
+{
+/* Send a message and get the response.  The 'M.m_type' field of the
+ * reply contains a value (>= 0) or an error code (<0). 
+ */
+  int k;
+
+  M.m_type = syscallnr;
+  k = sendrec(proc, &M);
+  if (k != OK) return(k);      /* send itself failed */
+  if (M.m_type < 0) {errno = -M.m_type; return(-1);}
+  return(M.m_type);
+}
+
+
+
+
+
+PUBLIC int len(s)
+register char *s;              /* character string whose length is needed */
+{
+/* Return the length of a character string, including the 0 at the end. */
+  register int k;
+
+  k = 0;
+  while (*s++ != 0) k++;
+  return(k+1);                 /* return length including the 0-byte at end */
+}
diff --git a/mach/minix/libsys/chdir.c b/mach/minix/libsys/chdir.c
new file mode 100644 (file)
index 0000000..357a979
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int chdir(name)
+char *name;
+{
+  return callm3(FS, CHDIR, 0, name);
+
+}
diff --git a/mach/minix/libsys/chmod.c b/mach/minix/libsys/chmod.c
new file mode 100644 (file)
index 0000000..7ae3eda
--- /dev/null
@@ -0,0 +1,9 @@
+#include "lib.h"
+
+PUBLIC int chmod(name, mode)
+char* name;
+int mode;
+{
+  return callm3(FS, CHMOD, mode, name);
+
+}
diff --git a/mach/minix/libsys/chown.c b/mach/minix/libsys/chown.c
new file mode 100644 (file)
index 0000000..0846102
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int chown(name, owner, grp)
+char *name;
+int owner, grp;
+{
+  return callm1(FS, CHOWN, len(name), owner, grp, name, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minix/libsys/chroot.c b/mach/minix/libsys/chroot.c
new file mode 100644 (file)
index 0000000..520abaf
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int chroot(name)
+char* name;
+{
+  return callm3(FS, CHROOT, 0, name);
+
+}
diff --git a/mach/minix/libsys/close.c b/mach/minix/libsys/close.c
new file mode 100644 (file)
index 0000000..72698b0
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int close(fd)
+int fd;
+{
+  return callm1(FS, CLOSE, fd, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+
+}
diff --git a/mach/minix/libsys/creat.c b/mach/minix/libsys/creat.c
new file mode 100644 (file)
index 0000000..f9c1360
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int creat(name, mode)
+char* name;
+int mode;
+{
+  return callm3(FS, CREAT, mode, name);
+}
diff --git a/mach/minix/libsys/dup.c b/mach/minix/libsys/dup.c
new file mode 100644 (file)
index 0000000..f8683ea
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int dup(fd)
+int fd;
+{
+  return callm1(FS, DUP, fd, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minix/libsys/dup2.c b/mach/minix/libsys/dup2.c
new file mode 100644 (file)
index 0000000..67e7c3d
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int dup2(fd, fd2)
+int fd, fd2;
+{
+  return callm1(FS, DUP, fd+0100, fd2, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minix/libsys/exec.c b/mach/minix/libsys/exec.c
new file mode 100644 (file)
index 0000000..26189e1
--- /dev/null
@@ -0,0 +1,103 @@
+#include "lib.h"
+
+char *nullptr[1];              /* the EXEC calls need a zero pointer */
+
+#define        PTRSIZE sizeof(char *)
+
+PUBLIC int execl(name, arg0)
+char *name;
+char *arg0;
+{
+  return execve(name, &arg0, nullptr);
+}
+
+PUBLIC int execle(name, argv)
+char *name, *argv;
+{
+  char **p;
+  p = (char **) &argv;
+  while (*p++) /* null statement */ ;
+  return execve(name, &argv, *p);
+}
+
+PUBLIC int execv(name, argv)
+char *name, *argv[];
+{
+  return execve(name, argv, nullptr);
+}
+
+
+PUBLIC int execve(name, argv, envp)
+char *name;                    /* pointer to name of file to be executed */
+char *argv[];                  /* pointer to argument array */
+char *envp[];                  /* pointer to environment */
+{
+  char stack[MAX_ISTACK_BYTES];
+  char **argorg, **envorg, *hp, **ap, *p;
+  int i, nargs, nenvps, stackbytes, offset;
+  extern errno;
+
+  /* Count the argument pointers and environment pointers. */
+  nargs = 0;
+  nenvps = 0;
+  argorg = argv;
+  envorg = envp;
+  while (*argorg++ != NIL_PTR) nargs++;
+  while (*envorg++ != NIL_PTR) nenvps++;
+
+  /* Prepare to set up the initial stack. */
+  hp = &stack[(nargs + nenvps + 3) * PTRSIZE];
+  if (hp + nargs + nenvps >= &stack[MAX_ISTACK_BYTES]) {
+       errno = E2BIG;
+       return(-1);
+  }
+  ap = (char **) stack;
+  *ap++ = (char *) nargs;
+
+  /* Prepare the argument pointers and strings. */
+  for (i = 0; i < nargs; i++) {
+       offset = hp - stack;
+       *ap++ = (char *) offset;
+       p = *argv++;
+       while (*p) {
+               *hp++ = *p++;
+               if (hp >= &stack[MAX_ISTACK_BYTES]) {
+                       errno = E2BIG;
+                       return(-1);
+               }
+       }
+       *hp++ = (char) 0;
+  }
+  *ap++ = NIL_PTR;
+
+  /* Prepare the environment pointers and strings. */
+  for (i = 0; i < nenvps; i++) {
+       offset = hp - stack;
+       *ap++ = (char *) offset;
+       p = *envp++;
+       while (*p) {
+               *hp++ = *p++;
+               if (hp >= &stack[MAX_ISTACK_BYTES]) {
+                       errno = E2BIG;
+                       return(-1);
+               }
+       }
+       *hp++ = (char) 0;
+  }
+  *ap++ = NIL_PTR;
+  stackbytes = ( ( (int)(hp - stack) + PTRSIZE - 1)/PTRSIZE) * PTRSIZE;
+  return callm1(MM_PROC_NR, EXEC, len(name), stackbytes, 0,name, stack,NIL_PTR);
+}
+
+
+PUBLIC execn(name)
+char *name;                    /* pointer to file to be exec'd */
+{
+/* Special version used when there are no args and no environment.  This call
+ * is principally used by INIT, to avoid having to allocate MAX_ISTACK_BYTES.
+ */
+
+  static char stack[3 * PTRSIZE];
+
+  return callm1(MM_PROC_NR, EXEC, len(name), sizeof(stack), 0, name, stack, NIL_PTR);
+}
diff --git a/mach/minix/libsys/exit.c b/mach/minix/libsys/exit.c
new file mode 100644 (file)
index 0000000..bcf436b
--- /dev/null
@@ -0,0 +1,10 @@
+#include "lib.h"
+
+PUBLIC int (*__cleanup)();
+
+PUBLIC int exit(status)
+int status;
+{
+  if (__cleanup) (*__cleanup)();
+  return callm1(MM, EXIT, status, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minix/libsys/fork.c b/mach/minix/libsys/fork.c
new file mode 100644 (file)
index 0000000..7d5c0fc
--- /dev/null
@@ -0,0 +1,6 @@
+#include "lib.h"
+
+PUBLIC int fork()
+{
+  return callm1(MM, FORK, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minix/libsys/fstat.c b/mach/minix/libsys/fstat.c
new file mode 100644 (file)
index 0000000..8fb6d66
--- /dev/null
@@ -0,0 +1,10 @@
+#include "lib.h"
+
+PUBLIC int fstat(fd, buffer)
+int fd;
+char *buffer;
+{
+  int n;
+  n = callm1(FS, FSTAT, fd, 0, 0, buffer, NIL_PTR, NIL_PTR);
+  return(n);
+}
diff --git a/mach/minix/libsys/getegid.c b/mach/minix/libsys/getegid.c
new file mode 100644 (file)
index 0000000..e416691
--- /dev/null
@@ -0,0 +1,9 @@
+#include "lib.h"
+
+PUBLIC gid getegid()
+{
+  int k;
+  k = callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  if (k < 0) return ( (gid) k);
+  return( (gid) M.m2_i1);
+}
diff --git a/mach/minix/libsys/geteuid.c b/mach/minix/libsys/geteuid.c
new file mode 100644 (file)
index 0000000..172f3df
--- /dev/null
@@ -0,0 +1,9 @@
+#include "lib.h"
+
+PUBLIC uid geteuid()
+{
+  int k;
+  k = callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  if (k < 0) return ( (uid) k);
+  return ((uid) M.m2_i1);
+}
diff --git a/mach/minix/libsys/getgid.c b/mach/minix/libsys/getgid.c
new file mode 100644 (file)
index 0000000..78fc92a
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC gid getgid()
+{
+  int k;
+  k = callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  return( (gid) k);
+}
diff --git a/mach/minix/libsys/getpid.c b/mach/minix/libsys/getpid.c
new file mode 100644 (file)
index 0000000..43ab9dd
--- /dev/null
@@ -0,0 +1,6 @@
+#include "lib.h"
+
+PUBLIC int getpid()
+{
+  return callm1(MM, GETPID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minix/libsys/getuid.c b/mach/minix/libsys/getuid.c
new file mode 100644 (file)
index 0000000..44801a3
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC uid getuid()
+{
+  int k;
+  k = callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  return( (uid) k);
+}
diff --git a/mach/minix/libsys/gtty.c b/mach/minix/libsys/gtty.c
new file mode 100644 (file)
index 0000000..8916d9b
--- /dev/null
@@ -0,0 +1,9 @@
+#include <sgtty.h>
+
+gtty(fd, argp)
+int fd;
+char *argp;
+{
+  return ioctl(fd, TIOCGETP, argp);
+}
+
diff --git a/mach/minix/libsys/ioctl.c b/mach/minix/libsys/ioctl.c
new file mode 100644 (file)
index 0000000..a46a733
--- /dev/null
@@ -0,0 +1,64 @@
+#include "lib.h"
+#include <minix/com.h>
+#include <sgtty.h>
+
+PUBLIC int ioctl(fd, request, u)
+int fd;
+int request;
+union {
+  struct sgttyb *argp;
+  struct tchars *argt;
+} u;
+
+{
+  int n;
+  long erase, kill, intr, quit, xon, xoff, eof, brk;
+
+  M.TTY_REQUEST = request;
+  M.TTY_LINE = fd;
+
+  switch(request) {
+     case TIOCSETP:
+       erase = u.argp->sg_erase & 0377;
+       kill = u.argp->sg_kill & 0377;
+       M.TTY_SPEK = (erase << 8) | kill;
+       M.TTY_FLAGS = u.argp->sg_flags;
+       n = callx(FS, IOCTL);
+       return(n);
+     case TIOCSETC:
+       intr = u.argt->t_intrc & 0377;
+       quit = u.argt->t_quitc & 0377;
+       xon  = u.argt->t_startc & 0377;
+       xoff = u.argt->t_stopc & 0377;
+       eof  = u.argt->t_eofc & 0377;
+       brk  = u.argt->t_brkc & 0377;           /* not used at the moment */
+       M.TTY_SPEK = (intr<<24) | (quit<<16) | (xon<<8) | (xoff<<0);
+       M.TTY_FLAGS = (eof<<8) | (brk<<0);
+       n = callx(FS, IOCTL);
+       return(n);
+       
+     case TIOCGETP:
+       n = callx(FS, IOCTL);
+       u.argp->sg_erase = (M.TTY_SPEK >> 8) & 0377;
+       u.argp->sg_kill  = (M.TTY_SPEK >> 0) & 0377;
+       u.argp->sg_flags = M.TTY_FLAGS;
+       return(n);
+
+     case TIOCGETC:
+       n = callx(FS, IOCTL);
+       u.argt->t_intrc  = (M.TTY_SPEK >> 24) & 0377;
+       u.argt->t_quitc  = (M.TTY_SPEK >> 16) & 0377;
+       u.argt->t_startc = (M.TTY_SPEK >>  8) & 0377;
+       u.argt->t_stopc  = (M.TTY_SPEK >>  0) & 0377;
+       u.argt->t_eofc   = (M.TTY_FLAGS >> 8) & 0377;
+       u.argt->t_brkc   = (M.TTY_FLAGS >> 8) & 0377;
+       return(n);
+
+     default:
+       n = -1;
+       errno = -(EINVAL);
+       return(n);
+  }
+}
+
diff --git a/mach/minix/libsys/kill.c b/mach/minix/libsys/kill.c
new file mode 100644 (file)
index 0000000..db10654
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int kill(proc, sig)
+int proc;                      /* which process is to be sent the signal */
+int sig;                       /* signal number */
+{
+  return callm1(MM, KILL, proc, sig, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minix/libsys/lib.h b/mach/minix/libsys/lib.h
new file mode 100644 (file)
index 0000000..32c25c7
--- /dev/null
@@ -0,0 +1,13 @@
+#include <minix/const.h>
+#include <minix/type.h>
+#include <minix/callnr.h>
+#include <errno.h>
+
+extern message M;
+
+#define MM                 0
+#define FS                 1
+
+extern int callm1(), callm3(), callx(), len();
+extern int errno;
+extern int begsig();           /* interrupts all vector here */
diff --git a/mach/minix/libsys/link.c b/mach/minix/libsys/link.c
new file mode 100644 (file)
index 0000000..9daee38
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int link(name, name2)
+char *name, *name2;
+{
+  return callm1(FS, LINK, len(name), len(name2), 0, name, name2, NIL_PTR);
+}
diff --git a/mach/minix/libsys/lseek.c b/mach/minix/libsys/lseek.c
new file mode 100644 (file)
index 0000000..ffcf165
--- /dev/null
@@ -0,0 +1,15 @@
+#include "lib.h"
+
+PUBLIC long lseek(fd, offset, whence)
+int fd;
+long offset;
+int whence;
+{
+  int k; 
+  M.m2_i1 = fd;
+  M.m2_l1 = offset;
+  M.m2_i2 = whence;
+  k = callx(FS, LSEEK);
+  if (k != OK) return( (long) k);      /* send itself failed */
+  return(M.m2_l1);
+}
diff --git a/mach/minix/libsys/message.c b/mach/minix/libsys/message.c
new file mode 100644 (file)
index 0000000..faaae54
--- /dev/null
@@ -0,0 +1,5 @@
+#include <minix/const.h>
+#include <minix/type.h>
+
+/* some compilers require an initializer to force storage allocation */
+message M = {0};
diff --git a/mach/minix/libsys/mknod.c b/mach/minix/libsys/mknod.c
new file mode 100644 (file)
index 0000000..7dbfeca
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int mknod(name, mode, addr)
+char *name;
+int mode, addr;
+{
+  return callm1(FS, MKNOD, len(name), mode, addr, name, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minix/libsys/mktemp.c b/mach/minix/libsys/mktemp.c
new file mode 100644 (file)
index 0000000..e29e5c9
--- /dev/null
@@ -0,0 +1,20 @@
+/* mktemp - make a name for a temporary file */
+
+char *mktemp(template)
+char *template;
+{
+  int pid, k;
+  char *p;
+
+  pid = getpid();              /* get process id as semi-unique number */
+  p = template;
+  while (*p++) ;               /* find end of string */
+  p--;                         /* backup to last character */
+
+  /* Replace XXXXXX at end of template with pid. */
+  while (*--p == 'X') {
+       *p = '0' + (pid % 10);
+       pid = pid/10;
+  }
+  return(template);
+}
diff --git a/mach/minix/libsys/mount.c b/mach/minix/libsys/mount.c
new file mode 100644 (file)
index 0000000..258276b
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int mount(special, name, rwflag)
+char *name, *special;
+int rwflag;
+{
+  return callm1(FS, MOUNT, len(special), len(name), rwflag, special, name, NIL_PTR);
+}
diff --git a/mach/minix/libsys/open.c b/mach/minix/libsys/open.c
new file mode 100644 (file)
index 0000000..228173d
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int open(name, mode)
+char* name;
+int mode;
+{
+  return callm3(FS, OPEN, mode, name);
+}
diff --git a/mach/minix/libsys/pause.c b/mach/minix/libsys/pause.c
new file mode 100644 (file)
index 0000000..2a0d1f6
--- /dev/null
@@ -0,0 +1,6 @@
+#include "lib.h"
+
+PUBLIC int pause()
+{
+  return callm1(MM, PAUSE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minix/libsys/pipe.c b/mach/minix/libsys/pipe.c
new file mode 100644 (file)
index 0000000..0505880
--- /dev/null
@@ -0,0 +1,14 @@
+#include "lib.h"
+
+PUBLIC int pipe(fild)
+int fild[2];
+{
+  int k;
+  k = callm1(FS, PIPE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  if (k >= 0) {
+       fild[0] = M.m1_i1;
+       fild[1] = M.m1_i2;
+       return(0);
+  } else
+       return(k);
+}
diff --git a/mach/minix/libsys/read.c b/mach/minix/libsys/read.c
new file mode 100644 (file)
index 0000000..1619a4d
--- /dev/null
@@ -0,0 +1,11 @@
+#include "lib.h"
+
+PUBLIC int read(fd, buffer, nbytes)
+int fd;
+char *buffer;
+int nbytes;
+{
+  int n;
+  n = callm1(FS, READ, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR);
+  return(n);
+}
diff --git a/mach/minix/libsys/setgid.c b/mach/minix/libsys/setgid.c
new file mode 100644 (file)
index 0000000..823e878
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int setgid(grp)
+int grp;
+{
+  return callm1(MM, SETGID, grp, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minix/libsys/setuid.c b/mach/minix/libsys/setuid.c
new file mode 100644 (file)
index 0000000..c53e0e3
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int setuid(usr)
+int usr;
+{
+  return callm1(MM, SETUID, usr, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minix/libsys/signal.c b/mach/minix/libsys/signal.c
new file mode 100644 (file)
index 0000000..e588d29
--- /dev/null
@@ -0,0 +1,27 @@
+#include "lib.h"
+#include <signal.h>
+
+int (*vectab[NSIG])(); /* array of functions to catch signals */
+
+/* The definition of signal really should be 
+ *  PUBLIC int (*signal(signr, func))()
+ * but some compilers refuse to accept this, even though it is correct.
+ * The only thing to do if you are stuck with such a defective compiler is
+ * change it to
+ *  PUBLIC int *signal(signr, func)
+ * and change ../h/signal.h accordingly.
+ */
+
+PUBLIC int (*signal(signr, func))()
+int signr;                     /* which signal is being set */
+int (*func)();                 /* pointer to function that catches signal */
+{
+  int r,(*old)();
+
+  old = vectab[signr - 1];
+  vectab[signr - 1] = func;
+  M.m6_i1 = signr;
+  M.m6_f1 = ( (func == SIG_IGN || func == SIG_DFL) ? func : begsig);
+  r = callx(MM, SIGNAL);
+  return( (r < 0 ? (int (*)()) r : old) );
+}
diff --git a/mach/minix/libsys/stat.c b/mach/minix/libsys/stat.c
new file mode 100644 (file)
index 0000000..ae7b446
--- /dev/null
@@ -0,0 +1,10 @@
+#include "lib.h"
+
+PUBLIC int stat(name, buffer)
+char *name;
+char *buffer;
+{
+  int n;
+  n = callm1(FS, STAT, len(name), 0, 0, name, buffer, NIL_PTR);
+  return(n);
+}
diff --git a/mach/minix/libsys/stderr.c b/mach/minix/libsys/stderr.c
new file mode 100644 (file)
index 0000000..7910f77
--- /dev/null
@@ -0,0 +1,8 @@
+std_err(s)
+char *s;
+{
+  char *p = s;
+
+  while(*p != 0) p++;
+  write(2, s, (int)(p - s));
+}
diff --git a/mach/minix/libsys/stime.c b/mach/minix/libsys/stime.c
new file mode 100644 (file)
index 0000000..548ac37
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int stime(top)
+long *top;
+{
+  M.m2_l1 = *top;
+  return callx(FS, STIME);
+}
diff --git a/mach/minix/libsys/stty.c b/mach/minix/libsys/stty.c
new file mode 100644 (file)
index 0000000..7dfe3db
--- /dev/null
@@ -0,0 +1,9 @@
+#include <sgtty.h>
+
+stty(fd, argp)
+int fd;
+char *argp;
+{
+  return ioctl(fd, TIOCSETP, argp);
+}
+
diff --git a/mach/minix/libsys/sync.c b/mach/minix/libsys/sync.c
new file mode 100644 (file)
index 0000000..4592d28
--- /dev/null
@@ -0,0 +1,6 @@
+#include "lib.h"
+
+PUBLIC int sync()
+{
+  return callm1(FS, SYNC, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minix/libsys/syslib.c b/mach/minix/libsys/syslib.c
new file mode 100644 (file)
index 0000000..fd696bc
--- /dev/null
@@ -0,0 +1,167 @@
+#include <minix/const.h>
+#include <minix/type.h>
+#include <minix/callnr.h>
+#include <minix/com.h>
+#include <errno.h>
+
+#define FS          FS_PROC_NR
+#define MM          MMPROCNR
+
+extern message M;
+
+
+/*----------------------------------------------------------------------------
+                       Messages to systask (special calls)
+----------------------------------------------------------------------------*/
+
+#ifdef ATARI_ST
+PUBLIC sys_xit(parent, proc, basep, sizep)
+phys_clicks *basep, *sizep;
+#else
+PUBLIC sys_xit(parent, proc)
+#endif
+int parent;                    /* parent of exiting proc. */
+int proc;                      /* which proc has exited */
+{
+/* A proc has exited.  Tell the kernel. */
+
+  callm1(SYSTASK, SYS_XIT, parent, proc, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+#ifdef ATARI_ST
+  *basep = (phys_clicks)M.m1_i1;
+  *sizep = (phys_clicks)M.m1_i2;
+#endif
+}
+
+
+PUBLIC sys_getsp(proc, newsp)
+int proc;                      /* which proc has enabled signals */
+vir_bytes *newsp;              /* place to put sp read from kernel */
+{
+/* Ask the kernel what the sp is. */
+
+
+  callm1(SYSTASK, SYS_GETSP, proc, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  *newsp = (vir_bytes) M.STACK_PTR;
+}
+
+
+PUBLIC sys_sig(proc, sig, sighandler)
+int proc;                      /* which proc has exited */
+int sig;                       /* signal number: 1 - 16 */
+int (*sighandler)();           /* pointer to signal handler in user space */
+{
+/* A proc has to be signaled.  Tell the kernel. */
+
+  M.m6_i1 = proc;
+  M.m6_i2 = sig;
+  M.m6_f1 = sighandler;
+  callx(SYSTASK, SYS_SIG);
+}
+
+
+#ifdef ATARI_ST
+PUBLIC sys_fork(parent, child, pid, shadow)
+#ifdef ALCYON_C_BUG_FIXED
+phys_clicks shadow;            /* memory allocated for shadow */
+#endif
+#else
+PUBLIC sys_fork(parent, child, pid)
+#endif
+int parent;                    /* proc doing the fork */
+int child;                     /* which proc has been created by the fork */
+int pid;                       /* process id assigned by MM */
+{
+/* A proc has forked.  Tell the kernel. */
+
+#ifdef ATARI_ST
+  callm1(SYSTASK, SYS_FORK, parent, child, pid, (char *)shadow, NIL_PTR, NIL_PTR);
+#else
+  callm1(SYSTASK, SYS_FORK, parent, child, pid, NIL_PTR, NIL_PTR, NIL_PTR);
+#endif
+}
+
+
+PUBLIC sys_exec(proc, ptr)
+int proc;                      /* proc that did exec */
+char *ptr;                     /* new stack pointer */
+{
+/* A proc has exec'd.  Tell the kernel. */
+
+  callm1(SYSTASK, SYS_EXEC, proc, 0, 0, ptr, NIL_PTR, NIL_PTR);
+}
+
+PUBLIC sys_newmap(proc, ptr)
+int proc;                      /* proc whose map is to be changed */
+char *ptr;                     /* pointer to new map */
+{
+/* A proc has been assigned a new memory map.  Tell the kernel. */
+
+
+  callm1(SYSTASK, SYS_NEWMAP, proc, 0, 0, ptr, NIL_PTR, NIL_PTR);
+}
+
+PUBLIC sys_copy(mptr)
+message *mptr;                 /* pointer to message */
+{
+/* A proc wants to use local copy. */
+
+  /* Make this routine better.  Also check other guys' error handling -DEBUG */
+  mptr->m_type = SYS_COPY;
+  if (sendrec(SYSTASK, mptr) != OK) panic("sys_copy can't send", NO_NUM);
+}
+
+PUBLIC sys_times(proc, ptr)
+int proc;                      /* proc whose times are needed */
+real_time ptr[4];                      /* pointer to time buffer */
+{
+/* Fetch the accounting info for a proc. */
+
+  callm1(SYSTASK, SYS_TIMES, proc, 0, 0, ptr, NIL_PTR, NIL_PTR);
+  ptr[0] = M.USER_TIME;
+  ptr[1] = M.SYSTEM_TIME;
+  ptr[2] = M.CHILD_UTIME;
+  ptr[3] = M.CHILD_STIME;
+}
+
+
+
+
+
+PUBLIC sys_abort()
+{
+/* Something awful has happened.  Abandon ship. */
+
+  callm1(SYSTASK, SYS_ABORT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
+
+#ifdef ATARI_ST
+PUBLIC sys_fresh(proc, ptr, dc, basep, sizep)
+int proc;                      /* proc whose map is to be changed */
+char *ptr;                     /* pointer to new map */
+phys_clicks dc;                        /* size of initialized data */
+phys_clicks *basep, *sizep;    /* base and size for free_mem() */
+{
+/* Create a fresh process image for exec().  Tell the kernel. */
+
+  callm1(SYSTASK, SYS_FRESH, proc, (int)dc, 0, ptr, NIL_PTR, NIL_PTR);
+  *basep = (phys_clicks)M.m1_i1;
+  *sizep = (phys_clicks)M.m1_i2;
+}
+#endif
+
+
+PUBLIC int tell_fs(what, p1, p2, p3)
+int what, p1, p2, p3;
+{
+/* This routine is only used by MM to inform FS of certain events:
+ *      tell_fs(CHDIR, slot, dir, 0)
+ *      tell_fs(EXIT, proc, 0, 0)
+ *      tell_fs(FORK, parent, child, pid)
+ *      tell_fs(SETGID, proc, realgid, effgid)
+ *      tell_fs(SETUID, proc, realuid, effuid)
+ *      tell_fs(SYNC, 0, 0, 0)
+ *      tell_fs(UNPAUSE, proc, signr, 0)
+ *      tell_fs(SETPGRP, proc, 0, 0)
+ */
+  callm1(FS, what, p1, p2, p3, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minix/libsys/time.c b/mach/minix/libsys/time.c
new file mode 100644 (file)
index 0000000..e34e1f2
--- /dev/null
@@ -0,0 +1,13 @@
+#include "lib.h"
+
+PUBLIC long time(tp)
+long *tp;
+{
+  int k;
+  long l;
+  k = callm1(FS, TIME, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  if (M.m_type < 0 || k != OK) {errno = -M.m_type; return(-1L);}
+  l = M.m2_l1;
+  if (tp != (long *) 0) *tp = l;
+  return(l);
+}
diff --git a/mach/minix/libsys/times.c b/mach/minix/libsys/times.c
new file mode 100644 (file)
index 0000000..77515d6
--- /dev/null
@@ -0,0 +1,15 @@
+#include "lib.h"
+#include <sys/types.h>
+#include <sys/times.h>
+
+PUBLIC int times(buf)
+struct tms *buf;
+{
+  int k;
+  k = callm1(FS, TIMES, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  buf->tms_utime = M.m4_l1;
+  buf->tms_stime = M.m4_l2;
+  buf->tms_cutime = M.m4_l3;
+  buf->tms_cstime = M.m4_l4;
+  return(k);
+}
diff --git a/mach/minix/libsys/umask.c b/mach/minix/libsys/umask.c
new file mode 100644 (file)
index 0000000..caeb075
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int umask(complmode)
+int complmode;
+{
+  return callm1(FS, UMASK, complmode, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minix/libsys/umount.c b/mach/minix/libsys/umount.c
new file mode 100644 (file)
index 0000000..d1fab6d
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int umount(name)
+char* name;
+{
+  return callm3(FS, UMOUNT, 0, name);
+}
diff --git a/mach/minix/libsys/unlink.c b/mach/minix/libsys/unlink.c
new file mode 100644 (file)
index 0000000..9c321ff
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int unlink(name)
+char *name;
+{
+  return callm3(FS, UNLINK, 0, name);
+}
diff --git a/mach/minix/libsys/utime.c b/mach/minix/libsys/utime.c
new file mode 100644 (file)
index 0000000..0c9b4ef
--- /dev/null
@@ -0,0 +1,12 @@
+#include "lib.h"
+
+PUBLIC int utime(name, timp)
+char *name;
+long timp[2];
+{
+  M.m2_i1 = len(name);
+  M.m2_l1 = timp[0];
+  M.m2_l2 = timp[1];
+  M.m2_p1 = name;
+  return callx(FS, UTIME);
+}
diff --git a/mach/minix/libsys/wait.c b/mach/minix/libsys/wait.c
new file mode 100644 (file)
index 0000000..c1472a0
--- /dev/null
@@ -0,0 +1,10 @@
+#include "lib.h"
+
+PUBLIC int wait(status)
+int *status;
+{
+  int k;
+  k = callm1(MM, WAIT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  if (status != 0) *status = M.m2_i1;
+  return(k);
+}
diff --git a/mach/minix/libsys/write.c b/mach/minix/libsys/write.c
new file mode 100644 (file)
index 0000000..e08826b
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int write(fd, buffer, nbytes)
+char *buffer;
+int nbytes;
+{
+  return callm1(FS, WRITE, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/.distr b/mach/minixST/libsys/.distr
new file mode 100644 (file)
index 0000000..9c858b3
--- /dev/null
@@ -0,0 +1,7 @@
+LIST
+Makefile
+compmodule
+head_em.s
+lib.h
+libsys_s.a
+end.s
diff --git a/mach/minixST/libsys/LIST b/mach/minixST/libsys/LIST
new file mode 100644 (file)
index 0000000..31379ee
--- /dev/null
@@ -0,0 +1,55 @@
+libsys_s.a
+stty.c
+gtty.c
+access.c
+alarm.c
+brk.c
+call.c
+chdir.c
+chmod.c
+chown.c
+chroot.c
+close.c
+creat.c
+dup.c
+dup2.c
+exec.c
+exit.c
+fork.c
+fstat.c
+getegid.c
+geteuid.c
+getgid.c
+getpid.c
+getuid.c
+ioctl.c
+kill.c
+link.c
+lseek.c
+message.c
+mknod.c
+mktemp.c
+mount.c
+open.c
+pause.c
+pipe.c
+read.c
+setgid.c
+setuid.c
+signal.c
+stat.c
+stderr.c
+stime.c
+sync.c
+syslib.c
+time.c
+times.c
+umask.c
+umount.c
+unlink.c
+utime.c
+wait.c
+write.c
+stbrksz.s
+stsndrec.s
+stcatch.s
diff --git a/mach/minixST/libsys/Makefile b/mach/minixST/libsys/Makefile
new file mode 100644 (file)
index 0000000..bf42930
--- /dev/null
@@ -0,0 +1,40 @@
+# $Header$
+MACH=minixST
+
+all:            libsys_o.a end.o head_em.o
+
+install:       all
+               ../../install libsys_o.a tail_mon
+               ../../install head_em.o head_em
+               ../../install end.o end_em
+
+cmp:           all
+               -../../compare libsys_o.a tail_mon
+               -../../compare head_em.o head_em
+               -../../compare end.o end_em
+
+
+end.o:         end.s
+               $(MACH) -I../../../h -O -c end.s
+
+head_em.o:     head_em.s
+               $(MACH) -I../../../h -O -c head_em.s
+
+libsys.a:      libsys_s.a
+               ASAR=aal ; export ASAR ;\
+               march . libsys.a
+
+libsys_o.a:    libsys.a ../../../lib/m68k2/tail_em
+               mkdir X; cd X; aal x ../libsys.a; aal x ../../../../lib/m68k2/tail_em; aal rv ../libsys_o.a *.o
+               rm -rf X
+
+clean:
+               rm -f *.o libsys_o.a libsys.a
+
+opr :
+               make pr | opr
+
+pr:
+               @pr `pwd`/head_em.s
+               @arch pv libsys.a | pr -h `pwd`/libsys.a
+               @pr `pwd`/end.s
diff --git a/mach/minixST/libsys/access.c b/mach/minixST/libsys/access.c
new file mode 100644 (file)
index 0000000..23a22dd
--- /dev/null
@@ -0,0 +1,9 @@
+#include "lib.h"
+
+PUBLIC int access(name, mode)
+char *name;
+int mode;
+{
+  return callm3(FS, ACCESS, mode, name);
+
+}
diff --git a/mach/minixST/libsys/alarm.c b/mach/minixST/libsys/alarm.c
new file mode 100644 (file)
index 0000000..9be91a8
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int alarm(sec)
+unsigned sec;
+{
+  return callm1(MM, ALARM, (int) sec, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/brk.c b/mach/minixST/libsys/brk.c
new file mode 100644 (file)
index 0000000..dac238a
--- /dev/null
@@ -0,0 +1,34 @@
+#include "lib.h"
+
+extern char *brksize;
+
+PUBLIC char *brk(addr)
+char *addr;
+{
+  int k;
+
+  k = callm1(MM, BRK, 0, 0, 0, addr, NIL_PTR, NIL_PTR);
+  if (k == OK) {
+       brksize = M.m2_p1;
+       return(NIL_PTR);
+  } else {
+       return( (char*) -1 );
+  }
+}
+
+
+PUBLIC char *sbrk(incr)
+int incr;
+{
+  char *newsize, *oldsize;
+  extern int endv, dorgv;
+
+  oldsize = brksize;
+  newsize = brksize + incr;
+  if (incr > 0 && newsize < oldsize) return( (char *) -1);
+  if (brk(newsize) == 0)
+       return(oldsize);
+  else
+       return( (char *) -1 );
+}
+
diff --git a/mach/minixST/libsys/call.c b/mach/minixST/libsys/call.c
new file mode 100644 (file)
index 0000000..141620c
--- /dev/null
@@ -0,0 +1,85 @@
+#include "lib.h"
+
+PUBLIC int errno;              /* place where error numbers go */
+
+PUBLIC int callm1(proc, syscallnr, int1, int2, int3, ptr1, ptr2, ptr3)
+int proc;                      /* FS or MM */
+int syscallnr;                 /* which system call */
+int int1;                      /* first integer parameter */
+int int2;                      /* second integer parameter */
+int int3;                      /* third integer parameter */
+char *ptr1;                    /* pointer parameter */
+char *ptr2;                    /* pointer parameter */
+char *ptr3;                    /* pointer parameter */
+{
+/* Send a message and get the response.  The 'M.m_type' field of the
+ * reply contains a value (>= 0) or an error code (<0). Use message format m1.
+ */
+  M.m1_i1 = int1;
+  M.m1_i2 = int2;
+  M.m1_i3 = int3;
+  M.m1_p1 = ptr1;
+  M.m1_p2 = ptr2;
+  M.m1_p3 = ptr3;
+  return callx(proc, syscallnr);
+}
+
+
+
+
+
+PUBLIC int callm3(proc, syscallnr, int1, name)
+int proc;                      /* FS or MM */
+int syscallnr;                 /* which system call */
+int int1;                      /* integer parameter */
+char *name;                    /* string */
+{
+/* This form of system call is used for those calls that contain at most
+ * one integer parameter along with a string.  If the string fits in the
+ * message, it is copied there.  If not, a pointer to it is passed.
+ */
+  register int k;
+  register char *rp;
+  k = len(name);
+  M.m3_i1 = k;
+  M.m3_i2 = int1;
+  M.m3_p1 = name;
+  rp = &M.m3_ca1[0];
+  if (k <= M3_STRING) while (k--) *rp++ = *name++;
+  return callx(proc, syscallnr);
+}
+
+
+
+
+
+PUBLIC int callx(proc, syscallnr)
+int proc;                      /* FS or MM */
+int syscallnr;                 /* which system call */
+{
+/* Send a message and get the response.  The 'M.m_type' field of the
+ * reply contains a value (>= 0) or an error code (<0). 
+ */
+  int k;
+
+  M.m_type = syscallnr;
+  k = sendrec(proc, &M);
+  if (k != OK) return(k);      /* send itself failed */
+  if (M.m_type < 0) {errno = -M.m_type; return(-1);}
+  return(M.m_type);
+}
+
+
+
+
+
+PUBLIC int len(s)
+register char *s;              /* character string whose length is needed */
+{
+/* Return the length of a character string, including the 0 at the end. */
+  register int k;
+
+  k = 0;
+  while (*s++ != 0) k++;
+  return(k+1);                 /* return length including the 0-byte at end */
+}
diff --git a/mach/minixST/libsys/chdir.c b/mach/minixST/libsys/chdir.c
new file mode 100644 (file)
index 0000000..357a979
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int chdir(name)
+char *name;
+{
+  return callm3(FS, CHDIR, 0, name);
+
+}
diff --git a/mach/minixST/libsys/chmod.c b/mach/minixST/libsys/chmod.c
new file mode 100644 (file)
index 0000000..7ae3eda
--- /dev/null
@@ -0,0 +1,9 @@
+#include "lib.h"
+
+PUBLIC int chmod(name, mode)
+char* name;
+int mode;
+{
+  return callm3(FS, CHMOD, mode, name);
+
+}
diff --git a/mach/minixST/libsys/chown.c b/mach/minixST/libsys/chown.c
new file mode 100644 (file)
index 0000000..0846102
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int chown(name, owner, grp)
+char *name;
+int owner, grp;
+{
+  return callm1(FS, CHOWN, len(name), owner, grp, name, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/chroot.c b/mach/minixST/libsys/chroot.c
new file mode 100644 (file)
index 0000000..520abaf
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int chroot(name)
+char* name;
+{
+  return callm3(FS, CHROOT, 0, name);
+
+}
diff --git a/mach/minixST/libsys/close.c b/mach/minixST/libsys/close.c
new file mode 100644 (file)
index 0000000..72698b0
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int close(fd)
+int fd;
+{
+  return callm1(FS, CLOSE, fd, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+
+}
diff --git a/mach/minixST/libsys/compmodule b/mach/minixST/libsys/compmodule
new file mode 100755 (executable)
index 0000000..039b0e1
--- /dev/null
@@ -0,0 +1,4 @@
+if minixST -c -L -LIB -DATARI_ST -DACK $1 1>&2
+then echo `basename $1 $2`.o
+else exit 1
+fi
diff --git a/mach/minixST/libsys/creat.c b/mach/minixST/libsys/creat.c
new file mode 100644 (file)
index 0000000..f9c1360
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int creat(name, mode)
+char* name;
+int mode;
+{
+  return callm3(FS, CREAT, mode, name);
+}
diff --git a/mach/minixST/libsys/dup.c b/mach/minixST/libsys/dup.c
new file mode 100644 (file)
index 0000000..f8683ea
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int dup(fd)
+int fd;
+{
+  return callm1(FS, DUP, fd, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/dup2.c b/mach/minixST/libsys/dup2.c
new file mode 100644 (file)
index 0000000..67e7c3d
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int dup2(fd, fd2)
+int fd, fd2;
+{
+  return callm1(FS, DUP, fd+0100, fd2, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/end.s b/mach/minixST/libsys/end.s
new file mode 100644 (file)
index 0000000..f746212
--- /dev/null
@@ -0,0 +1,16 @@
+.sect .text; .sect .rom; .sect .data; .sect .bss
+.define        endtext,enddata,endbss
+.define _end,_etext,_edata
+
+       .sect .text
+endtext:
+_etext:
+       .align 2
+       .sect .data
+enddata:
+_edata:
+       .align 2
+.sect .endsect
+_end:
+endbss:
+       .align 2
diff --git a/mach/minixST/libsys/exec.c b/mach/minixST/libsys/exec.c
new file mode 100644 (file)
index 0000000..26189e1
--- /dev/null
@@ -0,0 +1,103 @@
+#include "lib.h"
+
+char *nullptr[1];              /* the EXEC calls need a zero pointer */
+
+#define        PTRSIZE sizeof(char *)
+
+PUBLIC int execl(name, arg0)
+char *name;
+char *arg0;
+{
+  return execve(name, &arg0, nullptr);
+}
+
+PUBLIC int execle(name, argv)
+char *name, *argv;
+{
+  char **p;
+  p = (char **) &argv;
+  while (*p++) /* null statement */ ;
+  return execve(name, &argv, *p);
+}
+
+PUBLIC int execv(name, argv)
+char *name, *argv[];
+{
+  return execve(name, argv, nullptr);
+}
+
+
+PUBLIC int execve(name, argv, envp)
+char *name;                    /* pointer to name of file to be executed */
+char *argv[];                  /* pointer to argument array */
+char *envp[];                  /* pointer to environment */
+{
+  char stack[MAX_ISTACK_BYTES];
+  char **argorg, **envorg, *hp, **ap, *p;
+  int i, nargs, nenvps, stackbytes, offset;
+  extern errno;
+
+  /* Count the argument pointers and environment pointers. */
+  nargs = 0;
+  nenvps = 0;
+  argorg = argv;
+  envorg = envp;
+  while (*argorg++ != NIL_PTR) nargs++;
+  while (*envorg++ != NIL_PTR) nenvps++;
+
+  /* Prepare to set up the initial stack. */
+  hp = &stack[(nargs + nenvps + 3) * PTRSIZE];
+  if (hp + nargs + nenvps >= &stack[MAX_ISTACK_BYTES]) {
+       errno = E2BIG;
+       return(-1);
+  }
+  ap = (char **) stack;
+  *ap++ = (char *) nargs;
+
+  /* Prepare the argument pointers and strings. */
+  for (i = 0; i < nargs; i++) {
+       offset = hp - stack;
+       *ap++ = (char *) offset;
+       p = *argv++;
+       while (*p) {
+               *hp++ = *p++;
+               if (hp >= &stack[MAX_ISTACK_BYTES]) {
+                       errno = E2BIG;
+                       return(-1);
+               }
+       }
+       *hp++ = (char) 0;
+  }
+  *ap++ = NIL_PTR;
+
+  /* Prepare the environment pointers and strings. */
+  for (i = 0; i < nenvps; i++) {
+       offset = hp - stack;
+       *ap++ = (char *) offset;
+       p = *envp++;
+       while (*p) {
+               *hp++ = *p++;
+               if (hp >= &stack[MAX_ISTACK_BYTES]) {
+                       errno = E2BIG;
+                       return(-1);
+               }
+       }
+       *hp++ = (char) 0;
+  }
+  *ap++ = NIL_PTR;
+  stackbytes = ( ( (int)(hp - stack) + PTRSIZE - 1)/PTRSIZE) * PTRSIZE;
+  return callm1(MM_PROC_NR, EXEC, len(name), stackbytes, 0,name, stack,NIL_PTR);
+}
+
+
+PUBLIC execn(name)
+char *name;                    /* pointer to file to be exec'd */
+{
+/* Special version used when there are no args and no environment.  This call
+ * is principally used by INIT, to avoid having to allocate MAX_ISTACK_BYTES.
+ */
+
+  static char stack[3 * PTRSIZE];
+
+  return callm1(MM_PROC_NR, EXEC, len(name), sizeof(stack), 0, name, stack, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/exit.c b/mach/minixST/libsys/exit.c
new file mode 100644 (file)
index 0000000..bcf436b
--- /dev/null
@@ -0,0 +1,10 @@
+#include "lib.h"
+
+PUBLIC int (*__cleanup)();
+
+PUBLIC int exit(status)
+int status;
+{
+  if (__cleanup) (*__cleanup)();
+  return callm1(MM, EXIT, status, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/fork.c b/mach/minixST/libsys/fork.c
new file mode 100644 (file)
index 0000000..7d5c0fc
--- /dev/null
@@ -0,0 +1,6 @@
+#include "lib.h"
+
+PUBLIC int fork()
+{
+  return callm1(MM, FORK, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/fstat.c b/mach/minixST/libsys/fstat.c
new file mode 100644 (file)
index 0000000..8fb6d66
--- /dev/null
@@ -0,0 +1,10 @@
+#include "lib.h"
+
+PUBLIC int fstat(fd, buffer)
+int fd;
+char *buffer;
+{
+  int n;
+  n = callm1(FS, FSTAT, fd, 0, 0, buffer, NIL_PTR, NIL_PTR);
+  return(n);
+}
diff --git a/mach/minixST/libsys/getegid.c b/mach/minixST/libsys/getegid.c
new file mode 100644 (file)
index 0000000..e416691
--- /dev/null
@@ -0,0 +1,9 @@
+#include "lib.h"
+
+PUBLIC gid getegid()
+{
+  int k;
+  k = callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  if (k < 0) return ( (gid) k);
+  return( (gid) M.m2_i1);
+}
diff --git a/mach/minixST/libsys/geteuid.c b/mach/minixST/libsys/geteuid.c
new file mode 100644 (file)
index 0000000..172f3df
--- /dev/null
@@ -0,0 +1,9 @@
+#include "lib.h"
+
+PUBLIC uid geteuid()
+{
+  int k;
+  k = callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  if (k < 0) return ( (uid) k);
+  return ((uid) M.m2_i1);
+}
diff --git a/mach/minixST/libsys/getgid.c b/mach/minixST/libsys/getgid.c
new file mode 100644 (file)
index 0000000..78fc92a
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC gid getgid()
+{
+  int k;
+  k = callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  return( (gid) k);
+}
diff --git a/mach/minixST/libsys/getpid.c b/mach/minixST/libsys/getpid.c
new file mode 100644 (file)
index 0000000..43ab9dd
--- /dev/null
@@ -0,0 +1,6 @@
+#include "lib.h"
+
+PUBLIC int getpid()
+{
+  return callm1(MM, GETPID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/getuid.c b/mach/minixST/libsys/getuid.c
new file mode 100644 (file)
index 0000000..44801a3
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC uid getuid()
+{
+  int k;
+  k = callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  return( (uid) k);
+}
diff --git a/mach/minixST/libsys/gtty.c b/mach/minixST/libsys/gtty.c
new file mode 100644 (file)
index 0000000..8916d9b
--- /dev/null
@@ -0,0 +1,9 @@
+#include <sgtty.h>
+
+gtty(fd, argp)
+int fd;
+char *argp;
+{
+  return ioctl(fd, TIOCGETP, argp);
+}
+
diff --git a/mach/minixST/libsys/head_em.s b/mach/minixST/libsys/head_em.s
new file mode 100644 (file)
index 0000000..7320365
--- /dev/null
@@ -0,0 +1,65 @@
+.define .lino,.filn
+.define EXIT
+.define        begtext,begdata,begbss
+.define        EARRAY,ERANGE,ESET,EIDIVZ,EHEAP,EILLINS,ECASE,EBADGTO
+.define        hol0,.reghp,.limhp,.trpim,.trppc
+.sect .text
+.sect .rom
+.sect .data
+.sect .bss
+
+
+
+! EM runtime start-off for MINIX ST
+
+
+LINO_AD        = 0
+FILN_AD        = 4
+
+EARRAY = 0
+ERANGE = 1
+ESET   = 2
+EIDIVZ = 6
+EHEAP  = 17
+EILLINS        = 18
+ECASE  = 20
+EBADGTO = 27
+
+       .sect .text
+begtext:
+       move.l  sp,a0
+       move.l  (a0)+,d0
+       move.l  d0,d1
+       add.l   #1,d1
+        asl.l   #2,d1           ! pointers are four bytes on 68000
+        move.l  a0,a1
+        add.l   d1,a1
+        move.l  a1,-(sp)        ! push environ
+        move.l  a0,-(sp)        ! push argv
+        move.w  d0,-(sp)        ! push argc
+       jsr     _m_a_i_n
+       add     #010,sp
+EXIT:
+       move.w  d0,-(sp)
+       jsr     _exit
+L0:    bra     L0
+
+       .sect .data
+begdata:
+hol0:
+.lino:
+       .data2  0,0     ! lino
+.filn:
+       .data4  0       ! filn
+.reghp:
+       .data4  endbss
+.limhp:
+       .data4  endbss
+.trppc:
+       .data4  0
+.trpim:
+       .data2  0
+
+
+       .sect .bss
+begbss: !initialization is not needed because ALL entries are in zero space!
diff --git a/mach/minixST/libsys/ioctl.c b/mach/minixST/libsys/ioctl.c
new file mode 100644 (file)
index 0000000..a46a733
--- /dev/null
@@ -0,0 +1,64 @@
+#include "lib.h"
+#include <minix/com.h>
+#include <sgtty.h>
+
+PUBLIC int ioctl(fd, request, u)
+int fd;
+int request;
+union {
+  struct sgttyb *argp;
+  struct tchars *argt;
+} u;
+
+{
+  int n;
+  long erase, kill, intr, quit, xon, xoff, eof, brk;
+
+  M.TTY_REQUEST = request;
+  M.TTY_LINE = fd;
+
+  switch(request) {
+     case TIOCSETP:
+       erase = u.argp->sg_erase & 0377;
+       kill = u.argp->sg_kill & 0377;
+       M.TTY_SPEK = (erase << 8) | kill;
+       M.TTY_FLAGS = u.argp->sg_flags;
+       n = callx(FS, IOCTL);
+       return(n);
+     case TIOCSETC:
+       intr = u.argt->t_intrc & 0377;
+       quit = u.argt->t_quitc & 0377;
+       xon  = u.argt->t_startc & 0377;
+       xoff = u.argt->t_stopc & 0377;
+       eof  = u.argt->t_eofc & 0377;
+       brk  = u.argt->t_brkc & 0377;           /* not used at the moment */
+       M.TTY_SPEK = (intr<<24) | (quit<<16) | (xon<<8) | (xoff<<0);
+       M.TTY_FLAGS = (eof<<8) | (brk<<0);
+       n = callx(FS, IOCTL);
+       return(n);
+       
+     case TIOCGETP:
+       n = callx(FS, IOCTL);
+       u.argp->sg_erase = (M.TTY_SPEK >> 8) & 0377;
+       u.argp->sg_kill  = (M.TTY_SPEK >> 0) & 0377;
+       u.argp->sg_flags = M.TTY_FLAGS;
+       return(n);
+
+     case TIOCGETC:
+       n = callx(FS, IOCTL);
+       u.argt->t_intrc  = (M.TTY_SPEK >> 24) & 0377;
+       u.argt->t_quitc  = (M.TTY_SPEK >> 16) & 0377;
+       u.argt->t_startc = (M.TTY_SPEK >>  8) & 0377;
+       u.argt->t_stopc  = (M.TTY_SPEK >>  0) & 0377;
+       u.argt->t_eofc   = (M.TTY_FLAGS >> 8) & 0377;
+       u.argt->t_brkc   = (M.TTY_FLAGS >> 8) & 0377;
+       return(n);
+
+     default:
+       n = -1;
+       errno = -(EINVAL);
+       return(n);
+  }
+}
+
diff --git a/mach/minixST/libsys/kill.c b/mach/minixST/libsys/kill.c
new file mode 100644 (file)
index 0000000..db10654
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int kill(proc, sig)
+int proc;                      /* which process is to be sent the signal */
+int sig;                       /* signal number */
+{
+  return callm1(MM, KILL, proc, sig, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/lib.h b/mach/minixST/libsys/lib.h
new file mode 100644 (file)
index 0000000..32c25c7
--- /dev/null
@@ -0,0 +1,13 @@
+#include <minix/const.h>
+#include <minix/type.h>
+#include <minix/callnr.h>
+#include <errno.h>
+
+extern message M;
+
+#define MM                 0
+#define FS                 1
+
+extern int callm1(), callm3(), callx(), len();
+extern int errno;
+extern int begsig();           /* interrupts all vector here */
diff --git a/mach/minixST/libsys/link.c b/mach/minixST/libsys/link.c
new file mode 100644 (file)
index 0000000..9daee38
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int link(name, name2)
+char *name, *name2;
+{
+  return callm1(FS, LINK, len(name), len(name2), 0, name, name2, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/lseek.c b/mach/minixST/libsys/lseek.c
new file mode 100644 (file)
index 0000000..ffcf165
--- /dev/null
@@ -0,0 +1,15 @@
+#include "lib.h"
+
+PUBLIC long lseek(fd, offset, whence)
+int fd;
+long offset;
+int whence;
+{
+  int k; 
+  M.m2_i1 = fd;
+  M.m2_l1 = offset;
+  M.m2_i2 = whence;
+  k = callx(FS, LSEEK);
+  if (k != OK) return( (long) k);      /* send itself failed */
+  return(M.m2_l1);
+}
diff --git a/mach/minixST/libsys/message.c b/mach/minixST/libsys/message.c
new file mode 100644 (file)
index 0000000..faaae54
--- /dev/null
@@ -0,0 +1,5 @@
+#include <minix/const.h>
+#include <minix/type.h>
+
+/* some compilers require an initializer to force storage allocation */
+message M = {0};
diff --git a/mach/minixST/libsys/mknod.c b/mach/minixST/libsys/mknod.c
new file mode 100644 (file)
index 0000000..7dbfeca
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int mknod(name, mode, addr)
+char *name;
+int mode, addr;
+{
+  return callm1(FS, MKNOD, len(name), mode, addr, name, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/mktemp.c b/mach/minixST/libsys/mktemp.c
new file mode 100644 (file)
index 0000000..e29e5c9
--- /dev/null
@@ -0,0 +1,20 @@
+/* mktemp - make a name for a temporary file */
+
+char *mktemp(template)
+char *template;
+{
+  int pid, k;
+  char *p;
+
+  pid = getpid();              /* get process id as semi-unique number */
+  p = template;
+  while (*p++) ;               /* find end of string */
+  p--;                         /* backup to last character */
+
+  /* Replace XXXXXX at end of template with pid. */
+  while (*--p == 'X') {
+       *p = '0' + (pid % 10);
+       pid = pid/10;
+  }
+  return(template);
+}
diff --git a/mach/minixST/libsys/mount.c b/mach/minixST/libsys/mount.c
new file mode 100644 (file)
index 0000000..258276b
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int mount(special, name, rwflag)
+char *name, *special;
+int rwflag;
+{
+  return callm1(FS, MOUNT, len(special), len(name), rwflag, special, name, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/open.c b/mach/minixST/libsys/open.c
new file mode 100644 (file)
index 0000000..228173d
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int open(name, mode)
+char* name;
+int mode;
+{
+  return callm3(FS, OPEN, mode, name);
+}
diff --git a/mach/minixST/libsys/pause.c b/mach/minixST/libsys/pause.c
new file mode 100644 (file)
index 0000000..2a0d1f6
--- /dev/null
@@ -0,0 +1,6 @@
+#include "lib.h"
+
+PUBLIC int pause()
+{
+  return callm1(MM, PAUSE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/pipe.c b/mach/minixST/libsys/pipe.c
new file mode 100644 (file)
index 0000000..0505880
--- /dev/null
@@ -0,0 +1,14 @@
+#include "lib.h"
+
+PUBLIC int pipe(fild)
+int fild[2];
+{
+  int k;
+  k = callm1(FS, PIPE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  if (k >= 0) {
+       fild[0] = M.m1_i1;
+       fild[1] = M.m1_i2;
+       return(0);
+  } else
+       return(k);
+}
diff --git a/mach/minixST/libsys/read.c b/mach/minixST/libsys/read.c
new file mode 100644 (file)
index 0000000..1619a4d
--- /dev/null
@@ -0,0 +1,11 @@
+#include "lib.h"
+
+PUBLIC int read(fd, buffer, nbytes)
+int fd;
+char *buffer;
+int nbytes;
+{
+  int n;
+  n = callm1(FS, READ, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR);
+  return(n);
+}
diff --git a/mach/minixST/libsys/setgid.c b/mach/minixST/libsys/setgid.c
new file mode 100644 (file)
index 0000000..823e878
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int setgid(grp)
+int grp;
+{
+  return callm1(MM, SETGID, grp, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/setuid.c b/mach/minixST/libsys/setuid.c
new file mode 100644 (file)
index 0000000..c53e0e3
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int setuid(usr)
+int usr;
+{
+  return callm1(MM, SETUID, usr, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/signal.c b/mach/minixST/libsys/signal.c
new file mode 100644 (file)
index 0000000..e588d29
--- /dev/null
@@ -0,0 +1,27 @@
+#include "lib.h"
+#include <signal.h>
+
+int (*vectab[NSIG])(); /* array of functions to catch signals */
+
+/* The definition of signal really should be 
+ *  PUBLIC int (*signal(signr, func))()
+ * but some compilers refuse to accept this, even though it is correct.
+ * The only thing to do if you are stuck with such a defective compiler is
+ * change it to
+ *  PUBLIC int *signal(signr, func)
+ * and change ../h/signal.h accordingly.
+ */
+
+PUBLIC int (*signal(signr, func))()
+int signr;                     /* which signal is being set */
+int (*func)();                 /* pointer to function that catches signal */
+{
+  int r,(*old)();
+
+  old = vectab[signr - 1];
+  vectab[signr - 1] = func;
+  M.m6_i1 = signr;
+  M.m6_f1 = ( (func == SIG_IGN || func == SIG_DFL) ? func : begsig);
+  r = callx(MM, SIGNAL);
+  return( (r < 0 ? (int (*)()) r : old) );
+}
diff --git a/mach/minixST/libsys/stat.c b/mach/minixST/libsys/stat.c
new file mode 100644 (file)
index 0000000..ae7b446
--- /dev/null
@@ -0,0 +1,10 @@
+#include "lib.h"
+
+PUBLIC int stat(name, buffer)
+char *name;
+char *buffer;
+{
+  int n;
+  n = callm1(FS, STAT, len(name), 0, 0, name, buffer, NIL_PTR);
+  return(n);
+}
diff --git a/mach/minixST/libsys/stbrksz.s b/mach/minixST/libsys/stbrksz.s
new file mode 100644 (file)
index 0000000..98c9b75
--- /dev/null
@@ -0,0 +1,13 @@
+#
+       .define _brksize
+       .extern _end
+#ifdef ACK
+       .sect   .text
+       .sect   .rom
+       .sect   .data
+       .sect   .bss
+#endif ACK
+
+       .sect   .data
+_brksize:
+       .data4  _end
diff --git a/mach/minixST/libsys/stcatch.s b/mach/minixST/libsys/stcatch.s
new file mode 100644 (file)
index 0000000..37f2e8d
--- /dev/null
@@ -0,0 +1,39 @@
+#
+       .define _begsig
+       .extern _vectab
+       .extern _M
+#ifdef ACK
+       .sect   .text
+       .sect   .rom
+       .sect   .data
+       .sect   .bss
+#endif ACK
+
+#ifdef ALCYON
+#define FREEREGS d0-d2/a0-a2
+#else
+#define FREEREGS d0-d1/a0-a1
+#endif
+
+mtype = 2                      ! M+mtype = &M.m_type
+       .sect   .text
+_begsig:
+       movem.l FREEREGS,-(sp)
+       clr.l   d0
+#ifdef ALCYON
+       move.w  24(sp),d0       ! d0 = signal number
+#else
+       move.w  16(sp),d0       ! d0 = signal number
+#endif
+       move.w  _M+mtype,-(sp)  ! push status of last system call
+       move.w  d0,-(sp)        ! func called with signal number as arg
+       asl.l   #2,d0           ! pointers are four bytes on 68000
+       move.l  #_vectab,a0
+       move.l  -4(a0,d0),a0    ! a0 = address of routine to call
+       jsr     (a0)
+back:
+       add.l   #2,sp           ! get signal number off stack
+       move.w  (sp)+,_M+mtype  ! restore status of previous system call
+       movem.l (sp)+,FREEREGS
+       add.l   #2,sp           ! remove signal number from stack
+       rtr
diff --git a/mach/minixST/libsys/stderr.c b/mach/minixST/libsys/stderr.c
new file mode 100644 (file)
index 0000000..7910f77
--- /dev/null
@@ -0,0 +1,8 @@
+std_err(s)
+char *s;
+{
+  char *p = s;
+
+  while(*p != 0) p++;
+  write(2, s, (int)(p - s));
+}
diff --git a/mach/minixST/libsys/stime.c b/mach/minixST/libsys/stime.c
new file mode 100644 (file)
index 0000000..548ac37
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int stime(top)
+long *top;
+{
+  M.m2_l1 = *top;
+  return callx(FS, STIME);
+}
diff --git a/mach/minixST/libsys/stsndrec.s b/mach/minixST/libsys/stsndrec.s
new file mode 100644 (file)
index 0000000..fd2b18b
--- /dev/null
@@ -0,0 +1,36 @@
+#
+       .define _send
+       .define _receive
+       .define _sendrec
+#ifdef ACK
+       .sect   .text
+       .sect   .rom
+       .sect   .data
+       .sect   .bss
+#endif ACK
+! =====================================================================
+!                           send and receive                          =
+! =====================================================================
+! send(), receive(), sendrec() destroy d0, d1, and a0.
+
+! See ../h/com.h for C definitions
+SEND   = 1
+RECEIVE        = 2
+BOTH   = 3
+
+       .sect   .text
+
+_send: move.w  #SEND,d0        ! send(dest, ptr)
+       bra     L0
+
+_receive:
+       move.w  #RECEIVE,d0     ! receive(src, ptr)
+       bra     L0
+
+_sendrec:
+       move.w  #BOTH,d0        ! sendrec(srcdest, ptr)
+L0:                            ! d0 = SEND/RECEIVE/BOTH
+       move.w  4(sp),d1        ! d1 = dest-src
+       move.l  6(sp),a0        ! a0 = message pointer
+       trap    #0              ! trap to the kernel
+       rts                     ! return
diff --git a/mach/minixST/libsys/stty.c b/mach/minixST/libsys/stty.c
new file mode 100644 (file)
index 0000000..7dfe3db
--- /dev/null
@@ -0,0 +1,9 @@
+#include <sgtty.h>
+
+stty(fd, argp)
+int fd;
+char *argp;
+{
+  return ioctl(fd, TIOCSETP, argp);
+}
+
diff --git a/mach/minixST/libsys/sync.c b/mach/minixST/libsys/sync.c
new file mode 100644 (file)
index 0000000..4592d28
--- /dev/null
@@ -0,0 +1,6 @@
+#include "lib.h"
+
+PUBLIC int sync()
+{
+  return callm1(FS, SYNC, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/syslib.c b/mach/minixST/libsys/syslib.c
new file mode 100644 (file)
index 0000000..fd696bc
--- /dev/null
@@ -0,0 +1,167 @@
+#include <minix/const.h>
+#include <minix/type.h>
+#include <minix/callnr.h>
+#include <minix/com.h>
+#include <errno.h>
+
+#define FS          FS_PROC_NR
+#define MM          MMPROCNR
+
+extern message M;
+
+
+/*----------------------------------------------------------------------------
+                       Messages to systask (special calls)
+----------------------------------------------------------------------------*/
+
+#ifdef ATARI_ST
+PUBLIC sys_xit(parent, proc, basep, sizep)
+phys_clicks *basep, *sizep;
+#else
+PUBLIC sys_xit(parent, proc)
+#endif
+int parent;                    /* parent of exiting proc. */
+int proc;                      /* which proc has exited */
+{
+/* A proc has exited.  Tell the kernel. */
+
+  callm1(SYSTASK, SYS_XIT, parent, proc, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+#ifdef ATARI_ST
+  *basep = (phys_clicks)M.m1_i1;
+  *sizep = (phys_clicks)M.m1_i2;
+#endif
+}
+
+
+PUBLIC sys_getsp(proc, newsp)
+int proc;                      /* which proc has enabled signals */
+vir_bytes *newsp;              /* place to put sp read from kernel */
+{
+/* Ask the kernel what the sp is. */
+
+
+  callm1(SYSTASK, SYS_GETSP, proc, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  *newsp = (vir_bytes) M.STACK_PTR;
+}
+
+
+PUBLIC sys_sig(proc, sig, sighandler)
+int proc;                      /* which proc has exited */
+int sig;                       /* signal number: 1 - 16 */
+int (*sighandler)();           /* pointer to signal handler in user space */
+{
+/* A proc has to be signaled.  Tell the kernel. */
+
+  M.m6_i1 = proc;
+  M.m6_i2 = sig;
+  M.m6_f1 = sighandler;
+  callx(SYSTASK, SYS_SIG);
+}
+
+
+#ifdef ATARI_ST
+PUBLIC sys_fork(parent, child, pid, shadow)
+#ifdef ALCYON_C_BUG_FIXED
+phys_clicks shadow;            /* memory allocated for shadow */
+#endif
+#else
+PUBLIC sys_fork(parent, child, pid)
+#endif
+int parent;                    /* proc doing the fork */
+int child;                     /* which proc has been created by the fork */
+int pid;                       /* process id assigned by MM */
+{
+/* A proc has forked.  Tell the kernel. */
+
+#ifdef ATARI_ST
+  callm1(SYSTASK, SYS_FORK, parent, child, pid, (char *)shadow, NIL_PTR, NIL_PTR);
+#else
+  callm1(SYSTASK, SYS_FORK, parent, child, pid, NIL_PTR, NIL_PTR, NIL_PTR);
+#endif
+}
+
+
+PUBLIC sys_exec(proc, ptr)
+int proc;                      /* proc that did exec */
+char *ptr;                     /* new stack pointer */
+{
+/* A proc has exec'd.  Tell the kernel. */
+
+  callm1(SYSTASK, SYS_EXEC, proc, 0, 0, ptr, NIL_PTR, NIL_PTR);
+}
+
+PUBLIC sys_newmap(proc, ptr)
+int proc;                      /* proc whose map is to be changed */
+char *ptr;                     /* pointer to new map */
+{
+/* A proc has been assigned a new memory map.  Tell the kernel. */
+
+
+  callm1(SYSTASK, SYS_NEWMAP, proc, 0, 0, ptr, NIL_PTR, NIL_PTR);
+}
+
+PUBLIC sys_copy(mptr)
+message *mptr;                 /* pointer to message */
+{
+/* A proc wants to use local copy. */
+
+  /* Make this routine better.  Also check other guys' error handling -DEBUG */
+  mptr->m_type = SYS_COPY;
+  if (sendrec(SYSTASK, mptr) != OK) panic("sys_copy can't send", NO_NUM);
+}
+
+PUBLIC sys_times(proc, ptr)
+int proc;                      /* proc whose times are needed */
+real_time ptr[4];                      /* pointer to time buffer */
+{
+/* Fetch the accounting info for a proc. */
+
+  callm1(SYSTASK, SYS_TIMES, proc, 0, 0, ptr, NIL_PTR, NIL_PTR);
+  ptr[0] = M.USER_TIME;
+  ptr[1] = M.SYSTEM_TIME;
+  ptr[2] = M.CHILD_UTIME;
+  ptr[3] = M.CHILD_STIME;
+}
+
+
+
+
+
+PUBLIC sys_abort()
+{
+/* Something awful has happened.  Abandon ship. */
+
+  callm1(SYSTASK, SYS_ABORT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
+
+#ifdef ATARI_ST
+PUBLIC sys_fresh(proc, ptr, dc, basep, sizep)
+int proc;                      /* proc whose map is to be changed */
+char *ptr;                     /* pointer to new map */
+phys_clicks dc;                        /* size of initialized data */
+phys_clicks *basep, *sizep;    /* base and size for free_mem() */
+{
+/* Create a fresh process image for exec().  Tell the kernel. */
+
+  callm1(SYSTASK, SYS_FRESH, proc, (int)dc, 0, ptr, NIL_PTR, NIL_PTR);
+  *basep = (phys_clicks)M.m1_i1;
+  *sizep = (phys_clicks)M.m1_i2;
+}
+#endif
+
+
+PUBLIC int tell_fs(what, p1, p2, p3)
+int what, p1, p2, p3;
+{
+/* This routine is only used by MM to inform FS of certain events:
+ *      tell_fs(CHDIR, slot, dir, 0)
+ *      tell_fs(EXIT, proc, 0, 0)
+ *      tell_fs(FORK, parent, child, pid)
+ *      tell_fs(SETGID, proc, realgid, effgid)
+ *      tell_fs(SETUID, proc, realuid, effuid)
+ *      tell_fs(SYNC, 0, 0, 0)
+ *      tell_fs(UNPAUSE, proc, signr, 0)
+ *      tell_fs(SETPGRP, proc, 0, 0)
+ */
+  callm1(FS, what, p1, p2, p3, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/time.c b/mach/minixST/libsys/time.c
new file mode 100644 (file)
index 0000000..e34e1f2
--- /dev/null
@@ -0,0 +1,13 @@
+#include "lib.h"
+
+PUBLIC long time(tp)
+long *tp;
+{
+  int k;
+  long l;
+  k = callm1(FS, TIME, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  if (M.m_type < 0 || k != OK) {errno = -M.m_type; return(-1L);}
+  l = M.m2_l1;
+  if (tp != (long *) 0) *tp = l;
+  return(l);
+}
diff --git a/mach/minixST/libsys/times.c b/mach/minixST/libsys/times.c
new file mode 100644 (file)
index 0000000..77515d6
--- /dev/null
@@ -0,0 +1,15 @@
+#include "lib.h"
+#include <sys/types.h>
+#include <sys/times.h>
+
+PUBLIC int times(buf)
+struct tms *buf;
+{
+  int k;
+  k = callm1(FS, TIMES, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  buf->tms_utime = M.m4_l1;
+  buf->tms_stime = M.m4_l2;
+  buf->tms_cutime = M.m4_l3;
+  buf->tms_cstime = M.m4_l4;
+  return(k);
+}
diff --git a/mach/minixST/libsys/umask.c b/mach/minixST/libsys/umask.c
new file mode 100644 (file)
index 0000000..caeb075
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int umask(complmode)
+int complmode;
+{
+  return callm1(FS, UMASK, complmode, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+}
diff --git a/mach/minixST/libsys/umount.c b/mach/minixST/libsys/umount.c
new file mode 100644 (file)
index 0000000..d1fab6d
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int umount(name)
+char* name;
+{
+  return callm3(FS, UMOUNT, 0, name);
+}
diff --git a/mach/minixST/libsys/unlink.c b/mach/minixST/libsys/unlink.c
new file mode 100644 (file)
index 0000000..9c321ff
--- /dev/null
@@ -0,0 +1,7 @@
+#include "lib.h"
+
+PUBLIC int unlink(name)
+char *name;
+{
+  return callm3(FS, UNLINK, 0, name);
+}
diff --git a/mach/minixST/libsys/utime.c b/mach/minixST/libsys/utime.c
new file mode 100644 (file)
index 0000000..0c9b4ef
--- /dev/null
@@ -0,0 +1,12 @@
+#include "lib.h"
+
+PUBLIC int utime(name, timp)
+char *name;
+long timp[2];
+{
+  M.m2_i1 = len(name);
+  M.m2_l1 = timp[0];
+  M.m2_l2 = timp[1];
+  M.m2_p1 = name;
+  return callx(FS, UTIME);
+}
diff --git a/mach/minixST/libsys/wait.c b/mach/minixST/libsys/wait.c
new file mode 100644 (file)
index 0000000..c1472a0
--- /dev/null
@@ -0,0 +1,10 @@
+#include "lib.h"
+
+PUBLIC int wait(status)
+int *status;
+{
+  int k;
+  k = callm1(MM, WAIT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
+  if (status != 0) *status = M.m2_i1;
+  return(k);
+}
diff --git a/mach/minixST/libsys/write.c b/mach/minixST/libsys/write.c
new file mode 100644 (file)
index 0000000..e08826b
--- /dev/null
@@ -0,0 +1,8 @@
+#include "lib.h"
+
+PUBLIC int write(fd, buffer, nbytes)
+char *buffer;
+int nbytes;
+{
+  return callm1(FS, WRITE, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR);
+}