ifdefs for dev_bsize (almost working_
authorMike Karels <karels@ucbvax.Berkeley.EDU>
Fri, 3 Apr 1987 07:36:01 +0000 (23:36 -0800)
committerMike Karels <karels@ucbvax.Berkeley.EDU>
Fri, 3 Apr 1987 07:36:01 +0000 (23:36 -0800)
SCCS-vsn: sys/vax/vax/autoconf.c 7.5.1.1
SCCS-vsn: sys/vax/include/param.h 7.4.1.1

usr/src/sys/vax/include/param.h
usr/src/sys/vax/vax/autoconf.c

index 5a61b6c..d5a6f28 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)param.h     7.4 (Berkeley) %G%
+ *     @(#)param.h     7.4.1.1 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -33,14 +33,29 @@ u_short     ntohs(), htons();
 u_long ntohl(), htonl();
 #endif
 
 u_long ntohl(), htonl();
 #endif
 
+#define        KERNBASE        0x80000000      /* start of kernel virtual */
+#define        BTOPKERNBASE    ((u_long)KERNBASE >> PGSHIFT)
+
 #define        NBPG            512             /* bytes/page */
 #define        PGOFSET         (NBPG-1)        /* byte offset into page */
 #define        PGSHIFT         9               /* LOG2(NBPG) */
 #define        NPTEPG          (NBPG/(sizeof (struct pte)))
 
 #define        NBPG            512             /* bytes/page */
 #define        PGOFSET         (NBPG-1)        /* byte offset into page */
 #define        PGSHIFT         9               /* LOG2(NBPG) */
 #define        NPTEPG          (NBPG/(sizeof (struct pte)))
 
+#ifndef SECSIZE
 #define        DEV_BSIZE       512
 #define        DEV_BSHIFT      9               /* log2(DEV_BSIZE) */
 #define BLKDEV_IOSIZE  2048
 #define        DEV_BSIZE       512
 #define        DEV_BSHIFT      9               /* log2(DEV_BSIZE) */
 #define BLKDEV_IOSIZE  2048
+#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         (63 * 1024)     /* max raw I/O transfer size */
 
 #define        CLSIZE          2
 #define        CLSIZELOG2      1
 
 #define        CLSIZE          2
 #define        CLSIZELOG2      1
@@ -57,10 +72,17 @@ u_long      ntohl(), htonl();
 #define        ctos(x) (x)
 #define        stoc(x) (x)
 
 #define        ctos(x) (x)
 #define        stoc(x) (x)
 
+#ifndef SECSIZE
 /* Core clicks (512 bytes) to disk blocks */
 #define        ctod(x) (x)
 #define        dtoc(x) (x)
 /* Core clicks (512 bytes) to disk blocks */
 #define        ctod(x) (x)
 #define        dtoc(x) (x)
-#define        dtob(x) ((x)<<9)
+#define        dtob(x) ((x)<<PGSHIFT)
+#else SECSIZE
+/* Core clicks (512 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)<<9)
 
 /* clicks to bytes */
 #define        ctob(x) ((x)<<9)
@@ -68,6 +90,7 @@ u_long        ntohl(), htonl();
 /* bytes to clicks */
 #define        btoc(x) ((((unsigned)(x)+511)>>9))
 
 /* bytes to clicks */
 #define        btoc(x) ((((unsigned)(x)+511)>>9))
 
+#ifndef SECSIZE
 #define        btodb(bytes)                    /* calculates (bytes / DEV_BSIZE) */ \
        ((unsigned)(bytes) >> DEV_BSHIFT)
 #define        dbtob(db)                       /* calculates (db * DEV_BSIZE) */ \
 #define        btodb(bytes)                    /* calculates (bytes / DEV_BSIZE) */ \
        ((unsigned)(bytes) >> DEV_BSHIFT)
 #define        dbtob(db)                       /* calculates (db * DEV_BSIZE) */ \
@@ -80,6 +103,11 @@ u_long      ntohl(), htonl();
  * For now though just use DEV_BSIZE.
  */
 #define        bdbtofsb(bn)    ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
  * 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.
index 1d1a303..1958417 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)autoconf.c  7.5 (Berkeley) %G%
+ *     @(#)autoconf.c  7.5.1.1 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -18,8 +18,6 @@
 #include "mba.h"
 #include "uba.h"
 
 #include "mba.h"
 #include "uba.h"
 
-#include "pte.h"
-
 #include "param.h"
 #include "systm.h"
 #include "map.h"
 #include "param.h"
 #include "systm.h"
 #include "map.h"
 #include "conf.h"
 #include "dmap.h"
 #include "reboot.h"
 #include "conf.h"
 #include "dmap.h"
 #include "reboot.h"
+#ifdef SECSIZE
+#include "file.h"
+#include "ioctl.h"
+#include "disklabel.h"
+#endif SECSIZE
 
 
+#include "pte.h"
 #include "cpu.h"
 #include "mem.h"
 #include "mtpr.h"
 #include "cpu.h"
 #include "mem.h"
 #include "mtpr.h"
@@ -936,27 +940,82 @@ ioaccess(physa, pte, size)
 /*
  * Configure swap space and related parameters.
  */
 /*
  * Configure swap space and related parameters.
  */
+#ifndef SECSIZE
 swapconf()
 {
        register struct swdevt *swp;
        register int nblks;
 
 swapconf()
 {
        register struct swdevt *swp;
        register int nblks;
 
-       for (swp = swdevt; swp->sw_dev; swp++) {
+       for (swp = swdevt; swp->sw_dev; swp++)
                if (bdevsw[major(swp->sw_dev)].d_psize) {
                        nblks =
                if (bdevsw[major(swp->sw_dev)].d_psize) {
                        nblks =
-                           (*bdevsw[major(swp->sw_dev)].d_psize)(swp->sw_dev);
+                         (*bdevsw[major(swp->sw_dev)].d_psize)(swp->sw_dev);
                        if (nblks != -1 &&
                            (swp->sw_nblks == 0 || swp->sw_nblks > nblks))
                                swp->sw_nblks = nblks;
                }
                        if (nblks != -1 &&
                            (swp->sw_nblks == 0 || swp->sw_nblks > nblks))
                                swp->sw_nblks = nblks;
                }
-       }
-       if (!cold)                      /* in case called for mba device */
-               return;
        if (dumplo == 0 && bdevsw[major(dumpdev)].d_psize)
                dumplo = (*bdevsw[major(dumpdev)].d_psize)(dumpdev) - physmem;
        if (dumplo < 0)
                dumplo = 0;
 }
        if (dumplo == 0 && bdevsw[major(dumpdev)].d_psize)
                dumplo = (*bdevsw[major(dumpdev)].d_psize)(dumpdev) - physmem;
        if (dumplo < 0)
                dumplo = 0;
 }
+#else SECSIZE
+swapconf()
+{
+       register struct swdevt *swp;
+       register int nblks;
+       register int bsize;
+       struct partinfo dpart;
+
+       for (swp = swdevt; swp->sw_dev; swp++)
+               if ((nblks = psize(swp->sw_dev, &swp->sw_blksize,
+                   &swp->sw_bshift)) != -1 &&
+                   (swp->sw_nblks == 0 || swp->sw_nblks > nblks))
+                       swp->sw_nblks = nblks;
+
+       if (!cold)      /* In case called for addition of another drive */
+               return;
+       if (dumplo == 0) {
+               nblks = psize(dumpdev, (int *)0, (int *)0);
+               if (nblks == -1 || nblks < ctod(physmem))
+                       dumplo = 0;
+               else
+                       dumplo = nblks - ctod(physmem);
+       }
+}
+
+/*
+ * Return size of disk partition in DEV_BSIZE units.
+ * If needed, return sector size.
+ */
+psize(dev, psize, pshift)
+       register dev_t dev;
+       int *psize, *pshift;
+{
+       register int nblks, bsize, bshift;
+       struct partinfo dpart;
+
+       if ((*bdevsw[major(dev)].d_ioctl)(dev, DIOCGPART,
+           (caddr_t)&dpart, FREAD) == 0)
+               bsize = dpart.disklab->d_secsize;
+       else
+               bsize = DEV_BSIZE;
+       if (psize)
+               *psize = bsize;
+       bshift = 0;
+       for (nblks = DEV_BSIZE / bsize; nblks > 1; nblks >>= 1)
+               bshift++;
+       if (pshift)
+               *pshift = bshift;
+       nblks = -1;
+       if (bdevsw[major(dev)].d_psize) {
+               nblks = (*bdevsw[major(dev)].d_psize)(dev);
+               if (nblks != -1)
+                       nblks >>= bshift;
+       }
+       return (nblks);
+}
+#endif SECSIZE
 
 #define        DOSWAP                  /* Change swdevt, argdev, and dumpdev too */
 u_long bootdev;                /* should be dev_t, but not until 32 bits */
 
 #define        DOSWAP                  /* Change swdevt, argdev, and dumpdev too */
 u_long bootdev;                /* should be dev_t, but not until 32 bits */