FreeBSD/Linux Kernel Cross Reference
sys/dev/ips/ips.h
1 /*-
2 * Copyright (c) 2002 Adaptec Inc.
3 * All rights reserved.
4 *
5 * Written by: David Jeffery
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD$
29 */
30 #ifndef _IPS_H
31 #define _IPS_H
32
33 #ifdef _KERNEL
34
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/kernel.h>
38 #include <sys/module.h>
39 #include <sys/bus.h>
40 #include <sys/conf.h>
41 #include <sys/types.h>
42 #include <sys/queue.h>
43 #include <sys/bio.h>
44 #include <sys/malloc.h>
45 #include <sys/mutex.h>
46 #include <sys/sema.h>
47 #include <sys/time.h>
48
49 #include <machine/bus.h>
50 #include <sys/rman.h>
51 #include <machine/resource.h>
52
53 MALLOC_DECLARE(M_IPSBUF);
54
55 /*
56 * IPS MACROS
57 */
58
59 #define ips_read_1(sc,offset) bus_space_read_1(sc->bustag, sc->bushandle, offset)
60 #define ips_read_2(sc,offset) bus_space_read_2(sc->bustag, sc->bushandle, offset)
61 #define ips_read_4(sc,offset) bus_space_read_4(sc->bustag, sc->bushandle, offset)
62
63 #define ips_write_1(sc,offset,value) bus_space_write_1(sc->bustag, sc->bushandle, offset, value)
64 #define ips_write_2(sc,offset,value) bus_space_write_2(sc->bustag, sc->bushandle, offset, value)
65 #define ips_write_4(sc,offset,value) bus_space_write_4(sc->bustag, sc->bushandle, offset, value)
66
67 /* this is ugly. It zeros the end elements in an ips_command_t struct starting with the status element */
68 #define clear_ips_command(command) bzero(&((command)->status), (unsigned long)(&(command)[1])-(unsigned long)&((command)->status))
69
70 #define ips_read_request(iobuf) ((iobuf)->bio_cmd == BIO_READ)
71
72 #define COMMAND_ERROR(command) (((command)->status.fields.basic_status & IPS_GSC_STATUS_MASK) >= IPS_MIN_ERROR)
73
74 #define ips_set_error(command, error) do { \
75 (command)->status.fields.basic_status = IPS_DRV_ERROR; \
76 (command)->status.fields.reserved = ((error) & 0x0f); \
77 } while (0)
78
79 #ifndef IPS_DEBUG
80 #define DEVICE_PRINTF(x...)
81 #define PRINTF(x...)
82 #else
83 #define DEVICE_PRINTF(level,x...) if(IPS_DEBUG >= level)device_printf(x)
84 #define PRINTF(level,x...) if(IPS_DEBUG >= level)printf(x)
85 #endif
86
87 struct ips_softc;
88
89 typedef struct {
90 u_int32_t status[IPS_MAX_CMD_NUM];
91 u_int32_t base_phys_addr;
92 int nextstatus;
93 bus_dma_tag_t dmatag;
94 bus_dmamap_t dmamap;
95 } ips_copper_queue_t;
96
97 /* used to keep track of current commands to the card */
98 typedef struct ips_command{
99 u_int8_t command_number;
100 u_int8_t id;
101 u_int8_t timeout;
102 struct ips_softc * sc;
103 bus_dma_tag_t data_dmatag;
104 bus_dmamap_t data_dmamap;
105 bus_dmamap_t command_dmamap;
106 void * command_buffer;
107 u_int32_t command_phys_addr;/*WARNING! must be changed if 64bit addressing ever used*/
108 ips_cmd_status_t status;
109 SLIST_ENTRY(ips_command) next;
110 void * data_buffer;
111 void * arg;
112 void (* callback)(struct ips_command *command);
113 }ips_command_t;
114
115 typedef struct ips_softc{
116 struct resource * iores;
117 struct resource * irqres;
118 struct intr_config_hook ips_ich;
119 int configured;
120 int state;
121 int iotype;
122 int rid;
123 int irqrid;
124 void * irqcookie;
125 bus_space_tag_t bustag;
126 bus_space_handle_t bushandle;
127 bus_dma_tag_t adapter_dmatag;
128 bus_dma_tag_t command_dmatag;
129 bus_dma_tag_t sg_dmatag;
130 device_t dev;
131 struct cdev *device_file;
132 struct callout_handle timer;
133 u_int16_t adapter_type;
134 ips_adapter_info_t adapter_info;
135 device_t diskdev[IPS_MAX_NUM_DRIVES];
136 ips_drive_t drives[IPS_MAX_NUM_DRIVES];
137 u_int8_t drivecount;
138 u_int16_t ffdc_resetcount;
139 struct timeval ffdc_resettime;
140 u_int8_t next_drive;
141 u_int8_t max_cmds;
142 volatile u_int8_t used_commands;
143 ips_command_t *commandarray;
144 ips_command_t *staticcmd;
145 SLIST_HEAD(command_list, ips_command) free_cmd_list;
146 int (* ips_adapter_reinit)(struct ips_softc *sc,
147 int force);
148 void (* ips_adapter_intr)(void *sc);
149 void (* ips_issue_cmd)(ips_command_t *command);
150 void (* ips_poll_cmd)(ips_command_t *command);
151 ips_copper_queue_t * copper_queue;
152 struct mtx queue_mtx;
153 struct bio_queue_head queue;
154 struct sema cmd_sema;
155
156 }ips_softc_t;
157
158 /* function defines from ips_ioctl.c */
159 extern int ips_ioctl_request(ips_softc_t *sc, u_long ioctl_cmd, caddr_t addr,
160 int32_t flags);
161 /* function defines from ips_disk.c */
162 extern void ipsd_finish(struct bio *iobuf);
163
164 /* function defines from ips_commands.c */
165 extern int ips_flush_cache(ips_softc_t *sc);
166 extern void ips_start_io_request(ips_softc_t *sc);
167 extern int ips_get_drive_info(ips_softc_t *sc);
168 extern int ips_get_adapter_info(ips_softc_t *sc);
169 extern int ips_ffdc_reset(ips_softc_t *sc);
170 extern int ips_update_nvram(ips_softc_t *sc);
171 extern int ips_clear_adapter(ips_softc_t *sc);
172
173 /* function defines from ips.c */
174 extern int ips_get_free_cmd(ips_softc_t *sc, ips_command_t **command, unsigned long flags);
175 extern void ips_insert_free_cmd(ips_softc_t *sc, ips_command_t *command);
176 extern int ips_adapter_init(ips_softc_t *sc);
177 extern int ips_morpheus_reinit(ips_softc_t *sc, int force);
178 extern int ips_adapter_free(ips_softc_t *sc);
179 extern void ips_morpheus_intr(void *sc);
180 extern void ips_issue_morpheus_cmd(ips_command_t *command);
181 extern void ips_morpheus_poll(ips_command_t *command);
182 extern int ips_copperhead_reinit(ips_softc_t *sc, int force);
183 extern void ips_copperhead_intr(void *sc);
184 extern void ips_issue_copperhead_cmd(ips_command_t *command);
185 extern void ips_copperhead_poll(ips_command_t *command);
186
187 #endif
188 #endif
Cache object: 22cbf4ef2514ccf4907d9e0ba17b79fc
|