cxgb_t3fw.c revision 183292
155682Smarkm/*
255682Smarkm * from: FreeBSD: src/sys/tools/fw_stub.awk,v 1.6 2007/03/02 11:42:53 flz
355682Smarkm */
455682Smarkm#include <sys/cdefs.h>
555682Smarkm__FBSDID("$FreeBSD: head/sys/dev/cxgb/cxgb_t3fw.c 183292 2008-09-23 03:16:54Z kmacy $");
655682Smarkm#include <sys/param.h>
755682Smarkm#include <sys/errno.h>
855682Smarkm#include <sys/kernel.h>
955682Smarkm#include <sys/module.h>
1055682Smarkm#include <sys/linker.h>
1155682Smarkm#include <sys/firmware.h>
1255682Smarkm#include <sys/systm.h>
1355682Smarkm#include <cxgb_t3fw.h>
1455682Smarkm#include <t3b_protocol_sram.h>
1555682Smarkm#include <t3b_tp_eeprom.h>
1655682Smarkm
1755682Smarkmstatic int
1855682Smarkmcxgb_t3fw_modevent(module_t mod, int type, void *unused)
1955682Smarkm{
2055682Smarkm	const struct firmware *fp, *parent;
2155682Smarkm	int error;
2255682Smarkm	switch (type) {
2355682Smarkm	case MOD_LOAD:
2455682Smarkm
2555682Smarkm		fp = firmware_register("cxgb_t3fw", t3fw,
2655682Smarkm				       (size_t)t3fw_length,
2755682Smarkm				       0, NULL);
2855682Smarkm		if (fp == NULL)
2955682Smarkm			goto fail_0;
3055682Smarkm		parent = fp;
3155682Smarkm		return (0);
3255682Smarkm	fail_0:
3355682Smarkm		return (ENXIO);
3455682Smarkm	case MOD_UNLOAD:
3555682Smarkm		error = firmware_unregister("cxgb_t3fw");
36120945Snectar		return (error);
3755682Smarkm	}
3855682Smarkm	return (EINVAL);
3955682Smarkm}
4055682Smarkm
4155682Smarkmstatic moduledata_t cxgb_t3fw_mod = {
4255682Smarkm        "cxgb_t3fw",
4355682Smarkm        cxgb_t3fw_modevent,
4455682Smarkm        0
4555682Smarkm};
4655682SmarkmDECLARE_MODULE(cxgb_t3fw, cxgb_t3fw_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
4755682SmarkmMODULE_VERSION(cxgb_t3fw, 1);
4855682SmarkmMODULE_DEPEND(cxgb_t3fw, firmware, 1, 1, 1);
49120945Snectar
5055682Smarkmstatic int
5155682Smarkmcxgb_t3b_protocol_sram_modevent(module_t mod, int type, void *unused)
5255682Smarkm{
5355682Smarkm	const struct firmware *fp, *parent;
5455682Smarkm	int error;
55120945Snectar	switch (type) {
5655682Smarkm	case MOD_LOAD:
5755682Smarkm
5855682Smarkm		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		parent = fp;
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
74static moduledata_t cxgb_t3b_protocol_sram_mod = {
75        "cxgb_t3b_protocol_sram",
76        cxgb_t3b_protocol_sram_modevent,
77        0
78};
79DECLARE_MODULE(cxgb_t3b_protocol_sram, cxgb_t3b_protocol_sram_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
80MODULE_VERSION(cxgb_t3b_protocol_sram, 1);
81MODULE_DEPEND(cxgb_t3b_protocol_sram, firmware, 1, 1, 1);
82
83
84static int
85cxgb_t3b_tp_eeprom_modevent(module_t mod, int type, void *unused)
86{
87	const struct firmware *fp, *parent;
88	int error;
89	switch (type) {
90	case MOD_LOAD:
91
92		fp = firmware_register("cxgb_t3b_tp_eeprom", t3b_tp_eeprom,
93				       (size_t)t3b_tp_eeprom_length,
94				       0, NULL);
95		if (fp == NULL)
96			goto fail_0;
97		parent = fp;
98		return (0);
99	fail_0:
100		return (ENXIO);
101	case MOD_UNLOAD:
102		error = firmware_unregister("cxgb_t3b_tp_eeprom");
103		return (error);
104	}
105	return (EINVAL);
106}
107
108static moduledata_t cxgb_t3b_tp_eeprom_mod = {
109        "cxgb_t3b_tp_eeprom",
110        cxgb_t3b_tp_eeprom_modevent,
111        0
112};
113DECLARE_MODULE(cxgb_t3b_tp_eeprom, cxgb_t3b_tp_eeprom_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
114MODULE_VERSION(cxgb_t3b_tp_eeprom, 1);
115MODULE_DEPEND(cxgb_t3b_tp_eeprom, firmware, 1, 1, 1);
116