emlxs_fw.c revision 291a2b48b9adcd7b3666c34e80ba6411929afe7f
3184N/A/*
3184N/A * CDDL HEADER START
3184N/A *
3184N/A * The contents of this file are subject to the terms of the
3184N/A * Common Development and Distribution License (the "License").
3184N/A * You may not use this file except in compliance with the License.
3184N/A *
3184N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3184N/A * or http://www.opensolaris.org/os/licensing.
3184N/A * See the License for the specific language governing permissions
3184N/A * and limitations under the License.
3184N/A *
3184N/A * When distributing Covered Code, include this CDDL HEADER in each
3184N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3184N/A * If applicable, add the following below this CDDL HEADER, with the
3184N/A * fields enclosed by brackets "[]" replaced with your own identifying
3184N/A * information: Portions Copyright [yyyy] [name of copyright owner]
3184N/A *
3184N/A * CDDL HEADER END
3184N/A */
3184N/A
3184N/A/*
3184N/A * Copyright 2009 Emulex. All rights reserved.
3184N/A * Use is subject to License terms.
5150N/A */
6208N/A
3184N/A#define EMLXS_FW_TABLE_DEF
3184N/A
3184N/A#include <sys/types.h>
3184N/A#include <sys/modctl.h>
6639N/A#include <emlxs_version.h>
3184N/A#include <emlxs_fw.h>
6573N/A
3184N/Achar emlxs_fw_name[] = EMLXS_FW_NAME;
3184N/A
3184N/Astatic struct modlmisc emlxs_modlmisc = {
3184N/A &mod_miscops,
3184N/A emlxs_fw_name
3184N/A};
6621N/A
6621N/Astatic struct modlinkage emlxs_modlinkage = {
3184N/A MODREV_1,
6639N/A (void *)&emlxs_modlmisc,
6639N/A NULL
3184N/A};
6639N/A
3184N/Aint
3184N/A_init(void)
3184N/A{
3184N/A int rval;
3184N/A
3184N/A rval = mod_install(&emlxs_modlinkage);
3184N/A
3184N/A return (rval);
3184N/A
3184N/A} /* _init() */
3184N/A
3184N/Aint
3184N/A_fini()
3184N/A{
3184N/A int rval;
3184N/A
3184N/A rval = mod_remove(&emlxs_modlinkage);
3184N/A
3184N/A return (rval);
3184N/A
3184N/A} /* _fini() */
6573N/A
6639N/Aint
4802N/A_info(struct modinfo *modinfop)
3184N/A{
6573N/A int rval;
6639N/A
4802N/A rval = mod_info(&emlxs_modlinkage, modinfop);
3988N/A
6573N/A return (rval);
6573N/A
4802N/A} /* _fini() */
3184N/A
6573N/Aint
6573N/Aemlxs_fw_get(emlxs_firmware_t *fw)
6573N/A{
6573N/A uint32_t i;
6639N/A emlxs_firmware_t *fw_table;
4802N/A
3184N/A /* Find matching firmware table entry */
6573N/A fw_table = emlxs_fw_table;
4802N/A for (i = 0; i < EMLXS_FW_COUNT; i++, fw_table++) {
3184N/A /* Validate requested fw image */
6573N/A if ((fw_table->id == fw->id) &&
4802N/A (fw_table->kern == fw->kern) &&
3988N/A (fw_table->stub == fw->stub) &&
3184N/A (fw_table->sli1 == fw->sli1) &&
3184N/A (fw_table->sli2 == fw->sli2) &&
3184N/A (fw_table->sli3 == fw->sli3) &&
3184N/A (fw_table->sli4 == fw->sli4)) {
3184N/A /* Return image data and size */
3184N/A fw->image = fw_table->image;
4802N/A fw->size = fw_table->size;
3184N/A
6639N/A return (0);
6573N/A }
6573N/A }
6573N/A
3184N/A fw->image = NULL;
3184N/A fw->size = 0;
3184N/A
3184N/A return (1);
3184N/A
3184N/A} /* emlxs_fw_get() */
3184N/A