home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / tls / tls024.Z / tls024 / sdce376 / new / usr / include / sys / sdce.h
Encoding:
C/C++ Source or Header  |  1992-08-11  |  13.8 KB  |  344 lines

  1. #pragma comment(exestr, "@(#) sdce.h  92/05/13 ")
  2. /*
  3.  *      Header file sdce.h for sdce.c, a "MYLEX DCE376 SCSI Host Driver" 
  4.  *
  5.  *      Copyright (C) 1988-1992 The Santa Cruz Operation, Inc.
  6.  *              All Rights Reserved.
  7.  *      The information in this file is provided for the exclusive use of
  8.  *      the licensees of The Santa Cruz Operation, Inc.  Such users have the
  9.  *      right to use, modify, and incorporate this code into other products
  10.  *      for purposes authorized by the license agreement provided they include
  11.  *      this notice and the associated copyright notice with any such product.
  12.  *      The information in this file is provided "AS IS" without warranty.
  13.  *
  14.  */
  15. /*
  16.  *
  17.  *    DCE376 Caching SCSI host adapter command set
  18.  *    NOTE: Not all commands are implemented. 
  19.  *        NA    Not available
  20.  *        STD    Standard use in driver.
  21.  *        IOCTL   Accessable via ioctl() call.
  22.  *        RT      Accessable via ioctl() call but only to root.
  23.  *
  24.  */
  25. #define ENHANCE_RD_1    0x02 /* enhanced read mode 1        NA    */
  26. #define ENHANCE_WRT_1    0x03 /* enhanced write mode 1       NA    */
  27. #define CACHE_STATS    0x04 /* return cache statistics            IOCTL    */
  28. #define FORMAT_DRIVE    0x05 /* low level format, default disk params RT*/
  29. #define CACHE_FLUSH    0x06 /* flush cache contents to disk    IOCTL    */
  30. #define SET_CTRL_PARM    0x07 /* set controller parameters       RT      */
  31. #define LD_AND_EXECUTE    0x08 /* load and execute user firmware    NA      */
  32. #define DRIVE_PARAM     0x09 /* get disk drive geometry paramters  IOCTL*/
  33. #define DRIVE_DIAG      0x0A /* do disk drive diagnostics    RT      */
  34. #define RECAL_DRIVE    0x0B /* recalibrate drive            RT    */
  35. #define FRMWR_VERSION   0x0C /* get the firmware version    IOCTL    */
  36. #define SCSI_HST_CMD    0x0D /* execute scsi host command    STD    */
  37. #define IRQ_SET        0x0E /* set scsi mode, select irq  10 or 15 STD    */
  38. #define ENHANCE_RD_2    0x11 /* enhanced read mode 2         STD    */
  39. #define ENHANCE_WRT_2    0x12 /* enhanced write mode 2         STD    */
  40. #define XFER_MEMORY    0x13 /* transfer memory                 NA    */
  41. #define DO_CLUSTER_IO    0x17 /* clustered io    NA on older versions STD*/
  42.  
  43. #ifdef INKERNEL
  44. #define SCSI_NO_INFO    0xff
  45. #define START_STOP_CMD  0x1b /*  sent by Sdsk after inquiry command      */
  46.                  /*  New IO Req type define                  */
  47. #define DCE_HOST_CMD    0x81 /*  Host adapter specific commands         */
  48.                  /*  flush cache, cache stats, & set         */
  49.                  /*  controller parameters ...         */
  50. /*    
  51.  *    Multiply the slot number of the card by hex 1000 and add 0x0C80
  52.  *    to get the correct signature address.  Slot 1 would be 0x1C80.
  53.  */
  54. #define ADR_SIGNATURE    0x0C80      /*    IO addrress of signature      */
  55. #define DCE_SIGNATURE0    0x21009835  /*    Old Card  command 0x17 NA     */
  56. #define DCE_SIGNATURE1    0x22009835  /*      New Card             */
  57.  
  58. extern REQ_IO  *sdcereq_io_array[]; /*  defined in space.c        */
  59. REQ_IO  *sdce_lnk_reqs[32];         /*  holds all active io reqs used   */
  60.                     /*  when issuing linked commands via*/
  61.                     /*  mode 17. Firmware handles 32    */
  62.  
  63. struct  scsi_ha_cfg  sdcecfg[1];     /* local define                 */
  64. struct  scsi_dev_cfg Sdskcfg[1];     /* local define                 */
  65. struct  scsi_dev_cfg Sromcfg[1];     /* local define                 */
  66. struct  scsi_dev_cfg Stpcfg[1];      /* local define                 */
  67. int    tape_id[7];             /* Find the ID for the  tapes      */
  68. int    sdce_init_ok;             /* did we find the card            */
  69. int      sdce_brk_inprogress    = 0; /* used by the prep_host_scsi()    */
  70. int      sdce_brk_done            = 0; /* used by the prep_host_scsi()    */
  71.                                      /* flag to tell the intr routine to*/
  72.                      /*pass back the correct req_io after*/
  73.                      /* a large request has been chopped*/
  74.                      /* up                    */
  75. int  return_sense        = 0; /* firmware exists to return sense */
  76.                      /* data  initialized in sdceinit   */
  77. int  expect_IRQ14        = 0; /* There is no register to query if*/
  78.                      /* the card caused    irq.         */
  79. int  sdce_links;              /* Number of linked commands sent  */
  80.                      /* sent to card.            */
  81. int sdce_linked_cmd;             /* Flag for the intr function. This*/
  82.                      /* allows to tell if we expect link*/
  83.                      /* type irq's.                     */
  84. unsigned long linked_mask;         /* bit mask for number of linked   */
  85.                      /* passed to the card. 4 = 1111    */
  86. REQ_IO     *sdce_tape_temp_ptr    = (REQ_IO *)0;/* allows for error to be */
  87.                           /*  passed back for tapes */
  88.  
  89. static  struct Shareg regit;     /* Used for the Sharegister()  call     */
  90. static  HAINFO sdce_info;     /* Used to store adapter capabilities  */
  91. #endif
  92.  
  93. /*
  94.  *    Data structure to store host adapter info for user ioctls
  95.  */
  96. static union sdce_usr_data{
  97.     long    cstat[3];    /*  Cache statistics                       */
  98.     char    target;         /* Target ID                   */
  99.     char    dtype;         /* Target Drive type  0 = disk 5 = CDROM       */
  100.     char    fwv[9];      /* Used to store host firmware version        */
  101.     struct  ctrl_pmtrs { /* used to set controller parameters          */
  102.         char dmy[3]; /* not used                     */
  103.         char parameter;/* buffer size 0=4K, 1=8K  in *bit 1*       */
  104.         char flag;   /* parms to change.2=buf,4=wrt_thres,8=inact  */
  105.         char dmy2;   /* not used                    */
  106.         char wrt_threshold; /* number of updated buffers allowed   */
  107.         char inactivity;    /* idle time before flushing to disk   */
  108.         char dmy3[8]; /* not used                    */
  109.     } cp;
  110.     struct  dstat {   /*  Disk drive parameters*/
  111.         short    id;
  112.         short    hds;
  113.         short    cyl;
  114.         short    spt;
  115.         short    bps;
  116.         short    reserved[3];
  117.     } hd[7];
  118.     struct rstat {   /*  CD rom drive parameters */
  119.         short    id;
  120.         long    cap;
  121.         short    reserved[5];
  122.     } cd[7];
  123. } sdce_data;
  124.  
  125. #ifdef INKERNEL
  126. static int req_ready = 0; /*  used by intr routine to see if there are   */
  127.                           /*  any outstanding requests that need service */
  128. static int sdce_card[2] = {0,0};/* counter for root ioctl restrictions     */
  129.  
  130.  
  131. #define  MAX_REQ_QUEUE      35
  132. #define  REQ_ARRAY_SIZE   MAX_REQ_QUEUE+1
  133. static   REQ_IO  *req_io_array[REQ_ARRAY_SIZE];
  134. static   REQ_IO  *req_pending; /* request in progress            */
  135. unsigned long  mask_array[32] = { 
  136.             0x01, 0x03, 0x07, 0x0f, 
  137.             0x1f, 0x3f, 0x7f, 0xff, 
  138.                     0x01ff, 0x03ff, 0x07ff, 0x0fff, 
  139.             0x1fff, 0x3fff, 0x7fff, 0xffff,
  140.             0x01ffff, 0x03ffff, 0x07ffff, 0x0fffff, 
  141.             0x1fffff, 0x3fffff, 0x7fffff, 0xffffff,
  142.             0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff, 
  143.             0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff 
  144. };
  145.                                   
  146. /*
  147.  *    The dce_sys_internal req structure is for the use of the
  148.  *    driver itself to pass requests as if they came from one of the
  149.  *    peripherals.   This one is used for the sdcecache_flush .
  150.  */
  151. static   REQ_IO  dce_sys_internal;    /* io req for driver request       */
  152. static   REQ_IO  *dce_sys_ptr = (REQ_IO *)0;    /*two values (REQ_IO *)0 */
  153.                         /*or dce_sys_internal*/
  154. /*
  155.  * sdcedata_invalid command.
  156.  */
  157. static   REQ_IO  dce_fid_internal;    /* io req for driver request       */
  158. static   REQ_IO  *dce_fid_ptr = (REQ_IO *)0;    /*two values (REQ_IO *)0 */
  159.                         /*or dce_sys_internal*/
  160. /*
  161.  *    The dce_ioctl_internal req structure is for the use of the
  162.  *    driver itself to pass requests as if they came from the
  163.  *    one of the peripherals.   This one is used for the user
  164.  *    ioctl functions.
  165.  */
  166. static   REQ_IO  dce_ioctl_internal;   /* io req for ioctl/usr request    */
  167. static   REQ_IO  *dce_ioctl_ptr = (REQ_IO *)0;  /*two values (REQ_IO *)0  */
  168.                         /*or dce_ioctl_internal*/
  169.  
  170. int      do_mode_17    = 0;/* capable of doing command mode 17            */
  171. static   int sdce_index = 0;/* number of req_io request queued in driver*/
  172. static   char sdce_cmds[0x20]; /* An array of wait channel addresses    */
  173.                        /* a unique address for every command.   */
  174. static (*sdce_rd_wrt[7])();    /* Array of function pointers to either  */
  175.                    /* the enhanced rw or host cmd. setup in */
  176.                    /* the init function.                */
  177. static (*sdce_host_func)();    /* A function pointer to that is set in  */
  178.                    /* the init function that will point to  */
  179.                    /* the do_host_scsi() or the wd_host_scsi*/
  180.                    /* function.  Based on firmware rev.     */
  181. static (*sdce_proc_req_ptr)(); /* A function pointer that points to the */
  182.                    /* process_req() function. The first time*/
  183.                    /* thru this pointer points to a function*/
  184.                    /* that will check the return_sense flag.*/
  185.                    /* If it is set then steal IRQ 14 and    */
  186.                    /* change the pointer back to process_req*/
  187.  
  188. /* extern struct scsi_dev_cfg Sdskcfg[];
  189. extern struct scsi_dev_cfg Sromcfg[]; */
  190. /*
  191.  *    DCE376 Caching SCSI host adapter command set structure defines
  192.  */
  193. #pragma pack(1)
  194. /*
  195.  *    The structure below is used for linked commands.  The card can
  196.  *    handle up to 32 linked commands.  This would be 2 scatter requests
  197.  *    which would be great for async i/o.  A scatter request can be from
  198.  *    2 to 16 1k requests.  Async i/o is not restricted to 1K.
  199.  *    If scatter gather is turned off in the kernel,  the this feature
  200.  *    can be used to queue up cluster buf requests.  A cluster buf is
  201.  *    a contigous 2 to 16K buffer.  It would then be possible to put
  202.  *    a 512K request on the card.  Since this card supports disconnect
  203.  *    reconnect, this may be a big win if you have multiple drives
  204.  *    attached to the card.
  205.  */
  206. struct  link_cmd_struct   { /*  Structure required for mode 17 commands */
  207.     unsigned char    id; /*  Target  ID                */
  208.     unsigned char    rw; /*  Read or Write. 0 = RD  1 = Wrt      */
  209.     unsigned short  len;/*  Length of request in sectors        */
  210.     long         offset;/*  Offset into media to begin request    */
  211.     long        hst_adr;/*  Host physical memory address        */
  212.     long        pad;/*  paddding, not used            */
  213. } sdce_link[32];            /*  Card can handle up to 32 linked commands*/
  214.  
  215. /*
  216.  *    Structure of command used for making request sense data available
  217.  *    to the SCSI Tape driver (Stp) and the CD ROM driver (Srom).
  218.  *    If request sense data is not made available to the tape driver
  219.  *    you will be able to to a tape backup and restore, and even store
  220.  *    and retrieve multiple volumes from the same tape.  However, the
  221.  *    tape install with a btld will fail with a "tar directory check
  222.  *    sum error". The reason is that when the tape reaches tape mark
  223.  *    it will move the tape to the beginning of the next archive if it
  224.  *    gets the correct sense data back.  If it does not, it leaves the
  225.  *    tape there.  This is not a bug in the Stp driver.  It is a design
  226.  *    feature that prevents the tape fromm doing a rewind for large
  227.  *    product installations.  It saves the user time for installs for
  228.  *    SCO Open Desktop.
  229.  */
  230. struct wd_host_struct {
  231.     unsigned char    drive_id;  /* byte 0                    */
  232.     unsigned char    cdb_sz;    /* byte 1                    */
  233.     unsigned char    cdb_[12];  /* byte 2 - 13               */
  234.     paddr_t        data_ptr;  /* byte 14 - 17              */
  235.     unsigned char    op_code;   /* 0 No, 1 Wrt, or 2 Rd  byte 18     */
  236.     unsigned short    xfer_cnt;  /* in bytes up to 32K  byte  19 - 20 */
  237.     unsigned char   dummy;     /* not used   byte 21          */
  238.     unsigned char    sense_len; /* byte 22                   */
  239.     paddr_t        sense_ptr; /* byte 23 - 26              */
  240. } host_info;
  241. /*
  242.  *    The structure below shows how the mail box register on the
  243.  *    DCE are used for the different commands.
  244.  */
  245. struct  dce_mbx_registers {
  246.     unsigned char cmd_code;  /*  Command code            */
  247.     unsigned char reserved;
  248.     unsigned char drive_num; /*  Either Drive number or Status     */
  249.     union cmd_specific {
  250.         struct enhanced_rw_1 {  /* Enhanced Read or Write 1 NA     */
  251.             unsigned char head;
  252.             unsigned short cylinder;
  253.             unsigned char sector;
  254.             unsigned char sector_count;
  255.             paddr_t          host_addr;
  256.             long          not_used;
  257.         } erw1;
  258.         struct cache_statistics { /*  user ioctl        */
  259.             unsigned char error;
  260.             long          not_used1;
  261.             paddr_t          host_addr;
  262.             long          not_used2;
  263.         } c_stat;
  264.         struct set_controller_parameters {/* root user ioctl    */
  265.             unsigned char param_bits;
  266.             unsigned char flag_bits;
  267.             unsigned char reserved1;
  268.             unsigned char write_threshold;
  269.             unsigned char inactivity_period;
  270.             double        reserved2;
  271.             } scp;
  272.         struct pass_drive_parameters {/* user ioctl        */
  273.             unsigned char drive_type;
  274.             long          not_used1;
  275.             paddr_t          host_addr;
  276.             long          not_used2;
  277.         } pdp;
  278.         struct pass_version_number {/*    user ioctl        */
  279.             unsigned char error;
  280.             long          not_used1;
  281.             paddr_t          host_addr;
  282.             long          not_used2;
  283.         } pvn;
  284.         struct host_scsi_cmd { /* Execute host SCSI command */
  285.             unsigned char cdb_len;
  286.             paddr_t       cdb_addr;
  287.             paddr_t          host_addr;
  288.             unsigned char data_direction;
  289.             unsigned char reserved;
  290.             unsigned short transfer_count;
  291.         } hsc;
  292.         struct change_EOC_IRQ_request {/* switch modes/choose irq*/
  293.             unsigned char interrupt;/* 10 = 1, 15 = 0   */
  294.             double not_used1;
  295.             long   not_used2;
  296.         } eoc;
  297.         struct invalidate_drive_data {/* flush cache per ID    */
  298.             unsigned char error;  /* user ioctl        */
  299.             double not_used1;
  300.             long   not_used2; /*  not used  S001        */
  301.         } idd;
  302.         struct enhanced_rw_2 { /* Enhanced Read or Write 2 */
  303.             unsigned char error;
  304.             unsigned short sector_count;
  305.             unsigned short reserved;
  306.             paddr_t      host_addr;
  307.             unsigned long logical_block_number;
  308.         } erw2;
  309.         struct transfer_memory {
  310.             unsigned char error;
  311.             paddr_t          controller_addr;
  312.             paddr_t          host_addr;
  313.             unsigned char transfer_direction;
  314.             unsigned char not_used;
  315.             unsigned short transfer_count;
  316.         } tm;
  317.         struct cluster_cmd  { /* Used for both S/G and Cluster IO    */
  318.             char          pad1;
  319.             char          l_cnt;    /* Number of linked commands */
  320.             char          pad2[3];
  321.             unsigned long link_addr;/* p_addr to link struct     */
  322.             long          pad3;
  323.         }md17;
  324.         };
  325. } dce_mbx;
  326. #pragma pack()
  327.  
  328.  
  329. /* 
  330.  *     This  function is passed two arguments,  a starting I/O base 
  331.  *     address and  the address of a buffer containing data.  It writes 
  332.  *    the 16 bytes of data in the buffer with an incremental I/O address.  
  333.  *    For example to call the function with the arguments 
  334.  *    out16b( 0, ptr) would be the same as doing  four outd() functions.
  335.  *        outd( 0, ptr   )
  336.  *        outd( 4, ptr+4 )
  337.  *        outd( 8, ptr+8 )
  338.  *        outd(12, ptr+12)
  339.  */
  340. extern out16b();
  341. #endif
  342.  
  343.  
  344.