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

Cache object: 41177ece06457c359fc0c51482e9733b


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