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/kern/subr_autoconf.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  * Copyright (c) 1992, 1993
    3  *      The Regents of the University of California.  All rights reserved.
    4  *
    5  * This software was developed by the Computer Systems Engineering group
    6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
    7  * contributed to Berkeley.
    8  *
    9  * All advertising materials mentioning features or use of this software
   10  * must display the following acknowledgement:
   11  *      This product includes software developed by the University of
   12  *      California, Lawrence Berkeley Laboratories.
   13  *
   14  * Redistribution and use in source and binary forms, with or without
   15  * modification, are permitted provided that the following conditions
   16  * are met:
   17  * 1. Redistributions of source code must retain the above copyright
   18  *    notice, this list of conditions and the following disclaimer.
   19  * 2. Redistributions in binary form must reproduce the above copyright
   20  *    notice, this list of conditions and the following disclaimer in the
   21  *    documentation and/or other materials provided with the distribution.
   22  * 3. All advertising materials mentioning features or use of this software
   23  *    must display the following acknowledgement:
   24  *      This product includes software developed by the University of
   25  *      California, Berkeley and its contributors.
   26  * 4. Neither the name of the University nor the names of its contributors
   27  *    may be used to endorse or promote products derived from this software
   28  *    without specific prior written permission.
   29  *
   30  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   31  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   32  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   33  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   34  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   35  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   36  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   37  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   38  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   39  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   40  * SUCH DAMAGE.
   41  *
   42  *      @(#)subr_autoconf.c     8.1 (Berkeley) 6/10/93
   43  *
   44  */
   45 
   46 #include <sys/cdefs.h>
   47 __FBSDID("$FreeBSD: releng/5.2/sys/kern/subr_autoconf.c 117879 2003-07-22 10:36:36Z phk $");
   48 
   49 #include <sys/param.h>
   50 #include <sys/kernel.h>
   51 #include <sys/systm.h>
   52 
   53 /*
   54  * Autoconfiguration subroutines.
   55  */
   56 
   57 /*
   58  * "Interrupt driven config" functions.
   59  */
   60 static TAILQ_HEAD(, intr_config_hook) intr_config_hook_list =
   61         TAILQ_HEAD_INITIALIZER(intr_config_hook_list);
   62 
   63 
   64 /* ARGSUSED */
   65 static void run_interrupt_driven_config_hooks(void *dummy);
   66 static void
   67 run_interrupt_driven_config_hooks(dummy)
   68         void *dummy;
   69 {
   70         struct intr_config_hook *hook_entry, *next_entry;
   71 
   72         for (hook_entry = TAILQ_FIRST(&intr_config_hook_list);
   73              hook_entry != NULL;
   74              hook_entry = next_entry) {
   75                 next_entry = TAILQ_NEXT(hook_entry, ich_links);
   76                 (*hook_entry->ich_func)(hook_entry->ich_arg);
   77         }
   78 
   79         while (!TAILQ_EMPTY(&intr_config_hook_list)) {
   80                 tsleep(&intr_config_hook_list, PCONFIG, "conifhk", 0);
   81         }
   82 }
   83 SYSINIT(intr_config_hooks, SI_SUB_INT_CONFIG_HOOKS, SI_ORDER_FIRST,
   84         run_interrupt_driven_config_hooks, NULL)
   85 
   86 /*
   87  * Register a hook that will be called after "cold"
   88  * autoconfiguration is complete and interrupts can
   89  * be used to complete initialization.
   90  */
   91 int
   92 config_intrhook_establish(hook)
   93         struct intr_config_hook *hook;
   94 {
   95         struct intr_config_hook *hook_entry;
   96 
   97         for (hook_entry = TAILQ_FIRST(&intr_config_hook_list);
   98              hook_entry != NULL;
   99              hook_entry = TAILQ_NEXT(hook_entry, ich_links))
  100                 if (hook_entry == hook)
  101                         break;
  102         if (hook_entry != NULL) {
  103                 printf("config_intrhook_establish: establishing an "
  104                        "already established hook.\n");
  105                 return (1);
  106         }
  107         TAILQ_INSERT_TAIL(&intr_config_hook_list, hook, ich_links);
  108         if (cold == 0)
  109                 /* XXX Sufficient for modules loaded after initial config??? */
  110                 run_interrupt_driven_config_hooks(NULL);        
  111         return (0);
  112 }
  113 
  114 void
  115 config_intrhook_disestablish(hook)
  116         struct intr_config_hook *hook;
  117 {
  118         struct intr_config_hook *hook_entry;
  119 
  120         for (hook_entry = TAILQ_FIRST(&intr_config_hook_list);
  121              hook_entry != NULL;
  122              hook_entry = TAILQ_NEXT(hook_entry, ich_links))
  123                 if (hook_entry == hook)
  124                         break;
  125         if (hook_entry == NULL)
  126                 panic("config_intrhook_disestablish: disestablishing an "
  127                       "unestablished hook");
  128 
  129         TAILQ_REMOVE(&intr_config_hook_list, hook, ich_links);
  130         /* Wakeup anyone watching the list */
  131         wakeup(&intr_config_hook_list);
  132 }

Cache object: 3404ea348a1a12f7f907246ee1a2ac40


[ 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.