home *** CD-ROM | disk | FTP | other *** search
- #pragma comment(exestr, "@(#) sdce.h 92/05/13 ")
- /*
- * Header file sdce.h for sdce.c, a "MYLEX DCE376 SCSI Host Driver"
- *
- * Copyright (C) 1988-1992 The Santa Cruz Operation, Inc.
- * All Rights Reserved.
- * The information in this file is provided for the exclusive use of
- * the licensees of The Santa Cruz Operation, Inc. Such users have the
- * right to use, modify, and incorporate this code into other products
- * for purposes authorized by the license agreement provided they include
- * this notice and the associated copyright notice with any such product.
- * The information in this file is provided "AS IS" without warranty.
- *
- */
- /*
- *
- * DCE376 Caching SCSI host adapter command set
- * NOTE: Not all commands are implemented.
- * NA Not available
- * STD Standard use in driver.
- * IOCTL Accessable via ioctl() call.
- * RT Accessable via ioctl() call but only to root.
- *
- */
- #define ENHANCE_RD_1 0x02 /* enhanced read mode 1 NA */
- #define ENHANCE_WRT_1 0x03 /* enhanced write mode 1 NA */
- #define CACHE_STATS 0x04 /* return cache statistics IOCTL */
- #define FORMAT_DRIVE 0x05 /* low level format, default disk params RT*/
- #define CACHE_FLUSH 0x06 /* flush cache contents to disk IOCTL */
- #define SET_CTRL_PARM 0x07 /* set controller parameters RT */
- #define LD_AND_EXECUTE 0x08 /* load and execute user firmware NA */
- #define DRIVE_PARAM 0x09 /* get disk drive geometry paramters IOCTL*/
- #define DRIVE_DIAG 0x0A /* do disk drive diagnostics RT */
- #define RECAL_DRIVE 0x0B /* recalibrate drive RT */
- #define FRMWR_VERSION 0x0C /* get the firmware version IOCTL */
- #define SCSI_HST_CMD 0x0D /* execute scsi host command STD */
- #define IRQ_SET 0x0E /* set scsi mode, select irq 10 or 15 STD */
- #define ENHANCE_RD_2 0x11 /* enhanced read mode 2 STD */
- #define ENHANCE_WRT_2 0x12 /* enhanced write mode 2 STD */
- #define XFER_MEMORY 0x13 /* transfer memory NA */
- #define DO_CLUSTER_IO 0x17 /* clustered io NA on older versions STD*/
-
- #ifdef INKERNEL
- #define SCSI_NO_INFO 0xff
- #define START_STOP_CMD 0x1b /* sent by Sdsk after inquiry command */
- /* New IO Req type define */
- #define DCE_HOST_CMD 0x81 /* Host adapter specific commands */
- /* flush cache, cache stats, & set */
- /* controller parameters ... */
- /*
- * Multiply the slot number of the card by hex 1000 and add 0x0C80
- * to get the correct signature address. Slot 1 would be 0x1C80.
- */
- #define ADR_SIGNATURE 0x0C80 /* IO addrress of signature */
- #define DCE_SIGNATURE0 0x21009835 /* Old Card command 0x17 NA */
- #define DCE_SIGNATURE1 0x22009835 /* New Card */
-
- extern REQ_IO *sdcereq_io_array[]; /* defined in space.c */
- REQ_IO *sdce_lnk_reqs[32]; /* holds all active io reqs used */
- /* when issuing linked commands via*/
- /* mode 17. Firmware handles 32 */
-
- struct scsi_ha_cfg sdcecfg[1]; /* local define */
- struct scsi_dev_cfg Sdskcfg[1]; /* local define */
- struct scsi_dev_cfg Sromcfg[1]; /* local define */
- struct scsi_dev_cfg Stpcfg[1]; /* local define */
- int tape_id[7]; /* Find the ID for the tapes */
- int sdce_init_ok; /* did we find the card */
- int sdce_brk_inprogress = 0; /* used by the prep_host_scsi() */
- int sdce_brk_done = 0; /* used by the prep_host_scsi() */
- /* flag to tell the intr routine to*/
- /*pass back the correct req_io after*/
- /* a large request has been chopped*/
- /* up */
- int return_sense = 0; /* firmware exists to return sense */
- /* data initialized in sdceinit */
- int expect_IRQ14 = 0; /* There is no register to query if*/
- /* the card caused irq. */
- int sdce_links; /* Number of linked commands sent */
- /* sent to card. */
- int sdce_linked_cmd; /* Flag for the intr function. This*/
- /* allows to tell if we expect link*/
- /* type irq's. */
- unsigned long linked_mask; /* bit mask for number of linked */
- /* passed to the card. 4 = 1111 */
- REQ_IO *sdce_tape_temp_ptr = (REQ_IO *)0;/* allows for error to be */
- /* passed back for tapes */
-
- static struct Shareg regit; /* Used for the Sharegister() call */
- static HAINFO sdce_info; /* Used to store adapter capabilities */
- #endif
-
- /*
- * Data structure to store host adapter info for user ioctls
- */
- static union sdce_usr_data{
- long cstat[3]; /* Cache statistics */
- char target; /* Target ID */
- char dtype; /* Target Drive type 0 = disk 5 = CDROM */
- char fwv[9]; /* Used to store host firmware version */
- struct ctrl_pmtrs { /* used to set controller parameters */
- char dmy[3]; /* not used */
- char parameter;/* buffer size 0=4K, 1=8K in *bit 1* */
- char flag; /* parms to change.2=buf,4=wrt_thres,8=inact */
- char dmy2; /* not used */
- char wrt_threshold; /* number of updated buffers allowed */
- char inactivity; /* idle time before flushing to disk */
- char dmy3[8]; /* not used */
- } cp;
- struct dstat { /* Disk drive parameters*/
- short id;
- short hds;
- short cyl;
- short spt;
- short bps;
- short reserved[3];
- } hd[7];
- struct rstat { /* CD rom drive parameters */
- short id;
- long cap;
- short reserved[5];
- } cd[7];
- } sdce_data;
-
- #ifdef INKERNEL
- static int req_ready = 0; /* used by intr routine to see if there are */
- /* any outstanding requests that need service */
- static int sdce_card[2] = {0,0};/* counter for root ioctl restrictions */
-
-
- #define MAX_REQ_QUEUE 35
- #define REQ_ARRAY_SIZE MAX_REQ_QUEUE+1
- static REQ_IO *req_io_array[REQ_ARRAY_SIZE];
- static REQ_IO *req_pending; /* request in progress */
- unsigned long mask_array[32] = {
- 0x01, 0x03, 0x07, 0x0f,
- 0x1f, 0x3f, 0x7f, 0xff,
- 0x01ff, 0x03ff, 0x07ff, 0x0fff,
- 0x1fff, 0x3fff, 0x7fff, 0xffff,
- 0x01ffff, 0x03ffff, 0x07ffff, 0x0fffff,
- 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff,
- 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff,
- 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff
- };
-
- /*
- * The dce_sys_internal req structure is for the use of the
- * driver itself to pass requests as if they came from one of the
- * peripherals. This one is used for the sdcecache_flush .
- */
- static REQ_IO dce_sys_internal; /* io req for driver request */
- static REQ_IO *dce_sys_ptr = (REQ_IO *)0; /*two values (REQ_IO *)0 */
- /*or dce_sys_internal*/
- /*
- * sdcedata_invalid command.
- */
- static REQ_IO dce_fid_internal; /* io req for driver request */
- static REQ_IO *dce_fid_ptr = (REQ_IO *)0; /*two values (REQ_IO *)0 */
- /*or dce_sys_internal*/
- /*
- * The dce_ioctl_internal req structure is for the use of the
- * driver itself to pass requests as if they came from the
- * one of the peripherals. This one is used for the user
- * ioctl functions.
- */
- static REQ_IO dce_ioctl_internal; /* io req for ioctl/usr request */
- static REQ_IO *dce_ioctl_ptr = (REQ_IO *)0; /*two values (REQ_IO *)0 */
- /*or dce_ioctl_internal*/
-
- int do_mode_17 = 0;/* capable of doing command mode 17 */
- static int sdce_index = 0;/* number of req_io request queued in driver*/
- static char sdce_cmds[0x20]; /* An array of wait channel addresses */
- /* a unique address for every command. */
- static (*sdce_rd_wrt[7])(); /* Array of function pointers to either */
- /* the enhanced rw or host cmd. setup in */
- /* the init function. */
- static (*sdce_host_func)(); /* A function pointer to that is set in */
- /* the init function that will point to */
- /* the do_host_scsi() or the wd_host_scsi*/
- /* function. Based on firmware rev. */
- static (*sdce_proc_req_ptr)(); /* A function pointer that points to the */
- /* process_req() function. The first time*/
- /* thru this pointer points to a function*/
- /* that will check the return_sense flag.*/
- /* If it is set then steal IRQ 14 and */
- /* change the pointer back to process_req*/
-
- /* extern struct scsi_dev_cfg Sdskcfg[];
- extern struct scsi_dev_cfg Sromcfg[]; */
- /*
- * DCE376 Caching SCSI host adapter command set structure defines
- */
- #pragma pack(1)
- /*
- * The structure below is used for linked commands. The card can
- * handle up to 32 linked commands. This would be 2 scatter requests
- * which would be great for async i/o. A scatter request can be from
- * 2 to 16 1k requests. Async i/o is not restricted to 1K.
- * If scatter gather is turned off in the kernel, the this feature
- * can be used to queue up cluster buf requests. A cluster buf is
- * a contigous 2 to 16K buffer. It would then be possible to put
- * a 512K request on the card. Since this card supports disconnect
- * reconnect, this may be a big win if you have multiple drives
- * attached to the card.
- */
- struct link_cmd_struct { /* Structure required for mode 17 commands */
- unsigned char id; /* Target ID */
- unsigned char rw; /* Read or Write. 0 = RD 1 = Wrt */
- unsigned short len;/* Length of request in sectors */
- long offset;/* Offset into media to begin request */
- long hst_adr;/* Host physical memory address */
- long pad;/* paddding, not used */
- } sdce_link[32]; /* Card can handle up to 32 linked commands*/
-
- /*
- * Structure of command used for making request sense data available
- * to the SCSI Tape driver (Stp) and the CD ROM driver (Srom).
- * If request sense data is not made available to the tape driver
- * you will be able to to a tape backup and restore, and even store
- * and retrieve multiple volumes from the same tape. However, the
- * tape install with a btld will fail with a "tar directory check
- * sum error". The reason is that when the tape reaches tape mark
- * it will move the tape to the beginning of the next archive if it
- * gets the correct sense data back. If it does not, it leaves the
- * tape there. This is not a bug in the Stp driver. It is a design
- * feature that prevents the tape fromm doing a rewind for large
- * product installations. It saves the user time for installs for
- * SCO Open Desktop.
- */
- struct wd_host_struct {
- unsigned char drive_id; /* byte 0 */
- unsigned char cdb_sz; /* byte 1 */
- unsigned char cdb_[12]; /* byte 2 - 13 */
- paddr_t data_ptr; /* byte 14 - 17 */
- unsigned char op_code; /* 0 No, 1 Wrt, or 2 Rd byte 18 */
- unsigned short xfer_cnt; /* in bytes up to 32K byte 19 - 20 */
- unsigned char dummy; /* not used byte 21 */
- unsigned char sense_len; /* byte 22 */
- paddr_t sense_ptr; /* byte 23 - 26 */
- } host_info;
- /*
- * The structure below shows how the mail box register on the
- * DCE are used for the different commands.
- */
- struct dce_mbx_registers {
- unsigned char cmd_code; /* Command code */
- unsigned char reserved;
- unsigned char drive_num; /* Either Drive number or Status */
- union cmd_specific {
- struct enhanced_rw_1 { /* Enhanced Read or Write 1 NA */
- unsigned char head;
- unsigned short cylinder;
- unsigned char sector;
- unsigned char sector_count;
- paddr_t host_addr;
- long not_used;
- } erw1;
- struct cache_statistics { /* user ioctl */
- unsigned char error;
- long not_used1;
- paddr_t host_addr;
- long not_used2;
- } c_stat;
- struct set_controller_parameters {/* root user ioctl */
- unsigned char param_bits;
- unsigned char flag_bits;
- unsigned char reserved1;
- unsigned char write_threshold;
- unsigned char inactivity_period;
- double reserved2;
- } scp;
- struct pass_drive_parameters {/* user ioctl */
- unsigned char drive_type;
- long not_used1;
- paddr_t host_addr;
- long not_used2;
- } pdp;
- struct pass_version_number {/* user ioctl */
- unsigned char error;
- long not_used1;
- paddr_t host_addr;
- long not_used2;
- } pvn;
- struct host_scsi_cmd { /* Execute host SCSI command */
- unsigned char cdb_len;
- paddr_t cdb_addr;
- paddr_t host_addr;
- unsigned char data_direction;
- unsigned char reserved;
- unsigned short transfer_count;
- } hsc;
- struct change_EOC_IRQ_request {/* switch modes/choose irq*/
- unsigned char interrupt;/* 10 = 1, 15 = 0 */
- double not_used1;
- long not_used2;
- } eoc;
- struct invalidate_drive_data {/* flush cache per ID */
- unsigned char error; /* user ioctl */
- double not_used1;
- long not_used2; /* not used S001 */
- } idd;
- struct enhanced_rw_2 { /* Enhanced Read or Write 2 */
- unsigned char error;
- unsigned short sector_count;
- unsigned short reserved;
- paddr_t host_addr;
- unsigned long logical_block_number;
- } erw2;
- struct transfer_memory {
- unsigned char error;
- paddr_t controller_addr;
- paddr_t host_addr;
- unsigned char transfer_direction;
- unsigned char not_used;
- unsigned short transfer_count;
- } tm;
- struct cluster_cmd { /* Used for both S/G and Cluster IO */
- char pad1;
- char l_cnt; /* Number of linked commands */
- char pad2[3];
- unsigned long link_addr;/* p_addr to link struct */
- long pad3;
- }md17;
- };
- } dce_mbx;
- #pragma pack()
-
-
- /*
- * This function is passed two arguments, a starting I/O base
- * address and the address of a buffer containing data. It writes
- * the 16 bytes of data in the buffer with an incremental I/O address.
- * For example to call the function with the arguments
- * out16b( 0, ptr) would be the same as doing four outd() functions.
- * outd( 0, ptr )
- * outd( 4, ptr+4 )
- * outd( 8, ptr+8 )
- * outd(12, ptr+12)
- */
- extern out16b();
- #endif
-
-
-