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
|
/*-
* Copyright (c) 1999 Luoqi Chen.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
struct aic_transinfo {
u_int8_t period;
u_int8_t offset;
};
struct aic_tinfo {
u_int16_t lubusy;
u_int8_t flags;
u_int8_t scsirate;
struct aic_transinfo current;
struct aic_transinfo goal;
struct aic_transinfo user;
};
#define TINFO_DISC_ENB 0x01
#define TINFO_TAG_ENB 0x02
#define TINFO_SDTR_NEGO 0x04
#define TINFO_SDTR_SENT 0x08
struct aic_scb {
union ccb *ccb;
u_int8_t flags;
u_int8_t tag;
u_int8_t target;
u_int8_t lun;
u_int8_t status;
u_int8_t cmd_len;
u_int8_t *cmd_ptr;
u_int32_t data_len;
u_int8_t *data_ptr;
};
#define ccb_scb_ptr spriv_ptr0
#define ccb_aic_ptr spriv_ptr1
#define SCB_ACTIVE 0x01
#define SCB_DISCONNECTED 0x02
#define SCB_DEVICE_RESET 0x04
#define SCB_SENSE 0x08
enum { AIC6260, AIC6360, AIC6370, GM82C700 };
struct aic_softc {
device_t dev;
int unit;
bus_space_tag_t tag;
bus_space_handle_t bsh;
bus_dma_tag_t dmat;
struct cam_sim *sim;
struct cam_path *path;
TAILQ_HEAD(,ccb_hdr) pending_ccbs, nexus_ccbs;
struct aic_scb *nexus;
u_int32_t flags;
u_int8_t initiator;
u_int8_t state;
u_int8_t target;
u_int8_t lun;
u_int8_t prev_phase;
u_int8_t msg_outq;
u_int8_t msg_sent;
int msg_len;
char msg_buf[8];
struct aic_tinfo tinfo[8];
struct aic_scb scbs[256];
int min_period;
int max_period;
int chip_type;
};
#define AIC_DISC_ENABLE 0x01
#define AIC_DMA_ENABLE 0x02
#define AIC_PARITY_ENABLE 0x04
#define AIC_DWIO_ENABLE 0x08
#define AIC_RESOURCE_SHORTAGE 0x10
#define AIC_DROP_MSGIN 0x20
#define AIC_BUSFREE_OK 0x40
#define AIC_FAST_ENABLE 0x80
#define AIC_IDLE 0x00
#define AIC_SELECTING 0x01
#define AIC_RESELECTED 0x02
#define AIC_RECONNECTING 0x03
#define AIC_HASNEXUS 0x04
#define AIC_MSG_IDENTIFY 0x01
#define AIC_MSG_TAG_Q 0x02
#define AIC_MSG_SDTR 0x04
#define AIC_MSG_WDTR 0x08
#define AIC_MSG_MSGBUF 0x80
#define AIC_SYNC_PERIOD (200 / 4)
#define AIC_FAST_SYNC_PERIOD (100 / 4)
#define AIC_MIN_SYNC_PERIOD 112
#define AIC_SYNC_OFFSET 8
#define aic_inb(aic, port) \
bus_space_read_1((aic)->tag, (aic)->bsh, (port))
#define aic_outb(aic, port, value) \
bus_space_write_1((aic)->tag, (aic)->bsh, (port), (value))
#define aic_insb(aic, port, addr, count) \
bus_space_read_multi_1((aic)->tag, (aic)->bsh, (port), (addr), (count))
#define aic_outsb(aic, port, addr, count) \
bus_space_write_multi_1((aic)->tag, (aic)->bsh, (port), (addr), (count))
#define aic_insw(aic, port, addr, count) \
bus_space_read_multi_2((aic)->tag, (aic)->bsh, (port), \
(u_int16_t *)(addr), (count))
#define aic_outsw(aic, port, addr, count) \
bus_space_write_multi_2((aic)->tag, (aic)->bsh, (port), \
(u_int16_t *)(addr), (count))
#define aic_insl(aic, port, addr, count) \
bus_space_read_multi_4((aic)->tag, (aic)->bsh, (port), \
(u_int32_t *)(addr), (count))
#define aic_outsl(aic, port, addr, count) \
bus_space_write_multi_4((aic)->tag, (aic)->bsh, (port), \
(u_int32_t *)(addr), (count))
extern int aic_probe(struct aic_softc *);
extern int aic_attach(struct aic_softc *);
extern int aic_detach(struct aic_softc *);
extern void aic_intr(void *);
|