xref: /freebsd/sys/dev/cxgb/cxgb_t3fw.c (revision d4eeb02986980bf33dd56c41ceb9fc5f180c0d47)
1 /*
2  * from: FreeBSD: src/sys/tools/fw_stub.awk,v 1.6 2007/03/02 11:42:53 flz
3  */
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD$");
6 #include <sys/param.h>
7 #include <sys/errno.h>
8 #include <sys/kernel.h>
9 #include <sys/module.h>
10 #include <sys/linker.h>
11 #include <sys/firmware.h>
12 #include <sys/systm.h>
13 #include <cxgb_t3fw.h>
14 #include <t3b_protocol_sram.h>
15 #include <t3b_tp_eeprom.h>
16 #include <t3c_protocol_sram.h>
17 #include <t3c_tp_eeprom.h>
18 
19 static int
20 cxgb_t3fw_modevent(module_t mod, int type, void *unused)
21 {
22 	const struct firmware *fp;
23 	int error;
24 	switch (type) {
25 	case MOD_LOAD:
26 
27 		fp = firmware_register("cxgb_t3fw", t3fw,
28 				       (size_t)t3fw_length,
29 				       0, NULL);
30 		if (fp == NULL)
31 			goto fail_0;
32 		return (0);
33 	fail_0:
34 		return (ENXIO);
35 	case MOD_UNLOAD:
36 		error = firmware_unregister("cxgb_t3fw");
37 		return (error);
38 	}
39 	return (EINVAL);
40 }
41 
42 static moduledata_t cxgb_t3fw_mod = {
43         "cxgb_t3fw",
44         cxgb_t3fw_modevent,
45         0
46 };
47 DECLARE_MODULE(cxgb_t3fw, cxgb_t3fw_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
48 MODULE_VERSION(cxgb_t3fw, 1);
49 MODULE_DEPEND(cxgb_t3fw, firmware, 1, 1, 1);
50 
51 static int
52 cxgb_t3b_protocol_sram_modevent(module_t mod, int type, void *unused)
53 {
54 	const struct firmware *fp;
55 	int error;
56 	switch (type) {
57 	case MOD_LOAD:
58 
59 		fp = firmware_register("cxgb_t3b_protocol_sram", t3b_protocol_sram,
60 				       (size_t)t3b_protocol_sram_length,
61 				       0, NULL);
62 		if (fp == NULL)
63 			goto fail_0;
64 		return (0);
65 	fail_0:
66 		return (ENXIO);
67 	case MOD_UNLOAD:
68 		error = firmware_unregister("cxgb_t3b_protocol_sram");
69 		return (error);
70 	}
71 	return (EINVAL);
72 }
73 
74 static moduledata_t cxgb_t3b_protocol_sram_mod = {
75         "cxgb_t3b_protocol_sram",
76         cxgb_t3b_protocol_sram_modevent,
77         0
78 };
79 DECLARE_MODULE(cxgb_t3b_protocol_sram, cxgb_t3b_protocol_sram_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
80 MODULE_VERSION(cxgb_t3b_protocol_sram, 1);
81 MODULE_DEPEND(cxgb_t3b_protocol_sram, firmware, 1, 1, 1);
82 
83 static int
84 cxgb_t3b_tp_eeprom_modevent(module_t mod, int type, void *unused)
85 {
86 	const struct firmware *fp;
87 	int error;
88 	switch (type) {
89 	case MOD_LOAD:
90 
91 		fp = firmware_register("cxgb_t3b_tp_eeprom", t3b_tp_eeprom,
92 				       (size_t)t3b_tp_eeprom_length,
93 				       0, NULL);
94 		if (fp == NULL)
95 			goto fail_0;
96 		return (0);
97 	fail_0:
98 		return (ENXIO);
99 	case MOD_UNLOAD:
100 		error = firmware_unregister("cxgb_t3b_tp_eeprom");
101 		return (error);
102 	}
103 	return (EINVAL);
104 }
105 
106 static moduledata_t cxgb_t3b_tp_eeprom_mod = {
107         "cxgb_t3b_tp_eeprom",
108         cxgb_t3b_tp_eeprom_modevent,
109         0
110 };
111 DECLARE_MODULE(cxgb_t3b_tp_eeprom, cxgb_t3b_tp_eeprom_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
112 MODULE_VERSION(cxgb_t3b_tp_eeprom, 1);
113 MODULE_DEPEND(cxgb_t3b_tp_eeprom, firmware, 1, 1, 1);
114 
115 static int
116 cxgb_t3c_protocol_sram_modevent(module_t mod, int type, void *unused)
117 {
118 	const struct firmware *fp;
119 	int error;
120 	switch (type) {
121 	case MOD_LOAD:
122 
123 		fp = firmware_register("cxgb_t3c_protocol_sram", t3c_protocol_sram,
124 				       (size_t)t3c_protocol_sram_length,
125 				       0, NULL);
126 		if (fp == NULL)
127 			goto fail_0;
128 		return (0);
129 	fail_0:
130 		return (ENXIO);
131 	case MOD_UNLOAD:
132 		error = firmware_unregister("cxgb_t3c_protocol_sram");
133 		return (error);
134 	}
135 	return (EINVAL);
136 }
137 
138 static moduledata_t cxgb_t3c_protocol_sram_mod = {
139         "cxgb_t3c_protocol_sram",
140         cxgb_t3c_protocol_sram_modevent,
141         0
142 };
143 DECLARE_MODULE(cxgb_t3c_protocol_sram, cxgb_t3c_protocol_sram_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
144 MODULE_VERSION(cxgb_t3c_protocol_sram, 1);
145 MODULE_DEPEND(cxgb_t3c_protocol_sram, firmware, 1, 1, 1);
146 
147 static int
148 cxgb_t3c_tp_eeprom_modevent(module_t mod, int type, void *unused)
149 {
150 	const struct firmware *fp;
151 	int error;
152 	switch (type) {
153 	case MOD_LOAD:
154 
155 		fp = firmware_register("cxgb_t3c_tp_eeprom", t3c_tp_eeprom,
156 				       (size_t)t3c_tp_eeprom_length,
157 				       0, NULL);
158 		if (fp == NULL)
159 			goto fail_0;
160 		return (0);
161 	fail_0:
162 		return (ENXIO);
163 	case MOD_UNLOAD:
164 		error = firmware_unregister("cxgb_t3c_tp_eeprom");
165 		return (error);
166 	}
167 	return (EINVAL);
168 }
169 
170 static moduledata_t cxgb_t3c_tp_eeprom_mod = {
171         "cxgb_t3c_tp_eeprom",
172         cxgb_t3c_tp_eeprom_modevent,
173         0
174 };
175 DECLARE_MODULE(cxgb_t3c_tp_eeprom, cxgb_t3c_tp_eeprom_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
176 MODULE_VERSION(cxgb_t3c_tp_eeprom, 1);
177 MODULE_DEPEND(cxgb_t3c_tp_eeprom, firmware, 1, 1, 1);
178