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, *parent; 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 parent = fp; 33 return (0); 34 fail_0: 35 return (ENXIO); 36 case MOD_UNLOAD: 37 error = firmware_unregister("cxgb_t3fw"); 38 return (error); 39 } 40 return (EINVAL); 41 } 42 43 static moduledata_t cxgb_t3fw_mod = { 44 "cxgb_t3fw", 45 cxgb_t3fw_modevent, 46 0 47 }; 48 DECLARE_MODULE(cxgb_t3fw, cxgb_t3fw_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); 49 MODULE_VERSION(cxgb_t3fw, 1); 50 MODULE_DEPEND(cxgb_t3fw, firmware, 1, 1, 1); 51 52 static int 53 cxgb_t3b_protocol_sram_modevent(module_t mod, int type, void *unused) 54 { 55 const struct firmware *fp, *parent; 56 int error; 57 switch (type) { 58 case MOD_LOAD: 59 60 fp = firmware_register("cxgb_t3b_protocol_sram", t3b_protocol_sram, 61 (size_t)t3b_protocol_sram_length, 62 0, NULL); 63 if (fp == NULL) 64 goto fail_0; 65 parent = fp; 66 return (0); 67 fail_0: 68 return (ENXIO); 69 case MOD_UNLOAD: 70 error = firmware_unregister("cxgb_t3b_protocol_sram"); 71 return (error); 72 } 73 return (EINVAL); 74 } 75 76 static moduledata_t cxgb_t3b_protocol_sram_mod = { 77 "cxgb_t3b_protocol_sram", 78 cxgb_t3b_protocol_sram_modevent, 79 0 80 }; 81 DECLARE_MODULE(cxgb_t3b_protocol_sram, cxgb_t3b_protocol_sram_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); 82 MODULE_VERSION(cxgb_t3b_protocol_sram, 1); 83 MODULE_DEPEND(cxgb_t3b_protocol_sram, firmware, 1, 1, 1); 84 85 static int 86 cxgb_t3b_tp_eeprom_modevent(module_t mod, int type, void *unused) 87 { 88 const struct firmware *fp, *parent; 89 int error; 90 switch (type) { 91 case MOD_LOAD: 92 93 fp = firmware_register("cxgb_t3b_tp_eeprom", t3b_tp_eeprom, 94 (size_t)t3b_tp_eeprom_length, 95 0, NULL); 96 if (fp == NULL) 97 goto fail_0; 98 parent = fp; 99 return (0); 100 fail_0: 101 return (ENXIO); 102 case MOD_UNLOAD: 103 error = firmware_unregister("cxgb_t3b_tp_eeprom"); 104 return (error); 105 } 106 return (EINVAL); 107 } 108 109 static moduledata_t cxgb_t3b_tp_eeprom_mod = { 110 "cxgb_t3b_tp_eeprom", 111 cxgb_t3b_tp_eeprom_modevent, 112 0 113 }; 114 DECLARE_MODULE(cxgb_t3b_tp_eeprom, cxgb_t3b_tp_eeprom_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); 115 MODULE_VERSION(cxgb_t3b_tp_eeprom, 1); 116 MODULE_DEPEND(cxgb_t3b_tp_eeprom, firmware, 1, 1, 1); 117 118 static int 119 cxgb_t3c_protocol_sram_modevent(module_t mod, int type, void *unused) 120 { 121 const struct firmware *fp, *parent; 122 int error; 123 switch (type) { 124 case MOD_LOAD: 125 126 fp = firmware_register("cxgb_t3c_protocol_sram", t3c_protocol_sram, 127 (size_t)t3c_protocol_sram_length, 128 0, NULL); 129 if (fp == NULL) 130 goto fail_0; 131 parent = fp; 132 return (0); 133 fail_0: 134 return (ENXIO); 135 case MOD_UNLOAD: 136 error = firmware_unregister("cxgb_t3c_protocol_sram"); 137 return (error); 138 } 139 return (EINVAL); 140 } 141 142 static moduledata_t cxgb_t3c_protocol_sram_mod = { 143 "cxgb_t3c_protocol_sram", 144 cxgb_t3c_protocol_sram_modevent, 145 0 146 }; 147 DECLARE_MODULE(cxgb_t3c_protocol_sram, cxgb_t3c_protocol_sram_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); 148 MODULE_VERSION(cxgb_t3c_protocol_sram, 1); 149 MODULE_DEPEND(cxgb_t3c_protocol_sram, firmware, 1, 1, 1); 150 151 static int 152 cxgb_t3c_tp_eeprom_modevent(module_t mod, int type, void *unused) 153 { 154 const struct firmware *fp, *parent; 155 int error; 156 switch (type) { 157 case MOD_LOAD: 158 159 fp = firmware_register("cxgb_t3c_tp_eeprom", t3c_tp_eeprom, 160 (size_t)t3c_tp_eeprom_length, 161 0, NULL); 162 if (fp == NULL) 163 goto fail_0; 164 parent = fp; 165 return (0); 166 fail_0: 167 return (ENXIO); 168 case MOD_UNLOAD: 169 error = firmware_unregister("cxgb_t3c_tp_eeprom"); 170 return (error); 171 } 172 return (EINVAL); 173 } 174 175 static moduledata_t cxgb_t3c_tp_eeprom_mod = { 176 "cxgb_t3c_tp_eeprom", 177 cxgb_t3c_tp_eeprom_modevent, 178 0 179 }; 180 DECLARE_MODULE(cxgb_t3c_tp_eeprom, cxgb_t3c_tp_eeprom_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); 181 MODULE_VERSION(cxgb_t3c_tp_eeprom, 1); 182 MODULE_DEPEND(cxgb_t3c_tp_eeprom, firmware, 1, 1, 1); 183