add kvtopte, kvtophys
[unix-history] / usr / src / sys / tahoe / include / param.h
index 46868bf..3568869 100644 (file)
@@ -1,36 +1,77 @@
-/*     param.h 1.3     86/01/24        */
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)param.h     1.12 (Berkeley) %G%
+ */
 
 /*
  * Machine dependent constants for TAHOE.
  */
 
 /*
  * Machine dependent constants for TAHOE.
  */
-#define        NBPG    1024            /* bytes/page */
-#define        PGOFSET (NBPG-1)        /* byte offset into page */
-#define        PGSHIFT 10              /* LOG2(NBPG) */
+#define        MACHINE "tahoe"
+
+#ifndef BYTE_ORDER
+#include <machine/endian.h>
+#endif
+
+#define        CHAR_BIT        NBBY
+#define        CHAR_MAX        0x7f
+#define        CHAR_MIN        0x80
+#define        CLK_TCK         60                      /* for times() */
+#define        INT_MAX         0x7fffffff
+#define        INT_MIN         0x80000000
+#define        LONG_MAX        0x7fffffff
+#define        LONG_MIN        0x80000000
+#define        SCHAR_MAX       0x7f
+#define        SCHAR_MIN       0x80
+#define        SHRT_MAX        0x7fff
+#define        SHRT_MIN        0x8000
+#define        UCHAR_MAX       0xff
+#define        UINT_MAX        0xffffffff
+#define        ULONG_MAX       0xffffffff
+#define        USHRT_MAX       0xffff
+
+#define        NBPG            1024            /* bytes/page */
+#define        PGOFSET         (NBPG-1)        /* byte offset into page */
+#define        PGSHIFT         10              /* LOG2(NBPG) */
+#define        NPTEPG          (NBPG/(sizeof (struct pte)))
+
+#define        KERNBASE        0xc0000000      /* start of kernel virtual */
+#define        BTOPKERNBASE    ((u_long)KERNBASE >> PGSHIFT)
+
+#define        KERNBASE        0xc0000000      /* start of kernel virtual */
+#define        BTOPKERNBASE    ((u_long)KERNBASE >> PGSHIFT)
+
+#ifndef SECSIZE
+#define        DEV_BSIZE       1024
+#define        DEV_BSHIFT      10              /* log2(DEV_BSIZE) */
+#define BLKDEV_IOSIZE  1024            /* NBPG for physical controllers */
+#define        MAXPHYS         (64 * 1024)     /* max raw I/O transfer size */
+#else SECSIZE
+/*
+ * Devices without disk labels and the swap virtual device
+ * use "blocks" of exactly pagesize.  Devices with disk labels
+ * use device-dependent sector sizes for block and character interfaces.
+ */
+#define        DEV_BSIZE       NBPG
+#define        DEV_BSHIFT      PGSHIFT         /* log2(DEV_BSIZE) */
+#define BLKDEV_IOSIZE  NBPG            /* NBPG for unlabeled block devices */
+#endif SECSIZE
+#define        MAXPHYS         (64 * 1024)     /* max raw I/O transfer size */
 
 #define        CLSIZE          1
 #define        CLSIZELOG2      0
 
 
 #define        CLSIZE          1
 #define        CLSIZELOG2      0
 
-#define        SSIZE   2                       /* initial stack size/NBPG */
-#define        SINCR   2                       /* increment of stack/NBPG */
-#define        UPAGES  6                       /* pages of u-area (2 stack pages) */
+#define        SSIZE           2               /* initial stack size/NBPG */
+#define        SINCR           2               /* increment of stack/NBPG */
+#define        UPAGES          6               /* pages of u-area (2 stack pages) */
 
 #define        MAXCKEY 255             /* maximal allowed code key */
 #define        MAXDKEY 255             /* maximal allowed data key */
 #define        NCKEY   (MAXCKEY+1)     /* # code keys, including 0 (reserved) */
 #define        NDKEY   (MAXDKEY+1)     /* # data keys, including 0 (reserved) */
 
 
 #define        MAXCKEY 255             /* maximal allowed code key */
 #define        MAXDKEY 255             /* maximal allowed data key */
 #define        NCKEY   (MAXCKEY+1)     /* # code keys, including 0 (reserved) */
 #define        NDKEY   (MAXDKEY+1)     /* # data keys, including 0 (reserved) */
 
-/*
- * Statistics maintained for code and
- * data cache key allocations algorithms.
- */
-struct keystats {
-       long    ks_allocs;      /* number of keys allocated */
-       long    ks_free;        /* key allocated from free slot */
-       long    ks_norefs;      /* key marked in use, but refcnt 0 */
-       long    ks_taken;       /* key taken from single process */
-       long    ks_shared;      /* key taken from multiple processes */
-};
-
 /*
  * Some macros for units conversion
  */
 /*
  * Some macros for units conversion
  */
@@ -38,10 +79,17 @@ struct      keystats {
 #define        ctos(x) (x)
 #define        stoc(x) (x)
 
 #define        ctos(x) (x)
 #define        stoc(x) (x)
 
+#ifndef SECSIZE
 /* Core clicks (1024 bytes) to disk blocks */
 #define        ctod(x) (x)
 #define        dtoc(x) (x)
 #define        dtob(x) ((x)<<PGSHIFT)
 /* Core clicks (1024 bytes) to disk blocks */
 #define        ctod(x) (x)
 #define        dtoc(x) (x)
 #define        dtob(x) ((x)<<PGSHIFT)
+#else SECSIZE
+/* Core clicks (1024 bytes) to disk blocks; deprecated */
+#define        ctod(x) (x)                             /* XXX */
+#define        dtoc(x) (x)                             /* XXX */
+#define        dtob(x) ((x)<<PGSHIFT)                  /* XXX */
+#endif SECSIZE
 
 /* clicks to bytes */
 #define        ctob(x) ((x)<<PGSHIFT)
 
 /* clicks to bytes */
 #define        ctob(x) ((x)<<PGSHIFT)
@@ -49,6 +97,25 @@ struct       keystats {
 /* bytes to clicks */
 #define        btoc(x) ((((unsigned)(x)+NBPG-1) >> PGSHIFT))
 
 /* bytes to clicks */
 #define        btoc(x) ((((unsigned)(x)+NBPG-1) >> PGSHIFT))
 
+#ifndef SECSIZE
+#define        btodb(bytes)                    /* calculates (bytes / DEV_BSIZE) */ \
+       ((unsigned)(bytes) >> DEV_BSHIFT)
+#define        dbtob(db)                       /* calculates (db * DEV_BSIZE) */ \
+       ((unsigned)(db) << DEV_BSHIFT)
+
+/*
+ * Map a ``block device block'' to a file system block.
+ * This should be device dependent, and will be if we
+ * add an entry to cdevsw/bdevsw for that purpose.
+ * For now though just use DEV_BSIZE.
+ */
+#define        bdbtofsb(bn)    ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
+#else SECSIZE
+/* bytes to "disk blocks" and back; deprecated */
+#define        btodb(bytes)    ((unsigned)(bytes) >> DEV_BSHIFT)       /* XXX */
+#define        dbtob(db)       ((unsigned)(db) << DEV_BSHIFT)          /* XXX */
+#endif SECSIZE
+
 /*
  * Macros to decode processor status word.
  */
 /*
  * Macros to decode processor status word.
  */