[BACK]Return to fd.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / acorn32 / mainbus

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/arch/acorn32/mainbus/fd.c between version 1.37 and 1.37.6.3

version 1.37, 2008/01/08 06:29:39 version 1.37.6.3, 2009/01/17 13:27:47
Line 15 
Line 15 
  * 2. Redistributions in binary form must reproduce the above copyright   * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the   *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.   *    documentation and/or other materials provided with the distribution.
  * 3. All advertising materials mentioning features or use of this software  
  *    must display the following acknowledgement:  
  *        This product includes software developed by the NetBSD  
  *        Foundation, Inc. and its contributors.  
  * 4. Neither the name of The NetBSD Foundation nor the names of its  
  *    contributors may be used to endorse or promote products derived  
  *    from this software without specific prior written permission.  
  *   *
  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS   * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
Line 567  fd_dev_to_type(fd, dev)
Line 560  fd_dev_to_type(fd, dev)
 }  }
   
 void  void
 fdstrategy(bp)  fdstrategy(struct buf *bp)
         register struct buf *bp;        /* IO operation to perform */  
 {  {
         struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(bp->b_dev)];          struct fd_softc *fd = device_lookup_private(&fd_cd,FDUNIT(bp->b_dev));
         int sz;          int sz;
         int s;          int s;
   
Line 613  fdstrategy(bp)
Line 605  fdstrategy(bp)
   
         /* Queue transfer on drive, activate drive and controller if idle. */          /* Queue transfer on drive, activate drive and controller if idle. */
         s = splbio();          s = splbio();
         BUFQ_PUT(fd->sc_q, bp);          bufq_put(fd->sc_q, bp);
         callout_stop(&fd->sc_motoroff_ch);              /* a good idea */          callout_stop(&fd->sc_motoroff_ch);              /* a good idea */
         if (fd->sc_active == 0)          if (fd->sc_active == 0)
                 fdstart(fd);                  fdstart(fd);
Line 664  fdfinish(fd, bp)
Line 656  fdfinish(fd, bp)
          * another drive is waiting to be serviced, since there is a long motor           * another drive is waiting to be serviced, since there is a long motor
          * startup delay whenever we switch.           * startup delay whenever we switch.
          */           */
         (void)BUFQ_GET(fd->sc_q);          (void)bufq_get(fd->sc_q);
         if (fd->sc_drivechain.tqe_next && ++fd->sc_ops >= 8) {          if (fd->sc_drivechain.tqe_next && ++fd->sc_ops >= 8) {
                 fd->sc_ops = 0;                  fd->sc_ops = 0;
                 TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);                  TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);
                 if (BUFQ_PEEK(fd->sc_q) != NULL)                  if (bufq_peek(fd->sc_q) != NULL)
                         TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);                          TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
                 else                  else
                         fd->sc_active = 0;                          fd->sc_active = 0;
Line 799  out_fdc(iot, ioh, x)
Line 791  out_fdc(iot, ioh, x)
 }  }
   
 int  int
 fdopen(dev, flags, mode, l)  fdopen(dev_t dev, int flags, int mode, struct lwp *l)
         dev_t dev;  
         int flags;  
         int mode;  
         struct lwp *l;  
 {  {
         int unit;  
         struct fd_softc *fd;          struct fd_softc *fd;
         struct fd_type *type;          struct fd_type *type;
   
         unit = FDUNIT(dev);          fd = device_lookup_private(&fd_cd, FDUNIT(dev));
         if (unit >= fd_cd.cd_ndevs)          if (fd == NULL)
                 return ENXIO;  
         fd = fd_cd.cd_devs[unit];  
         if (fd == 0)  
                 return ENXIO;                  return ENXIO;
         type = fd_dev_to_type(fd, dev);          type = fd_dev_to_type(fd, dev);
         if (type == NULL)          if (type == NULL)
Line 832  fdopen(dev, flags, mode, l)
Line 816  fdopen(dev, flags, mode, l)
 }  }
   
 int  int
 fdclose(dev, flags, mode, l)  fdclose(dev_t dev, int flags, int mode, struct lwp *l)
         dev_t dev;  
         int flags;  
         int mode;  
         struct lwp *l;  
 {  {
         struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)];          struct fd_softc *fd = device_lookup_private(&fd_cd, FDUNIT(dev));
   
         fd->sc_flags &= ~FD_OPEN;          fd->sc_flags &= ~FD_OPEN;
         fd->sc_opts &= ~(FDOPT_NORETRY|FDOPT_SILENT);          fd->sc_opts &= ~(FDOPT_NORETRY|FDOPT_SILENT);
Line 861  fdcstart(fdc)
Line 841  fdcstart(fdc)
         (void) fdcintr(fdc);          (void) fdcintr(fdc);
 }  }
   
 void  static void
 fdcstatus(dv, n, s)  fdcpstatus(int n, struct fdc_softc *fdc)
         struct device *dv;  
         int n;  
         const char *s;  
 {  {
         struct fdc_softc *fdc = (void *) device_parent(dv);  
         char bits[64];          char bits[64];
   
         if (n == 0) {  
                 out_fdc(fdc->sc_iot, fdc->sc_ioh, NE7CMD_SENSEI);  
                 (void) fdcresult(fdc);  
                 n = 2;  
         }  
   
         printf("%s: %s", dv->dv_xname, s);  
   
         switch (n) {          switch (n) {
         case 0:          case 0:
                 printf("\n");                  printf("\n");
                 break;                  break;
         case 2:          case 2:
                 printf(" (st0 %s cyl %d)\n",                  snprintb(bits, sizeof(bits), NE7_ST0BITS, fdc->sc_status[0]);
                     bitmask_snprintf(fdc->sc_status[0], NE7_ST0BITS,                  printf(" (st0 %s cyl %d)\n", bits, fdc->sc_status[1]);
                     bits, sizeof(bits)), fdc->sc_status[1]);  
                 break;                  break;
         case 7:          case 7:
                 printf(" (st0 %s", bitmask_snprintf(fdc->sc_status[0],                  snprintb(bits, sizeof(bits), NE7_ST0BITS, fdc->sc_status[0]);
                     NE7_ST0BITS, bits, sizeof(bits)));                  printf(" (st0 %s", bits);
                 printf(" st1 %s", bitmask_snprintf(fdc->sc_status[1],                  snprintb(bits, sizeof(bits), NE7_ST1BITS, fdc->sc_status[1]);
                     NE7_ST1BITS, bits, sizeof(bits)));                  printf(" st1 %s", bits);
                 printf(" st2 %s", bitmask_snprintf(fdc->sc_status[2],                  snprintb(bits, sizeof(bits), NE7_ST2BITS, fdc->sc_status[2]);
                     NE7_ST2BITS, bits, sizeof(bits)));                  printf(" st2 %s", bits);
                 printf(" cyl %d head %d sec %d)\n",                  printf(" cyl %d head %d sec %d)\n",
                     fdc->sc_status[3], fdc->sc_status[4], fdc->sc_status[5]);                      fdc->sc_status[3], fdc->sc_status[4], fdc->sc_status[5]);
                 break;                  break;
Line 906  fdcstatus(dv, n, s)
Line 873  fdcstatus(dv, n, s)
 }  }
   
 void  void
   fdcstatus(dv, n, s)
           struct device *dv;
           int n;
           const char *s;
   {
           struct fdc_softc *fdc = (void *) device_parent(dv);
   
           if (n == 0) {
                   out_fdc(fdc->sc_iot, fdc->sc_ioh, NE7CMD_SENSEI);
                   (void) fdcresult(fdc);
                   n = 2;
           }
   
           printf("%s: %s", dv->dv_xname, s);
           fdcpstatus(n, fdc);
   }
   
   void
 fdctimeout(arg)  fdctimeout(arg)
         void *arg;          void *arg;
 {  {
Line 919  fdctimeout(arg)
Line 904  fdctimeout(arg)
 #endif  #endif
         fdcstatus(&fd->sc_dev, 0, "timeout");          fdcstatus(&fd->sc_dev, 0, "timeout");
   
         if (BUFQ_PEEK(fd->sc_q) != NULL)          if (bufq_peek(fd->sc_q) != NULL)
                 fdc->sc_state++;                  fdc->sc_state++;
         else          else
                 fdc->sc_state = DEVIDLE;                  fdc->sc_state = DEVIDLE;
Line 964  loop:
Line 949  loop:
         }          }
   
         /* Is there a transfer to this drive?  If not, deactivate drive. */          /* Is there a transfer to this drive?  If not, deactivate drive. */
         bp = BUFQ_PEEK(fd->sc_q);          bp = bufq_peek(fd->sc_q);
         if (bp == NULL) {          if (bp == NULL) {
                 fd->sc_ops = 0;                  fd->sc_ops = 0;
                 TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);                  TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);
Line 1263  void
Line 1248  void
 fdcretry(fdc)  fdcretry(fdc)
         struct fdc_softc *fdc;          struct fdc_softc *fdc;
 {  {
         char bits[64];  
         struct fd_softc *fd;          struct fd_softc *fd;
         struct buf *bp;          struct buf *bp;
   
         fd = fdc->sc_drives.tqh_first;          fd = fdc->sc_drives.tqh_first;
         bp = BUFQ_PEEK(fd->sc_q);          bp = bufq_peek(fd->sc_q);
   
         if (fd->sc_opts & FDOPT_NORETRY)          if (fd->sc_opts & FDOPT_NORETRY)
             goto fail;              goto fail;
Line 1294  fdcretry(fdc)
Line 1278  fdcretry(fdc)
                         diskerr(bp, "fd", "hard error", LOG_PRINTF,                          diskerr(bp, "fd", "hard error", LOG_PRINTF,
                                 fd->sc_skip / FDC_BSIZE,                                  fd->sc_skip / FDC_BSIZE,
                                 (struct disklabel *)NULL);                                  (struct disklabel *)NULL);
                           fdcpstatus(7, fdc);
                         printf(" (st0 %s",  
                                bitmask_snprintf(fdc->sc_status[0],  
                                                 NE7_ST0BITS, bits,  
                                                 sizeof(bits)));  
                         printf(" st1 %s",  
                                bitmask_snprintf(fdc->sc_status[1],  
                                                 NE7_ST1BITS, bits,  
                                                 sizeof(bits)));  
                         printf(" st2 %s",  
                                bitmask_snprintf(fdc->sc_status[2],  
                                                 NE7_ST2BITS, bits,  
                                                 sizeof(bits)));  
                         printf(" cyl %d head %d sec %d)\n",  
                                fdc->sc_status[3],  
                                fdc->sc_status[4],  
                                fdc->sc_status[5]);  
                 }                  }
   
                 bp->b_error = EIO;                  bp->b_error = EIO;
Line 1320  fdcretry(fdc)
Line 1288  fdcretry(fdc)
 }  }
   
 int  int
 fdioctl(dev, cmd, addr, flag, l)  fdioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
         dev_t dev;  
         u_long cmd;  
         void *addr;  
         int flag;  
         struct lwp *l;  
 {  {
         struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)];          struct fd_softc *fd = device_lookup_private(&fd_cd, FDUNIT(dev));
         struct fdformat_parms *form_parms;          struct fdformat_parms *form_parms;
         struct fdformat_cmd *form_cmd;          struct fdformat_cmd *form_cmd;
         struct ne7_fd_formb *fd_formb;          struct ne7_fd_formb *fd_formb;
Line 1502  fdioctl(dev, cmd, addr, flag, l)
Line 1465  fdioctl(dev, cmd, addr, flag, l)
 }  }
   
 int  int
 fdformat(dev, finfo, l)  fdformat(dev_t dev, struct ne7_fd_formb *finfo, struct lwp *l)
         dev_t dev;  
         struct ne7_fd_formb *finfo;  
         struct lwp *l;  
 {  {
         int rv = 0;          int rv = 0;
         struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)];          struct fd_softc *fd = device_lookup_private(&fd_cd,FDUNIT(dev));
         struct fd_type *type = fd->sc_type;          struct fd_type *type = fd->sc_type;
         struct buf *bp;          struct buf *bp;
   

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.37.6.3

CVSweb <webmaster@jp.NetBSD.org>