1380a989bSDoug Rabson /*- 2f0cfa1b1SPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3f0cfa1b1SPedro F. Giffuni * 4380a989bSDoug Rabson * Copyright (c) 1999 Assar Westerlund 5380a989bSDoug Rabson * All rights reserved. 6380a989bSDoug Rabson * 7380a989bSDoug Rabson * Redistribution and use in source and binary forms, with or without 8380a989bSDoug Rabson * modification, are permitted provided that the following conditions 9380a989bSDoug Rabson * are met: 10380a989bSDoug Rabson * 1. Redistributions of source code must retain the above copyright 11380a989bSDoug Rabson * notice, this list of conditions and the following disclaimer. 12380a989bSDoug Rabson * 2. Redistributions in binary form must reproduce the above copyright 13380a989bSDoug Rabson * notice, this list of conditions and the following disclaimer in the 14380a989bSDoug Rabson * documentation and/or other materials provided with the distribution. 15380a989bSDoug Rabson * 16380a989bSDoug Rabson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17380a989bSDoug Rabson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18380a989bSDoug Rabson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19380a989bSDoug Rabson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20380a989bSDoug Rabson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21380a989bSDoug Rabson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22380a989bSDoug Rabson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23380a989bSDoug Rabson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24380a989bSDoug Rabson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25380a989bSDoug Rabson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26380a989bSDoug Rabson * SUCH DAMAGE. 27380a989bSDoug Rabson * 287f3dea24SPeter Wemm * $FreeBSD$ 29380a989bSDoug Rabson */ 30380a989bSDoug Rabson 31380a989bSDoug Rabson #include <sys/param.h> 32380a989bSDoug Rabson #include <sys/proc.h> 33380a989bSDoug Rabson #include <sys/module.h> 34282a3889SKevin Lo #include <sys/sysproto.h> 35380a989bSDoug Rabson #include <sys/sysent.h> 36380a989bSDoug Rabson #include <sys/kernel.h> 37380a989bSDoug Rabson #include <sys/systm.h> 38380a989bSDoug Rabson 39380a989bSDoug Rabson /* 40380a989bSDoug Rabson * The function for implementing the syscall. 41380a989bSDoug Rabson */ 42380a989bSDoug Rabson static int 43a220d00eSAndrew R. Reiter hello(struct thread *td, void *arg) 44380a989bSDoug Rabson { 45195ebc7eSPawel Jakub Dawidek 46380a989bSDoug Rabson printf("hello kernel\n"); 47195ebc7eSPawel Jakub Dawidek return (0); 48380a989bSDoug Rabson } 49380a989bSDoug Rabson 50380a989bSDoug Rabson /* 51380a989bSDoug Rabson * The `sysent' for the new syscall 52380a989bSDoug Rabson */ 53380a989bSDoug Rabson static struct sysent hello_sysent = { 54dc318a4fSFernando Apesteguía .sy_narg = 0, 55dc318a4fSFernando Apesteguía .sy_call = hello 56380a989bSDoug Rabson }; 57380a989bSDoug Rabson 58380a989bSDoug Rabson /* 59380a989bSDoug Rabson * The offset in sysent where the syscall is allocated. 60380a989bSDoug Rabson */ 61380a989bSDoug Rabson static int offset = NO_SYSCALL; 62380a989bSDoug Rabson 63380a989bSDoug Rabson /* 64380a989bSDoug Rabson * The function called at load/unload. 65380a989bSDoug Rabson */ 66380a989bSDoug Rabson static int 67380a989bSDoug Rabson load(struct module *module, int cmd, void *arg) 68380a989bSDoug Rabson { 69380a989bSDoug Rabson int error = 0; 70380a989bSDoug Rabson 71380a989bSDoug Rabson switch (cmd) { 72380a989bSDoug Rabson case MOD_LOAD : 73380a989bSDoug Rabson printf("syscall loaded at %d\n", offset); 74380a989bSDoug Rabson break; 75380a989bSDoug Rabson case MOD_UNLOAD : 76380a989bSDoug Rabson printf("syscall unloaded from %d\n", offset); 77380a989bSDoug Rabson break; 78380a989bSDoug Rabson default : 7974bf4e16SPawel Jakub Dawidek error = EOPNOTSUPP; 80380a989bSDoug Rabson break; 81380a989bSDoug Rabson } 82195ebc7eSPawel Jakub Dawidek return (error); 83380a989bSDoug Rabson } 84380a989bSDoug Rabson 85380a989bSDoug Rabson SYSCALL_MODULE(syscall, &offset, &hello_sysent, load, NULL); 86