aic7xxxvar.h revision 1.1 1 1.1 mycroft /*
2 1.1 mycroft * Interface to the generic driver for the aic7xxx based adaptec
3 1.1 mycroft * SCSI controllers. This is used to implement product specific
4 1.1 mycroft * probe and attach routines.
5 1.1 mycroft *
6 1.1 mycroft * Copyright (c) 1994, 1995 Justin T. Gibbs.
7 1.1 mycroft * All rights reserved.
8 1.1 mycroft *
9 1.1 mycroft * Redistribution and use in source and binary forms, with or without
10 1.1 mycroft * modification, are permitted provided that the following conditions
11 1.1 mycroft * are met:
12 1.1 mycroft * 1. Redistributions of source code must retain the above copyright
13 1.1 mycroft * notice immediately at the beginning of the file, without modification,
14 1.1 mycroft * this list of conditions, and the following disclaimer.
15 1.1 mycroft * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 mycroft * notice, this list of conditions and the following disclaimer in the
17 1.1 mycroft * documentation and/or other materials provided with the distribution.
18 1.1 mycroft * 3. Absolutely no warranty of function or purpose is made by the author
19 1.1 mycroft * Justin T. Gibbs.
20 1.1 mycroft * 4. Modifications may be freely made to this file if the above conditions
21 1.1 mycroft * are met.
22 1.1 mycroft *
23 1.1 mycroft * $Id: aic7xxxvar.h,v 1.1 1995/10/09 09:49:31 mycroft Exp $
24 1.1 mycroft */
25 1.1 mycroft
26 1.1 mycroft #ifndef _AIC7XXX_H_
27 1.1 mycroft #define _AIC7XXX_H_
28 1.1 mycroft
29 1.1 mycroft /*#include "ahc.h" /* for NAHC from config */
30 1.1 mycroft
31 1.1 mycroft #define AHC_NSEG 256 /* number of dma segments supported */
32 1.1 mycroft
33 1.1 mycroft #define AHC_SCB_MAX 16 /*
34 1.1 mycroft * Up to 16 SCBs on some types of aic7xxx based
35 1.1 mycroft * boards. The aic7770 family only have 4
36 1.1 mycroft */
37 1.1 mycroft
38 1.1 mycroft /* #define AHCDEBUG */
39 1.1 mycroft
40 1.1 mycroft typedef u_long physaddr;
41 1.1 mycroft typedef u_long physlen;
42 1.1 mycroft
43 1.1 mycroft struct ahc_dma_seg {
44 1.1 mycroft physaddr seg_addr;
45 1.1 mycroft physlen seg_len;
46 1.1 mycroft };
47 1.1 mycroft
48 1.1 mycroft typedef u_char ahc_type;
49 1.1 mycroft #define AHC_NONE 0x00
50 1.1 mycroft #define AHC_WIDE 0x02 /* Wide Channel */
51 1.1 mycroft #define AHC_TWIN 0x08 /* Twin Channel */
52 1.1 mycroft #define AHC_274 0x10 /* EISA Based Controller */
53 1.1 mycroft #define AHC_284 0x20 /* VL/ISA Based Controller */
54 1.1 mycroft #define AHC_AIC7870 0x40 /* PCI Based Controller */
55 1.1 mycroft #define AHC_294 0xc0 /* PCI Based Controller */
56 1.1 mycroft
57 1.1 mycroft /*
58 1.1 mycroft * The driver keeps up to MAX_SCB scb structures per card in memory. Only the
59 1.1 mycroft * first 26 bytes of the structure are valid for the hardware, the rest used
60 1.1 mycroft * for driver level bookeeping. The "__attribute ((packed))" tags ensure that
61 1.1 mycroft * gcc does not attempt to pad the long ints in the structure to word
62 1.1 mycroft * boundaries since the first 26 bytes of this structure must have the correct
63 1.1 mycroft * offsets for the hardware to find them. The driver is further optimized
64 1.1 mycroft * so that we only have to download the first 19 bytes since as long
65 1.1 mycroft * as we always use S/G, the last fields should be zero anyway.
66 1.1 mycroft */
67 1.1 mycroft #if __GNUC__ >= 2
68 1.1 mycroft #if __GNUC_MINOR__ <5
69 1.1 mycroft #pragma pack(1)
70 1.1 mycroft #endif
71 1.1 mycroft #endif
72 1.1 mycroft
73 1.1 mycroft struct ahc_scb {
74 1.1 mycroft /* ------------ Begin hardware supported fields ---------------- */
75 1.1 mycroft /*1*/ u_char control;
76 1.1 mycroft #define SCB_NEEDWDTR 0x80 /* Initiate Wide Negotiation */
77 1.1 mycroft #define SCB_NEEDSDTR 0x40 /* Initiate Sync Negotiation */
78 1.1 mycroft #define SCB_TE 0x20 /* Tag enable */
79 1.1 mycroft #define SCB_NEEDDMA 0x08 /* Refresh SCB from host ram */
80 1.1 mycroft #define SCB_DIS 0x04
81 1.1 mycroft #define SCB_TAG_TYPE 0x3
82 1.1 mycroft #define SIMPLE_QUEUE 0x0
83 1.1 mycroft #define HEAD_QUEUE 0x1
84 1.1 mycroft #define OR_QUEUE 0x2
85 1.1 mycroft /*2*/ u_char target_channel_lun; /* 4/1/3 bits */
86 1.1 mycroft /*3*/ u_char SG_segment_count;
87 1.1 mycroft /*7*/ physaddr SG_list_pointer __attribute__ ((packed));
88 1.1 mycroft /*11*/ physaddr cmdpointer __attribute__ ((packed));
89 1.1 mycroft /*12*/ u_char cmdlen;
90 1.1 mycroft /*14*/ u_char RESERVED[2]; /* must be zero */
91 1.1 mycroft /*15*/ u_char target_status;
92 1.1 mycroft /*18*/ u_char residual_data_count[3];
93 1.1 mycroft /*19*/ u_char residual_SG_segment_count;
94 1.1 mycroft #define SCB_DOWN_SIZE 19 /* amount to actually download */
95 1.1 mycroft #define SCB_BZERO_SIZE 19 /*
96 1.1 mycroft * amount we need to clear between
97 1.1 mycroft * commands
98 1.1 mycroft */
99 1.1 mycroft /*23*/ physaddr data __attribute__ ((packed));
100 1.1 mycroft /*26*/ u_char datalen[3];
101 1.1 mycroft #define SCB_UP_SIZE 26 /*
102 1.1 mycroft * amount we need to upload to perform
103 1.1 mycroft * a request sense.
104 1.1 mycroft */
105 1.1 mycroft /*30*/ physaddr host_scb __attribute__ ((packed));
106 1.1 mycroft /*31*/ u_char next_waiting; /* Used to thread SCBs awaiting
107 1.1 mycroft * selection
108 1.1 mycroft */
109 1.1 mycroft #define SCB_LIST_NULL 0x10 /* SCB list equivelent to NULL */
110 1.1 mycroft #if 0
111 1.1 mycroft /*
112 1.1 mycroft * No real point in transferring this to the
113 1.1 mycroft * SCB registers.
114 1.1 mycroft */
115 1.1 mycroft unsigned char RESERVED[1];
116 1.1 mycroft #endif
117 1.1 mycroft /*-----------------end of hardware supported fields----------------*/
118 1.1 mycroft TAILQ_ENTRY(ahc_scb) chain;
119 1.1 mycroft struct scsi_xfer *xs; /* the scsi_xfer for this cmd */
120 1.1 mycroft int flags;
121 1.1 mycroft #define SCB_FREE 0
122 1.1 mycroft #define SCB_ACTIVE 1
123 1.1 mycroft #define SCB_ABORTED 2
124 1.1 mycroft #define SCB_CHKSENSE 3
125 1.1 mycroft #define SCB_IMMED 4
126 1.1 mycroft #define SCB_IMMED_FAIL 8
127 1.1 mycroft int position; /* Position in scbarray */
128 1.1 mycroft struct ahc_dma_seg ahc_dma[AHC_NSEG] __attribute__ ((packed));
129 1.1 mycroft struct scsi_sense sense_cmd; /* SCSI command block */
130 1.1 mycroft };
131 1.1 mycroft
132 1.1 mycroft #if __GNUC__ >= 2
133 1.1 mycroft #if __GNUC_MINOR__ <5
134 1.1 mycroft #pragma pack(4)
135 1.1 mycroft #endif
136 1.1 mycroft #endif
137 1.1 mycroft
138 1.1 mycroft struct ahc_softc {
139 1.1 mycroft struct device sc_dev;
140 1.1 mycroft void *sc_ih;
141 1.1 mycroft
142 1.1 mycroft int sc_iobase;
143 1.1 mycroft int sc_irq;
144 1.1 mycroft
145 1.1 mycroft ahc_type type;
146 1.1 mycroft
147 1.1 mycroft struct ahc_scb *scbarray[AHC_SCB_MAX]; /* Mirror boards scbarray */
148 1.1 mycroft TAILQ_HEAD(, ahc_scb) free_scb;
149 1.1 mycroft int ahc_scsi_dev; /* our scsi id */
150 1.1 mycroft int ahc_scsi_dev_b; /* B channel scsi id */
151 1.1 mycroft struct ahc_scb *immed_ecb; /* an outstanding immediete command */
152 1.1 mycroft struct scsi_link sc_link;
153 1.1 mycroft struct scsi_link sc_link_b; /* Second bus for Twin channel cards */
154 1.1 mycroft u_short needsdtr_orig; /* Targets we initiate sync neg with */
155 1.1 mycroft u_short needwdtr_orig; /* Targets we initiate wide neg with */
156 1.1 mycroft u_short needsdtr; /* Current list of negotiated targets */
157 1.1 mycroft u_short needwdtr; /* Current list of negotiated targets */
158 1.1 mycroft u_short sdtrpending; /* Pending SDTR to these targets */
159 1.1 mycroft u_short wdtrpending; /* Pending WDTR to these targets */
160 1.1 mycroft u_short tagenable; /* Targets that can handle tagqueing */
161 1.1 mycroft int numscbs;
162 1.1 mycroft int activescbs;
163 1.1 mycroft u_char maxscbs;
164 1.1 mycroft u_char unpause;
165 1.1 mycroft u_char pause;
166 1.1 mycroft };
167 1.1 mycroft
168 1.1 mycroft #endif /* _AIC7XXX_H_ */
169