home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / src / cmd / standalone / newrk.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-28  |  2.5 KB  |  96 lines

  1. /*
  2.  * Copyright (c) 1986 Regents of the University of California.
  3.  * All rights reserved.  The Berkeley software License Agreement
  4.  * specifies the terms and conditions for redistribution.
  5.  *
  6.  *    @(#)rk.c    2.1 (2.11BSD) 1995/06/08
  7.  */
  8.  
  9. /*
  10.  * RK disk driver
  11.  */
  12.  
  13. #include <sys/param.h>
  14. #include <sys/inode.h>
  15. #include "saio.h"
  16.  
  17. /* bits in rkcs */
  18. #define RKCS_ERR        0100000         /* error */
  19. #define RKCS_HE         0040000         /* hard error */
  20. #define RKCS_SCP        0020000         /* search complete */
  21. /* bit 12 is unused */
  22. #define RKCS_INHBA      0004000         /* inhibit bus address increment */
  23. #define RKCS_FMT        0002000         /* format */
  24. /* bit 9 is unused */
  25. #define RKCS_SSE        0000400         /* stop on soft error */
  26. #define RKCS_RDY        0000200         /* control ready */
  27. #define RKCS_IDE        0000100         /* interrupt on done enable */
  28. /* bits 5-4 are the UNIBUS extension bits */
  29. /* bits 3-1 is the command */
  30. #define RKCS_GO         0000001         /* go */
  31. #define RKCS_BITS       \
  32. "\10\20ERR\17HE\16SCP\15INHBA\14FMT\13SSE\12RDY\11IDE\1GO"
  33.  
  34. /* commands */
  35. #define RKCS_RESET      0000000         /* control reset */
  36. #define RKCS_WCOM       0000002         /* write */
  37. #define RKCS_RCOM       0000004         /* read */
  38. #define RKCS_WCHK       0000006         /* write check */
  39. #define RKCS_SEEK       0000010         /* seek */
  40. #define RKCS_RCHK       0000012         /* read check */
  41. #define RKCS_DRESET     0000014         /* drive reset */
  42. #define RKCS_WLCK       0000016         /* write lock */
  43.  
  44.  
  45. struct  rkdevice
  46. {
  47.         short   rkds;
  48.         short   rker;
  49.         short   rkcs;
  50.         short   rkwc;
  51.         caddr_t rkba;
  52.         short   rkda;
  53. };
  54.  
  55.  
  56. #define    NRK    2
  57.  
  58.     struct    rkdevice *RKcsr[NRK + 1] =
  59.         {
  60.         (struct rkdevice *)0177400,
  61.         (struct    rkdevice *)0,
  62.         (struct rkdevice *)-1
  63.         };
  64.  
  65. rkstrategy(io, func)
  66.     register struct iob *io;
  67. {
  68.     register com;
  69.     register struct rkdevice *rkaddr;
  70.     daddr_t bn;
  71.     int dn, cn, sn, bae, lo16;
  72.  
  73.     bn = io->i_bn;
  74.     dn = io->i_unit;
  75.     cn = bn/12;
  76.     sn = bn%12;
  77.     rkaddr = RKcsr[io->i_ctlr];
  78.     rkaddr->rkda = (dn<<13) | (cn<<4) | sn;
  79.     rkaddr->rkba = (caddr_t)lo16;
  80.     rkaddr->rkwc = -(io->i_cc>>1);
  81.     com = (bae<<4)|RKCS_GO;
  82.     if (func == READ)
  83.         com |= RKCS_RCOM;
  84.     else
  85.         com |= RKCS_WCOM;
  86.     rkaddr->rkcs = com;
  87.     while ((rkaddr->rkcs & RKCS_RDY) == 0)
  88.         continue;
  89.     if (rkaddr->rkcs<0) {    /* error bit */
  90.         printf("RK%d,%d err cy=%d sc=%d, er=%o, ds=%o\n",
  91.             io->i_ctlr, io->i_unit, cn, sn, rkaddr->rker, rkaddr->rkds);
  92.         return(-1);
  93.     }
  94.     return(io->i_cc);
  95. }
  96.