xref: /freebsd/share/man/man9/SYSCALL_MODULE.9 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
150c39ea7SAlexander Langer.\" -*- nroff -*-
250c39ea7SAlexander Langer.\"
350c39ea7SAlexander Langer.\" Copyright (c) 2001 Alexander Langer
450c39ea7SAlexander Langer.\"
550c39ea7SAlexander Langer.\" All rights reserved.
650c39ea7SAlexander Langer.\"
750c39ea7SAlexander Langer.\" This program is free software.
850c39ea7SAlexander Langer.\"
950c39ea7SAlexander Langer.\" Redistribution and use in source and binary forms, with or without
1050c39ea7SAlexander Langer.\" modification, are permitted provided that the following conditions
1150c39ea7SAlexander Langer.\" are met:
1250c39ea7SAlexander Langer.\" 1. Redistributions of source code must retain the above copyright
1350c39ea7SAlexander Langer.\"    notice, this list of conditions and the following disclaimer.
1450c39ea7SAlexander Langer.\" 2. Redistributions in binary form must reproduce the above copyright
1550c39ea7SAlexander Langer.\"    notice, this list of conditions and the following disclaimer in the
1650c39ea7SAlexander Langer.\"    documentation and/or other materials provided with the distribution.
1750c39ea7SAlexander Langer.\"
1850c39ea7SAlexander Langer.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
1950c39ea7SAlexander Langer.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2050c39ea7SAlexander Langer.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2150c39ea7SAlexander Langer.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
2250c39ea7SAlexander Langer.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2350c39ea7SAlexander Langer.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2450c39ea7SAlexander Langer.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2550c39ea7SAlexander Langer.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2650c39ea7SAlexander Langer.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2750c39ea7SAlexander Langer.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2850c39ea7SAlexander Langer.\"
29*9f135336SKa Ho Ng.Dd June 15, 2023
3050c39ea7SAlexander Langer.Dt SYSCALL_MODULE 9
3150c39ea7SAlexander Langer.Os
3250c39ea7SAlexander Langer.Sh NAME
3350c39ea7SAlexander Langer.Nm SYSCALL_MODULE
3450c39ea7SAlexander Langer.Nd syscall kernel module declaration macro
3550c39ea7SAlexander Langer.Sh SYNOPSIS
36f16b3c0dSChad David.In sys/param.h
37f16b3c0dSChad David.In sys/kernel.h
3832eef9aeSRuslan Ermilov.In sys/proc.h
3932eef9aeSRuslan Ermilov.In sys/module.h
4032eef9aeSRuslan Ermilov.In sys/sysent.h
41be9365a9SMaxim Konovalov.Fn SYSCALL_MODULE name "int *offset" "struct sysent *new_sysent" "modeventhand_t evh" "void *arg"
4250c39ea7SAlexander Langer.Sh DESCRIPTION
4350c39ea7SAlexander LangerThe
4450c39ea7SAlexander Langer.Fn SYSCALL_MODULE
4550c39ea7SAlexander Langermacro declares a new syscall.
4650c39ea7SAlexander Langer.Fn SYSCALL_MODULE
47b8797aecSMark Johnstonexpands into a kernel module declaration with name
48b8797aecSMark Johnston.Ql sys/ Ns Fa name .
4950c39ea7SAlexander Langer.Pp
5066700df0SGiorgos KeramidasThe rest of the arguments expected by this macro are:
5166700df0SGiorgos Keramidas.Bl -tag -width ".Fa new_sysent"
5266700df0SGiorgos Keramidas.It Fa offset
5366700df0SGiorgos KeramidasA pointer to an
5450c39ea7SAlexander Langer.Vt int
5550c39ea7SAlexander Langerwhich saves the offset in
5650c39ea7SAlexander Langer.Vt "struct sysent"
5766700df0SGiorgos Keramidaswhere the syscall is allocated.
58b89281abSJulian ElischerIf the location pointed to by
59b89281abSJulian Elischer.Fa offset
60b89281abSJulian Elischerholds a non 0 number it will be used if possible.
61d52d61d0SJulian ElischerIf it holds 0 then one will be assigned.
6266700df0SGiorgos Keramidas.It Fa new_sysent
63be9365a9SMaxim Konovalovis a pointer to a structure that specifies the function implementing
64be9365a9SMaxim Konovalovthe syscall and the number of arguments this function needs (see
65fe08efe6SRuslan Ermilov.In sys/sysent.h ) .
6666700df0SGiorgos Keramidas.It Fa evh
6766700df0SGiorgos KeramidasA pointer to the kernel module event handler function with the argument
6850c39ea7SAlexander Langer.Fa arg .
6950c39ea7SAlexander LangerPlease refer to
7050c39ea7SAlexander Langer.Xr module 9
7150c39ea7SAlexander Langerfor more information.
7266700df0SGiorgos Keramidas.It Fa arg
7366700df0SGiorgos KeramidasThe argument passed to the callback functions of the
7466700df0SGiorgos Keramidas.Fa evh
7566700df0SGiorgos Keramidasevent handler when it is called.
7666700df0SGiorgos Keramidas.El
77d52d61d0SJulian Elischer.Pp
78d52d61d0SJulian ElischerThe syscall number assigned to the module can be retrieved using the
79*9f135336SKa Ho Ng.Xr modstat 2
80d52d61d0SJulian Elischerand
81*9f135336SKa Ho Ng.Xr modfind 2
82*9f135336SKa Ho Ngsystem calls.
83d52d61d0SJulian ElischerThe MACRO
84d52d61d0SJulian Elischer.Fn SYSCALL_MODULE_HELPER
85d52d61d0SJulian Elischerincludes
86d52d61d0SJulian Elischer.Fn SYSCALL_MODULE
87d52d61d0SJulian Elischerand much of its boilerplate code.
8850c39ea7SAlexander Langer.Sh EXAMPLES
8950c39ea7SAlexander LangerA minimal example for a syscall module can be found in
9050c39ea7SAlexander Langer.Pa /usr/share/examples/kld/syscall/module/syscall.c .
9150c39ea7SAlexander Langer.Sh SEE ALSO
9250c39ea7SAlexander Langer.Xr module 9
9350c39ea7SAlexander Langer.Pp
9450c39ea7SAlexander Langer.Pa /usr/share/examples/kld/syscall/module/syscall.c
9550c39ea7SAlexander Langer.Sh AUTHORS
9650c39ea7SAlexander LangerThis manual page was written by
978a7314fcSBaptiste Daroussin.An Alexander Langer Aq Mt alex@FreeBSD.org .
98