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, 48 NULL 49 }; 50 51 int 52 _init(void) 53 { 54 int rval; 55 56 rval = mod_install(&emlxs_modlinkage); 57 58 return (rval); 59 60 } /* _init() */ 61 62 int 63 _fini() 64 { 65 int rval; 66 67 rval = mod_remove(&emlxs_modlinkage); 68 69 return (rval); 70 71 } /* _fini() */ 72 73 int 74 _info(struct modinfo *modinfop) 75 { 76 int rval; 77 78 rval = mod_info(&emlxs_modlinkage, modinfop); 79 80 return (rval); 81 82 } /* _fini() */ 83 84 int 85 emlxs_fw_get(emlxs_firmware_t *fw) 86 { 87 uint32_t i; 88 emlxs_firmware_t *fw_table; 89 90 /* Find matching firmware table entry */ 91 fw_table = emlxs_fw_mod_table; 92 for (i = 0; i < emlxs_fw_mod_count; i++, fw_table++) { 93 /* Validate requested fw image */ 94 if ((fw_table->id == fw->id) && 95 (fw_table->kern == fw->kern) && 96 (fw_table->stub == fw->stub) && 97 (fw_table->sli1 == fw->sli1) && 98 (fw_table->sli2 == fw->sli2) && 99 (fw_table->sli3 == fw->sli3) && 100 (fw_table->sli4 == fw->sli4)) { 101 /* Return image data and size */ 102 fw->image = fw_table->image; 103 fw->size = fw_table->size; 104 105 return (0); 106 } 107 } 108 109 fw->image = NULL; 110 fw->size = 0; 111 112 return (1); 113 114 } /* emlxs_fw_get() */