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