xref: /freebsd/share/man/man9/SYSCALL_MODULE.9 (revision 9f135336f5057ae5a3f54fd9b1aa517cff0f9d3b)
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.\"
2950c39ea7SAlexander Langer.\" $FreeBSD$
3050c39ea7SAlexander Langer.\"
31*9f135336SKa Ho Ng.Dd June 15, 2023
3250c39ea7SAlexander Langer.Dt SYSCALL_MODULE 9
3350c39ea7SAlexander Langer.Os
3450c39ea7SAlexander Langer.Sh NAME
3550c39ea7SAlexander Langer.Nm SYSCALL_MODULE
3650c39ea7SAlexander Langer.Nd syscall kernel module declaration macro
3750c39ea7SAlexander Langer.Sh SYNOPSIS
38f16b3c0dSChad David.In sys/param.h
39f16b3c0dSChad David.In sys/kernel.h
4032eef9aeSRuslan Ermilov.In sys/proc.h
4132eef9aeSRuslan Ermilov.In sys/module.h
4232eef9aeSRuslan Ermilov.In sys/sysent.h
43be9365a9SMaxim Konovalov.Fn SYSCALL_MODULE name "int *offset" "struct sysent *new_sysent" "modeventhand_t evh" "void *arg"
4450c39ea7SAlexander Langer.Sh DESCRIPTION
4550c39ea7SAlexander LangerThe
4650c39ea7SAlexander Langer.Fn SYSCALL_MODULE
4750c39ea7SAlexander Langermacro declares a new syscall.
4850c39ea7SAlexander Langer.Fn SYSCALL_MODULE
49b8797aecSMark Johnstonexpands into a kernel module declaration with name
50b8797aecSMark Johnston.Ql sys/ Ns Fa name .
5150c39ea7SAlexander Langer.Pp
5266700df0SGiorgos KeramidasThe rest of the arguments expected by this macro are:
5366700df0SGiorgos Keramidas.Bl -tag -width ".Fa new_sysent"
5466700df0SGiorgos Keramidas.It Fa offset
5566700df0SGiorgos KeramidasA pointer to an
5650c39ea7SAlexander Langer.Vt int
5750c39ea7SAlexander Langerwhich saves the offset in
5850c39ea7SAlexander Langer.Vt "struct sysent"
5966700df0SGiorgos Keramidaswhere the syscall is allocated.
60b89281abSJulian ElischerIf the location pointed to by
61b89281abSJulian Elischer.Fa offset
62b89281abSJulian Elischerholds a non 0 number it will be used if possible.
63d52d61d0SJulian ElischerIf it holds 0 then one will be assigned.
6466700df0SGiorgos Keramidas.It Fa new_sysent
65be9365a9SMaxim Konovalovis a pointer to a structure that specifies the function implementing
66be9365a9SMaxim Konovalovthe syscall and the number of arguments this function needs (see
67fe08efe6SRuslan Ermilov.In sys/sysent.h ) .
6866700df0SGiorgos Keramidas.It Fa evh
6966700df0SGiorgos KeramidasA pointer to the kernel module event handler function with the argument
7050c39ea7SAlexander Langer.Fa arg .
7150c39ea7SAlexander LangerPlease refer to
7250c39ea7SAlexander Langer.Xr module 9
7350c39ea7SAlexander Langerfor more information.
7466700df0SGiorgos Keramidas.It Fa arg
7566700df0SGiorgos KeramidasThe argument passed to the callback functions of the
7666700df0SGiorgos Keramidas.Fa evh
7766700df0SGiorgos Keramidasevent handler when it is called.
7866700df0SGiorgos Keramidas.El
79d52d61d0SJulian Elischer.Pp
80d52d61d0SJulian ElischerThe syscall number assigned to the module can be retrieved using the
81*9f135336SKa Ho Ng.Xr modstat 2
82d52d61d0SJulian Elischerand
83*9f135336SKa Ho Ng.Xr modfind 2
84*9f135336SKa Ho Ngsystem calls.
85d52d61d0SJulian ElischerThe MACRO
86d52d61d0SJulian Elischer.Fn SYSCALL_MODULE_HELPER
87d52d61d0SJulian Elischerincludes
88d52d61d0SJulian Elischer.Fn SYSCALL_MODULE
89d52d61d0SJulian Elischerand much of its boilerplate code.
9050c39ea7SAlexander Langer.Sh EXAMPLES
9150c39ea7SAlexander LangerA minimal example for a syscall module can be found in
9250c39ea7SAlexander Langer.Pa /usr/share/examples/kld/syscall/module/syscall.c .
9350c39ea7SAlexander Langer.Sh SEE ALSO
9450c39ea7SAlexander Langer.Xr module 9
9550c39ea7SAlexander Langer.Pp
9650c39ea7SAlexander Langer.Pa /usr/share/examples/kld/syscall/module/syscall.c
9750c39ea7SAlexander Langer.Sh AUTHORS
9850c39ea7SAlexander LangerThis manual page was written by
998a7314fcSBaptiste Daroussin.An Alexander Langer Aq Mt alex@FreeBSD.org .
100