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 March 3, 2001 32.Dt DECLARE_MODULE 9 33.Os 34.Sh NAME 35.Nm DECLARE_MODULE 36.Nd kernel module declaration macro 37.Sh SYNOPSIS 38.Fd #include <sys/module.h> 39.Fn DECLARE_MODULE "name" "moduledata_t data" "sub" "order" 40.Sh DESCRIPTION 41The 42.Fn DECLARE_MODULE 43macro declares a generic kernel module. 44It is used to register the module with the system, using the 45.Fn SYSINIT 46macro. 47.Fn DECLARE_MODULE 48is usually used within other macros, such as 49.Xr DRIVER_MODULE 9 , 50.Xr DEV_MODULE 9 51and 52.Xr SYSCALL_MODULE 9 . 53However, it can be called directly of course, for example in 54order to implement dynamic sysctls. 55.Pp 56The arguments to 57.Fn DECLARE_MODULE : 58.Pp 59.Fa name 60is the name of the module, which will be used in the 61.Fn SYSINIT 62call to identify the module. 63.Pp 64.Fa data 65is a pointer to the 66.Vt moduledata_t 67structure, which contains two main items, the official name of the 68module name, which will be used in the 69.Vt module_t 70structure and a pointer to the event handler function of type 71.Vt modeventhand_t . 72.Pp 73.Fa sub 74is an argument directed to the 75.Fn SYSINIT 76macro. 77Valid values for this are contained in the 78.Vt sysstem_sub_id 79enumeration 80(see 81.Pa kernel.h ) 82and specify the type of system startup interfaces. 83The 84.Xr DRIVER_MODULE 9 85macro uses a value of 86.Dv SI_SUB_DRIVERS 87here for example, since these modules contain a driver for a device. 88For kernel modules that are loaded at runtime, a value of 89.Dv SI_SUB_EXEC 90is common. 91.Pp 92The 93.Fa order 94value is another argument for 95.Fn SYSINIT . 96It represents the KLDs order of initialization within the subsystem. 97Valid values are defined in the 98.Vt sysinit_elem_order 99enumeration 100.Pa ( kernel.h ) . 101.Sh SEE ALSO 102.Xr DEV_MODULE 9 , 103.Xr DRIVER_MODULE 9 , 104.Xr module 9 , 105.Xr SYSCALL_MODULE 9 106.Pp 107.Pa /usr/include/sys/kernel.h , 108.Pa /usr/share/examples/kld 109.Sh AUTHORS 110.An -nosplit 111This manual page was written by 112.An Alexander Langer Aq alex@FreeBSD.org , 113inspired by the KLD Facility Programming Tutorial by 114.An Andrew Reiter Aq arr@watson.org . 115