Changeset View
Changeset View
Standalone View
Standalone View
share/man/man9/config_intrhook.9
Show All 20 Lines | |||||
.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||||
.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | .\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||||
.\" DAMAGE. | .\" DAMAGE. | ||||
.\" | .\" | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd September 24, 2006 | .Dd August 10, 2017 | ||||
.Dt CONFIG_INTRHOOK 9 | .Dt CONFIG_INTRHOOK 9 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm config_intrhook | .Nm config_intrhook | ||||
.Nd schedule a function to be run after interrupts have been enabled, | .Nd schedule a function to be run after interrupts have been enabled, | ||||
but before root is mounted | but before root is mounted | ||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||
.In sys/kernel.h | .In sys/kernel.h | ||||
.Vt typedef void (*ich_func_t)(void *arg); | |||||
.Ft int | .Ft int | ||||
.Fn config_intrhook_establish "struct intr_config_hook *hook" | .Fn config_intrhook_establish "struct intr_config_hook *hook" | ||||
.Ft void | .Ft void | ||||
.Fn config_intrhook_disestablish "struct intr_config_hook *hook" | .Fn config_intrhook_disestablish "struct intr_config_hook *hook" | ||||
.Ft void | |||||
.Fn config_intrhook_oneshot "ich_func_t func" "void *arg" | |||||
.Sh DESCRIPTION | .Sh DESCRIPTION | ||||
The | The | ||||
.Fn config_intrhook_establish | .Fn config_intrhook_establish | ||||
function schedules a function to be run after interrupts have been | function schedules a function to be run after interrupts have been | ||||
enabled, but before root is mounted. | enabled, but before root is mounted. | ||||
If the system has already passed this point in its initialization, | If the system has already passed this point in its initialization, | ||||
the function is called immediately. | the function is called immediately. | ||||
.Pp | .Pp | ||||
The | The | ||||
.Fn config_intrhook_disestablish | .Fn config_intrhook_disestablish | ||||
function removes the entry from the hook queue. | function removes the entry from the hook queue. | ||||
.Pp | .Pp | ||||
The | |||||
.Fn config_intrhook_oneshot | |||||
function schedules a function to be run as described for | |||||
.Fn 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. | |||||
.Pp | |||||
Before root is mounted, all the previously established hooks are | Before root is mounted, all the previously established hooks are | ||||
run. | run. | ||||
The boot process is then stalled until all handlers remove their hook | The boot process is then stalled until all handlers remove their hook | ||||
from the hook queue with | from the hook queue with | ||||
.Fn config_intrhook_disestablish . | .Fn config_intrhook_disestablish . | ||||
The boot process then proceeds to attempt to mount the root file | The boot process then proceeds to attempt to mount the root file | ||||
system. | system. | ||||
Any driver that can potentially provide devices they wish to be | Any driver that can potentially provide devices they wish to be | ||||
mounted as root must use either this hook, or probe all these devices | mounted as root must use either this hook, or probe all these devices | ||||
in the initial probe. | in the initial probe. | ||||
Since interrupts are disabled during the probe process, many drivers | Since interrupts are disabled during the probe process, many drivers | ||||
need a method to probe for devices with interrupts enabled. | need a method to probe for devices with interrupts enabled. | ||||
.Pp | .Pp | ||||
The requests are made with the | The requests are made with the | ||||
.Vt intr_config_hook | .Vt intr_config_hook | ||||
structure. | structure. | ||||
This structure is defined as follows: | This structure is defined as follows: | ||||
.Bd -literal | .Bd -literal | ||||
struct intr_config_hook { | struct intr_config_hook { | ||||
TAILQ_ENTRY(intr_config_hook) ich_links;/* Private */ | TAILQ_ENTRY(intr_config_hook) ich_links;/* Private */ | ||||
void (*ich_func)(void *arg); /* function to call */ | ich_func_t ich_func; /* function to call */ | ||||
void *ich_arg; /* Argument to call */ | void *ich_arg; /* Argument to call */ | ||||
}; | }; | ||||
.Ed | .Ed | ||||
.Pp | .Pp | ||||
Storage for the | Storage for the | ||||
.Vt intr_config_hook | .Vt intr_config_hook | ||||
structure must be provided by the driver. | structure must be provided by the driver. | ||||
It must be stable from just before the hook is established until | It must be stable from just before the hook is established until | ||||
after the hook is disestablished. | after the hook is disestablished. | ||||
Show All 22 Lines |