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

  1. #
  2. /*
  3.  * rp03 disk driver
  4.  */
  5.  
  6. #include <sys/param.h>
  7. #include <sys/inode.h>
  8. #include "saio.h"
  9.  
  10. struct device {
  11.     int    rpds;
  12.     int    rper;
  13.     union {
  14.         int    w;
  15.         char    c;
  16.     } rpcs;
  17.     int    rpwc;
  18.     char    *rpba;
  19.     int    rpca;
  20.     int    rpda;
  21. };
  22.  
  23. #define RPADDR ((struct device *) 0176710)
  24.  
  25. #define    GO    01
  26. #define    DONE    0200
  27. #define    RESET    0
  28. #define    HSEEK    014
  29.  
  30. #define    IENABLE    0100
  31. #define    READY    0200
  32. #define    RCOM    4
  33. #define    WCOM    2
  34.  
  35. #define    SUFU    01000
  36. #define    SUSU    02000
  37. #define    SUSI    04000
  38. #define    HNF    010000
  39.  
  40.  
  41.  
  42. rpstrategy(io, func)
  43. register struct iob *io;
  44. {
  45.     int com,cn,tn,sn;
  46.  
  47.  
  48. /*
  49.     dn = unit>>3;
  50.     bn = bp->b_blkno;
  51.     cn = bn/(20*10) + rp_sizes[unit&07].cyloff;
  52. */
  53.     cn = io->i_bn/(20*10);
  54.     sn = io->i_bn%(20*10);
  55.     tn = sn/10;
  56.     sn = sn%10;
  57.     RPADDR->rpcs.w = (io->i_unit<<8);
  58.     RPADDR->rpda = (tn<<8) | sn;
  59.     RPADDR->rpca = cn;
  60.     RPADDR->rpba = io->i_ma;
  61.     RPADDR->rpwc = -(io->i_cc>>1);
  62.     com = (segflag<<4)|GO;
  63.     if (func == READ)
  64.         com |= RCOM; else
  65.         com |= WCOM;
  66.     
  67.     RPADDR->rpcs.w |= com;
  68.     while ((RPADDR->rpcs.w&DONE)==0)
  69.         ;
  70.     if (RPADDR->rpcs.w < 0) {    /* error bit */
  71.         printf("disk error: cyl=%d track=%d sect=%d er=%o ds=%o\n",
  72.             cn, tn, sn, RPADDR->rper, RPADDR->rpds);
  73.         return(-1);
  74.     }
  75.     return(io->i_cc);
  76. }
  77.