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 usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 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 2009 Emulex. All rights reserved. 24 * Use is subject to License terms. 25 */ 26 27 #define EMLXS_FW_TABLE_DEF 28 29 #include <sys/types.h> 30 #include <sys/modctl.h> 31 #include <emlxs_version.h> 32 #include <emlxs_fw.h> 33 34 char emlxs_fw_name[] = EMLXS_FW_NAME; 35 36 static struct modlmisc emlxs_modlmisc = { 37 &mod_miscops, 38 emlxs_fw_name 39 }; 40 41 static struct modlinkage emlxs_modlinkage = { 42 MODREV_1, 43 (void *)&emlxs_modlmisc, 44 NULL 45 }; 46 47 int 48 _init(void) 49 { 50 int rval; 51 52 rval = mod_install(&emlxs_modlinkage); 53 54 return (rval); 55 56 } /* _init() */ 57 58 int 59 _fini() 60 { 61 int rval; 62 63 rval = mod_remove(&emlxs_modlinkage); 64 65 return (rval); 66 67 } /* _fini() */ 68 69 int 70 _info(struct modinfo *modinfop) 71 { 72 int rval; 73 74 rval = mod_info(&emlxs_modlinkage, modinfop); 75 76 return (rval); 77 78 } /* _fini() */ 79 80 int 81 emlxs_fw_get(emlxs_firmware_t *fw) 82 { 83 uint32_t i; 84 emlxs_firmware_t *fw_table; 85 86 /* Find matching firmware table entry */ 87 fw_table = emlxs_fw_table; 88 for (i = 0; i < EMLXS_FW_COUNT; i++, fw_table++) { 89 /* Validate requested fw image */ 90 if ((fw_table->id == fw->id) && 91 (fw_table->kern == fw->kern) && 92 (fw_table->stub == fw->stub) && 93 (fw_table->sli1 == fw->sli1) && 94 (fw_table->sli2 == fw->sli2) && 95 (fw_table->sli3 == fw->sli3) && 96 (fw_table->sli4 == fw->sli4)) { 97 /* Return image data and size */ 98 fw->image = fw_table->image; 99 fw->size = fw_table->size; 100 101 return (0); 102 } 103 } 104 105 fw->image = NULL; 106 fw->size = 0; 107 108 return (1); 109 110 } /* emlxs_fw_get() */ 111