Annotation of sys/dev/ic/cacvar.h, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: cacvar.h,v 1.3 2003/03/06 22:31:21 mickey Exp $ */
2: /* $NetBSD: cacvar.h,v 1.7 2000/10/19 14:28:47 ad Exp $ */
3:
4: /*-
5: * Copyright (c) 2000 The NetBSD Foundation, Inc.
6: * All rights reserved.
7: *
8: * This code is derived from software contributed to The NetBSD Foundation
9: * by Andrew Doran.
10: *
11: * Redistribution and use in source and binary forms, with or without
12: * modification, are permitted provided that the following conditions
13: * are met:
14: * 1. Redistributions of source code must retain the above copyright
15: * notice, this list of conditions and the following disclaimer.
16: * 2. Redistributions in binary form must reproduce the above copyright
17: * notice, this list of conditions and the following disclaimer in the
18: * documentation and/or other materials provided with the distribution.
19: * 3. All advertising materials mentioning features or use of this software
20: * must display the following acknowledgement:
21: * This product includes software developed by the NetBSD
22: * Foundation, Inc. and its contributors.
23: * 4. Neither the name of The NetBSD Foundation nor the names of its
24: * contributors may be used to endorse or promote products derived
25: * from this software without specific prior written permission.
26: *
27: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37: * POSSIBILITY OF SUCH DAMAGE.
38: */
39:
40: #ifndef _IC_CACVAR_H_
41: #define _IC_CACVAR_H_
42:
43: #define CAC_MAX_CCBS 128
44: #define CAC_MAX_XFER (0xffff * 512)
45: #define CAC_SG_SIZE 32
46: #define CAC_SECTOR_SIZE 512
47:
48: #define cac_inb(sc, port) \
49: bus_space_read_1((sc)->sc_iot, (sc)->sc_ioh, port)
50: #define cac_inw(sc, port) \
51: bus_space_read_2((sc)->sc_iot, (sc)->sc_ioh, port)
52: #define cac_inl(sc, port) \
53: bus_space_read_4((sc)->sc_iot, (sc)->sc_ioh, port)
54: #define cac_outb(sc, port, val) \
55: bus_space_write_1((sc)->sc_iot, (sc)->sc_ioh, port, val)
56: #define cac_outw(sc, port, val) \
57: bus_space_write_2((sc)->sc_iot, (sc)->sc_ioh, port, val)
58: #define cac_outl(sc, port, val) \
59: bus_space_write_4((sc)->sc_iot, (sc)->sc_ioh, port, val)
60:
61: /*
62: * Stupid macros to deal with alignment/endianness issues.
63: */
64:
65: #define CAC_GET1(x) \
66: (((u_char *)&(x))[0])
67: #define CAC_GET2(x) \
68: (((u_char *)&(x))[0] | (((u_char *)&(x))[1] << 8))
69: #define CAC_GET4(x) \
70: ((((u_char *)&(x))[0] | (((u_char *)&(x))[1] << 8)) | \
71: (((u_char *)&(x))[0] << 16 | (((u_char *)&(x))[1] << 24)))
72:
73: struct cac_ccb {
74: /* Data the controller will touch - 276 bytes */
75: struct cac_hdr ccb_hdr;
76: struct cac_req ccb_req;
77: struct cac_sgb ccb_seg[CAC_SG_SIZE];
78:
79: /* Data the controller won't touch */
80: int ccb_flags;
81: int ccb_datasize;
82: paddr_t ccb_paddr;
83: bus_dmamap_t ccb_dmamap_xfer;
84: SIMPLEQ_ENTRY(cac_ccb) ccb_chain;
85: struct scsi_xfer *ccb_xs;
86: };
87:
88: #define CAC_CCB_DATA_IN 0x0001 /* Map describes inbound xfer */
89: #define CAC_CCB_DATA_OUT 0x0002 /* Map describes outbound xfer */
90: #define CAC_CCB_ACTIVE 0x0004 /* Command submitted to controller */
91:
92: struct cac_softc;
93:
94: struct cac_linkage {
95: struct cac_ccb *(*cl_completed)(struct cac_softc *);
96: int (*cl_fifo_full)(struct cac_softc *);
97: void (*cl_intr_enable)(struct cac_softc *, int);
98: int (*cl_intr_pending)(struct cac_softc *);
99: void (*cl_submit)(struct cac_softc *, struct cac_ccb *);
100: };
101:
102: struct cac_softc {
103: struct device sc_dv;
104: bus_space_tag_t sc_iot;
105: bus_space_handle_t sc_ioh;
106: bus_dma_tag_t sc_dmat;
107: bus_dmamap_t sc_dmamap;
108: int sc_nunits;
109: void *sc_ih;
110: struct scsi_link sc_link;
111: const struct cac_linkage *sc_cl;
112: caddr_t sc_ccbs;
113: paddr_t sc_ccbs_paddr;
114: SIMPLEQ_HEAD(, cac_ccb) sc_ccb_free;
115: SIMPLEQ_HEAD(, cac_ccb) sc_ccb_queue;
116: struct cac_drive_info *sc_dinfos;
117: };
118:
119: int cac_init(struct cac_softc *, int);
120: int cac_intr(void *);
121:
122: extern const struct cac_linkage cac_l0;
123:
124: #endif /* !_IC_CACVAR_H_ */
CVSweb