Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/sys/arch/vax/vsa Pull up revision 1.10 + 1.12 (requeste...



details:   https://anonhg.NetBSD.org/src/rev/c438b76b3dab
branches:  netbsd-1-5
changeset: 488309:c438b76b3dab
user:      ragge <ragge%NetBSD.org@localhost>
date:      Wed Jun 28 13:32:24 2000 +0000

description:
Pull up revision 1.10 + 1.12 (requested by ragge):
Fixes broken MFM support + DMA area queueing.

diffstat:

 sys/arch/vax/vsa/hdc9224.c |  1386 +++++++++++++++++--------------------------
 1 files changed, 546 insertions(+), 840 deletions(-)

diffs (truncated from 1653 to 300 lines):

diff -r 6774fced05ab -r c438b76b3dab sys/arch/vax/vsa/hdc9224.c
--- a/sys/arch/vax/vsa/hdc9224.c        Wed Jun 28 13:31:54 2000 +0000
+++ b/sys/arch/vax/vsa/hdc9224.c        Wed Jun 28 13:32:24 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hdc9224.c,v 1.9 1998/04/13 12:17:31 ragge Exp $ */
+/*     $NetBSD: hdc9224.c,v 1.9.24.1 2000/06/28 13:32:24 ragge Exp $ */
 /*
  * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
  * All rights reserved.
@@ -38,21 +38,17 @@
  *     Roger Ivie
  *     Rick Macklem
  *     Mike Young
+ *
+ * Rewritten by Ragge 25 Jun 2000. New features:
+ *     - Uses interrupts instead of polling to signal ready.
+ *     - Can cooperate with the SCSI routines WRT. the DMA area.
+ *
+ * TODO:
+ *     - Floppy support missing.
+ *     - Bad block forwarding missing.
+ *     - Statistics collection.
  */
-
-/* #define DEBUG       */
-/* #define TRACE       */
-static int haveLock = 0;
-static int keepLock = 0;
-
-#define F_READ 11
-#define F_WRITE 12
-
-#define trace(x)
-#define debug(x)
-
-#include "hdc.h"
-#if NHDC > 0
+#undef RDDEBUG
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -72,6 +68,12 @@
 #include <sys/syslog.h>
 #include <sys/reboot.h>
 
+#include <vm/vm.h>
+#include <vm/vm_kern.h>
+
+#include <ufs/ufs/dinode.h> /* For BBSIZE */
+#include <ufs/ffs/fs.h>
+
 #include <machine/pte.h>
 #include <machine/sid.h>
 #include <machine/cpu.h>
@@ -79,24 +81,14 @@
 #include <machine/ka410.h>
 #include <machine/vsbus.h>
 #include <machine/rpb.h>
+#include <machine/scb.h>
+
+#include <dev/mscp/mscp.h> /* For DEC disk encoding */
 
 #include <vax/vsa/hdc9224.h>
 
-
-/*
- * some definitions 
- */
-#define CTLRNAME  "hdc"
-#define UNITNAME  "rd"
-#define HDC_PRI          LOG_INFO
-
-/* Bits in minor device */ 
-#define HDCUNIT(dev)   DISKUNIT(dev)
-#define HDCPART(dev)   DISKPART(dev)
-#define HDCCTLR(dev)   0
-#define HDCLABELDEV(dev)       (MAKEDISKDEV(major(dev),HDCUNIT(dev),RAW_PART))
-
-#define MAX_WAIT       (1000*1000)     /* # of loop-instructions in seconds */
+#include "ioconf.h"
+#include "locators.h"
 
 
 /* 
@@ -104,34 +96,34 @@
  */
 #define _aP    __attribute__ ((packed))        /* force byte-alignment */
 struct rdgeom {
-  char mbz[10];                /* 10 bytes of zero */
-  long xbn_count _aP;  /* number of XBNs */
-  long dbn_count _aP;  /* number of DBNs */
-  long lbn_count _aP;  /* number of LBNs (Logical-Block-Numbers) */
-  long rbn_count _aP;  /* number of RBNs (Replacement-Block-Numbers) */
-  short nspt;          /* number of sectors per track */
-  short ntracks;       /* number of tracks */
-  short ncylinders;    /* number of cylinders */
-  short precomp;       /* first cylinder for write precompensation */
-  short reduced;       /* first cylinder for reduced write current */
-  short seek_rate;     /* seek rate or zero for buffered seeks */
-  short crc_eec;       /* 0 if CRC is being used or 1 if ECC is being used */
-  short rct;           /* "replacement control table" (RCT) */
-  short rct_ncopies;   /* number of copies of the RCT */
-  long media_id _aP;   /* media identifier */
-  short interleave;    /* sector-to-sector interleave */
-  short headskew;      /* head-to-head skew */
-  short cylskew;       /* cylinder-to-cylinder skew */
-  short gap0_size;     /* size of GAP 0 in the MFM format */
-  short gap1_size;     /* size of GAP 1 in the MFM format */
-  short gap2_size;     /* size of GAP 2 in the MFM format */
-  short gap3_size;     /* size of GAP 3 in the MFM format */
-  short sync_value;    /* sync value used to start a track when formatting */
-  char reserved[32];   /* reserved for use by the RQDX1/2/3 formatter */
-  short serial_number; /* serial number */
+       char mbz[10];           /* 10 bytes of zero */
+       long xbn_count _aP;     /* number of XBNs */
+       long dbn_count _aP;     /* number of DBNs */
+       long lbn_count _aP;     /* number of LBNs (Logical-Block-Numbers) */
+       long rbn_count _aP;     /* number of RBNs (Replacement-Block-Numbers) */
+       short nspt;             /* number of sectors per track */
+       short ntracks;          /* number of tracks */
+       short ncylinders;       /* number of cylinders */
+       short precomp;          /* first cylinder for write precompensation */
+       short reduced;          /* first cylinder for reduced write current */
+       short seek_rate;        /* seek rate or zero for buffered seeks */
+       short crc_eec;          /* 0 if CRC, 1 if ECC is being used */
+       short rct;              /* "replacement control table" (RCT) */
+       short rct_ncopies;      /* number of copies of the RCT */
+       long    media_id _aP;   /* media identifier */
+       short interleave;       /* sector-to-sector interleave */
+       short headskew;         /* head-to-head skew */
+       short cylskew;          /* cylinder-to-cylinder skew */
+       short gap0_size;        /* size of GAP 0 in the MFM format */
+       short gap1_size;        /* size of GAP 1 in the MFM format */
+       short gap2_size;        /* size of GAP 2 in the MFM format */
+       short gap3_size;        /* size of GAP 3 in the MFM format */
+       short sync_value;       /* sync value used when formatting */
+       char    reserved[32];   /* reserved for use by the RQDX formatter */
+       short serial_number;    /* serial number */
 #if 0  /* we don't need these 412 useless bytes ... */
-  char fill[412-2];    /* Filler bytes to the end of the block */
-  short checksum;      /* checksum over the XBN */
+       char    fill[412-2];    /* Filler bytes to the end of the block */
+       short checksum; /* checksum over the XBN */
 #endif
 };
 
@@ -139,77 +131,79 @@
  * Software status
  */
 struct rdsoftc {
-       struct device   sc_dev;         /* must be here! (pseudo-OOP:) */
-       struct disk     sc_dk;          /* disklabel etc. */
-       struct rdgeom   sc_xbn;         /* on-disk geometry information */
-       struct rdparams {
-               u_short cylinders;      /* number of cylinders */
-               u_char  heads;          /* number of heads (tracks) */
-               u_char  sectors;        /* number of sectors/track */
-               u_long  diskblks;       /* number of sectors/disk */
-               u_long  disklbns;       /* number of available sectors */
-               u_long  blksize;        /* number of bytes/sector */
-               u_long  diskbytes;      /* number of bytes/disk */
-               char    diskname[8];
-       } sc_param;
-       int     sc_drive;               /* physical unit number */
-       int     sc_flags;
-       int     sc_state;
-       int     sc_mode;
+       struct device sc_dev;           /* must be here! (pseudo-OOP:) */
+       struct disk sc_disk;            /* disklabel etc. */
+       struct rdgeom sc_xbn;           /* on-disk geometry information */
+       int sc_drive;           /* physical unit number */
 };
 
 struct hdcsoftc {
        struct device sc_dev;           /* must be here (pseudo-OOP:) */
-       struct hdc9224_DKCreg *sc_dkc;  /* I/O address of the controller */
+       struct evcnt sc_intrcnt;
+       struct vsbus_dma sc_vd;
+       vaddr_t sc_regs;                /* register addresses */
+       struct buf_queue sc_q;
+       struct buf *sc_active;
        struct hdc9224_UDCreg sc_creg;  /* (command) registers to be written */
        struct hdc9224_UDCreg sc_sreg;  /* (status) registers being read */
-       struct confargs *sc_cfargs;     /* remember args being probed with */
-       char    *sc_dmabase;            /* */
-       long    sc_dmasize;             /* */
-       long    sc_ioaddr;              /* unmapped I/O address */
-       long    sc_ivec;                /* interrupt vector address */
-       short   sc_ibit;                /* bit-value in interrupt register */
-       short   sc_status;              /* copy of status register */
-       short   sc_state;
-       short   sc_flags;
-       short   sc_errors;
+       caddr_t sc_dmabase;             /* */
+       int     sc_dmasize;
+       caddr_t sc_bufaddr;             /* Current in-core address */
+       int sc_diskblk;                 /* Current block on disk */
+       int sc_bytecnt;                 /* How much left to transfer */
+       int sc_xfer;                    /* Current transfer size */
+       int sc_retries;
+       volatile u_char sc_status;      /* last status from interrupt */
+       char sc_intbit;
+};
+
+struct hdc_attach_args {
+       int ha_drive;
 };
 
 /*
- * Device definition for (new) autoconfiguration.
+ * prototypes for (almost) all the internal routines
  */
-int    hdcmatch  __P((struct device *parent, struct cfdata *, void *aux));
-void   hdcattach __P((struct device *parent, struct device *self, void *aux));
-int    hdcprint  __P((void *aux, const char *name));
+static int hdcmatch(struct device *, struct cfdata *, void *);
+static void hdcattach(struct device *, struct device *, void *);
+static int hdcprint(void *, const char *);
+static int rdmatch(struct device *, struct cfdata *, void *);
+static void rdattach(struct device *, struct device *, void *);
+static void hdcintr(void *);
+static int hdc_command(struct hdcsoftc *, int);
+static void rd_readgeom(struct hdcsoftc *, struct rdsoftc *);
+#ifdef RDDEBUG
+static void hdc_printgeom( struct rdgeom *);
+#endif
+static void hdc_writeregs(struct hdcsoftc *);
+static void hdcstart(struct hdcsoftc *, struct buf *);
+static int hdc_rdselect(struct hdcsoftc *, int);
+static void rdmakelabel(struct disklabel *, struct rdgeom *);
+static void hdc_writeregs(struct hdcsoftc *);
+static void hdc_readregs(struct hdcsoftc *);
+static void hdc_qstart(void *);
+ 
+bdev_decl(rd);
+cdev_decl(rd);
 
 struct cfattach hdc_ca = {
        sizeof(struct hdcsoftc), hdcmatch, hdcattach
 };
 
-int    rdmatch __P((struct device *parent, struct cfdata *cfdata, void *aux));
-void   rdattach __P((struct device *parent, struct device *self, void *aux));
-int    rdprint __P((void *aux, const char *name));
-void   rdstrategy __P((struct buf *bp));
-
 struct cfattach rd_ca = {
        sizeof(struct rdsoftc), rdmatch, rdattach
 };
 
-extern struct cfdriver rd_cd;
-
-struct dkdriver rddkdriver = { rdstrategy };
 
-/*
- * prototypes for (almost) all the internal routines
- */
-int hdc_reset  __P((struct hdcsoftc *sc));
-int hdc_select __P((struct hdcsoftc *sc, int drive));
-int hdc_command __P((struct hdcsoftc *sc, int cmd));
+/* At least 0.7 uS between register accesses */
+static int rd_dmasize, inq = 0;
+static int u;
+#define        WAIT    asm("movl _u,_u;movl _u,_u;movl _u,_u; movl _u,_u")
 
-int hdc_getdata         __P((struct hdcsoftc *hdc, struct rdsoftc *rd, int drive));
-int hdc_getlabel __P((struct hdcsoftc *hdc, struct rdsoftc *rd, int drive));
-
-void rdgetlabel __P((struct rdsoftc *sc));
+#define        HDC_WREG(x)     *(volatile char *)(sc->sc_regs) = (x)
+#define        HDC_RREG        *(volatile char *)(sc->sc_regs)
+#define        HDC_WCMD(x)     *(volatile char *)(sc->sc_regs + 4) = (x)
+#define        HDC_RSTAT       *(volatile char *)(sc->sc_regs + 4)
 
 /*
  * new-config's hdcmatch() is similiar to old-config's hdcprobe(), 
@@ -218,104 +212,99 @@
  *     is not yet allocated. Thus we do this in hdcattach()...
  */
 int
-hdcmatch(parent, cf, aux)
-       struct device *parent;
-       struct cfdata *cf;
-       void *aux;
+hdcmatch(struct device *parent, struct cfdata *cf, void *aux)
 {
-       struct confargs *ca = aux;
+       struct vsbus_attach_args *va = aux;
+       volatile char *hdc_csr = (char *)va->va_addr;
+       int i;
 
-       trace(("hdcmatch(0x%x, %d, %s)\n", parent, cf->cf_unit, ca->ca_name));
+       u = 8; /* !!! - GCC */
+
+       if (vax_boardtype == VAX_BTYP_49 || vax_boardtype == VAX_BTYP_46
+           || vax_boardtype == VAX_BTYP_48)
+               return 0;
 
-       if (strcmp(ca->ca_name, "hdc") &&
-           strcmp(ca->ca_name, "hdc9224") &&



Home | Main Index | Thread Index | Old Index