---
name: "config_intrhook"
section: "9"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/config_intrhook"
---

# config\_intrhook(9)

schedule a function to be run after interrupts have been enabled, but before root is mounted

## NAME

**config\_intrhook** – schedule a function to be run after interrupts have been enabled, but before root is mounted

## SYNOPSIS

**#include \<sys/kernel.h\>**

*typedef* *void* *(\*ich\_func\_t)(void* *\*arg);*

*int*\

**config\_intrhook\_establish**(*struct intr\_config\_hook \*hook*);

*void*\

**config\_intrhook\_disestablish**(*struct intr\_config\_hook \*hook*);

*int*\

**config\_intrhook\_drain**(*struct intr\_config\_hook \*hook*);

*void*\

**config\_intrhook\_oneshot**(*ich\_func\_t func*, *void \*arg*);

## DESCRIPTION

The **config\_intrhook\_establish**() function schedules a function to be run after interrupts have been enabled, but before root is mounted. If the system has already passed this point in its initialization, the function is called immediately.

The **config\_intrhook\_disestablish**() function removes the entry from the hook queue.

The **config\_intrhook\_drain**() function removes the entry from the hook queue in a safe way. If the hook is not currently active it removes *hook* from the hook queue and returns *ICHS\_QUEUED*. If the hook is active, it waits for the hook to complete before returning *ICHS\_RUNNING*. If the hook has previously completed, it returns *ICHS\_DONE*. Because a *config\_intrhook* is undefined prior to **config\_intrhook\_establish**(), this function may only be called after that function has returned.

The **config\_intrhook\_oneshot**() function schedules a function to be run as described for **config\_intrhook\_establish**(); the entry is automatically removed from the hook queue after that function runs. This is appropriate when additional device configuration must be done after interrupts are enabled, but there is no need to stall the boot process after that. This function allocates memory using M\_WAITOK; do not call this while holding any non-sleepable locks.

Before root is mounted, all the previously established hooks are run. The boot process is then stalled until all handlers remove their hook from the hook queue with **config\_intrhook\_disestablish**(). The boot process then proceeds to attempt to mount the root file system. Any driver that can potentially provide devices they wish to be mounted as root must use either this hook, or probe all these devices in the initial probe. Since interrupts are disabled during the probe process, many drivers need a method to probe for devices with interrupts enabled.

The requests are made with the *intr\_config\_hook* structure. This structure is defined as follows:

```
struct intr_config_hook {
	TAILQ_ENTRY(intr_config_hook) ich_links;/* Private */
	ich_func_t	ich_func;		/* function to call */
	void		*ich_arg;		/* Argument to call */
};
```

Storage for the *intr\_config\_hook* structure must be provided by the driver. It must be stable from just before the hook is established until after the hook is disestablished.

Specifically, hooks are run at **SI\_SUB\_INT\_CONFIG\_HOOKS**(), which is immediately after the scheduler is started, and just before the root file system device is discovered.

## RETURN VALUES

A zero return value means the hook was successfully added to the queue (with either deferred or immediate execution). A non-zero return value means the hook could not be added to the queue because it was already on the queue.

## SEE ALSO

[DEVICE\_ATTACH(9)](/DEVICE_ATTACH/9.md)

## HISTORY

These functions were introduced in FreeBSD 3.0 with the CAM subsystem, but are available for any driver to use.

## AUTHORS

The functions were written by Justin Gibbs ⟨*gibbs@FreeBSD.org*⟩. This manual page was written by M. Warner Losh ⟨*imp@FreeBSD.org*⟩.
