Linux Audio

Check our new training course

Embedded Linux Audio

Check our new training course
with Creative Commons CC-BY-SA
lecture materials

Bootlin logo

Elixir Cross Referencer

Loading...
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
/*
 * sim710.scr - Copyright (C) 1999 Richard Hirst
 */

/* Offsets from DSA, allow 128 elements of scatter/gather */

ABSOLUTE dsa_select  = 0
ABSOLUTE dsa_msgout  = 8
ABSOLUTE dsa_cmnd    = 16
ABSOLUTE dsa_status  = 24
ABSOLUTE dsa_msgin   = 32
ABSOLUTE dsa_datain  = 40	/* 8 * 128 = 1024 bytes */
ABSOLUTE dsa_dataout = 1064	/* 8 * 128 = 1024 bytes */
ABSOLUTE dsa_size     = 2088

ABSOLUTE reselected_identify = 0
ABSOLUTE msgin_buf = 0

/* Interrupt values passed back to driver */

ABSOLUTE int_bad_extmsg1a	= 0xab930000
ABSOLUTE int_bad_extmsg1b	= 0xab930001
ABSOLUTE int_bad_extmsg2a	= 0xab930002
ABSOLUTE int_bad_extmsg2b	= 0xab930003
ABSOLUTE int_bad_extmsg3a	= 0xab930004
ABSOLUTE int_bad_extmsg3b	= 0xab930005
ABSOLUTE int_bad_msg1		= 0xab930006
ABSOLUTE int_bad_msg2		= 0xab930007
ABSOLUTE int_bad_msg3		= 0xab930008
ABSOLUTE int_cmd_bad_phase	= 0xab930009
ABSOLUTE int_cmd_complete	= 0xab93000a
ABSOLUTE int_data_bad_phase	= 0xab93000b
ABSOLUTE int_msg_sdtr1		= 0xab93000c
ABSOLUTE int_msg_sdtr2		= 0xab93000d
ABSOLUTE int_msg_sdtr3		= 0xab93000e
ABSOLUTE int_no_msgout1		= 0xab93000f
ABSOLUTE int_no_msgout2		= 0xab930010
ABSOLUTE int_no_msgout3		= 0xab930011
ABSOLUTE int_not_cmd_complete	= 0xab930012
ABSOLUTE int_sel_no_ident	= 0xab930013
ABSOLUTE int_sel_not_cmd	= 0xab930014
ABSOLUTE int_status_not_msgin	= 0xab930015
ABSOLUTE int_resel_not_msgin	= 0xab930016
ABSOLUTE int_reselected		= 0xab930017
ABSOLUTE int_selected		= 0xab930018
ABSOLUTE int_disc1		= 0xab930019
ABSOLUTE int_disc2		= 0xab93001a
ABSOLUTE int_disc3		= 0xab93001b
ABSOLUTE int_not_rej		= 0xab93001c


/* Bit field settings used to record status in SCRATCH */

ABSOLUTE had_select	= 0x01
ABSOLUTE had_msgout	= 0x02
ABSOLUTE had_cmdout	= 0x04
ABSOLUTE had_datain	= 0x08
ABSOLUTE had_dataout	= 0x10
ABSOLUTE had_status	= 0x20
ABSOLUTE had_msgin	= 0x40
ABSOLUTE had_extmsg	= 0x80


/* These scripts are heavily based on the examples in the NCR 53C710
 * Programmer's Guide (Preliminary).
 */

ENTRY do_select
do_select:
	CLEAR TARGET
	MOVE SCRATCH0 & 0 TO SCRATCH0
	; Enable selection timer
	MOVE CTEST7 & 0xef TO CTEST7
	SELECT ATN FROM dsa_select, reselect
	JUMP get_status, WHEN STATUS
	; Disable selection timer
	MOVE CTEST7 | 0x10 TO CTEST7
	MOVE SCRATCH0 | had_select TO SCRATCH0
	INT int_sel_no_ident, IF NOT MSG_OUT
	MOVE SCRATCH0 | had_msgout TO SCRATCH0
	MOVE FROM dsa_msgout, when MSG_OUT
ENTRY done_ident
done_ident:
	JUMP get_status, IF STATUS
redo_msgin1:
	JUMP get_msgin1, WHEN MSG_IN
	INT int_sel_not_cmd, IF NOT CMD
ENTRY resume_cmd
resume_cmd:
	MOVE SCRATCH0 | had_cmdout TO SCRATCH0
	MOVE FROM dsa_cmnd, WHEN CMD
ENTRY resume_pmm
resume_pmm:
redo_msgin2:
	JUMP get_msgin2, WHEN MSG_IN
	JUMP get_status, IF STATUS
	JUMP input_data, IF DATA_IN
	JUMP output_data, IF DATA_OUT
	INT int_cmd_bad_phase

get_status:
	; Disable selection timer
	MOVE CTEST7 | 0x10 TO CTEST7
	MOVE FROM dsa_status, WHEN STATUS
	INT int_status_not_msgin, WHEN NOT MSG_IN
	MOVE FROM dsa_msgin, WHEN MSG_IN
	INT int_not_cmd_complete, IF NOT 0x00
	CLEAR ACK
ENTRY wait_disc_complete
wait_disc_complete:
	WAIT DISCONNECT
	INT int_cmd_complete

input_data:
	MOVE SCRATCH0 | had_datain TO SCRATCH0
ENTRY patch_input_data
patch_input_data:
	JUMP 0
	MOVE FROM dsa_datain+0x0000, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0008, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0010, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0018, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0020, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0028, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0030, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0038, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0040, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0048, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0050, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0058, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0060, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0068, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0070, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0078, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0080, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0088, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0090, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0098, WHEN DATA_IN
	MOVE FROM dsa_datain+0x00a0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x00a8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x00b0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x00b8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x00c0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x00c8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x00d0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x00d8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x00e0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x00e8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x00f0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x00f8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0100, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0108, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0110, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0118, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0120, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0128, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0130, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0138, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0140, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0148, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0150, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0158, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0160, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0168, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0170, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0178, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0180, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0188, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0190, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0198, WHEN DATA_IN
	MOVE FROM dsa_datain+0x01a0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x01a8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x01b0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x01b8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x01c0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x01c8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x01d0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x01d8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x01e0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x01e8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x01f0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x01f8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0200, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0208, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0210, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0218, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0220, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0228, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0230, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0238, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0240, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0248, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0250, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0258, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0260, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0268, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0270, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0278, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0280, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0288, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0290, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0298, WHEN DATA_IN
	MOVE FROM dsa_datain+0x02a0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x02a8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x02b0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x02b8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x02c0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x02c8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x02d0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x02d8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x02e0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x02e8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x02f0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x02f8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0300, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0308, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0310, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0318, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0320, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0328, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0330, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0338, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0340, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0348, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0350, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0358, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0360, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0368, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0370, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0378, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0380, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0388, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0390, WHEN DATA_IN
	MOVE FROM dsa_datain+0x0398, WHEN DATA_IN
	MOVE FROM dsa_datain+0x03a0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x03a8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x03b0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x03b8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x03c0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x03c8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x03d0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x03d8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x03e0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x03e8, WHEN DATA_IN
	MOVE FROM dsa_datain+0x03f0, WHEN DATA_IN
	MOVE FROM dsa_datain+0x03f8, WHEN DATA_IN
	JUMP end_data_trans

output_data:
	MOVE SCRATCH0 | had_dataout TO SCRATCH0
ENTRY patch_output_data
patch_output_data:
	JUMP 0
	MOVE FROM dsa_dataout+0x0000, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0008, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0010, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0018, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0020, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0028, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0030, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0038, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0040, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0048, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0050, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0058, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0060, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0068, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0070, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0078, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0080, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0088, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0090, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0098, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x00a0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x00a8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x00b0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x00b8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x00c0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x00c8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x00d0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x00d8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x00e0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x00e8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x00f0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x00f8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0100, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0108, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0110, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0118, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0120, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0128, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0130, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0138, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0140, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0148, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0150, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0158, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0160, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0168, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0170, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0178, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0180, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0188, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0190, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0198, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x01a0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x01a8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x01b0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x01b8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x01c0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x01c8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x01d0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x01d8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x01e0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x01e8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x01f0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x01f8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0200, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0208, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0210, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0218, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0220, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0228, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0230, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0238, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0240, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0248, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0250, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0258, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0260, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0268, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0270, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0278, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0280, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0288, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0290, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0298, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x02a0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x02a8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x02b0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x02b8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x02c0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x02c8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x02d0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x02d8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x02e0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x02e8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x02f0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x02f8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0300, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0308, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0310, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0318, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0320, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0328, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0330, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0338, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0340, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0348, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0350, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0358, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0360, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0368, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0370, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0378, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0380, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0388, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0390, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x0398, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x03a0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x03a8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x03b0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x03b8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x03c0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x03c8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x03d0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x03d8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x03e0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x03e8, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x03f0, WHEN DATA_OUT
	MOVE FROM dsa_dataout+0x03f8, WHEN DATA_OUT
ENTRY end_data_trans
end_data_trans:
redo_msgin3:
	JUMP get_status, WHEN STATUS
	JUMP get_msgin3, WHEN MSG_IN
	INT int_data_bad_phase

get_msgin1:
	MOVE SCRATCH0 | had_msgin TO SCRATCH0
	MOVE 1, msgin_buf, WHEN MSG_IN
	JUMP ext_msg1, IF 0x01		; Extended Message
	JUMP ignore_msg1, IF 0x02	; Save Data Pointers
	JUMP ignore_msg1, IF 0x03	; Save Restore Pointers
	JUMP disc1, IF 0x04		; Disconnect
	INT int_bad_msg1
ignore_msg1:
	CLEAR ACK
	JUMP redo_msgin1
ext_msg1:
	MOVE SCRATCH0 | had_extmsg TO SCRATCH0
	CLEAR ACK
	MOVE 1, msgin_buf + 1, WHEN MSG_IN
	JUMP ext_msg1a, IF 0x03
	INT int_bad_extmsg1a
ext_msg1a:
	CLEAR ACK
	MOVE 1, msgin_buf + 2, WHEN MSG_IN
	JUMP ext_msg1b, IF 0x01		; Must be SDTR
	INT int_bad_extmsg1b
ext_msg1b:
	CLEAR ACK
	MOVE 2, msgin_buf + 3, WHEN MSG_IN
	INT int_msg_sdtr1
disc1:
	CLEAR ACK
ENTRY wait_disc1
wait_disc1:
	WAIT DISCONNECT
	INT int_disc1
ENTRY resume_msgin1a
resume_msgin1a:
	CLEAR ACK
	JUMP redo_msgin1
ENTRY resume_msgin1b
resume_msgin1b:
	SET ATN
	CLEAR ACK
	INT int_no_msgout1, WHEN NOT MSG_OUT
	MOVE SCRATCH0 | had_msgout TO SCRATCH0
	MOVE FROM dsa_msgout, when MSG_OUT
	JUMP redo_msgin1

get_msgin2:
	MOVE SCRATCH0 | had_msgin TO SCRATCH0
	MOVE 1, msgin_buf, WHEN MSG_IN
	JUMP ext_msg2, IF 0x01		; Extended Message
	JUMP ignore_msg2, IF 0x02	; Save Data Pointers
	JUMP ignore_msg2, IF 0x03	; Save Restore Pointers
	JUMP disc2, IF 0x04		; Disconnect
	INT int_bad_msg2
ignore_msg2:
	CLEAR ACK
	JUMP redo_msgin2
ext_msg2:
	MOVE SCRATCH0 | had_extmsg TO SCRATCH0
	CLEAR ACK
	MOVE 1, msgin_buf + 1, WHEN MSG_IN
	JUMP ext_msg2a, IF 0x03
	INT int_bad_extmsg2a
ext_msg2a:
	CLEAR ACK
	MOVE 1, msgin_buf + 2, WHEN MSG_IN
	JUMP ext_msg2b, IF 0x01		; Must be SDTR
	INT int_bad_extmsg2b
ext_msg2b:
	CLEAR ACK
	MOVE 2, msgin_buf + 3, WHEN MSG_IN
	INT int_msg_sdtr2
disc2:
	CLEAR ACK
ENTRY wait_disc2
wait_disc2:
	WAIT DISCONNECT
	INT int_disc2
ENTRY resume_msgin2a
resume_msgin2a:
	CLEAR ACK
	JUMP redo_msgin2
ENTRY resume_msgin2b
resume_msgin2b:
	SET ATN
	CLEAR ACK
	INT int_no_msgout2, WHEN NOT MSG_OUT
	MOVE SCRATCH0 | had_msgout TO SCRATCH0
	MOVE FROM dsa_msgout, when MSG_OUT
	JUMP redo_msgin2

get_msgin3:
	MOVE SCRATCH0 | had_msgin TO SCRATCH0
	MOVE 1, msgin_buf, WHEN MSG_IN
	JUMP ext_msg3, IF 0x01		; Extended Message
	JUMP ignore_msg3, IF 0x02	; Save Data Pointers
	JUMP ignore_msg3, IF 0x03	; Save Restore Pointers
	JUMP disc3, IF 0x04		; Disconnect
	INT int_bad_msg3
ignore_msg3:
	CLEAR ACK
	JUMP redo_msgin3
ext_msg3:
	MOVE SCRATCH0 | had_extmsg TO SCRATCH0
	CLEAR ACK
	MOVE 1, msgin_buf + 1, WHEN MSG_IN
	JUMP ext_msg3a, IF 0x03
	INT int_bad_extmsg3a
ext_msg3a:
	CLEAR ACK
	MOVE 1, msgin_buf + 2, WHEN MSG_IN
	JUMP ext_msg3b, IF 0x01		; Must be SDTR
	INT int_bad_extmsg3b
ext_msg3b:
	CLEAR ACK
	MOVE 2, msgin_buf + 3, WHEN MSG_IN
	INT int_msg_sdtr3
disc3:
	CLEAR ACK
ENTRY wait_disc3
wait_disc3:
	WAIT DISCONNECT
	INT int_disc3
ENTRY resume_msgin3a
resume_msgin3a:
	CLEAR ACK
	JUMP redo_msgin3
ENTRY resume_msgin3b
resume_msgin3b:
	SET ATN
	CLEAR ACK
	INT int_no_msgout3, WHEN NOT MSG_OUT
	MOVE SCRATCH0 | had_msgout TO SCRATCH0
	MOVE FROM dsa_msgout, when MSG_OUT
	JUMP redo_msgin3

ENTRY resume_rej_ident
resume_rej_ident:
	CLEAR ATN
	MOVE 1, msgin_buf, WHEN MSG_IN
	INT int_not_rej, IF NOT 0x07		; Reject
	CLEAR ACK
	JUMP done_ident

ENTRY reselect
reselect:
	; Disable selection timer
	MOVE CTEST7 | 0x10 TO CTEST7
	WAIT RESELECT resel_err
	INT int_resel_not_msgin, WHEN NOT MSG_IN
	MOVE 1, reselected_identify, WHEN MSG_IN
	INT int_reselected
resel_err:
	MOVE CTEST2 & 0x40 TO SFBR
	JUMP selected, IF 0x00
	MOVE SFBR & 0 TO SFBR
ENTRY patch_new_dsa
patch_new_dsa:
	MOVE SFBR | 0x11 TO DSA0
	MOVE SFBR | 0x22 TO DSA1
	MOVE SFBR | 0x33 TO DSA2
	MOVE SFBR | 0x44 TO DSA3
	JUMP do_select

selected:
	INT int_selected