1.\" -*- nroff -*- 2.\" 3.\" Copyright (c) 2000 Alexander Langer 4.\" 5.\" All rights reserved. 6.\" 7.\" This program is free software. 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.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 19.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 22.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28.\" 29.\" $FreeBSD$ 30.\" 31.Dd February 12, 2018 32.Dt DRIVER_MODULE 9 33.Os 34.Sh NAME 35.Nm DRIVER_MODULE , 36.Nm DRIVER_MODULE_ORDERED , 37.Nm EARLY_DRIVER_MODULE , 38.Nm EARLY_DRIVER_MODULE_ORDERED 39.Nd kernel driver declaration macro 40.Sh SYNOPSIS 41.In sys/param.h 42.In sys/kernel.h 43.In sys/bus.h 44.In sys/module.h 45.Fn DRIVER_MODULE name busname "driver_t driver" "devclass_t devclass" "modeventhand_t evh" "void *arg" 46.Fn DRIVER_MODULE_ORDERED name busname "driver_t driver" "devclass_t devclass" "modeventhand_t evh" "void *arg" "int order" 47.Fn EARLY_DRIVER_MODULE name busname "driver_t driver" "devclass_t devclass" "modeventhand_t evh" "void *arg" "enum sysinit_elem_order order" "int pass" 48.Fn EARLY_DRIVER_MODULE_ORDERED name busname "driver_t driver" "devclass_t devclass" "modeventhand_t evh" "void *arg" "enum sysinit_elem_order order" "int pass" 49.Sh DESCRIPTION 50The 51.Fn DRIVER_MODULE 52macro declares a kernel driver. 53.Fn DRIVER_MODULE 54expands to the real driver declaration, where the phrase 55.Fa name 56is used as the naming prefix for the driver and its functions. 57Note that it is supplied as plain text, and not a 58.Li char 59or 60.Li char * . 61.Pp 62.Fa busname 63is the parent bus of the driver (PCI, ISA, PPBUS and others), e.g.\& 64.Ql pci , 65.Ql isa , 66or 67.Ql ppbus . 68.Pp 69The identifier used in 70.Fn DRIVER_MODULE 71can be different from the driver name. 72Also, the same driver identifier can exist on different buses, 73which is a pretty clean way of making front ends for different cards 74using the same driver on the same or different buses. 75For example, the following is allowed: 76.Pp 77.Fn DRIVER_MODULE foo isa foo_driver foo_devclass NULL NULL ; 78.Pp 79.Fn DRIVER_MODULE foo pci foo_driver foo_devclass NULL NULL ; 80.Pp 81.Fa driver 82is the driver of type 83.Li driver_t , 84which contains the information about the driver and is therefore one of the 85two most important parts of the call to 86.Fn DRIVER_MODULE . 87.Pp 88The 89.Fa devclass 90argument contains the kernel-internal information about the device, 91which will be used within the kernel driver module. 92.Pp 93The 94.Fa evh 95argument is the event handler which is called when the driver (or module) 96is loaded or unloaded (see 97.Xr module 9 ) . 98.Pp 99The 100.Fa arg 101is unused at this time and should be a 102.Dv NULL 103pointer. 104.Pp 105The 106.Fn DRIVER_MODULE_ORDERED 107macro allows a driver to be registered in a specific order. 108This can be useful if a single kernel module contains multiple drivers 109that are inter-dependent. 110The 111.Fa order 112argument should be one of the 113.Xr SYSINIT 9 114initialization ordering constants 115.Pq Dv SI_ORDER_* . 116The default order for a driver module is 117.Dv SI_ORDER_MIDDLE . 118Typically a module will specify an order of 119.Dv SI_ORDER_ANY 120for a single driver to ensure it is registered last. 121.Pp 122The 123.Fn EARLY_DRIVER_MODULE 124macro allows a driver to be registered for a specific pass level. 125The boot time probe and attach process makes multiple passes over the 126device tree. 127Certain critical drivers that provide basic services needed by other 128devices are attached during earlier passes. 129Most drivers are attached in a final general pass. 130A driver that attaches during an early pass must register for a specific 131pass level 132.Pq BUS_PASS_* 133via the 134.Fa pass 135argument. 136Once a driver is registered it is available to attach to devices for 137all subsequent passes. 138.Pp 139The 140.Fn EARLY_DRIVER_MODULE_ORDERED 141macro allows a driver to be registered both in a specific order and 142for a specific pass level. 143.Sh SEE ALSO 144.Xr device 9 , 145.Xr driver 9 , 146.Xr module 9 , 147.Xr MODULE_PNP_INFO 9 , 148.Xr SYSINIT 9 149.Sh AUTHORS 150This manual page was written by 151.An Alexander Langer Aq Mt alex@FreeBSD.org . 152