1fa81ece8SWarner Losh.\" 2bd84dd2fSRuslan Ermilov.\" Copyright (C) 2006 M. Warner Losh <imp@FreeBSD.org>. All rights reserved. 3fa81ece8SWarner Losh.\" 4fa81ece8SWarner Losh.\" Redistribution and use in source and binary forms, with or without 5fa81ece8SWarner Losh.\" modification, are permitted provided that the following conditions 6fa81ece8SWarner Losh.\" are met: 7fa81ece8SWarner Losh.\" 1. Redistributions of source code must retain the above copyright 8fa81ece8SWarner Losh.\" notice(s), this list of conditions and the following disclaimer as 9fa81ece8SWarner Losh.\" the first lines of this file unmodified other than the possible 10fa81ece8SWarner Losh.\" addition of one or more copyright notices. 11fa81ece8SWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright 12fa81ece8SWarner Losh.\" notice(s), this list of conditions and the following disclaimer in the 13fa81ece8SWarner Losh.\" documentation and/or other materials provided with the distribution. 14fa81ece8SWarner Losh.\" 15fa81ece8SWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 16fa81ece8SWarner Losh.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17fa81ece8SWarner Losh.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18fa81ece8SWarner Losh.\" DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY 19fa81ece8SWarner Losh.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20fa81ece8SWarner Losh.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21fa81ece8SWarner Losh.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22fa81ece8SWarner Losh.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23fa81ece8SWarner Losh.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24fa81ece8SWarner Losh.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 25fa81ece8SWarner Losh.\" DAMAGE. 26fa81ece8SWarner Losh.\" 27fa81ece8SWarner Losh.\" $FreeBSD$ 28fa81ece8SWarner Losh.\" 29*2db14f97SIan Lepore.Dd August 10, 2017 30fa81ece8SWarner Losh.Dt CONFIG_INTRHOOK 9 31fa81ece8SWarner Losh.Os 32fa81ece8SWarner Losh.Sh NAME 33fa81ece8SWarner Losh.Nm config_intrhook 34bd84dd2fSRuslan Ermilov.Nd schedule a function to be run after interrupts have been enabled, 35bd84dd2fSRuslan Ermilovbut before root is mounted 36fa81ece8SWarner Losh.Sh SYNOPSIS 37fa81ece8SWarner Losh.In sys/kernel.h 38*2db14f97SIan Lepore.Vt typedef void (*ich_func_t)(void *arg); 39bd84dd2fSRuslan Ermilov.Ft int 40fa81ece8SWarner Losh.Fn config_intrhook_establish "struct intr_config_hook *hook" 41bd84dd2fSRuslan Ermilov.Ft void 42fa81ece8SWarner Losh.Fn config_intrhook_disestablish "struct intr_config_hook *hook" 43*2db14f97SIan Lepore.Ft void 44*2db14f97SIan Lepore.Fn config_intrhook_oneshot "ich_func_t func" "void *arg" 45fa81ece8SWarner Losh.Sh DESCRIPTION 46fa81ece8SWarner LoshThe 47fa81ece8SWarner Losh.Fn config_intrhook_establish 48fa81ece8SWarner Loshfunction schedules a function to be run after interrupts have been 49fa81ece8SWarner Loshenabled, but before root is mounted. 50fa81ece8SWarner LoshIf the system has already passed this point in its initialization, 51fa81ece8SWarner Loshthe function is called immediately. 52fa81ece8SWarner Losh.Pp 53fa81ece8SWarner LoshThe 54fa81ece8SWarner Losh.Fn config_intrhook_disestablish 55fa81ece8SWarner Loshfunction removes the entry from the hook queue. 56fa81ece8SWarner Losh.Pp 57*2db14f97SIan LeporeThe 58*2db14f97SIan Lepore.Fn config_intrhook_oneshot 59*2db14f97SIan Leporefunction schedules a function to be run as described for 60*2db14f97SIan Lepore.Fn config_intrhook_establish ; 61*2db14f97SIan Leporethe entry is automatically removed from the hook queue 62*2db14f97SIan Leporeafter that function runs. 63*2db14f97SIan LeporeThis is appropriate when additional device configuration must be done 64*2db14f97SIan Leporeafter interrupts are enabled, but there is no need to stall the 65*2db14f97SIan Leporeboot process after that. 66*2db14f97SIan LeporeThis function allocates memory using M_WAITOK; do not call this while 67*2db14f97SIan Leporeholding any non-sleepable locks. 68*2db14f97SIan Lepore.Pp 69fa81ece8SWarner LoshBefore root is mounted, all the previously established hooks are 70fa81ece8SWarner Loshrun. 71fa81ece8SWarner LoshThe boot process is then stalled until all handlers remove their hook 72fa81ece8SWarner Loshfrom the hook queue with 73fa81ece8SWarner Losh.Fn config_intrhook_disestablish . 74fa81ece8SWarner LoshThe boot process then proceeds to attempt to mount the root file 75fa81ece8SWarner Loshsystem. 76fa81ece8SWarner LoshAny driver that can potentially provide devices they wish to be 77fa81ece8SWarner Loshmounted as root must use either this hook, or probe all these devices 78fa81ece8SWarner Loshin the initial probe. 79fa81ece8SWarner LoshSince interrupts are disabled during the probe process, many drivers 80fa81ece8SWarner Loshneed a method to probe for devices with interrupts enabled. 81fa81ece8SWarner Losh.Pp 82fa81ece8SWarner LoshThe requests are made with the 83bd84dd2fSRuslan Ermilov.Vt intr_config_hook 84fa81ece8SWarner Loshstructure. 85fa81ece8SWarner LoshThis structure is defined as follows: 86fa81ece8SWarner Losh.Bd -literal 87fa81ece8SWarner Loshstruct intr_config_hook { 88fa81ece8SWarner Losh TAILQ_ENTRY(intr_config_hook) ich_links;/* Private */ 89*2db14f97SIan Lepore ich_func_t ich_func; /* function to call */ 90fa81ece8SWarner Losh void *ich_arg; /* Argument to call */ 91fa81ece8SWarner Losh}; 92fa81ece8SWarner Losh.Ed 93fa81ece8SWarner Losh.Pp 94fa81ece8SWarner LoshStorage for the 95fa81ece8SWarner Losh.Vt intr_config_hook 96fa81ece8SWarner Loshstructure must be provided by the driver. 97fa81ece8SWarner LoshIt must be stable from just before the hook is established until 98fa81ece8SWarner Loshafter the hook is disestablished. 99fa81ece8SWarner Losh.Pp 100fa81ece8SWarner LoshSpecifically, hooks are run at 101fa81ece8SWarner Losh.Fn SI_SUB_INT_CONFIG_HOOKS , 1029280e5faSMike Pritchardwhich is immediately after the scheduler is started, 103fa81ece8SWarner Loshand just before the root file system device is discovered. 104fa81ece8SWarner Losh.Sh RETURN VALUES 1050cc19870SWarner LoshA zero return value means the hook was successfully added to the queue 1060cc19870SWarner Losh(with either deferred or immediate execution). 1070cc19870SWarner LoshA non-zero return value means the hook could not be added to the queue 1080cc19870SWarner Loshbecause it was already on the queue. 109fa81ece8SWarner Losh.Sh SEE ALSO 110fa81ece8SWarner Losh.Xr DEVICE_ATTACH 9 111fa81ece8SWarner Losh.Sh HISTORY 112fa81ece8SWarner LoshThese functions were introduced in 113fa81ece8SWarner Losh.Fx 3.0 114fa81ece8SWarner Loshwith the CAM subsystem, but are available for any driver to use. 115fa81ece8SWarner Losh.Sh AUTHORS 116bd84dd2fSRuslan Ermilov.An -nosplit 117fa81ece8SWarner LoshThe functions were written by 1188a7314fcSBaptiste Daroussin.An Justin Gibbs Aq Mt gibbs@FreeBSD.org . 119fa81ece8SWarner LoshThis manual page was written by 1208a7314fcSBaptiste Daroussin.An M. Warner Losh Aq Mt imp@FreeBSD.org . 121