37 #include <sys/cdefs.h>
42 #include <sys/param.h>
43 #include <sys/kernel.h>
44 #include <sys/linker.h>
46 #include <sys/mutex.h>
47 #include <sys/systm.h>
56 static TAILQ_HEAD(, intr_config_hook) intr_config_hook_list =
57 TAILQ_HEAD_INITIALIZER(intr_config_hook_list);
58 static struct intr_config_hook *next_to_notify;
59 static struct mtx intr_config_hook_lock;
60 MTX_SYSINIT(intr_config_hook, &intr_config_hook_lock, "intr config", MTX_DEF);
69 #define WARNING_INTERVAL_SECS 60
71 run_interrupt_driven_config_hooks_warning(
int warned)
73 struct intr_config_hook *hook_entry;
78 printf(
"run_interrupt_driven_hooks: still waiting after %d "
80 TAILQ_FOREACH(hook_entry, &intr_config_hook_list, ich_links) {
82 (caddr_t)hook_entry->ich_func, namebuf,
83 sizeof(namebuf), &offset) == 0)
86 printf(
" %p", hook_entry->ich_func);
91 (
"run_interrupt_driven_config_hooks: waited too long"));
98 struct intr_config_hook *hook_entry;
100 mtx_lock(&intr_config_hook_lock);
109 mtx_unlock(&intr_config_hook_lock);
114 while (next_to_notify != NULL) {
115 hook_entry = next_to_notify;
116 next_to_notify = TAILQ_NEXT(hook_entry, ich_links);
117 mtx_unlock(&intr_config_hook_lock);
118 (*hook_entry->ich_func)(hook_entry->ich_arg);
119 mtx_lock(&intr_config_hook_lock);
123 mtx_unlock(&intr_config_hook_lock);
134 mtx_lock(&intr_config_hook_lock);
136 while (!TAILQ_EMPTY(&intr_config_hook_list)) {
137 if (msleep(&intr_config_hook_list, &intr_config_hook_lock,
140 mtx_unlock(&intr_config_hook_lock);
142 run_interrupt_driven_config_hooks_warning(warned);
143 mtx_lock(&intr_config_hook_lock);
146 mtx_unlock(&intr_config_hook_lock);
149 SYSINIT(intr_config_hooks, SI_SUB_INT_CONFIG_HOOKS, SI_ORDER_FIRST,
160 struct intr_config_hook *hook_entry;
162 mtx_lock(&intr_config_hook_lock);
163 TAILQ_FOREACH(hook_entry, &intr_config_hook_list, ich_links)
164 if (hook_entry == hook)
166 if (hook_entry != NULL) {
167 mtx_unlock(&intr_config_hook_lock);
168 printf(
"config_intrhook_establish: establishing an "
169 "already established hook.\n");
172 TAILQ_INSERT_TAIL(&intr_config_hook_list, hook, ich_links);
173 if (next_to_notify == NULL)
174 next_to_notify = hook;
175 mtx_unlock(&intr_config_hook_lock);
189 struct intr_config_hook *hook_entry;
191 mtx_lock(&intr_config_hook_lock);
192 TAILQ_FOREACH(hook_entry, &intr_config_hook_list, ich_links)
193 if (hook_entry == hook)
195 if (hook_entry == NULL)
196 panic(
"config_intrhook_disestablish: disestablishing an "
197 "unestablished hook");
199 if (next_to_notify == hook)
200 next_to_notify = TAILQ_NEXT(hook, ich_links);
201 TAILQ_REMOVE(&intr_config_hook_list, hook, ich_links);
204 wakeup(&intr_config_hook_list);
205 mtx_unlock(&intr_config_hook_lock);
211 DB_SHOW_COMMAND(conifhk, db_show_conifhk)
213 struct intr_config_hook *hook_entry;
217 TAILQ_FOREACH(hook_entry, &intr_config_hook_list, ich_links) {
219 (caddr_t)hook_entry->ich_func, namebuf,
sizeof(namebuf),
221 db_printf(
"hook: %p at %s+%#lx arg: %p\n",
222 hook_entry->ich_func, namebuf, offset,
223 hook_entry->ich_arg);
225 db_printf(
"hook: %p at ??+?? arg %p\n",
226 hook_entry->ich_func, hook_entry->ich_arg);
MTX_SYSINIT(et_eventtimers_init,&et_eventtimers_mtx,"et_mtx", MTX_DEF)
void config_intrhook_disestablish(struct intr_config_hook *hook)
static TAILQ_HEAD(MTX_SYSINIT(intr_config_hook)
void panic(const char *fmt,...)
static void run_interrupt_driven_config_hooks()
static void boot_run_interrupt_driven_config_hooks(void *dummy)
int config_intrhook_establish(struct intr_config_hook *hook)
int printf(const char *fmt,...)
SYSINIT(intr_config_hooks, SI_SUB_INT_CONFIG_HOOKS, SI_ORDER_FIRST, boot_run_interrupt_driven_config_hooks, NULL)
int linker_search_symbol_name(caddr_t value, char *buf, u_int buflen, long *offset)
#define WARNING_INTERVAL_SECS
int linker_ddb_search_symbol_name(caddr_t value, char *buf, u_int buflen, long *offset)