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
|
/* $OpenBSD: siopvar.h,v 1.15 2010/07/23 07:47:13 jsg Exp $ */
/* $NetBSD: siopvar.h,v 1.22 2005/11/18 23:10:32 bouyer Exp $ */
/*
* Copyright (c) 2000 Manuel Bouyer.
*
* 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 ``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 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.
*
*/
/* structure and definitions for the siop driver */
/* Number of tag */
#define SIOP_NTAG 16
/*
* xfer description of the script: tables and reselect script
* In struct siop_common_cmd siop_xfer will point to this.
*/
struct siop_xfer {
struct siop_common_xfer siop_tables;
/* u_int32_t resel[sizeof(load_dsa) / sizeof(load_dsa[0])]; */
/* Add some entries to make size 384 bytes (256+128) */
u_int32_t resel[36];
} __packed;
/*
* This describes a command handled by the SCSI controller
* These are chained in either a free list or an active list
* We have one queue per target
*/
struct siop_cmd {
TAILQ_ENTRY (siop_cmd) next;
struct siop_common_cmd cmd_c;
struct siop_cbd *siop_cbdp; /* pointer to our siop_cbd */
int reselslot;
u_int32_t saved_offset; /* offset in table after disc without sdp */
};
#define cmd_tables cmd_c.siop_tables
/* command block descriptors: an array of siop_cmd + an array of siop_xfer */
struct siop_cbd {
TAILQ_ENTRY (siop_cbd) next;
struct siop_cmd *cmds;
struct siop_xfer *xfers;
bus_dmamap_t xferdma; /* DMA map for this block of xfers */
};
/* per-tag struct */
struct siop_tag {
struct siop_cmd *active; /* active command */
u_int reseloff;
};
/* per lun struct */
struct siop_lun {
struct siop_tag siop_tag[SIOP_NTAG]; /* tag array */
int lun_flags;
#define SIOP_LUNF_FULL 0x01 /* queue full message */
u_int reseloff;
};
/*
* per target struct; siop_common_cmd->target and siop_common_softc->targets[]
* will point to this
*/
struct siop_target {
struct siop_common_target target_c;
struct siop_lun *siop_lun[8]; /* per-lun state */
u_int reseloff;
struct siop_lunsw *lunsw;
};
struct siop_lunsw {
TAILQ_ENTRY (siop_lunsw) next;
u_int32_t lunsw_off; /* offset of this lun sw, from sc_scriptaddr*/
u_int32_t lunsw_size; /* size of this lun sw */
};
TAILQ_HEAD(cmd_list, siop_cmd);
TAILQ_HEAD(cbd_list, siop_cbd);
TAILQ_HEAD(lunsw_list, siop_lunsw);
/* Driver internal state */
struct siop_softc {
struct siop_common_softc sc_c;
int sc_currschedslot; /* current scheduler slot */
struct cbd_list cmds; /* list of command block descriptors */
struct cmd_list free_list; /* cmd descr free list */
struct cmd_list urgent_list; /* high priority cmd descr list */
struct cmd_list ready_list; /* cmd descr ready list */
struct scsi_iopool iopool; /* cmd pool */
struct lunsw_list lunsw_list; /* lunsw free list */
u_int32_t script_free_lo; /* free ram offset from sc_scriptaddr */
u_int32_t script_free_hi; /* free ram offset from sc_scriptaddr */
int sc_ntargets; /* number of known targets */
u_int32_t sc_flags;
};
/* defs for sc_flags */
#define SCF_CHAN_NOSLOT 0x0001 /* channel out of scheduler slot */
void siop_attach(struct siop_softc *);
int siop_intr(void *);
void siop_add_dev(struct siop_softc *, int, int);
void siop_del_dev(struct siop_softc *, int, int);
|