This source file includes following definitions.
- AHC_NONE
- AHC_CHIPID_MASK
- AHC_AIC7770
- AHC_AIC7850
- AHC_AIC7855
- AHC_AIC7859
- AHC_AIC7860
- AHC_AIC7870
- AHC_AIC7880
- AHC_AIC7895
- AHC_AIC7895C
- AHC_AIC7890
- AHC_AIC7896
- AHC_AIC7892
- AHC_AIC7899
- AHC_VL
- AHC_EISA
- AHC_PCI
- AHC_BUS_MASK
- ahc_chip
- AHC_FENONE
- AHC_ULTRA
- AHC_ULTRA2
- AHC_WIDE
- AHC_TWIN
- AHC_MORE_SRAM
- AHC_CMD_CHAN
- AHC_QUEUE_REGS
- AHC_SG_PRELOAD
- AHC_SPIOCAP
- AHC_MULTI_TID
- AHC_HS_MAILBOX
- AHC_DT
- AHC_NEW_TERMCTL
- AHC_MULTI_FUNC
- AHC_LARGE_SCBS
- AHC_AUTORATE
- AHC_AUTOPAUSE
- AHC_TARGETMODE
- AHC_MULTIROLE
- AHC_REMOVABLE
- AHC_AIC7770_FE
- AHC_FENONE
- AHC_TARGETMODE
- AHC_AIC7850_FE
- AHC_SPIOCAP
- AHC_AUTOPAUSE
- AHC_ULTRA
- AHC_AIC7860_FE
- AHC_AIC7850_FE
- AHC_TARGETMODE
- AHC_AIC7870_FE
- AHC_AUTOPAUSE
- AHC_AIC7870_FE
- AHC_AIC7880_FE
- AHC_ULTRA
- AHC_AIC7890_FE
- AHC_MORE_SRAM
- AHC_CMD_CHAN
- AHC_ULTRA2
- AHC_QUEUE_REGS
- AHC_SG_PRELOAD
- AHC_MULTI_TID
- AHC_HS_MAILBOX
- AHC_NEW_TERMCTL
- AHC_LARGE_SCBS
- AHC_TARGETMODE
- AHC_AIC7892_FE
- AHC_AIC7890_FE
- AHC_DT
- AHC_AUTORATE
- AHC_AUTOPAUSE
- AHC_AIC7895_FE
- AHC_AIC7880_FE
- AHC_MORE_SRAM
- AHC_AUTOPAUSE
- AHC_CMD_CHAN
- AHC_MULTI_FUNC
- AHC_LARGE_SCBS
- AHC_AIC7895C_FE
- AHC_AIC7895_FE
- AHC_MULTI_TID
- AHC_AIC7896_FE
- AHC_AIC7890_FE
- AHC_MULTI_FUNC
- AHC_AIC7899_FE
- AHC_AIC7892_FE
- AHC_MULTI_FUNC
- ahc_feature
- AHC_BUGNONE
- AHC_TMODE_WIDEODD_BUG
- AHC_AUTOFLUSH_BUG
- AHC_CACHETHEN_BUG
- AHC_CACHETHEN_DIS_BUG
- AHC_PCI_2_1_RETRY_BUG
- AHC_PCI_MWI_BUG
- AHC_SCBCHAN_UPLOAD_BUG
- ahc_bug
- AHC_FNONE
- AHC_PRIMARY_CHANNEL
- AHC_USEDEFAULTS
- AHC_SEQUENCER_DEBUG
- AHC_SHARED_SRAM
- AHC_LARGE_SEEPROM
- AHC_RESET_BUS_A
- AHC_RESET_BUS_B
- AHC_EXTENDED_TRANS_A
- AHC_EXTENDED_TRANS_B
- AHC_TERM_ENB_A
- AHC_TERM_ENB_B
- AHC_INITIATORROLE
- AHC_TARGETROLE
- AHC_NEWEEPROM_FMT
- AHC_RESOURCE_SHORTAGE
- AHC_TQINFIFO_BLOCKED
- AHC_INT50_SPEEDFLEX
- AHC_SCB_BTT
- AHC_BIOS_ENABLED
- AHC_ALL_INTERRUPTS
- AHC_PAGESCBS
- AHC_EDGE_INTERRUPT
- AHC_39BIT_ADDRESSING
- AHC_LSCBS_ENABLED
- AHC_SCB_CONFIG_USED
- AHC_NO_BIOS_INIT
- AHC_DISABLE_PCI_PERR
- AHC_HAS_TERM_LOGIC
- AHC_SHUTDOWN_RECOVERY
- ahc_flag
- SCB_FLAG_NONE
- SCB_OTHERTCL_TIMEOUT
- SCB_DEVICE_RESET
- SCB_SENSE
- SCB_CDB32_PTR
- SCB_AUTO_NEGOTIATE
- SCB_NEGOTIATE
- SCB_ABORT
- SCB_UNTAGGEDQ
- SCB_ACTIVE
- SCB_TARGET_IMMEDIATE
- SCB_TRANSMISSION_ERROR
- SCB_TARGET_SCB
- SCB_SILENT
- scb_flag
- MSG_TYPE_NONE
- MSG_TYPE_INITIATOR_MSGOUT
- MSG_TYPE_INITIATOR_MSGIN
- MSG_TYPE_TARGET_MSGOUT
- MSG_TYPE_TARGET_MSGIN
- ahc_msg_type
- MSGLOOP_IN_PROG
- MSGLOOP_MSGCOMPLETE
- MSGLOOP_TERMINATED
- msg_loop_stat
- ROLE_UNKNOWN
- ROLE_INITIATOR
- ROLE_TARGET
- role_t
- SEARCH_COMPLETE
- SEARCH_COUNT
- SEARCH_REMOVE
- ahc_search_action
- AHC_NEG_TO_GOAL
- AHC_NEG_IF_NON_ASYNC
- AHC_NEG_ALWAYS
- ahc_neg_type
- AHC_QUEUE_NONE
- AHC_QUEUE_BASIC
- AHC_QUEUE_TAGGED
- ahc_queue_alg
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 #ifndef _AIC7XXXVAR_H_
50 #define _AIC7XXXVAR_H_
51
52 #undef AHC_DEBUG
53
54
55 #include <dev/microcode/aic7xxx/aic7xxx_reg.h>
56
57 #include <dev/ic/aic7xxx_cam.h>
58
59 struct ahc_platform_data;
60 struct scb_platform_data;
61 struct seeprom_descriptor;
62
63
64 #ifndef MAX
65 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
66 #endif
67
68 #ifndef MIN
69 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
70 #endif
71
72 #ifndef TRUE
73 #define TRUE 1
74 #endif
75 #ifndef FALSE
76 #define FALSE 0
77 #endif
78
79 #define NUM_ELEMENTS(array) (sizeof(array) / sizeof(*array))
80
81 #define ALL_CHANNELS '\0'
82 #define ALL_TARGETS_MASK 0xFFFF
83 #define INITIATOR_WILDCARD (~0)
84
85 #define SCSIID_TARGET(ahc, scsiid) \
86 (((scsiid) & ((((ahc)->features & AHC_TWIN) != 0) ? TWIN_TID : TID)) \
87 >> TID_SHIFT)
88 #define SCSIID_OUR_ID(scsiid) \
89 ((scsiid) & OID)
90 #define SCSIID_CHANNEL(ahc, scsiid) \
91 ((((ahc)->features & AHC_TWIN) != 0) \
92 ? ((((scsiid) & TWIN_CHNLB) != 0) ? 'B' : 'A') \
93 : 'A')
94 #define SCB_IS_SCSIBUS_B(ahc, scb) \
95 (SCSIID_CHANNEL(ahc, (scb)->hscb->scsiid) == 'B')
96 #define SCB_GET_OUR_ID(scb) \
97 SCSIID_OUR_ID((scb)->hscb->scsiid)
98 #define SCB_GET_TARGET(ahc, scb) \
99 SCSIID_TARGET((ahc), (scb)->hscb->scsiid)
100 #define SCB_GET_CHANNEL(ahc, scb) \
101 SCSIID_CHANNEL(ahc, (scb)->hscb->scsiid)
102 #define SCB_GET_LUN(scb) \
103 ((scb)->hscb->lun & LID)
104 #define SCB_GET_TARGET_OFFSET(ahc, scb) \
105 (SCB_GET_TARGET(ahc, scb))
106 #define SCB_GET_TARGET_MASK(ahc, scb) \
107 (0x01 << (SCB_GET_TARGET_OFFSET(ahc, scb)))
108 #ifdef AHC_DEBUG
109 #define SCB_IS_SILENT(scb) \
110 ((ahc_debug & AHC_SHOW_MASKED_ERRORS) == 0 \
111 && (((scb)->flags & SCB_SILENT) != 0))
112 #else
113 #define SCB_IS_SILENT(scb) \
114 (((scb)->flags & SCB_SILENT) != 0)
115 #endif
116 #define TCL_TARGET_OFFSET(tcl) \
117 ((((tcl) >> 4) & TID) >> 4)
118 #define TCL_LUN(tcl) \
119 (tcl & (AHC_NUM_LUNS - 1))
120 #define BUILD_TCL(scsiid, lun) \
121 ((lun) | (((scsiid) & TID) << 4))
122
123 #ifndef AHC_TARGET_MODE
124 #undef AHC_TMODE_ENABLE
125 #define AHC_TMODE_ENABLE 0
126 #endif
127
128
129
130
131
132 #define AHC_NUM_TARGETS 16
133
134
135
136
137
138
139
140 #define AHC_NUM_LUNS 64
141
142
143
144
145
146 #define AHC_MAXTRANSFER_SIZE MIN(MAXPHYS,0x00ffffff)
147
148
149
150
151
152
153 #define AHC_SCB_MAX 255
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173 #define AHC_MAX_QUEUE 253
174
175
176
177
178
179
180 #define AHC_SCB_MAX_ALLOC (AHC_MAX_QUEUE+1)
181
182
183
184
185
186
187 #define AHC_TMODE_CMDS 256
188
189
190 #define AHC_BUSRESET_DELAY 25
191
192
193
194
195
196
197 typedef enum {
198 AHC_NONE = 0x0000,
199 AHC_CHIPID_MASK = 0x00FF,
200 AHC_AIC7770 = 0x0001,
201 AHC_AIC7850 = 0x0002,
202 AHC_AIC7855 = 0x0003,
203 AHC_AIC7859 = 0x0004,
204 AHC_AIC7860 = 0x0005,
205 AHC_AIC7870 = 0x0006,
206 AHC_AIC7880 = 0x0007,
207 AHC_AIC7895 = 0x0008,
208 AHC_AIC7895C = 0x0009,
209 AHC_AIC7890 = 0x000a,
210 AHC_AIC7896 = 0x000b,
211 AHC_AIC7892 = 0x000c,
212 AHC_AIC7899 = 0x000d,
213 AHC_VL = 0x0100,
214 AHC_EISA = 0x0200,
215 AHC_PCI = 0x0400,
216 AHC_BUS_MASK = 0x0F00
217 } ahc_chip;
218
219
220
221
222 typedef enum {
223 AHC_FENONE = 0x00000,
224 AHC_ULTRA = 0x00001,
225 AHC_ULTRA2 = 0x00002,
226 AHC_WIDE = 0x00004,
227 AHC_TWIN = 0x00008,
228 AHC_MORE_SRAM = 0x00010,
229 AHC_CMD_CHAN = 0x00020,
230 AHC_QUEUE_REGS = 0x00040,
231 AHC_SG_PRELOAD = 0x00080,
232 AHC_SPIOCAP = 0x00100,
233 AHC_MULTI_TID = 0x00200,
234 AHC_HS_MAILBOX = 0x00400,
235 AHC_DT = 0x00800,
236 AHC_NEW_TERMCTL = 0x01000,
237 AHC_MULTI_FUNC = 0x02000,
238 AHC_LARGE_SCBS = 0x04000,
239 AHC_AUTORATE = 0x08000,
240 AHC_AUTOPAUSE = 0x10000,
241 AHC_TARGETMODE = 0x20000,
242 AHC_MULTIROLE = 0x40000,
243 AHC_REMOVABLE = 0x80000,
244 AHC_AIC7770_FE = AHC_FENONE,
245
246
247
248
249
250
251
252 AHC_AIC7850_FE = AHC_SPIOCAP|AHC_AUTOPAUSE|AHC_TARGETMODE|AHC_ULTRA,
253 AHC_AIC7860_FE = AHC_AIC7850_FE,
254 AHC_AIC7870_FE = AHC_TARGETMODE|AHC_AUTOPAUSE,
255 AHC_AIC7880_FE = AHC_AIC7870_FE|AHC_ULTRA,
256
257
258
259
260
261
262
263
264
265 AHC_AIC7890_FE = AHC_MORE_SRAM|AHC_CMD_CHAN|AHC_ULTRA2
266 |AHC_QUEUE_REGS|AHC_SG_PRELOAD|AHC_MULTI_TID
267 |AHC_HS_MAILBOX|AHC_NEW_TERMCTL|AHC_LARGE_SCBS
268 |AHC_TARGETMODE,
269 AHC_AIC7892_FE = AHC_AIC7890_FE|AHC_DT|AHC_AUTORATE|AHC_AUTOPAUSE,
270 AHC_AIC7895_FE = AHC_AIC7880_FE|AHC_MORE_SRAM|AHC_AUTOPAUSE
271 |AHC_CMD_CHAN|AHC_MULTI_FUNC|AHC_LARGE_SCBS,
272 AHC_AIC7895C_FE = AHC_AIC7895_FE|AHC_MULTI_TID,
273 AHC_AIC7896_FE = AHC_AIC7890_FE|AHC_MULTI_FUNC,
274 AHC_AIC7899_FE = AHC_AIC7892_FE|AHC_MULTI_FUNC
275 } ahc_feature;
276
277
278
279
280 typedef enum {
281 AHC_BUGNONE = 0x00,
282
283
284
285
286
287 AHC_TMODE_WIDEODD_BUG = 0x01,
288
289
290
291
292
293 AHC_AUTOFLUSH_BUG = 0x02,
294
295
296
297 AHC_CACHETHEN_BUG = 0x04,
298
299
300
301
302 AHC_CACHETHEN_DIS_BUG = 0x08,
303
304
305
306 AHC_PCI_2_1_RETRY_BUG = 0x10,
307
308
309
310
311
312 AHC_PCI_MWI_BUG = 0x20,
313
314
315
316
317
318
319 AHC_SCBCHAN_UPLOAD_BUG = 0x40
320 } ahc_bug;
321
322
323
324
325
326
327 typedef enum {
328 AHC_FNONE = 0x000,
329 AHC_PRIMARY_CHANNEL = 0x003,
330
331
332
333 AHC_USEDEFAULTS = 0x004,
334
335
336
337
338
339 AHC_SEQUENCER_DEBUG = 0x008,
340 AHC_SHARED_SRAM = 0x010,
341 AHC_LARGE_SEEPROM = 0x020,
342 AHC_RESET_BUS_A = 0x040,
343 AHC_RESET_BUS_B = 0x080,
344 AHC_EXTENDED_TRANS_A = 0x100,
345 AHC_EXTENDED_TRANS_B = 0x200,
346 AHC_TERM_ENB_A = 0x400,
347 AHC_TERM_ENB_B = 0x800,
348 AHC_INITIATORROLE = 0x1000,
349
350
351
352 AHC_TARGETROLE = 0x2000,
353
354
355
356 AHC_NEWEEPROM_FMT = 0x4000,
357 AHC_RESOURCE_SHORTAGE = 0x8000,
358 AHC_TQINFIFO_BLOCKED = 0x10000,
359 AHC_INT50_SPEEDFLEX = 0x20000,
360
361
362
363 AHC_SCB_BTT = 0x40000,
364
365
366
367
368 AHC_BIOS_ENABLED = 0x80000,
369 AHC_ALL_INTERRUPTS = 0x100000,
370 AHC_PAGESCBS = 0x400000,
371 AHC_EDGE_INTERRUPT = 0x800000,
372 AHC_39BIT_ADDRESSING = 0x1000000,
373 AHC_LSCBS_ENABLED = 0x2000000,
374 AHC_SCB_CONFIG_USED = 0x4000000,
375 AHC_NO_BIOS_INIT = 0x8000000,
376 AHC_DISABLE_PCI_PERR = 0x10000000,
377 AHC_HAS_TERM_LOGIC = 0x20000000,
378 AHC_SHUTDOWN_RECOVERY = 0x40000000
379 } ahc_flag;
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 struct status_pkt {
406 uint32_t residual_datacnt;
407 uint32_t residual_sg_ptr;
408 uint8_t scsi_status;
409 };
410
411
412
413
414 struct target_data {
415 uint32_t residual_datacnt;
416 uint32_t residual_sg_ptr;
417 uint8_t scsi_status;
418 uint8_t target_phases;
419 uint8_t data_phase;
420 uint8_t initiator_tag;
421 };
422
423 struct hardware_scb {
424 union {
425
426
427
428
429
430
431 uint8_t cdb[12];
432 uint32_t cdb_ptr;
433 struct status_pkt status;
434 struct target_data tdata;
435 } shared_data;
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 uint32_t dataptr;
474 uint32_t datacnt;
475
476
477
478
479 uint32_t sgptr;
480 #define SG_PTR_MASK 0xFFFFFFF8
481 uint8_t control;
482 uint8_t scsiid;
483 uint8_t lun;
484 uint8_t tag;
485
486
487
488 uint8_t cdb_len;
489 uint8_t scsirate;
490 uint8_t scsioffset;
491 uint8_t next;
492
493
494
495
496
497 uint8_t cdb32[32];
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 struct ahc_dma_seg {
524 uint32_t addr;
525 uint32_t len;
526 #define AHC_DMA_LAST_SEG 0x80000000
527 #define AHC_SG_HIGH_ADDR_MASK 0x7F000000
528 #define AHC_SG_LEN_MASK 0x00FFFFFF
529 };
530
531 struct sg_map_node {
532 bus_dmamap_t sg_dmamap;
533 bus_addr_t sg_physaddr;
534 bus_dma_segment_t sg_dmasegs;
535 int sg_nseg;
536 struct ahc_dma_seg* sg_vaddr;
537 SLIST_ENTRY(sg_map_node) links;
538 };
539
540 struct ahc_pci_busdata {
541 pci_chipset_tag_t pc;
542 pcitag_t tag;
543 u_int dev;
544 u_int func;
545 pcireg_t class;
546 };
547
548
549
550
551 typedef enum {
552 SCB_FLAG_NONE = 0x0000,
553 SCB_OTHERTCL_TIMEOUT = 0x0002,
554
555
556
557
558
559
560
561 SCB_DEVICE_RESET = 0x0004,
562 SCB_SENSE = 0x0008,
563 SCB_CDB32_PTR = 0x0010,
564 SCB_AUTO_NEGOTIATE = 0x0040,
565 SCB_NEGOTIATE = 0x0080,
566 SCB_ABORT = 0x0100,
567 SCB_UNTAGGEDQ = 0x0200,
568 SCB_ACTIVE = 0x0400,
569 SCB_TARGET_IMMEDIATE = 0x0800,
570 SCB_TRANSMISSION_ERROR = 0x1000,
571
572
573
574
575
576
577
578
579
580 SCB_TARGET_SCB = 0x2000,
581 SCB_SILENT = 0x4000
582
583
584
585
586
587 } scb_flag;
588
589 struct scb {
590 struct hardware_scb *hscb;
591 union {
592 SLIST_ENTRY(scb) sle;
593 TAILQ_ENTRY(scb) tqe;
594 } links;
595 LIST_ENTRY(scb) pending_links;
596
597 struct scsipi_xfer *xs;
598 struct ahc_softc *ahc_softc;
599 scb_flag flags;
600 #ifndef __linux__
601 bus_dmamap_t dmamap;
602 #endif
603 struct scb_platform_data *platform_data;
604 struct sg_map_node *sg_map;
605 struct ahc_dma_seg *sg_list;
606 bus_addr_t sg_list_phys;
607 u_int sg_count;
608 };
609
610 struct scb_data {
611 SLIST_HEAD(, scb) free_scbs;
612
613
614
615 struct scb *scbindex[256];
616
617
618
619
620
621
622
623
624 struct hardware_scb *hscbs;
625 struct scb *scbarray;
626 struct scsipi_sense_data *sense;
627
628
629
630
631 bus_dmamap_t hscb_dmamap;
632 bus_addr_t hscb_busaddr;
633 bus_dma_segment_t hscb_seg;
634 int hscb_nseg;
635 int hscb_size;
636
637 bus_dmamap_t sense_dmamap;
638 bus_addr_t sense_busaddr;
639 bus_dma_segment_t sense_seg;
640 int sense_nseg;
641 int sense_size;
642
643 SLIST_HEAD(, sg_map_node) sg_maps;
644 uint8_t numscbs;
645 uint8_t maxhscbs;
646 uint8_t init_level;
647
648
649
650 };
651
652
653
654
655
656
657 struct target_cmd {
658 uint8_t scsiid;
659 uint8_t identify;
660 uint8_t bytes[22];
661
662
663
664
665 uint8_t cmd_valid;
666
667
668
669
670
671
672
673
674
675
676 uint8_t pad[7];
677 };
678
679
680
681
682
683 #define AHC_TMODE_EVENT_BUFFER_SIZE 8
684 struct ahc_tmode_event {
685 uint8_t initiator_id;
686 uint8_t event_type;
687 #define EVENT_TYPE_BUS_RESET 0xFF
688 uint8_t event_arg;
689 };
690
691
692
693
694
695
696
697
698 #ifdef AHC_TARGET_MODE
699 struct ahc_tmode_lstate {
700 #if 0
701 struct cam_path *path;
702 struct ccb_hdr_slist accept_tios;
703 struct ccb_hdr_slist immed_notifies;
704 #endif
705 struct ahc_tmode_event event_buffer[AHC_TMODE_EVENT_BUFFER_SIZE];
706 uint8_t event_r_idx;
707 uint8_t event_w_idx;
708 };
709 #else
710 struct ahc_tmode_lstate;
711 #endif
712
713
714 #define AHC_TRANS_CUR 0x01
715 #define AHC_TRANS_ACTIVE 0x03
716 #define AHC_TRANS_GOAL 0x04
717 #define AHC_TRANS_USER 0x08
718
719 #define AHC_WIDTH_UNKNOWN 0xFF
720 #define AHC_PERIOD_UNKNOWN 0xFF
721 #define AHC_OFFSET_UNKNOWN 0xFF
722 #define AHC_PPR_OPTS_UNKNOWN 0xFF
723
724
725
726
727 struct ahc_transinfo {
728 uint8_t protocol_version;
729 uint8_t transport_version;
730 uint8_t width;
731 uint8_t period;
732 uint8_t offset;
733 uint8_t ppr_options;
734 };
735
736
737
738 struct ahc_initiator_tinfo {
739 uint8_t scsirate;
740 struct ahc_transinfo curr;
741 struct ahc_transinfo goal;
742 struct ahc_transinfo user;
743 };
744
745
746
747
748
749
750
751
752 struct ahc_tmode_tstate {
753 struct ahc_tmode_lstate* enabled_luns[AHC_NUM_LUNS];
754 struct ahc_initiator_tinfo transinfo[AHC_NUM_TARGETS];
755
756
757
758
759 uint16_t auto_negotiate;
760 uint16_t ultraenb;
761 uint16_t discenable;
762 uint16_t tagenable;
763 };
764
765
766
767
768 struct ahc_syncrate {
769 u_int sxfr_u2;
770 u_int sxfr;
771 #define ULTRA_SXFR 0x100
772 #define ST_SXFR 0x010
773 #define DT_SXFR 0x040
774 uint8_t period;
775 char *rate;
776 };
777
778
779 #define AHC_ASYNC_XFER_PERIOD 0x45
780 #define AHC_ULTRA2_XFER_PERIOD 0x0a
781
782
783
784
785 #define AHC_SYNCRATE_DT 0
786 #define AHC_SYNCRATE_ULTRA2 1
787 #define AHC_SYNCRATE_ULTRA 3
788 #define AHC_SYNCRATE_FAST 6
789 #define AHC_SYNCRATE_MAX AHC_SYNCRATE_DT
790 #define AHC_SYNCRATE_MIN 13
791
792
793
794
795
796
797 struct ahc_phase_table_entry {
798 uint8_t phase;
799 uint8_t mesg_out;
800 char *phasemsg;
801 };
802
803
804
805 struct seeprom_config {
806
807
808
809 uint16_t device_flags[16];
810 #define CFXFER 0x0007
811 #define CFSYNCH 0x0008
812 #define CFDISC 0x0010
813 #define CFWIDEB 0x0020
814 #define CFSYNCHISULTRA 0x0040
815 #define CFSYNCSINGLE 0x0080
816 #define CFSTART 0x0100
817 #define CFINCBIOS 0x0200
818 #define CFRNFOUND 0x0400
819 #define CFMULTILUNDEV 0x0800
820 #define CFWBCACHEENB 0x4000
821 #define CFWBCACHENOP 0xc000
822
823
824
825
826 uint16_t bios_control;
827 #define CFSUPREM 0x0001
828 #define CFSUPREMB 0x0002
829 #define CFBIOSEN 0x0004
830 #define CFBIOS_BUSSCAN 0x0008
831 #define CFSM2DRV 0x0010
832 #define CFSTPWLEVEL 0x0010
833 #define CF284XEXTEND 0x0020
834 #define CFCTRL_A 0x0020
835 #define CFTERM_MENU 0x0040
836 #define CFEXTEND 0x0080
837 #define CFSCAMEN 0x0100
838 #define CFMSG_LEVEL 0x0600
839 #define CFMSG_VERBOSE 0x0000
840 #define CFMSG_SILENT 0x0200
841 #define CFMSG_DIAG 0x0400
842 #define CFBOOTCD 0x0800
843
844
845
846
847
848 uint16_t adapter_control;
849 #define CFAUTOTERM 0x0001
850 #define CFULTRAEN 0x0002
851 #define CF284XSELTO 0x0003
852 #define CF284XFIFO 0x000C
853 #define CFSTERM 0x0004
854 #define CFWSTERM 0x0008
855 #define CFSPARITY 0x0010
856 #define CF284XSTERM 0x0020
857 #define CFMULTILUN 0x0020
858 #define CFRESETB 0x0040
859 #define CFCLUSTERENB 0x0080
860 #define CFBOOTCHAN 0x0300
861 #define CFBOOTCHANSHIFT 8
862 #define CFSEAUTOTERM 0x0400
863 #define CFSELOWTERM 0x0800
864 #define CFSEHIGHTERM 0x1000
865 #define CFENABLEDV 0x4000
866
867
868
869
870 uint16_t brtime_id;
871 #define CFSCSIID 0x000f
872
873 #define CFBRTIME 0xff00
874
875
876
877
878 uint16_t max_targets;
879 #define CFMAXTARG 0x00ff
880 #define CFBOOTLUN 0x0f00
881 #define CFBOOTID 0xf000
882 uint16_t res_1[10];
883 uint16_t signature;
884 #define CFSIGNATURE 0x250
885 #define CFSIGNATURE2 0x300
886 uint16_t checksum;
887 };
888
889
890 typedef enum {
891 MSG_TYPE_NONE = 0x00,
892 MSG_TYPE_INITIATOR_MSGOUT = 0x01,
893 MSG_TYPE_INITIATOR_MSGIN = 0x02,
894 MSG_TYPE_TARGET_MSGOUT = 0x03,
895 MSG_TYPE_TARGET_MSGIN = 0x04
896 } ahc_msg_type;
897
898 typedef enum {
899 MSGLOOP_IN_PROG,
900 MSGLOOP_MSGCOMPLETE,
901 MSGLOOP_TERMINATED
902 } msg_loop_stat;
903
904
905 TAILQ_HEAD(scb_tailq, scb);
906
907 struct ahc_aic7770_softc {
908
909
910
911 uint8_t busspd;
912 uint8_t bustime;
913 };
914
915 struct ahc_pci_softc {
916
917
918
919 uint32_t devconfig;
920 uint16_t targcrccnt;
921 uint8_t command;
922 uint8_t csize_lattime;
923 uint8_t optionmode;
924 uint8_t crccontrol1;
925 uint8_t dscommand0;
926 uint8_t dspcistatus;
927 uint8_t scbbaddr;
928 uint8_t dff_thrsh;
929 };
930
931 union ahc_bus_softc {
932 struct ahc_aic7770_softc aic7770_softc;
933 struct ahc_pci_softc pci_softc;
934 };
935
936 typedef void (*ahc_bus_intr_t)(struct ahc_softc *);
937 typedef int (*ahc_bus_chip_init_t)(struct ahc_softc *);
938 typedef void ahc_callback_t (void *);
939
940 struct ahc_softc {
941 struct device sc_dev;
942
943 struct scsipi_channel sc_channel;
944 struct scsipi_channel sc_channel_b;
945 struct device * sc_child;
946 struct device * sc_child_b;
947 struct scsipi_adapter sc_adapter;
948
949 bus_space_tag_t tag;
950 bus_space_handle_t bsh;
951
952 #ifndef __linux__
953 bus_dma_tag_t buffer_dmat;
954 #endif
955 struct scb_data *scb_data;
956
957 struct scb *next_queued_scb;
958
959
960
961
962 LIST_HEAD(, scb) pending_scbs;
963
964
965
966
967
968
969
970 u_int untagged_queue_lock;
971
972
973
974
975
976
977
978
979 struct scb_tailq untagged_queues[AHC_NUM_TARGETS];
980
981
982
983
984 union ahc_bus_softc bus_softc;
985
986
987
988
989 struct ahc_platform_data *platform_data;
990
991
992
993
994 ahc_dev_softc_t dev_softc;
995
996
997
998
999 ahc_bus_intr_t bus_intr;
1000
1001
1002
1003
1004
1005 ahc_bus_chip_init_t bus_chip_init;
1006
1007
1008
1009
1010
1011
1012
1013 struct ahc_tmode_tstate *enabled_targets[AHC_NUM_TARGETS];
1014
1015 char inited_target[AHC_NUM_TARGETS];
1016
1017
1018
1019
1020
1021 struct ahc_tmode_lstate *black_hole;
1022
1023
1024
1025
1026
1027 struct ahc_tmode_lstate *pending_device;
1028
1029
1030
1031
1032 ahc_chip chip;
1033 ahc_feature features;
1034 ahc_bug bugs;
1035 ahc_flag flags;
1036 struct seeprom_config *seep_config;
1037
1038
1039 uint8_t unpause;
1040 uint8_t pause;
1041
1042
1043 uint8_t qoutfifonext;
1044 uint8_t qinfifonext;
1045 uint8_t *qoutfifo;
1046 uint8_t *qinfifo;
1047
1048
1049 struct cs *critical_sections;
1050 u_int num_critical_sections;
1051
1052
1053 TAILQ_ENTRY(ahc_softc) links;
1054
1055
1056 char channel;
1057 char channel_b;
1058
1059
1060 uint8_t our_id;
1061 uint8_t our_id_b;
1062
1063
1064
1065
1066 int unsolicited_ints;
1067
1068
1069
1070
1071 struct target_cmd *targetcmds;
1072 uint8_t tqinfifonext;
1073
1074
1075
1076
1077 uint8_t seqctl;
1078
1079
1080
1081
1082 uint8_t send_msg_perror;
1083 ahc_msg_type msg_type;
1084 uint8_t msgout_buf[12];
1085 uint8_t msgin_buf[12];
1086 u_int msgout_len;
1087 u_int msgout_index;
1088 u_int msgin_index;
1089
1090
1091 void *ih;
1092
1093
1094
1095
1096
1097 bus_dma_tag_t parent_dmat;
1098 bus_dmamap_t shared_data_dmamap;
1099 bus_addr_t shared_data_busaddr;
1100
1101 bus_dma_segment_t shared_data_seg;
1102 int shared_data_nseg;
1103 int shared_data_size;
1104 int sc_dmaflags;
1105
1106
1107
1108
1109
1110
1111 bus_addr_t dma_bug_buf;
1112
1113
1114 u_int enabled_luns;
1115
1116
1117 u_int init_level;
1118
1119
1120 u_int pci_cachesize;
1121
1122
1123
1124
1125
1126
1127 u_int pci_target_perr_count;
1128 #define AHC_PCI_TARGET_PERR_THRESH 10
1129
1130
1131 u_int instruction_ram_size;
1132
1133
1134 char *name;
1135 int unit;
1136
1137
1138 int seltime;
1139 int seltime_b;
1140
1141 uint16_t user_discenable;
1142 uint16_t user_tagenable;
1143
1144 struct ahc_pci_busdata *bd;
1145
1146 void *shutdown_hook;
1147 };
1148
1149 TAILQ_HEAD(ahc_softc_tailq, ahc_softc);
1150 extern struct ahc_softc_tailq ahc_tailq;
1151
1152
1153 typedef enum {
1154 ROLE_UNKNOWN,
1155 ROLE_INITIATOR,
1156 ROLE_TARGET
1157 } role_t;
1158
1159 struct ahc_devinfo {
1160 int our_scsiid;
1161 int target_offset;
1162 uint16_t target_mask;
1163 u_int target;
1164 u_int lun;
1165 char channel;
1166 role_t role;
1167
1168
1169
1170 };
1171
1172
1173 typedef int (ahc_device_setup_t)(struct ahc_softc *);
1174
1175 struct ahc_pci_identity {
1176 uint64_t full_id;
1177 uint64_t id_mask;
1178 ahc_device_setup_t *setup;
1179 };
1180 extern struct ahc_pci_identity ahc_pci_ident_table[];
1181
1182
1183 struct aic7770_identity {
1184 uint32_t full_id;
1185 uint32_t id_mask;
1186 const char *name;
1187 ahc_device_setup_t *setup;
1188 };
1189 extern struct aic7770_identity aic7770_ident_table[];
1190 extern const int ahc_num_aic7770_devs;
1191
1192 #define AHC_EISA_SLOT_OFFSET 0xc00
1193 #define AHC_EISA_IOSIZE 0x100
1194
1195
1196
1197 u_int ahc_index_busy_tcl(struct ahc_softc *, u_int);
1198 void ahc_unbusy_tcl(struct ahc_softc *, u_int);
1199 void ahc_busy_tcl(struct ahc_softc *, u_int, u_int);
1200
1201
1202 const struct ahc_pci_identity *ahc_find_pci_device(pcireg_t, pcireg_t, u_int);
1203 int ahc_pci_config(struct ahc_softc *,
1204 struct ahc_pci_identity *);
1205 int ahc_pci_test_register_access(struct ahc_softc *);
1206
1207
1208 struct aic7770_identity *aic7770_find_device(uint32_t);
1209 int aic7770_config(struct ahc_softc *,
1210 struct aic7770_identity *, u_int);
1211
1212
1213 int ahc_probe_scbs(struct ahc_softc *);
1214 void ahc_run_untagged_queues(struct ahc_softc *ahc);
1215 void ahc_run_untagged_queue(struct ahc_softc *ahc,
1216 struct scb_tailq *queue);
1217 void ahc_qinfifo_requeue_tail(struct ahc_softc *ahc,
1218 struct scb *scb);
1219 int ahc_match_scb(struct ahc_softc *ahc, struct scb *scb,
1220 int target, char channel, int lun,
1221 u_int tag, role_t role);
1222
1223
1224 int ahc_softc_init(struct ahc_softc *);
1225 #ifndef DEBUG
1226 void ahc_controller_info(struct ahc_softc *, char *, size_t);
1227 #endif
1228 int ahc_chip_init(struct ahc_softc *ahc);
1229 int ahc_init(struct ahc_softc *ahc);
1230 void ahc_intr_enable(struct ahc_softc *ahc, int enable);
1231 void ahc_softc_insert(struct ahc_softc *);
1232 void ahc_set_unit(struct ahc_softc *, int);
1233 void ahc_set_name(struct ahc_softc *, char *);
1234 void ahc_alloc_scbs(struct ahc_softc *ahc);
1235 void ahc_free(struct ahc_softc *ahc);
1236 int ahc_reset(struct ahc_softc *ahc, int reinit);
1237 void ahc_shutdown(void *arg);
1238
1239
1240 void ahc_pci_intr(struct ahc_softc *);
1241 void ahc_clear_intstat(struct ahc_softc *);
1242 void ahc_run_qoutfifo(struct ahc_softc *);
1243 #ifdef AHC_TARGET_MODE
1244 void ahc_run_tqinfifo(struct ahc_softc *ahc, int paused);
1245 #endif
1246 void ahc_handle_brkadrint(struct ahc_softc *ahc);
1247 void ahc_handle_seqint(struct ahc_softc *ahc, u_int intstat);
1248 void ahc_handle_scsiint(struct ahc_softc *ahc,
1249 u_int intstat);
1250 void ahc_clear_critical_section(struct ahc_softc *ahc);
1251
1252
1253 typedef enum {
1254 SEARCH_COMPLETE,
1255 SEARCH_COUNT,
1256 SEARCH_REMOVE
1257 } ahc_search_action;
1258 int ahc_search_qinfifo(struct ahc_softc *, int, char,
1259 int, u_int, role_t, uint32_t, ahc_search_action);
1260 int ahc_search_untagged_queues(struct ahc_softc *,
1261 struct scsipi_xfer *, int, char, int, uint32_t,
1262 ahc_search_action);
1263 int ahc_search_disc_list(struct ahc_softc *, int, char,
1264 int, u_int, int, int, int);
1265 void ahc_freeze_devq(struct ahc_softc *, struct scb *);
1266 int ahc_reset_channel(struct ahc_softc *, char, int);
1267 int ahc_abort_scbs(struct ahc_softc *, int, char, int,
1268 u_int, role_t, uint32_t);
1269 void ahc_restart(struct ahc_softc *);
1270 void ahc_calc_residual(struct ahc_softc *, struct scb *);
1271
1272 struct ahc_phase_table_entry*
1273 ahc_lookup_phase_entry(int phase);
1274 void ahc_compile_devinfo(struct ahc_devinfo *devinfo,
1275 u_int our_id, u_int target,
1276 u_int lun, char channel,
1277 role_t role);
1278
1279 struct ahc_syncrate* ahc_find_syncrate(struct ahc_softc *ahc, u_int *period,
1280 u_int *ppr_options, u_int maxsync);
1281 u_int ahc_find_period(struct ahc_softc *ahc,
1282 u_int scsirate, u_int maxsync);
1283 void ahc_validate_offset(struct ahc_softc *ahc,
1284 struct ahc_initiator_tinfo *tinfo,
1285 struct ahc_syncrate *syncrate,
1286 u_int *offset, int wide,
1287 role_t role);
1288 void ahc_validate_width(struct ahc_softc *ahc,
1289 struct ahc_initiator_tinfo *tinfo,
1290 u_int *bus_width,
1291 role_t role);
1292
1293
1294
1295
1296 typedef enum {
1297 AHC_NEG_TO_GOAL,
1298 AHC_NEG_IF_NON_ASYNC,
1299 AHC_NEG_ALWAYS
1300 } ahc_neg_type;
1301 int ahc_update_neg_request(struct ahc_softc *,
1302 struct ahc_devinfo *, struct ahc_tmode_tstate *,
1303 struct ahc_initiator_tinfo*, ahc_neg_type);
1304 void ahc_set_width(struct ahc_softc *, struct ahc_devinfo *,
1305 u_int, u_int, int);
1306 void ahc_set_syncrate(struct ahc_softc *,
1307 struct ahc_devinfo *, struct ahc_syncrate *,
1308 u_int, u_int, u_int, u_int, int);
1309 void ahc_scb_devinfo(struct ahc_softc *,
1310 struct ahc_devinfo *, struct scb *);
1311
1312
1313 typedef enum {
1314 AHC_QUEUE_NONE,
1315 AHC_QUEUE_BASIC,
1316 AHC_QUEUE_TAGGED
1317 } ahc_queue_alg;
1318
1319 void ahc_set_tags(struct ahc_softc *ahc,
1320 struct ahc_devinfo *devinfo,
1321 ahc_queue_alg alg);
1322
1323
1324 #ifdef AHC_TARGET_MODE
1325 void ahc_send_lstate_events(struct ahc_softc *,
1326 struct ahc_tmode_lstate *);
1327 void ahc_handle_en_lun(struct ahc_softc *, struct scsipi_xfer *);
1328 cam_status ahc_find_tmode_devs(struct ahc_softc *,
1329 struct ahc_tmode_tstate **, struct ahc_tmode_lstate **,
1330 int);
1331 #ifndef AHC_TMODE_ENABLE
1332 #define AHC_TMODE_ENABLE 0
1333 #endif
1334 #endif
1335
1336 #ifdef AHC_DEBUG
1337 extern uint32_t ahc_debug;
1338 #define AHC_SHOW_MISC 0x0001
1339 #define AHC_SHOW_SENSE 0x0002
1340 #define AHC_DUMP_SEEPROM 0x0004
1341 #define AHC_SHOW_TERMCTL 0x0008
1342 #define AHC_SHOW_MEMORY 0x0010
1343 #define AHC_SHOW_MESSAGES 0x0020
1344 #define AHC_SHOW_DV 0x0040
1345 #define AHC_SHOW_SELTO 0x0080
1346 #define AHC_SHOW_QFULL 0x0200
1347 #define AHC_SHOW_QUEUE 0x0400
1348 #define AHC_SHOW_TQIN 0x0800
1349 #define AHC_SHOW_MASKED_ERRORS 0x1000
1350 #define AHC_DEBUG_SEQUENCER 0x2000
1351 #endif
1352 void ahc_print_scb(struct scb *scb);
1353 void ahc_print_devinfo(struct ahc_softc *ahc,
1354 struct ahc_devinfo *dev);
1355 void ahc_dump_card_state(struct ahc_softc *ahc);
1356 int ahc_print_register(ahc_reg_parse_entry_t *table,
1357 u_int num_entries,
1358 const char *name,
1359 u_int address,
1360 u_int value,
1361 u_int *cur_column,
1362 u_int wrap_point);
1363
1364 int ahc_acquire_seeprom(struct ahc_softc *ahc,
1365 struct seeprom_descriptor *sd);
1366 void ahc_release_seeprom(struct seeprom_descriptor *sd);
1367
1368 void ahc_check_extport(struct ahc_softc *, u_int *);
1369 #endif