Path: blob/main/sys/cddl/compat/opensolaris/kern/opensolaris.c
48383 views
/*-1* Copyright 2007 John Birrell <[email protected]>2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6* 1. Redistributions of source code must retain the above copyright7* notice, this list of conditions and the following disclaimer.8* 2. Redistributions in binary form must reproduce the above copyright9* notice, this list of conditions and the following disclaimer in the10* documentation and/or other materials provided with the distribution.11*12* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND13* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE14* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE15* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE16* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL17* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS18* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)19* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT20* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY21* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF22* SUCH DAMAGE.23*24*/2526#include <sys/param.h>27#include <sys/conf.h>28#include <sys/cpuvar.h>29#include <sys/errno.h>30#include <sys/jail.h>31#include <sys/kernel.h>32#include <sys/misc.h>33#include <sys/module.h>34#include <sys/mutex.h>3536extern struct opensolaris_utsname utsname;3738cpu_core_t cpu_core[MAXCPU];39kmutex_t cpu_lock;40solaris_cpu_t solaris_cpu[MAXCPU];41int nsec_per_tick;4243/*44* OpenSolaris subsystem initialisation.45*/46static void47opensolaris_load(void *dummy)48{49int i;5051/*52* "Enable" all CPUs even though they may not exist just so53* that the asserts work. On FreeBSD, if a CPU exists, it is54* enabled.55*/56for (i = 0; i < MAXCPU; i++) {57solaris_cpu[i].cpuid = i;58solaris_cpu[i].cpu_flags &= CPU_ENABLE;59}6061mutex_init(&cpu_lock, "OpenSolaris CPU lock", MUTEX_DEFAULT, NULL);6263nsec_per_tick = NANOSEC / hz;64}6566SYSINIT(opensolaris_register, SI_SUB_OPENSOLARIS, SI_ORDER_FIRST, opensolaris_load, NULL);6768static void69opensolaris_unload(void *dummy __unused)70{71mutex_destroy(&cpu_lock);72}7374SYSUNINIT(opensolaris_unregister, SI_SUB_OPENSOLARIS, SI_ORDER_FIRST, opensolaris_unload, NULL);7576static int77opensolaris_modevent(module_t mod __unused, int type, void *data __unused)78{79int error = 0;8081switch (type) {82case MOD_LOAD:83break;8485case MOD_UNLOAD:86break;8788case MOD_SHUTDOWN:89break;9091default:92error = EOPNOTSUPP;93break;9495}96return (error);97}9899DEV_MODULE(opensolaris, opensolaris_modevent, NULL);100MODULE_VERSION(opensolaris, 1);101102103