Deleted Added
full compact
aic7xxx.seq (5562) aic7xxx.seq (5647)
1# @(#)aic7xxx.seq 1.32 94/11/29 jda
2#
1# @(#)aic7xxx.seq 1.32 94/11/29 jda
2#
3# Adaptec 274x/284x/294x device driver for Linux.
3# Adaptec 274x/284x/294x device driver for Linux and FreeBSD.
4# Copyright (c) 1994 The University of Calgary Department of Computer Science.
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4# Copyright (c) 1994 The University of Calgary Department of Computer Science.
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19#
19
20
20VERSION AIC7XXX_SEQ_VERSION 1.32
21# FreeBSD, Twin, Wide, 2 command per target support, and other optimizations
22# provided by Justin T. Gibbs (gibbs@FreeBSD.org)
23#
24# $Id$
21
25
26VERSION AIC7XXX_SEQ_VERSION 1.5
27
22SCBMASK = 0x1f
23
24SCSISEQ = 0x00
25SXFRCTL0 = 0x01
26SXFRCTL1 = 0x02
27SCSISIGI = 0x03
28SCSISIGO = 0x03
29SCSIRATE = 0x04

--- 35 unchanged lines hidden (view full) ---

65QOUTFIFO = 0x9d
66
67SCSICONF_A = 0x5a
68SCSICONF_B = 0x5b
69
70# The two reserved bytes at SCBARRAY+1[23] are expected to be set to
71# zero, and the reserved bit in SCBARRAY+0 is used as an internal flag
72# to indicate whether or not to reload scatter-gather parameters after
28SCBMASK = 0x1f
29
30SCSISEQ = 0x00
31SXFRCTL0 = 0x01
32SXFRCTL1 = 0x02
33SCSISIGI = 0x03
34SCSISIGO = 0x03
35SCSIRATE = 0x04

--- 35 unchanged lines hidden (view full) ---

71QOUTFIFO = 0x9d
72
73SCSICONF_A = 0x5a
74SCSICONF_B = 0x5b
75
76# The two reserved bytes at SCBARRAY+1[23] are expected to be set to
77# zero, and the reserved bit in SCBARRAY+0 is used as an internal flag
78# to indicate whether or not to reload scatter-gather parameters after
73# a disconnect.
79# a disconnect. We also use bits 6 & 7 to indicate whether or not to
80# initiate SDTR or WDTR repectively when starting this command.
74#
75SCBARRAY+0 = 0xa0
81#
82SCBARRAY+0 = 0xa0
83
84DISCONNECTED = 0x04
85NEEDDMA = 0x08
86SG_LOAD = 0x10
87NEEDSDTR = 0x40
88NEEDWDTR = 0x80
89
76SCBARRAY+1 = 0xa1
77SCBARRAY+2 = 0xa2
78SCBARRAY+3 = 0xa3
90SCBARRAY+1 = 0xa1
91SCBARRAY+2 = 0xa2
92SCBARRAY+3 = 0xa3
93SCBARRAY+4 = 0xa4
94SCBARRAY+5 = 0xa5
95SCBARRAY+6 = 0xa6
79SCBARRAY+7 = 0xa7
96SCBARRAY+7 = 0xa7
97SCBARRAY+8 = 0xa8
98SCBARRAY+9 = 0xa9
99SCBARRAY+10 = 0xaa
80SCBARRAY+11 = 0xab
100SCBARRAY+11 = 0xab
101SCBARRAY+12 = 0xac
102SCBARRAY+13 = 0xad
81SCBARRAY+14 = 0xae
82SCBARRAY+15 = 0xaf
83SCBARRAY+16 = 0xb0
84SCBARRAY+17 = 0xb1
85SCBARRAY+18 = 0xb2
86SCBARRAY+19 = 0xb3
87SCBARRAY+20 = 0xb4
88SCBARRAY+21 = 0xb5
89SCBARRAY+22 = 0xb6
90SCBARRAY+23 = 0xb7
91SCBARRAY+24 = 0xb8
92SCBARRAY+25 = 0xb9
103SCBARRAY+14 = 0xae
104SCBARRAY+15 = 0xaf
105SCBARRAY+16 = 0xb0
106SCBARRAY+17 = 0xb1
107SCBARRAY+18 = 0xb2
108SCBARRAY+19 = 0xb3
109SCBARRAY+20 = 0xb4
110SCBARRAY+21 = 0xb5
111SCBARRAY+22 = 0xb6
112SCBARRAY+23 = 0xb7
113SCBARRAY+24 = 0xb8
114SCBARRAY+25 = 0xb9
115SCBARRAY+26 = 0xba
93
116
94SIGNAL_0 = 0x01 # unknown scsi bus phase
95SIGNAL_1 = 0x11 # message reject
96SIGNAL_2 = 0x21 # no IDENTIFY after reconnect
97SIGNAL_3 = 0x31 # no cmd match for reconnect
98SIGNAL_4 = 0x41 # SDTR -> SCSIRATE conversion
99STATUS_ERROR = 0x51
100SIGNAL_WDTR = 0x61
117BAD_PHASE = 0x01 # unknown scsi bus phase
118SEND_REJECT = 0x11 # sending a message reject
119NO_IDENT = 0x21 # no IDENTIFY after reconnect
120NO_MATCH = 0x31 # no cmd match for reconnect
121MSG_SDTR = 0x41 # SDTR message recieved
122MSG_WDTR = 0x51 # WDTR message recieved
123MSG_REJECT = 0x61 # Reject message recieved
124BAD_STATUS = 0x71 # Bad status from target
101
102# The host adapter card (at least the BIOS) uses 20-2f for SCSI
103# device information, 32-33 and 5a-5f as well. As it turns out, the
104# BIOS trashes 20-2f, writing the synchronous negotiation results
105# on top of the BIOS values, so we re-use those for our per-target
106# scratchspace (actually a value that can be copied directly into
107# SCSIRATE). The kernel driver will enable synchronous negotiation
108# for all targets that have a value other than 0 in the lower four
109# bits of the target scratch space. This should work irregardless of
125
126# The host adapter card (at least the BIOS) uses 20-2f for SCSI
127# device information, 32-33 and 5a-5f as well. As it turns out, the
128# BIOS trashes 20-2f, writing the synchronous negotiation results
129# on top of the BIOS values, so we re-use those for our per-target
130# scratchspace (actually a value that can be copied directly into
131# SCSIRATE). The kernel driver will enable synchronous negotiation
132# for all targets that have a value other than 0 in the lower four
133# bits of the target scratch space. This should work irregardless of
110# whether the bios has been installed. NEEDSDTR has one bit per target
111# indicating if an SDTR message is needed for that device - this will
112# be set initially (based on a search through the target scratch space),
113# as well as after a bus reset condition.
134# whether the bios has been installed. NEEDWDTR and NEEDSDTR are the top
135# two bits of the SCB control byte. The kernel driver will set these
136# when a WDTR or SDTR message should be sent to the target the SCB's
137# command references.
114#
115# The high bit of DROPATN is set if ATN should be dropped before the ACK
116# when outb is called. REJBYTE contains the first byte of a MESSAGE IN
117# message, so the driver can report an intelligible error if a message is
118# rejected.
119#
120# FLAGS's high bit is true if we are currently handling a reselect;
121# its next-highest bit is true ONLY IF we've seen an IDENTIFY message

--- 6 unchanged lines hidden (view full) ---

128#
129SYNCNEG = 0x20
130
131DROPATN = 0x30
132REJBYTE = 0x31
133DISC_DSB_A = 0x32
134DISC_DSB_B = 0x33
135
138#
139# The high bit of DROPATN is set if ATN should be dropped before the ACK
140# when outb is called. REJBYTE contains the first byte of a MESSAGE IN
141# message, so the driver can report an intelligible error if a message is
142# rejected.
143#
144# FLAGS's high bit is true if we are currently handling a reselect;
145# its next-highest bit is true ONLY IF we've seen an IDENTIFY message

--- 6 unchanged lines hidden (view full) ---

152#
153SYNCNEG = 0x20
154
155DROPATN = 0x30
156REJBYTE = 0x31
157DISC_DSB_A = 0x32
158DISC_DSB_B = 0x33
159
136NEEDWDTR_A = 0x34
137NEEDWDTR_B = 0x35
138
139MSG_LEN = 0x36
140MSG_START+0 = 0x37
141MSG_START+1 = 0x38
142MSG_START+2 = 0x39
143MSG_START+3 = 0x3a
144MSG_START+4 = 0x3b
145MSG_START+5 = 0x3c
146-MSG_START+0 = 0xc9 # 2's complement of MSG_START+0
147
148ARG_1 = 0x4c # sdtr conversion args & return
160MSG_LEN = 0x36
161MSG_START+0 = 0x37
162MSG_START+1 = 0x38
163MSG_START+2 = 0x39
164MSG_START+3 = 0x3a
165MSG_START+4 = 0x3b
166MSG_START+5 = 0x3c
167-MSG_START+0 = 0xc9 # 2's complement of MSG_START+0
168
169ARG_1 = 0x4c # sdtr conversion args & return
170BUS_16_BIT = 0x01
149RETURN_1 = 0x4c
150
151SIGSTATE = 0x4d # value written to SCSISIGO
171RETURN_1 = 0x4c
172
173SIGSTATE = 0x4d # value written to SCSISIGO
152NEEDSDTR_A = 0x4e # send SDTR message, 1 bit/trgt
153NEEDSDTR_B = 0x4f
154
174
155SG_SIZEOF = 0x8 # sizeof(struct scatterlist)
175# Linux users should use 0xc (12) for SG_SIZEOF
176SG_SIZEOF = 0x8 # sizeof(struct ahc_dma)
177#SG_SIZEOF = 0xc # sizeof(struct scatterlist)
178SCB_SIZEOF = 0x13 # sizeof SCB to DMA (19 bytes)
179
156SG_NOLOAD = 0x50 # load SG pointer/length?
157SG_COUNT = 0x51 # working value of SG count
158SG_NEXT = 0x52 # working value of SG pointer
159SG_NEXT+0 = 0x52
160SG_NEXT+1 = 0x53
161SG_NEXT+2 = 0x54
162SG_NEXT+3 = 0x55
163
164SCBCOUNT = 0x56 # the actual number of SCBs
165FLAGS = 0x57 # Device configuration flags
166TWIN_BUS = 0x01
167WIDE_BUS = 0x02
180SG_NOLOAD = 0x50 # load SG pointer/length?
181SG_COUNT = 0x51 # working value of SG count
182SG_NEXT = 0x52 # working value of SG pointer
183SG_NEXT+0 = 0x52
184SG_NEXT+1 = 0x53
185SG_NEXT+2 = 0x54
186SG_NEXT+3 = 0x55
187
188SCBCOUNT = 0x56 # the actual number of SCBs
189FLAGS = 0x57 # Device configuration flags
190TWIN_BUS = 0x01
191WIDE_BUS = 0x02
168CHECK_DTR = 0x08
169SENSE = 0x10
170ACTIVE_MSG = 0x20
171IDENTIFY_SEEN = 0x40
172RESELECTED = 0x80
173
174ACTIVE_A = 0x58
175ACTIVE_B = 0x59
176

--- 7 unchanged lines hidden (view full) ---

184# transaction on the current channel.
185 xor SBLKCTL,0x08 # Toggle to the other bus
186 test SCSISIGI,0x4 jnz reselect # BSYI
187 xor SBLKCTL,0x08 # Toggle to the original bus
188start2:
189 test SCSISIGI,0x4 jnz reselect # BSYI
190 test QINCNT,SCBMASK jz start
191
192SENSE = 0x10
193ACTIVE_MSG = 0x20
194IDENTIFY_SEEN = 0x40
195RESELECTED = 0x80
196
197ACTIVE_A = 0x58
198ACTIVE_B = 0x59
199

--- 7 unchanged lines hidden (view full) ---

207# transaction on the current channel.
208 xor SBLKCTL,0x08 # Toggle to the other bus
209 test SCSISIGI,0x4 jnz reselect # BSYI
210 xor SBLKCTL,0x08 # Toggle to the original bus
211start2:
212 test SCSISIGI,0x4 jnz reselect # BSYI
213 test QINCNT,SCBMASK jz start
214
192# We have at least one queued SCB now. Set the SCB pointer
193# from the FIFO so we see the right bank of SCB registers,
194# then set SCSI options and set the initiator and target
195# SCSI IDs.
215# We have at least one queued SCB now. Set the SCB pointer
216# from the FIFO so we see the right bank of SCB registers,
217# then set SCSI options and set the initiator and target
218# SCSI IDs.
196#
197 mov SCBPTR,QINFIFO
198
219#
220 mov SCBPTR,QINFIFO
221
222# If the control byte of this SCB has the NEEDDMA flag set, we have
223# yet to DMA it from host memory
224
225test SCBARRAY+0,NEEDDMA jz test_busy
226 clr HCNT+2
227 clr HCNT+1
228 mvi HCNT+0,SCB_SIZEOF
229
230 mvi A,4
231 mvi DINDEX,HADDR
232 mvi SCBARRAY+26 call bcopy
233
234 mvi DFCNTRL,0xd # HDMAEN|DIRECTION|FIFORESET
235
236# Wait for DMA from host memory to data FIFO to complete, then disable
237# DMA and wait for it to acknowledge that it's off.
238#
239scb_load1:
240 test DFSTATUS,0x8 jz scb_load1 # HDONE
241
242 clr DFCNTRL # disable DMA
243scb_load2:
244 test DFCNTRL,0x8 jnz scb_load2 # HDMAENACK
245
246# Copy the SCB from the FIFO to the SCBARRAY
247
248 mov SCBARRAY+0, DFDAT
249 mov SCBARRAY+1, DFDAT
250 mov SCBARRAY+2, DFDAT
251 mov SCBARRAY+3, DFDAT
252 mov SCBARRAY+4, DFDAT
253 mov SCBARRAY+5, DFDAT
254 mov SCBARRAY+6, DFDAT
255 mov SCBARRAY+7, DFDAT
256 mov SCBARRAY+8, DFDAT
257 mov SCBARRAY+9, DFDAT
258 mov SCBARRAY+10, DFDAT
259 mov SCBARRAY+11, DFDAT
260 mov SCBARRAY+12, DFDAT
261 mov SCBARRAY+13, DFDAT
262 mov SCBARRAY+14, DFDAT
263 mov SCBARRAY+15, DFDAT
264 mov SCBARRAY+16, DFDAT
265 mov SCBARRAY+17, DFDAT
266 mov SCBARRAY+18, DFDAT
267 and SCBARRAY+0, 0xf7
268
199# See if there is not already an active SCB for this target. This code
200# locks out on a per target basis instead of target/lun. Although this
201# is not ideal for devices that have multiple luns active at the same
202# time, it is faster than looping through all SCB's looking for active
203# commands. It may be benificial to make findscb a more general procedure
204# to see if the added cost of the search is negligible. This code also
205# assumes that the kernel driver will clear the active flags on board
206# initialization, board reset, and a target's SELTO.
207
269# See if there is not already an active SCB for this target. This code
270# locks out on a per target basis instead of target/lun. Although this
271# is not ideal for devices that have multiple luns active at the same
272# time, it is faster than looping through all SCB's looking for active
273# commands. It may be benificial to make findscb a more general procedure
274# to see if the added cost of the search is negligible. This code also
275# assumes that the kernel driver will clear the active flags on board
276# initialization, board reset, and a target's SELTO.
277
278test_busy:
208 and FUNCTION1,0x70,SCBARRAY+1
209 mov A,FUNCTION1
210 test SCBARRAY+1,0x88 jz test_a # Id < 8 && A channel
211
212 test ACTIVE_B,A jnz requeue
213 or ACTIVE_B,A # Mark the current target as busy
214 jmp start_scb
215

--- 7 unchanged lines hidden (view full) ---

223 mov QINFIFO, SCBPTR
224 jmp start
225
226test_a:
227 test ACTIVE_A,A jnz requeue
228 or ACTIVE_A,A # Mark the current target as busy
229
230start_scb:
279 and FUNCTION1,0x70,SCBARRAY+1
280 mov A,FUNCTION1
281 test SCBARRAY+1,0x88 jz test_a # Id < 8 && A channel
282
283 test ACTIVE_B,A jnz requeue
284 or ACTIVE_B,A # Mark the current target as busy
285 jmp start_scb
286

--- 7 unchanged lines hidden (view full) ---

294 mov QINFIFO, SCBPTR
295 jmp start
296
297test_a:
298 test ACTIVE_A,A jnz requeue
299 or ACTIVE_A,A # Mark the current target as busy
300
301start_scb:
302 or SCBARRAY+0,NEEDDMA
231 and SINDEX,0x08,SCBARRAY+1
232 and A,WIDE_BUS,FLAGS # Wide bus?
233 or SINDEX,A
234 mov SBLKCTL,SINDEX # select channel, bus width
235 mov SCBARRAY+1 call initialize
236 clr SG_NOLOAD
237 and FLAGS,0x3f # !RESELECTING
238

--- 8 unchanged lines hidden (view full) ---

247#
248 mov SCBARRAY+1 call disconnect # disconnect ok?
249
250 and SINDEX,0x7,SCBARRAY+1 # lun
251 or SINDEX,A # return value from disconnect
252 or SINDEX,0x80 call mk_mesg # IDENTIFY message
253
254 mov A,SINDEX
303 and SINDEX,0x08,SCBARRAY+1
304 and A,WIDE_BUS,FLAGS # Wide bus?
305 or SINDEX,A
306 mov SBLKCTL,SINDEX # select channel, bus width
307 mov SCBARRAY+1 call initialize
308 clr SG_NOLOAD
309 and FLAGS,0x3f # !RESELECTING
310

--- 8 unchanged lines hidden (view full) ---

319#
320 mov SCBARRAY+1 call disconnect # disconnect ok?
321
322 and SINDEX,0x7,SCBARRAY+1 # lun
323 or SINDEX,A # return value from disconnect
324 or SINDEX,0x80 call mk_mesg # IDENTIFY message
325
326 mov A,SINDEX
327 test SCBARRAY+0,0xc0 jz !message # WDTR or SDTR??
255 cmp MSG_START+0,A jne !message # did driver beat us?
328 cmp MSG_START+0,A jne !message # did driver beat us?
256 test FLAGS,CHECK_DTR jz !message # Don't even bother with DTR?
257 mvi MSG_START+1 call mk_dtr # build DTR message if needed
258
259!message:
260
261# Enable selection phase as an initiator, and do automatic ATN
262# after the selection.
263#
264 mvi SCSISEQ,0x48 # ENSELO|ENAUTOATNO

--- 67 unchanged lines hidden (view full) ---

332
333 cmp ALLZEROS,A je p_dataout
334 cmp A,0x40 je p_datain
335 cmp A,0x80 je p_command
336 cmp A,0xc0 je p_status
337 cmp A,0xa0 je p_mesgout
338 cmp A,0xe0 je p_mesgin
339
329 mvi MSG_START+1 call mk_dtr # build DTR message if needed
330
331!message:
332
333# Enable selection phase as an initiator, and do automatic ATN
334# after the selection.
335#
336 mvi SCSISEQ,0x48 # ENSELO|ENAUTOATNO

--- 67 unchanged lines hidden (view full) ---

404
405 cmp ALLZEROS,A je p_dataout
406 cmp A,0x40 je p_datain
407 cmp A,0x80 je p_command
408 cmp A,0xc0 je p_status
409 cmp A,0xa0 je p_mesgout
410 cmp A,0xe0 je p_mesgin
411
340 mvi INTSTAT,SIGNAL_0 # unknown - signal driver
412 mvi INTSTAT,BAD_PHASE # unknown - signal driver
341
342p_dataout:
343 mvi 0 call scsisig # !CDO|!IOO|!MSGO
344 call assert
345 call sg_load
346
347 mvi A,3
348 mvi DINDEX,HCNT

--- 190 unchanged lines hidden (view full) ---

539# the old one and the sequencer code will imediately jump to start
540# working on it. If the kernel driver does not wish to request sense,
541# the sequencer program counter is incremented by 1, preventing another run
542# on the current SCB and the command is allowed to complete. We don't
543# bother to post to the QOUTFIFO in the error case since it would require
544# extra work in the kernel driver to ensure that the entry was removed
545# before the command complete code tried processing it.
546
413
414p_dataout:
415 mvi 0 call scsisig # !CDO|!IOO|!MSGO
416 call assert
417 call sg_load
418
419 mvi A,3
420 mvi DINDEX,HCNT

--- 190 unchanged lines hidden (view full) ---

611# the old one and the sequencer code will imediately jump to start
612# working on it. If the kernel driver does not wish to request sense,
613# the sequencer program counter is incremented by 1, preventing another run
614# on the current SCB and the command is allowed to complete. We don't
615# bother to post to the QOUTFIFO in the error case since it would require
616# extra work in the kernel driver to ensure that the entry was removed
617# before the command complete code tried processing it.
618
547 test SCBARRAY+14,0xff jz status_ok # 0 Status?
548 mvi INTSTAT,STATUS_ERROR # let driver know
619 test SCBARRAY+14,0xff jz status_ok # 0 Status?
620 mvi INTSTAT,BAD_STATUS # let driver know
549 test FLAGS,SENSE jz status_ok
550 jmp p_mesgin_done
551
552status_ok:
553
554# First, mark this target as free.
555 and FUNCTION1,0x70,SCBARRAY+1
556 mov A,FUNCTION1

--- 23 unchanged lines hidden (view full) ---

580
581 cmp A,1 je p_mesginSDTR # Syncronous negotiation message
582 cmp A,3 je p_mesginWDTR # Wide negotiation message
583 jmp p_mesginN
584
585p_mesginWDTR:
586 cmp ARG_1,2 jne p_mesginN # extended mesg length = 2
587 mvi A call inb_next # Width of bus
621 test FLAGS,SENSE jz status_ok
622 jmp p_mesgin_done
623
624status_ok:
625
626# First, mark this target as free.
627 and FUNCTION1,0x70,SCBARRAY+1
628 mov A,FUNCTION1

--- 23 unchanged lines hidden (view full) ---

652
653 cmp A,1 je p_mesginSDTR # Syncronous negotiation message
654 cmp A,3 je p_mesginWDTR # Wide negotiation message
655 jmp p_mesginN
656
657p_mesginWDTR:
658 cmp ARG_1,2 jne p_mesginN # extended mesg length = 2
659 mvi A call inb_next # Width of bus
588 mvi INTSTAT,SIGNAL_WDTR # let driver know
660 mvi INTSTAT,MSG_WDTR # let driver know
589 test RETURN_1,0x80 jz p_mesgin_done# Do we need to send WDTR?
590
591# We didn't initiate the wide negotiation, so we must respond to the request
592 and RETURN_1,0x7f # Clear the SEND_WDTR Flag
593 or FLAGS,ACTIVE_MSG
661 test RETURN_1,0x80 jz p_mesgin_done# Do we need to send WDTR?
662
663# We didn't initiate the wide negotiation, so we must respond to the request
664 and RETURN_1,0x7f # Clear the SEND_WDTR Flag
665 or FLAGS,ACTIVE_MSG
666 mvi DINDEX,MSG_START+0
594 mvi MSG_START+0 call mk_wdtr # build WDTR message
595 or SINDEX,0x10,SIGSTATE # turn on ATNO
596 call scsisig
597 jmp p_mesgin_done
598
599p_mesginSDTR:
600 cmp ARG_1,3 jne p_mesginN # extended mesg length = 3
601 mvi ARG_1 call inb_next # xfer period
602 mvi A call inb_next # REQ/ACK offset
667 mvi MSG_START+0 call mk_wdtr # build WDTR message
668 or SINDEX,0x10,SIGSTATE # turn on ATNO
669 call scsisig
670 jmp p_mesgin_done
671
672p_mesginSDTR:
673 cmp ARG_1,3 jne p_mesginN # extended mesg length = 3
674 mvi ARG_1 call inb_next # xfer period
675 mvi A call inb_next # REQ/ACK offset
603 mvi INTSTAT,SIGNAL_4 # call driver to convert
676 mvi INTSTAT,MSG_SDTR # call driver to convert
604
605 test RETURN_1,0x80 jz p_mesgin_done# Do we need to mk_sdtr?
606
607 or FLAGS,ACTIVE_MSG
677
678 test RETURN_1,0x80 jz p_mesgin_done# Do we need to mk_sdtr?
679
680 or FLAGS,ACTIVE_MSG
681 mvi DINDEX, MSG_START+0
608 mvi MSG_START+0 call mk_sdtr
609 or SINDEX,0x10,SIGSTATE # turn on ATNO
610 call scsisig
611 jmp p_mesgin_done
612
613# Is it a disconnect message? Set a flag in the SCB to remind us
614# and await the bus going free.
615#

--- 41 unchanged lines hidden (view full) ---

657
658 and SCBARRAY+0,0xfb # clear disconnect bit in SCB
659 or FLAGS,0xc0 # make note of IDENTIFY
660
661 call sg_scb2ram # implied restore pointers
662 # required on reselect
663 jmp p_mesgin_done
664
682 mvi MSG_START+0 call mk_sdtr
683 or SINDEX,0x10,SIGSTATE # turn on ATNO
684 call scsisig
685 jmp p_mesgin_done
686
687# Is it a disconnect message? Set a flag in the SCB to remind us
688# and await the bus going free.
689#

--- 41 unchanged lines hidden (view full) ---

731
732 and SCBARRAY+0,0xfb # clear disconnect bit in SCB
733 or FLAGS,0xc0 # make note of IDENTIFY
734
735 call sg_scb2ram # implied restore pointers
736 # required on reselect
737 jmp p_mesgin_done
738
665# Message reject? If we have an outstanding WDTR or SDTR negotiation, assume
666# that it's a response from the target selecting 8bit or asynchronous transfer,
667# otherwise just ignore it since we have no clue what it pertains to.
739# Message reject? Let the kernel driver handle this. If we have an
740# outstanding WDTR or SDTR negotiation, assume that it's a response from
741# the target selecting 8bit or asynchronous transfer, otherwise just ignore
742# it since we have no clue what it pertains to.
668#
743#
669# XXX - I don't have a device that responds this way. Does this code
670# actually work?
671#
672p_mesgin6:
673 cmp A,7 jne p_mesgin7 # message reject code?
674
744p_mesgin6:
745 cmp A,7 jne p_mesgin7 # message reject code?
746
675 and FUNCTION1,0x70,SCSIID # outstanding SDTR message?
676 mov A,FUNCTION1
677
678 test SBLKCTL,0x08 jnz p_mesgin6_b
679 test SCSIID,0x80 jnz p_mesgin6_b
680 test NEEDWDTR_A,A jnz clear_wdtr_a
681 test NEEDSDTR_A,A jnz clear_sdtr_a
682 jmp p_mesgin_done # no - ignore rejection
683
684clear_sdtr_a:
685 call ndx_dtr # note use of asynch xfer
686 mov DINDEX,SINDEX
687 and DINDIR,0x80,SINDIR
688
689 not A
690 and NEEDSDTR_A,A
691 jmp clear_sdtr_done
692
693clear_wdtr_a:
694 call ndx_dtr # note use of 8bit xfer
695 mov DINDEX,SINDEX
696 and DINDIR,0x7f,SINDIR
697
698 not A
699 and NEEDWDTR_A,A
700 jmp clear_wdtr_done
701
702p_mesgin6_b:
703 test NEEDWDTR_B,A jnz clear_wdtr_b
704 test NEEDSDTR_B,A jnz clear_sdtr_b
705 jmp p_mesgin_done # no - ignore rejection
706
707clear_wdtr_b:
708 call ndx_dtr # note use of 8bit xfer
709 mov DINDEX,SINDEX
710 and DINDIR,0x7f,SINDIR
711
712 not A
713 and NEEDWDTR_B,A
714
715clear_wdtr_done:
716 and SCSIRATE,0x7f # select 8bit xfer
747 mvi INTSTAT, MSG_REJECT
717 jmp p_mesgin_done
718
748 jmp p_mesgin_done
749
719clear_sdtr_b:
720 call ndx_dtr # note use of asynch xfer
721 mov DINDEX,SINDEX
722 and DINDIR,0x80,SINDIR
723
724 not A
725 and NEEDSDTR_B,A
726
727clear_sdtr_done:
728 and SCSIRATE,0xf0 # select asynch xfer
729 jmp p_mesgin_done
730
731# [ ADD MORE MESSAGE HANDLING HERE ]
732#
733p_mesgin7:
734
735# We have no idea what this message in is, and there's no way
736# to pass it up to the kernel, so we issue a message reject and
737# hope for the best. Since we're now using manual PIO mode to
738# read in the message, there should no longer be a race condition
739# present when we assert ATN. In any case, rejection should be a
740# rare occurrence - signal the driver when it happens.
741#
742p_mesginN:
743 or SINDEX,0x10,SIGSTATE # turn on ATNO
744 call scsisig
750# [ ADD MORE MESSAGE HANDLING HERE ]
751#
752p_mesgin7:
753
754# We have no idea what this message in is, and there's no way
755# to pass it up to the kernel, so we issue a message reject and
756# hope for the best. Since we're now using manual PIO mode to
757# read in the message, there should no longer be a race condition
758# present when we assert ATN. In any case, rejection should be a
759# rare occurrence - signal the driver when it happens.
760#
761p_mesginN:
762 or SINDEX,0x10,SIGSTATE # turn on ATNO
763 call scsisig
745 mvi INTSTAT,SIGNAL_1 # let driver know
764 mvi INTSTAT,SEND_REJECT # let driver know
746
747 mvi 0x7 call mk_mesg # MESSAGE REJECT message
748
749p_mesgin_done:
750 call inb_last # ack & turn auto PIO back on
751 jmp ITloop
752
753# Bus free phase. It might be useful to interrupt the device

--- 205 unchanged lines hidden (view full) ---

959
960# Assert that if we've been reselected, then we've seen an IDENTIFY
961# message.
962#
963assert:
964 test FLAGS,RESELECTED jz assert1 # reselected?
965 test FLAGS,IDENTIFY_SEEN jnz assert1 # seen IDENTIFY?
966
765
766 mvi 0x7 call mk_mesg # MESSAGE REJECT message
767
768p_mesgin_done:
769 call inb_last # ack & turn auto PIO back on
770 jmp ITloop
771
772# Bus free phase. It might be useful to interrupt the device

--- 205 unchanged lines hidden (view full) ---

978
979# Assert that if we've been reselected, then we've seen an IDENTIFY
980# message.
981#
982assert:
983 test FLAGS,RESELECTED jz assert1 # reselected?
984 test FLAGS,IDENTIFY_SEEN jnz assert1 # seen IDENTIFY?
985
967 mvi INTSTAT,SIGNAL_2 # no - cause a kernel panic
986 mvi INTSTAT,NO_IDENT # no - cause a kernel panic
968
969assert1:
970 ret
971
972# Find out if disconnection is ok from the information the BIOS has left
973# us. The tcl from SCBARRAY+1 should be in SINDEX; A will
974# contain either 0x40 (disconnection ok) or 0x00 (disconnection not ok)
975# on exit.

--- 38 unchanged lines hidden (view full) ---

1014 test SCBARRAY+0,0x4 jz findSCB2 # should be disconnected
1015 ret
1016
1017findSCB2:
1018 inc SINDEX
1019 mov A,SCBCOUNT
1020 cmp SINDEX,A jne findSCB1
1021
987
988assert1:
989 ret
990
991# Find out if disconnection is ok from the information the BIOS has left
992# us. The tcl from SCBARRAY+1 should be in SINDEX; A will
993# contain either 0x40 (disconnection ok) or 0x00 (disconnection not ok)
994# on exit.

--- 38 unchanged lines hidden (view full) ---

1033 test SCBARRAY+0,0x4 jz findSCB2 # should be disconnected
1034 ret
1035
1036findSCB2:
1037 inc SINDEX
1038 mov A,SCBCOUNT
1039 cmp SINDEX,A jne findSCB1
1040
1022 mvi INTSTAT,SIGNAL_3 # not found - signal kernel
1041 mvi INTSTAT,NO_MATCH # not found - signal kernel
1023 mvi 0x6 call mk_mesg # ABORT message
1024
1025 or SINDEX,0x10,SIGSTATE # assert ATNO
1026 call scsisig
1027 ret
1028
1029# Make a working copy of the scatter-gather parameters in the SCB.
1030#

--- 17 unchanged lines hidden (view full) ---

1048 mov SCBARRAY+2,SG_COUNT
1049
1050 mvi A,4
1051 mvi DINDEX,SCBARRAY+3
1052 mvi SG_NEXT call bcopy
1053
1054 and SCBARRAY+0,0xef,SCBARRAY+0
1055 test SG_NOLOAD,0x80 jz sg_ram2scb1 # reload s/g?
1042 mvi 0x6 call mk_mesg # ABORT message
1043
1044 or SINDEX,0x10,SIGSTATE # assert ATNO
1045 call scsisig
1046 ret
1047
1048# Make a working copy of the scatter-gather parameters in the SCB.
1049#

--- 17 unchanged lines hidden (view full) ---

1067 mov SCBARRAY+2,SG_COUNT
1068
1069 mvi A,4
1070 mvi DINDEX,SCBARRAY+3
1071 mvi SG_NEXT call bcopy
1072
1073 and SCBARRAY+0,0xef,SCBARRAY+0
1074 test SG_NOLOAD,0x80 jz sg_ram2scb1 # reload s/g?
1056 or SCBARRAY+0,0x10
1075 or SCBARRAY+0,SG_LOAD
1057
1058sg_ram2scb1:
1059 ret
1060
1061# Load a struct scatter if needed and set up the data address and
1062# length. If the working value of the SG count is nonzero, then
1063# we need to load a new set of values.
1064#

--- 42 unchanged lines hidden (view full) ---

1107# };
1108#
1109
1110 mov SCBARRAY+19,DFDAT # new data address
1111 mov SCBARRAY+20,DFDAT
1112 mov SCBARRAY+21,DFDAT
1113 mov SCBARRAY+22,DFDAT
1114
1076
1077sg_ram2scb1:
1078 ret
1079
1080# Load a struct scatter if needed and set up the data address and
1081# length. If the working value of the SG count is nonzero, then
1082# we need to load a new set of values.
1083#

--- 42 unchanged lines hidden (view full) ---

1126# };
1127#
1128
1129 mov SCBARRAY+19,DFDAT # new data address
1130 mov SCBARRAY+20,DFDAT
1131 mov SCBARRAY+21,DFDAT
1132 mov SCBARRAY+22,DFDAT
1133
1134# For Linux, we must throw away four bytes since there is a 32bit gap
1135# in the middle of a struct scatterlist
1136# mov NONE,DFDAT
1137# mov NONE,DFDAT
1138# mov NONE,DFDAT
1139# mov NONE,DFDAT
1140
1115 mov SCBARRAY+23,DFDAT
1116 mov SCBARRAY+24,DFDAT
1141 mov SCBARRAY+23,DFDAT
1142 mov SCBARRAY+24,DFDAT
1117 mov SCBARRAY+25,DFDAT
1118 mov NONE,DFDAT #Only support 24 bit length.
1143 mov SCBARRAY+25,DFDAT #Only support 24 bit length.
1119
1120sg_load3:
1121 ret
1122
1123# Advance the scatter-gather pointers only IF NEEDED. If SG is enabled,
1124# and the SCSI transfer count is zero (note that this should be called
1125# right after a DMA finishes), then move the working copies of the SG
1126# pointer/length along. If the SCSI transfer count is not zero, then

--- 41 unchanged lines hidden (view full) ---

1168# starting at the address passed in SINDEX. DINDEX is modified on return.
1169# The SCSI-II spec requires that Wide negotiation occur first and you can
1170# only negotiat one or the other at a time otherwise in the event of a message
1171# reject, you wouldn't be able to tell which message was the culpret.
1172#
1173mk_dtr:
1174 mov DINDEX,SINDEX # save SINDEX
1175
1144
1145sg_load3:
1146 ret
1147
1148# Advance the scatter-gather pointers only IF NEEDED. If SG is enabled,
1149# and the SCSI transfer count is zero (note that this should be called
1150# right after a DMA finishes), then move the working copies of the SG
1151# pointer/length along. If the SCSI transfer count is not zero, then

--- 41 unchanged lines hidden (view full) ---

1193# starting at the address passed in SINDEX. DINDEX is modified on return.
1194# The SCSI-II spec requires that Wide negotiation occur first and you can
1195# only negotiat one or the other at a time otherwise in the event of a message
1196# reject, you wouldn't be able to tell which message was the culpret.
1197#
1198mk_dtr:
1199 mov DINDEX,SINDEX # save SINDEX
1200
1176 call ndx_dtr
1177 test SCBARRAY+1,0x88 jz mk_dtr_a
1178 test NEEDWDTR_B,A jnz mk_wdtr_16 # do we need negotiation?
1179 test NEEDSDTR_B,A jnz mk_sdtr
1180 ret
1181mk_dtr_a:
1182 test NEEDWDTR_A,A jnz mk_wdtr_16 # do we need negotiation?
1183 test NEEDSDTR_A,A jnz mk_sdtr
1184 ret
1201 test SCBARRAY+0,NEEDWDTR jnz mk_wdtr_16bit
1202 jmp mk_sdtr
1185
1203
1186mk_wdtr_16:
1187 mvi ARG_1,1 # 16bit wide bus
1188
1204mk_wdtr_16bit:
1205 mvi ARG_1,BUS_16_BIT
1189mk_wdtr:
1190 mvi DINDIR,1 # extended message
1191 mvi DINDIR,2 # extended message length = 2
1192 mvi DINDIR,3 # WDTR code
1193 mov DINDIR,ARG_1 # bus width
1194
1195 add MSG_LEN,-MSG_START+0,DINDEX # update message length
1196 ret

--- 53 unchanged lines hidden ---
1206mk_wdtr:
1207 mvi DINDIR,1 # extended message
1208 mvi DINDIR,2 # extended message length = 2
1209 mvi DINDIR,3 # WDTR code
1210 mov DINDIR,ARG_1 # bus width
1211
1212 add MSG_LEN,-MSG_START+0,DINDEX # update message length
1213 ret

--- 53 unchanged lines hidden ---