The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/ispfw/ispfw.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * ISP Firmware Modules for FreeBSD
    5  *
    6  * Copyright (c) 2000, 2001, 2006 by Matthew Jacob
    7  * All rights reserved.
    8  *
    9  * Redistribution and use in source and binary forms, with or without
   10  * modification, are permitted provided that the following conditions
   11  * are met:
   12  * 1. Redistributions of source code must retain the above copyright
   13  *    notice immediately at the beginning of the file, without modification,
   14  *    this list of conditions, and the following disclaimer.
   15  * 2. The name of the author may not be used to endorse or promote products
   16  *    derived from this software without specific prior written permission.
   17  *
   18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
   22  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   28  * SUCH DAMAGE.
   29  */
   30 
   31 #include <sys/cdefs.h>
   32 __FBSDID("$FreeBSD$");
   33 
   34 #include <sys/param.h>
   35 #include <sys/firmware.h>
   36 #include <sys/kernel.h>
   37 #include <sys/linker.h>
   38 #include <sys/module.h>
   39 #include <sys/systm.h>
   40 
   41 #if     defined(ISP_ALL) || !defined(KLD_MODULE) 
   42 #define ISP_2400        1
   43 #define ISP_2500        1
   44 #endif
   45 
   46 #ifndef MODULE_NAME
   47 #define MODULE_NAME     "ispfw"
   48 #endif
   49 
   50 #if     defined(ISP_2400)
   51 #include <dev/ispfw/asm_2400.h>
   52 #endif
   53 #if     defined(ISP_2500)
   54 #include <dev/ispfw/asm_2500.h>
   55 #endif
   56 
   57 #if     defined(ISP_2400)
   58 static int      isp_2400_loaded;
   59 #endif
   60 #if     defined(ISP_2500)
   61 static int      isp_2500_loaded;
   62 #endif
   63 
   64 #define ISPFW_VERSION   1
   65 
   66 #define RMACRO(token)   do {                                            \
   67         if (token##_loaded)                                             \
   68                 break;                                                  \
   69         if (firmware_register(#token, token##_risc_code,                \
   70             token##_risc_code[3] * sizeof(token##_risc_code[3]),        \
   71             ISPFW_VERSION, NULL) == NULL)                               \
   72                 break;                                                  \
   73         token##_loaded++;                                               \
   74 } while (0)
   75 
   76 #define UMACRO(token)   do {                                            \
   77         if (!token##_loaded)                                            \
   78                 break;                                                  \
   79         if (firmware_unregister(#token) != 0) {                         \
   80                 error = EBUSY;                                          \
   81                 break;                                                  \
   82         }                                                               \
   83         token##_loaded--;                                               \
   84 } while (0)
   85 
   86 static int
   87 do_load_fw(void)
   88 {
   89 
   90 #if     defined(ISP_2400)
   91         RMACRO(isp_2400);
   92 #endif
   93 #if     defined(ISP_2500)
   94         RMACRO(isp_2500);
   95 #endif
   96         return (0);
   97 }
   98 
   99 static int
  100 do_unload_fw(void)
  101 {
  102         int error = 0;
  103 
  104 #if     defined(ISP_2400)
  105         UMACRO(isp_2400);
  106 #endif
  107 #if     defined(ISP_2500)
  108         UMACRO(isp_2500);
  109 #endif
  110         return (error);
  111 }
  112 
  113 static int
  114 module_handler(module_t mod, int what, void *arg)
  115 {
  116 
  117         switch (what) {
  118         case MOD_LOAD:
  119                 return (do_load_fw());
  120         case MOD_UNLOAD:
  121                 return (do_unload_fw());
  122         }
  123         return (EOPNOTSUPP);
  124 }
  125 static moduledata_t ispfw_mod = {
  126         MODULE_NAME, module_handler, NULL
  127 };
  128 #if     defined(ISP_ALL) || !defined(KLD_MODULE) 
  129 DECLARE_MODULE(ispfw, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD);
  130 #elif   defined(ISP_2400)
  131 DECLARE_MODULE(isp_2400, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD);
  132 #elif   defined(ISP_2500)
  133 DECLARE_MODULE(isp_2500, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD);
  134 #else
  135 #error  "firmware not specified"
  136 #endif

Cache object: c25931c5fb2a9f06d612c62a2e14418f


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.