initterm-r0drv.cpp revision 54319ad88c52a9ca6391d892b9e4cb83e9dc075d
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * IPRT - Initialization & Termination, R0 Driver, Common.
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * available from http://www.virtualbox.org. This file is free software;
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * you can redistribute it and/or modify it under the terms of the GNU
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * General Public License (GPL) as published by the Free Software
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * The contents of this file may alternatively be used under the terms
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * of the Common Development and Distribution License Version 1.0
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * VirtualBox OSE distribution, in which case the provisions of the
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * CDDL are applicable instead of those of the GPL.
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * You may elect to license modified versions of this file under the
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * terms and conditions of either the GPL or the CDDL or both.
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * additional information or have any questions.
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync/*******************************************************************************
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync* Header Files *
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync*******************************************************************************/
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync/*******************************************************************************
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync* Global Variables *
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync*******************************************************************************/
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync/** Count of current IPRT users.
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * In ring-0 several drivers / kmods / kexts / wossnames may share the
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * same runtime code. So, we need to keep count in order not to terminate
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * it prematurely. */
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * Initalizes the ring-0 driver runtime library.
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * @returns iprt status code.
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * @param fReserved Flags reserved for the future.
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * The first user initializes it.
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * We rely on the module loader to ensure that there are no
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * initialization races should two modules share the IPRT.
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync#if !defined(RT_OS_LINUX) && !defined(RT_OS_WINDOWS)
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * Terminates the ring-0 driver runtime library.
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync * Last user does the cleanup.
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync int32_t cNewUsers = ASMAtomicDecS32(&g_crtR0Users);
41c77a6173c9afd8d2ea87955be516ae7d8d0dc9vboxsync#if !defined(RT_OS_LINUX) && !defined(RT_OS_WINDOWS)