spinlock-r0drv-solaris.c revision fc0e1701814ea969173fadb20fef6833b04fb2bc
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * IPRT - Spinlocks, Ring-0 Driver, Solaris.
c0b6af690ad705bddfa87c643b89770a7a0aaf5avboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * available from http://www.virtualbox.org. This file is free software;
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * you can redistribute it and/or modify it under the terms of the GNU
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * General Public License (GPL) as published by the Free Software
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * The contents of this file may alternatively be used under the terms
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * of the Common Development and Distribution License Version 1.0
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * VirtualBox OSE distribution, in which case the provisions of the
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * CDDL are applicable instead of those of the GPL.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * You may elect to license modified versions of this file under the
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * terms and conditions of either the GPL or the CDDL or both.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * additional information or have any questions.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync/*******************************************************************************
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync* Header Files *
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync*******************************************************************************/
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync/*******************************************************************************
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync* Structures and Typedefs *
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync*******************************************************************************/
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Wrapper for the struct mutex type.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync /** Spinlock magic value (RTSPINLOCK_MAGIC). */
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync /** A Solaris spinlock. */
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync /** The idAssertCpu variable before acquring the lock for asserting after
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * releasing the spinlock. */
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync /** The CPU that owns the lock. */
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Allocate.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *));
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pThis));
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Initialize & return.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync mutex_init(&pThis->Mtx, "IPRT Spinlock", MUTEX_SPIN, (void *)ipltospl(DISP_LEVEL));
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Validate input.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync AssertMsgReturn(pThis->u32Magic == RTSPINLOCK_MAGIC,
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync ("Invalid spinlock %p magic=%#x\n", pThis, pThis->u32Magic),
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync * Make the lock invalid and release the memory.
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsyncRTDECL(void) RTSpinlockAcquireNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsyncRTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
9fc464631dc4a68fbb5eb6419d61fbe91b6b16bdvboxsync PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
#ifdef RT_STRICT
#ifdef RT_STRICT