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