1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at
9 * http://www.opensource.org/licenses/cddl1.txt.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2004-2012 Emulex. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #define DRIVER_NAME "emlxs"
28 #define EMLXS_FW_TABLE_DEF
29
30 #include <sys/types.h>
31 #include <sys/modctl.h>
32 #include <emlxs_version.h>
33 #include <emlxs_fw.h>
34
35 emlxs_firmware_t emlxs_fw_mod_table[] = EMLXS_FW_TABLE;
36 int emlxs_fw_mod_count = sizeof (emlxs_fw_mod_table) /
37 sizeof (emlxs_firmware_t);
38 char emlxs_fw_mod_name[] = EMLXS_FW_NAME;
39
40 static struct modlmisc emlxs_modlmisc = {
41 &mod_miscops,
42 emlxs_fw_mod_name
43 };
44
45 static struct modlinkage emlxs_modlinkage = {
46 MODREV_1,
47 { (void *)&emlxs_modlmisc, NULL }
48 };
49
50 int
51 _init(void)
52 {
53 int rval;
54
55 rval = mod_install(&emlxs_modlinkage);
56
57 return (rval);
58
59 } /* _init() */
60
61 int
62 _fini()
63 {
64 int rval;
65
66 rval = mod_remove(&emlxs_modlinkage);
67
68 return (rval);
69
70 } /* _fini() */
71
72 int
73 _info(struct modinfo *modinfop)
74 {
75 int rval;
76
77 rval = mod_info(&emlxs_modlinkage, modinfop);
78
79 return (rval);
80
81 } /* _fini() */
82
83 int
84 emlxs_fw_get(emlxs_firmware_t *fw)
85 {
86 uint32_t i;
87 emlxs_firmware_t *fw_table;
88
89 /* Find matching firmware table entry */
90 fw_table = emlxs_fw_mod_table;
91 for (i = 0; i < emlxs_fw_mod_count; i++, fw_table++) {
92 /* Validate requested fw image */
93 if ((fw_table->id == fw->id) &&
94 (fw_table->kern == fw->kern) &&
95 (fw_table->stub == fw->stub) &&
96 (fw_table->sli1 == fw->sli1) &&
97 (fw_table->sli2 == fw->sli2) &&
98 (fw_table->sli3 == fw->sli3) &&
99 (fw_table->sli4 == fw->sli4)) {
100 /* Return image data and size */
101 fw->image = fw_table->image;
102 fw->size = fw_table->size;
103
104 return (0);
105 }
106 }
107
108 fw->image = NULL;
109 fw->size = 0;
110
111 return (1);
112
113 } /* emlxs_fw_get() */