ec_rxstart doesn't eists
[unix-history] / usr / src / sys / kern / subr_xxx.c
index 281c5bb..940ca27 100644 (file)
-/*     subr_xxx.c      4.12    82/07/15        */
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/conf.h"
-#include "../h/inode.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/buf.h"
-#include "../h/proc.h"
-#include "../h/fs.h"
-#include "../h/vm.h"
-#include "../h/pte.h"
-#include "../h/cmap.h"
+/*
+ * Copyright (c) 1982, 1986, 1991 Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ *
+ *     @(#)subr_xxx.c  7.10 (Berkeley) %G%
+ */
 
 /*
 
 /*
- * Pass back  c  to the user at his location u_base;
- * update u_base, u_count, and u_offset.  Return -1
- * on the last character of the user's read.
- * u_base is in the user address space unless u_segflg is set.
+ * Miscellaneous trivial functions, including many
+ * that are often inline-expanded or done in assembler.
  */
  */
-passc(c)
-register c;
-{
-       register id;
-
-       if ((id = u.u_segflg) == 1)
-               *u.u_base = c;
-       else
-               if (id?suibyte(u.u_base, c):subyte(u.u_base, c) < 0) {
-                       u.u_error = EFAULT;
-                       return (-1);
-               }
-       u.u_count--;
-       u.u_offset++;
-       u.u_base++;
-       return (u.u_count == 0? -1: 0);
-}
-
-#include "ct.h"
-#if NCT > 0
+#include "param.h"
+#include "systm.h"
+#include "machine/cpu.h"
+
+/*
+ * Unsupported device function (e.g. writing to read-only device).
+ */
+enodev()
+{
+
+       return (ENODEV);
+}
+
 /*
 /*
- * Pick up and return the next character from the user's
- * write call at location u_base;
- * update u_base, u_count, and u_offset.  Return -1
- * when u_count is exhausted.  u_base is in the user's
- * address space unless u_segflg is set.
+ * Unconfigured device function; driver not configured.
  */
  */
-cpass()
-{
-       register c, id;
-
-       if (u.u_count == 0)
-               return (-1);
-       if ((id = u.u_segflg) == 1)
-               c = *u.u_base;
-       else
-               if ((c = id==0?fubyte(u.u_base):fuibyte(u.u_base)) < 0) {
-                       u.u_error = EFAULT;
-                       return (-1);
-               }
-       u.u_count--;
-       u.u_offset++;
-       u.u_base++;
-       return (c&0377);
-}
-#endif
+enxio()
+{
+
+       return (ENXIO);
+}
 
 /*
 
 /*
- * Routine which sets a user error; placed in
- * illegal entries in the bdevsw and cdevsw tables.
+ * Unsupported ioctl function.
  */
  */
-nodev()
+enoioctl()
 {
 
 {
 
-       u.u_error = ENODEV;
+       return (ENOTTY);
 }
 
 /*
 }
 
 /*
- * Null routine; placed in insignificant entries
- * in the bdevsw and cdevsw tables.
+ * Unsupported system function.
+ * This is used for an otherwise-reasonable operation
+ * that is not supported by the current system binary.
  */
  */
-nulldev()
+enosys()
 {
 
 {
 
+       return (ENOSYS);
 }
 
 }
 
+/*
+ * Return error for operation not supported
+ * on a specific object or file type.
+ */
+eopnotsupp()
+{
+
+       return (EOPNOTSUPP);
+}
+
+/*
+ * Generic null operation, always returns success.
+ */
+nullop()
+{
+
+       return (0);
+}
+
+/*
+ * Definitions of various trivial functions;
+ * usually expanded inline rather than being defined here.
+ */
+#ifdef NEED_MINMAX
 imin(a, b)
 imin(a, b)
+       int a, b;
 {
 
        return (a < b ? a : b);
 }
 
 imax(a, b)
 {
 
        return (a < b ? a : b);
 }
 
 imax(a, b)
+       int a, b;
 {
 
        return (a > b ? a : b);
 }
 
 {
 
        return (a > b ? a : b);
 }
 
-unsigned
+unsigned int
 min(a, b)
        unsigned int a, b;
 {
 min(a, b)
        unsigned int a, b;
 {
@@ -105,7 +99,7 @@ min(a, b)
        return (a < b ? a : b);
 }
 
        return (a < b ? a : b);
 }
 
-unsigned
+unsigned int
 max(a, b)
        unsigned int a, b;
 {
 max(a, b)
        unsigned int a, b;
 {
@@ -113,62 +107,77 @@ max(a, b)
        return (a > b ? a : b);
 }
 
        return (a > b ? a : b);
 }
 
-struct proc *
-pfind(pid)
-       int pid;
+long
+lmin(a, b)
+       long a, b;
 {
 {
-       register struct proc *p;
 
 
-       for (p = &proc[pidhash[PIDHASH(pid)]]; p != &proc[0]; p = &proc[p->p_idhash])
-               if (p->p_pid == pid)
-                       return (p);
-       return ((struct proc *)0);
+       return (a < b ? a : b);
 }
 }
-extern cabase, calimit;
-extern struct pte camap[];
 
 
-caddr_t        cacur = (caddr_t)&cabase;
-caddr_t        camax = (caddr_t)&cabase;
-int    cax = 0;
-/*
- * This is a kernel-mode storage allocator.
- * It is very primitive, currently, in that
- * there is no way to give space back.
- * It serves, for the time being, the needs of
- * auto-configuration code and the like which
- * need to allocate some stuff at boot time.
- */
-caddr_t
-calloc(size)
-       int size;
-{
-       register caddr_t res;
-       register int i;
-
-       if (cacur+size >= (caddr_t)&calimit)
-               panic("calloc");
-       while (cacur+size > camax) {
-               (void) vmemall(&camap[cax], CLSIZE, &proc[0], CSYS);
-               vmaccess(&camap[cax], camax, CLSIZE);
-               for (i = 0; i < CLSIZE; i++)
-                       clearseg(camap[cax++].pg_pfnum);
-               camax += NBPG * CLSIZE;
-       }
-       res = cacur;
-       cacur += size;
-       return (res);
+long
+lmax(a, b)
+       long a, b;
+{
+
+       return (a > b ? a : b);
+}
+
+unsigned long
+ulmin(a, b)
+       unsigned long a, b;
+{
+
+       return (a < b ? a : b);
+}
+
+unsigned long
+ulmax(a, b)
+       unsigned long a, b;
+{
+
+       return (a > b ? a : b);
 }
 }
-#ifndef vax
+#endif /* NEED_MINMAX */
+
+#ifdef NEED_FFS
 ffs(mask)
        register long mask;
 {
 ffs(mask)
        register long mask;
 {
-       register int i;
+       register int bit;
 
 
-       for(i=1; i<NSIG; i++) {
-               if (mask & 1)
-                       return (i);
+       if (!mask)
+               return(0);
+       for (bit = 1;; ++bit) {
+               if (mask&0x01)
+                       return(bit);
                mask >>= 1;
        }
                mask >>= 1;
        }
+}
+#endif /* NEED_FFS */
+
+#ifdef NEED_BCMP
+bcmp(v1, v2, len)
+       void *v1, *v2;
+       register unsigned len;
+{
+       register u_char *s1 = v1, *s2 = v2;
+
+       while (len--)
+               if (*s1++ != *s2++)
+                       return (1);
        return (0);
 }
        return (0);
 }
-#endif
+#endif /* NEED_BCMP */
+
+#ifdef NEED_STRLEN
+strlen(s1)
+       register char *s1;
+{
+       register int len;
+
+       for (len = 0; *s1++ != '\0'; len++)
+               ;
+       return (len);
+}
+#endif /* NEED_STRLEN */