1/*- |
2 * ISP Firmware Modules for FreeBSD |
3 * |
4 * Copyright (c) 2000, 2001, 2006 by Matthew Jacob |
5 * All rights reserved. 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 immediately at the beginning of the file, without modification, 12 * this list of conditions, and the following disclaimer. --- 9 unchanged lines hidden (view full) --- 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 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/dev/ispfw/ispfw.c 160212 2006-07-09 17:50:20Z mjacob $"); |
31 32#include <sys/param.h> 33#include <sys/kernel.h> |
34#include <sys/module.h> |
35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/linker.h> 38#include <sys/firmware.h> |
39 |
40#if defined(ISP_ALL) || !defined(KLD_MODULE) 41#define ISP_1040 1 42#define ISP_1040_IT 1 43#define ISP_1080 1 44#define ISP_1080_IT 1 45#define ISP_12160 1 46#define ISP_12160_IT 1 47#define ISP_2100 1 48#define ISP_2200 1 49#define ISP_2300 1 50#define ISP_2322 1 51#ifdef __sparc64__ 52#define ISP_1000 1 53#endif 54#define MODULE_NAME "isp" 55#endif 56 57#if defined(ISP_1040) || defined(ISP_1040_IT) |
58#include <dev/ispfw/asm_1040.h> |
59#endif 60#if defined(ISP_1080) || defined(ISP_1080_IT) |
61#include <dev/ispfw/asm_1080.h> |
62#endif 63#if defined(ISP_12160) || defined(ISP_12160_IT) |
64#include <dev/ispfw/asm_12160.h> |
65#endif 66#if defined(ISP_2100) |
67#include <dev/ispfw/asm_2100.h> |
68#endif 69#if defined(ISP_2200) |
70#include <dev/ispfw/asm_2200.h> |
71#endif 72#if defined(ISP_2300) |
73#include <dev/ispfw/asm_2300.h> |
74#endif 75#if defined(ISP_2322) |
76#include <dev/ispfw/asm_2322.h> |
77#endif 78#if defined(ISP_1000) |
79#include <dev/ispfw/asm_1000.h> 80#endif 81 |
82#define ISPFW_VERSION 1 83#define RMACRO(token) \ 84 if (firmware_register(#token, token##_risc_code, \ 85 token##_risc_code [3] << 1, ISPFW_VERSION, NULL) == NULL) { \ 86 printf("unable to register firmware '%s'\n", #token); \ 87 } else { \ 88 printf("registered firmware set <%s>\n", #token); \ 89 } |
90 |
91#define UMACRO(token) \ 92 firmware_unregister(#token); \ 93 printf("unregistered firmware set <%s>\n", #token); |
94 |
95static int |
96do_load_fw(void) |
97{ |
98#if defined(ISP_1000) 99 RMACRO(isp_1000); 100#endif 101#if defined(ISP_1040) 102 RMACRO(isp_1040); 103#endif 104#if defined(ISP_1040_IT) 105 RMACRO(isp_1040_it); 106#endif 107#if defined(ISP_1080) 108 RMACRO(isp_1080); 109#endif 110#if defined(ISP_1080_IT) 111 RMACRO(isp_1080_it); 112#endif 113#if defined(ISP_12160) 114 RMACRO(isp_12160); 115#endif 116#if defined(ISP_12160_IT) 117 RMACRO(isp_12160_it); 118#endif 119#if defined(ISP_2100) 120 RMACRO(isp_2100); 121#endif 122#if defined(ISP_2200) 123 RMACRO(isp_2200); 124#endif 125#if defined(ISP_2300) 126 RMACRO(isp_2300); 127#endif 128#if defined(ISP_2322) 129 RMACRO(isp_2322); 130#endif 131 return (0); |
132} 133 |
134static int 135do_unload_fw(void) |
136{ |
137#if defined(ISP_1000) 138 UMACRO(isp_1000); 139#elif defined(ISP_1040) 140 UMACRO(isp_1040); 141#elif defined(ISP_1040_IT) 142 UMACRO(isp_1040_it); 143#elif defined(ISP_1080) 144 UMACRO(isp_1080); 145#elif defined(ISP_1080_IT) 146 UMACRO(isp_1080_it); 147#elif defined(ISP_12160) 148 UMACRO(isp_12160); 149#elif defined(ISP_12160_IT) 150 UMACRO(isp_12160_it); 151#elif defined(ISP_2100) 152 UMACRO(isp_2100); 153#elif defined(ISP_2200) 154 UMACRO(isp_2200); 155#elif defined(ISP_2300) 156 UMACRO(isp_2300); 157#elif defined(ISP_2322) 158 UMACRO(isp_2322); |
159#endif |
160 return (0); |
161} 162 163static int |
164module_handler(module_t mod, int what, void *arg) |
165{ |
166 int r; |
167 switch (what) { 168 case MOD_LOAD: |
169 r = do_load_fw(); |
170 break; 171 case MOD_UNLOAD: |
172 r = do_unload_fw(); |
173 break; 174 default: |
175 r = EOPNOTSUPP; |
176 break; 177 } |
178 return (r); |
179} 180static moduledata_t ispfw_mod = { |
181 MODULE_NAME, module_handler, NULL |
182}; |
183#ifndef KLD_MODULE 184DECLARE_MODULE(isp, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); 185#else 186#if defined(ISP_1000) 187DECLARE_MODULE(isp_1000, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); 188#elif defined(ISP_1040) 189DECLARE_MODULE(isp_1040, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); 190#elif defined(ISP_1040_IT) 191DECLARE_MODULE(isp_1040_it, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); 192#elif defined(ISP_1080) 193DECLARE_MODULE(isp_1080, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); 194#elif defined(ISP_1080_IT) 195DECLARE_MODULE(isp_1080_it, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); 196#elif defined(ISP_12160) 197DECLARE_MODULE(isp_12160, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); 198#elif defined(ISP_12160_IT) 199DECLARE_MODULE(isp_12160_IT, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); 200#elif defined(ISP_2100) 201DECLARE_MODULE(isp_2100, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); 202#elif defined(ISP_2200) 203DECLARE_MODULE(isp_2200, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); 204#elif defined(ISP_2300) 205DECLARE_MODULE(isp_2300, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); 206#elif defined(ISP_2322) 207DECLARE_MODULE(isp_2322, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); 208#endif 209#endif |