2 * ISP Firmware Modules for FreeBSD
4 * Copyright (c) 2000, 2001, 2006 by Matthew Jacob
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice immediately at the beginning of the file, without modification,
12 * this list of conditions, and the following disclaimer.
13 * 2. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
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 FOR
20 * 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
28 * $FreeBSD: src/sys/dev/ispfw/ispfw.c,v 1.22 2010/03/05 03:37:42 sobomax Exp $
31 #include <sys/param.h>
32 #include <sys/firmware.h>
33 #include <sys/kernel.h>
34 #include <sys/linker.h>
35 #include <sys/module.h>
36 #include <sys/systm.h>
38 #if defined(ISP_ALL) || !defined(KLD_MODULE)
44 #define ISP_12160_IT 1
50 #define ISP_2400_MULTI 1
52 #define ISP_2500_MULTI 1
56 #define MODULE_NAME "ispfw"
59 #if defined(ISP_1040) || defined(ISP_1040_IT)
60 #include <dev/disk/ispfw/asm_1040.h>
62 #if defined(ISP_1080) || defined(ISP_1080_IT)
63 #include <dev/disk/ispfw/asm_1080.h>
65 #if defined(ISP_12160) || defined(ISP_12160_IT)
66 #include <dev/disk/ispfw/asm_12160.h>
69 #include <dev/disk/ispfw/asm_2100.h>
72 #include <dev/disk/ispfw/asm_2200.h>
75 #include <dev/disk/ispfw/asm_2300.h>
78 #include <dev/disk/ispfw/asm_2322.h>
80 #if defined(ISP_2400) || defined(ISP_2400_MULTI)
81 #include <dev/disk/ispfw/asm_2400.h>
83 #if defined(ISP_2500) || defined(ISP_2500_MULTI)
84 #include <dev/disk/ispfw/asm_2500.h>
88 static int isp_1000_loaded
;
91 static int isp_1040_loaded
;
93 #if defined(ISP_1040_IT)
94 static int isp_1040_it_loaded
;
97 static int isp_1080_loaded
;
99 #if defined(ISP_1080_IT)
100 static int isp_1080_it_loaded
;
102 #if defined(ISP_12160)
103 static int isp_12160_loaded
;
105 #if defined(ISP_12160_IT)
106 static int isp_12160_it_loaded
;
108 #if defined(ISP_2100)
109 static int isp_2100_loaded
;
111 #if defined(ISP_2200)
112 static int isp_2200_loaded
;
114 #if defined(ISP_2300)
115 static int isp_2300_loaded
;
117 #if defined(ISP_2322)
118 static int isp_2322_loaded
;
120 #if defined(ISP_2400)
121 static int isp_2400_loaded
;
123 #if defined(ISP_2400_MULTI)
124 static int isp_2400_multi_loaded
;
126 #if defined(ISP_2500)
127 static int isp_2500_loaded
;
129 #if defined(ISP_2500_MULTI)
130 static int isp_2500_multi_loaded
;
133 #define ISPFW_VERSION 1
135 #if !defined(KLD_MODULE)
141 #define RMACRO(token) do { \
142 if (token##_loaded) \
144 if (firmware_register(#token, token##_risc_code, \
145 token##_risc_code[3] * sizeof(token##_risc_code[3]), \
146 ISPFW_VERSION, NULL) == NULL) { \
147 kprintf("%s: unable to register firmware <%s>\n", \
148 MODULE_NAME, #token); \
152 if (bootverbose || ISPFW_KLD) \
153 kprintf("%s: registered firmware <%s>\n", MODULE_NAME, \
157 #define UMACRO(token) do { \
158 if (!token##_loaded) \
160 if (firmware_unregister(#token) != 0) { \
161 kprintf("%s: unable to unregister firmware <%s>\n", \
162 MODULE_NAME, #token); \
166 if (bootverbose || ISPFW_KLD) \
167 kprintf("%s: unregistered firmware <%s>\n", MODULE_NAME,\
175 #if defined(ISP_1000)
178 #if defined(ISP_1040)
181 #if defined(ISP_1040_IT)
184 #if defined(ISP_1080)
187 #if defined(ISP_1080_IT)
190 #if defined(ISP_12160)
193 #if defined(ISP_12160_IT)
194 RMACRO(isp_12160_it
);
196 #if defined(ISP_2100)
199 #if defined(ISP_2200)
202 #if defined(ISP_2300)
205 #if defined(ISP_2322)
208 #if defined(ISP_2400)
211 #if defined(ISP_2400_MULTI)
212 RMACRO(isp_2400_multi
);
214 #if defined(ISP_2500)
217 #if defined(ISP_2500_MULTI)
218 RMACRO(isp_2500_multi
);
226 #if defined(ISP_1000)
229 #if defined(ISP_1040)
232 #if defined(ISP_1040_IT)
235 #if defined(ISP_1080)
238 #if defined(ISP_1080_IT)
241 #if defined(ISP_12160)
244 #if defined(ISP_12160_IT)
245 UMACRO(isp_12160_it
);
247 #if defined(ISP_2100)
250 #if defined(ISP_2200)
253 #if defined(ISP_2300)
256 #if defined(ISP_2322)
259 #if defined(ISP_2400)
262 #if defined(ISP_2400_MULTI)
263 UMACRO(isp_2400_multi
);
265 #if defined(ISP_2500)
268 #if defined(ISP_2500_MULTI)
269 UMACRO(isp_2500_multi
);
274 module_handler(module_t mod
, int what
, void *arg
)
291 static moduledata_t ispfw_mod
= {
292 MODULE_NAME
, module_handler
, NULL
294 #if defined(ISP_ALL) || !defined(KLD_MODULE)
295 DECLARE_MODULE(ispfw
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
296 MODULE_VERSION(ispfw
, 1);
297 #elif defined(ISP_1000)
298 DECLARE_MODULE(isp_1000
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
299 MODULE_VERSION(isp_1000
, 1);
300 #elif defined(ISP_1040)
301 DECLARE_MODULE(isp_1040
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
302 MODULE_VERSION(isp_1040
, 1);
303 #elif defined(ISP_1040_IT)
304 DECLARE_MODULE(isp_1040_it
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
305 MODULE_VERSION(isp_1040_it
, 1);
306 #elif defined(ISP_1080)
307 DECLARE_MODULE(isp_1080
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
308 MODULE_VERSION(isp_1080
, 1);
309 #elif defined(ISP_1080_IT)
310 DECLARE_MODULE(isp_1080_it
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
311 MODULE_VERSION(isp_1080_it
, 1);
312 #elif defined(ISP_12160)
313 DECLARE_MODULE(isp_12160
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
314 MODULE_VERSION(isp_12160
, 1);
315 #elif defined(ISP_12160_IT)
316 DECLARE_MODULE(isp_12160_it
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
317 MODULE_VERSION(isp_12160_it
, 1);
318 #elif defined(ISP_2100)
319 DECLARE_MODULE(isp_2100
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
320 MODULE_VERSION(isp_2100
, 1);
321 #elif defined(ISP_2200)
322 DECLARE_MODULE(isp_2200
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
323 MODULE_VERSION(isp_2200
, 1);
324 #elif defined(ISP_2300)
325 DECLARE_MODULE(isp_2300
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
326 MODULE_VERSION(isp_2300
, 1);
327 #elif defined(ISP_2322)
328 DECLARE_MODULE(isp_2322
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
329 MODULE_VERSION(isp_2322
, 1);
330 #elif defined(ISP_2400)
331 DECLARE_MODULE(isp_2400
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
332 MODULE_VERSION(isp_2400
, 1);
333 #elif defined(ISP_2400_MULTI)
334 DECLARE_MODULE(isp_2400_multi
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
335 MODULE_VERSION(isp_2400_multi
, 1);
336 #elif defined(ISP_2500)
337 DECLARE_MODULE(isp_2500
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
338 MODULE_VERSION(isp_2500
, 1);
339 #elif defined(ISP_2500_MULTI)
340 DECLARE_MODULE(isp_2500_multi
, ispfw_mod
, SI_SUB_DRIVERS
, SI_ORDER_THIRD
);
341 MODULE_VERSION(isp_2500_multi
, 1);
343 #error "firmware not specified"