opensolaris.c revision 194118
150476Speter/*- 215903Swosch * Copyright 2007 John Birrell <jb@FreeBSD.org> 315903Swosch * 415903Swosch * Redistribution and use in source and binary forms, with or without 515903Swosch * modification, are permitted provided that the following conditions 615903Swosch * are met: 715903Swosch * 1. Redistributions of source code must retain the above copyright 815903Swosch * notice, this list of conditions and the following disclaimer. 915903Swosch * 2. Redistributions in binary form must reproduce the above copyright 1015903Swosch * notice, this list of conditions and the following disclaimer in the 1115903Swosch * documentation and/or other materials provided with the distribution. 1215903Swosch * 1315903Swosch * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14139761Skrion * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1534678Sbde * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1623546Swosch * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 1723546Swosch * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1823546Swosch * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1939161Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2015903Swosch * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2139161Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2215903Swosch * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2315903Swosch * SUCH DAMAGE. 2415903Swosch * 2515903Swosch * $FreeBSD: head/sys/cddl/compat/opensolaris/kern/opensolaris.c 194118 2009-06-13 15:39:12Z jamie $ 2615903Swosch * 2715903Swosch */ 2815903Swosch 2932216Swosch#include <sys/cdefs.h> 3032216Swosch#include <sys/types.h> 3132216Swosch#include <sys/conf.h> 3232216Swosch#include <sys/cpuvar.h> 3315903Swosch#include <sys/errno.h> 3415903Swosch#include <sys/jail.h> 3515903Swosch#include <sys/kernel.h> 3615903Swosch#include <sys/misc.h> 37119057Sobrien#include <sys/module.h> 3815903Swosch#include <sys/mutex.h> 3915903Swosch 4015903Swoschcpu_core_t cpu_core[MAXCPU]; 4115903Swoschkmutex_t cpu_lock; 4215903Swoschsolaris_cpu_t solaris_cpu[MAXCPU]; 4315903Swosch 4415903Swosch/* 4565501Sobrien * OpenSolaris subsystem initialisation. 4615903Swosch */ 47186894Sbzstatic void 4815903Swoschopensolaris_load(void *dummy) 49186894Sbz{ 5015903Swosch int i; 5153033Sphantom 5215903Swosch printf("This module (opensolaris) contains code covered by the\n"); 5315903Swosch printf("Common Development and Distribution License (CDDL)\n"); 5415903Swosch printf("see http://opensolaris.org/os/licensing/opensolaris_license/\n"); 5515903Swosch 5615903Swosch /* 5739161Sobrien * "Enable" all CPUs even though they may not exist just so 5815903Swosch * that the asserts work. On FreeBSD, if a CPU exists, it is 5939161Sobrien * enabled. 6015903Swosch */ 6115903Swosch for (i = 0; i < MAXCPU; i++) { 6215903Swosch solaris_cpu[i].cpuid = i; 6315903Swosch solaris_cpu[i].cpu_flags &= CPU_ENABLE; 6415903Swosch } 6515903Swosch 6615903Swosch mutex_init(&cpu_lock, "OpenSolaris CPU lock", MUTEX_DEFAULT, NULL); 6715903Swosch} 6815903Swosch 6915903SwoschSYSINIT(opensolaris_register, SI_SUB_OPENSOLARIS, SI_ORDER_FIRST, opensolaris_load, NULL); 7015903Swosch 7115903Swoschstatic void 7215903Swoschopensolaris_unload(void) 7315903Swosch{ 7415903Swosch mutex_destroy(&cpu_lock); 7515903Swosch} 7615903Swosch 7715903SwoschSYSUNINIT(opensolaris_unregister, SI_SUB_OPENSOLARIS, SI_ORDER_FIRST, opensolaris_unload, NULL); 7815903Swosch 7915903Swoschstatic int 8015903Swoschopensolaris_modevent(module_t mod __unused, int type, void *data __unused) 8115903Swosch{ 8215903Swosch int error = 0; 8315903Swosch 8415903Swosch switch (type) { 8515903Swosch case MOD_LOAD: 8615903Swosch utsname.nodename = prison0.pr_hostname; 8715903Swosch break; 8815903Swosch 8915903Swosch case MOD_UNLOAD: 9015903Swosch break; 9115903Swosch 9215903Swosch case MOD_SHUTDOWN: 9315903Swosch break; 9490627Sphantom 9515903Swosch default: 9690626Sphantom error = EOPNOTSUPP; 9715903Swosch break; 9890626Sphantom 9915903Swosch } 10061462Sghelmer return (error); 10115903Swosch} 10232216Swosch 10315903SwoschDEV_MODULE(opensolaris, opensolaris_modevent, NULL); 10494982SruMODULE_VERSION(opensolaris, 1); 10594982Sru