Changeset 63345 in vbox for trunk/src/VBox/Runtime/r0drv
- Timestamp:
- Aug 11, 2016 6:25:33 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 109979
- Location:
- trunk/src/VBox/Runtime/r0drv/netbsd
- Files:
-
- 11 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/netbsd/assert-r0drv-netbsd.c
r63342 r63345 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Assertion Workers, Ring-0 Drivers, FreeBSD.3 * IPRT - Assertion Workers, Ring-0 Drivers, NetBSD. 4 4 */ 5 5 … … 29 29 */ 30 30 31 32 31 /********************************************************************************************************************************* 33 32 * Header Files * 34 33 *********************************************************************************************************************************/ 35 #include "the- freebsd-kernel.h"34 #include "the-netbsd-kernel.h" 36 35 37 36 #include <iprt/assert.h> 38 37 #include <iprt/log.h> 39 #include <iprt/string.h>40 38 #include <iprt/stdarg.h> 41 39 … … 54 52 DECLHIDDEN(void) rtR0AssertNativeMsg2V(bool fInitial, const char *pszFormat, va_list va) 55 53 { 56 char szMsg[256]; 57 58 RTStrPrintfV(szMsg, sizeof(szMsg) - 1, pszFormat, va); 59 szMsg[sizeof(szMsg) - 1] = '\0'; 60 printf("%s", szMsg); 61 62 NOREF(fInitial); 54 /** @todo implement rtR0AssertNativeMsg2V. */ 63 55 } 64 56 … … 66 58 RTR0DECL(void) RTR0AssertPanicSystem(void) 67 59 { 68 /** @todo implement RTR0AssertPanicSystem. */ 60 panic("%s%s", g_szRTAssertMsg1, g_szRTAssertMsg2); 61 69 62 } 70 -
trunk/src/VBox/Runtime/r0drv/netbsd/initterm-r0drv-netbsd.c
r63342 r63345 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Initialization & Termination, Ring-0 Driver, FreeBSD.3 * IPRT - Initialization & Termination, Ring-0 Driver, NetBSD. 4 4 */ 5 5 … … 29 29 */ 30 30 31 32 31 /********************************************************************************************************************************* 33 32 * Header Files * 34 33 *********************************************************************************************************************************/ 35 #include "the- freebsd-kernel.h"34 #include "the-netbsd-kernel.h" 36 35 37 36 #include <iprt/err.h> … … 51 50 /* nothing to undo */ 52 51 } 53 -
trunk/src/VBox/Runtime/r0drv/netbsd/memuserkernel-r0drv-netbsd.c
r63342 r63345 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - User & Kernel Memory, Ring-0 Driver, FreeBSD.3 * IPRT - User & Kernel Memory, Ring-0 Driver, NetBSD. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2009-201 6Oracle Corporation7 * Copyright (C) 2009-2012 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 29 29 * Header Files * 30 30 *********************************************************************************************************************************/ 31 #include "the- freebsd-kernel.h"31 #include "the-netbsd-kernel.h" 32 32 33 33 #include <iprt/mem.h> … … 81 81 return VERR_NOT_SUPPORTED; 82 82 } 83 -
trunk/src/VBox/Runtime/r0drv/netbsd/process-r0drv-netbsd.c
r63342 r63345 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Process Management, Ring-0 Driver, FreeBSD.3 * IPRT - Process Management, Ring-0 Driver, NetBSD. 4 4 */ 5 5 6 6 /* 7 * Copyright (c) 2007 knut st. osmundsen <[email protected]>8 *9 7 * Permission is hereby granted, free of charge, to any person 10 8 * obtaining a copy of this software and associated documentation … … 29 27 */ 30 28 31 32 29 /********************************************************************************************************************************* 33 30 * Header Files * 34 31 *********************************************************************************************************************************/ 35 #include "the- freebsd-kernel.h"32 #include "the-netbsd-kernel.h" 36 33 37 34 #include <iprt/process.h> … … 49 46 return (RTR0PROCESS)curproc; 50 47 } 51 -
trunk/src/VBox/Runtime/r0drv/netbsd/semevent-r0drv-netbsd.c
r63342 r63345 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Single Release Event Semaphores, Ring-0 Driver, FreeBSD.3 * IPRT - Single Release Event Semaphores, Ring-0 Driver, NetBSD. 4 4 */ 5 5 … … 29 29 */ 30 30 31 32 31 /********************************************************************************************************************************* 33 32 * Header Files * 34 33 *********************************************************************************************************************************/ 35 34 #define RTSEMEVENT_WITHOUT_REMAPPING 36 #include "the- freebsd-kernel.h"35 #include "the-netbsd-kernel.h" 37 36 #include "internal/iprt.h" 38 37 #include <iprt/semaphore.h> … … 44 43 #include <iprt/mem.h> 45 44 46 #include "sleepqueue-r0drv- freebsd.h"45 #include "sleepqueue-r0drv-netbsd.h" 47 46 #include "internal/magics.h" 48 47 … … 52 51 *********************************************************************************************************************************/ 53 52 /** 54 * FreeBSD event semaphore.53 * NetBSD event semaphore. 55 54 */ 56 55 typedef struct RTSEMEVENTINTERNAL … … 254 253 return 1000000000 / hz; 255 254 } 256 -
trunk/src/VBox/Runtime/r0drv/netbsd/semeventmulti-r0drv-netbsd.c
r63342 r63345 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Multiple Release Event Semaphores, Ring-0 Driver, FreeBSD.3 * IPRT - Multiple Release Event Semaphores, Ring-0 Driver, NetBSD. 4 4 */ 5 5 … … 29 29 */ 30 30 31 32 31 /********************************************************************************************************************************* 33 32 * Header Files * 34 33 *********************************************************************************************************************************/ 35 34 #define RTSEMEVENTMULTI_WITHOUT_REMAPPING 36 #include "the- freebsd-kernel.h"35 #include "the-netbsd-kernel.h" 37 36 #include "internal/iprt.h" 38 37 #include <iprt/semaphore.h> … … 44 43 #include <iprt/lockvalidator.h> 45 44 46 #include "sleepqueue-r0drv- freebsd.h"45 #include "sleepqueue-r0drv-netbsd.h" 47 46 #include "internal/magics.h" 48 47 … … 65 64 /** @} */ 66 65 67 68 66 /********************************************************************************************************************************* 69 67 * Structures and Typedefs * 70 68 *********************************************************************************************************************************/ 71 69 /** 72 * FreeBSD multiple release event semaphore.70 * NetBSD multiple release event semaphore. 73 71 */ 74 72 typedef struct RTSEMEVENTMULTIINTERNAL … … 318 316 } 319 317 RT_EXPORT_SYMBOL(RTSemEventMultiGetResolution); 320 -
trunk/src/VBox/Runtime/r0drv/netbsd/semfastmutex-r0drv-netbsd.c
r63342 r63345 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Fast Mutex Semaphores, Ring-0 Driver, FreeBSD.3 * IPRT - Fast Mutex Semaphores, Ring-0 Driver, NetBSD. 4 4 */ 5 5 … … 29 29 */ 30 30 31 32 31 /********************************************************************************************************************************* 33 32 * Header Files * 34 33 *********************************************************************************************************************************/ 35 #include "the- freebsd-kernel.h"34 #include "the-netbsd-kernel.h" 36 35 37 36 #include <iprt/semaphore.h> … … 48 47 *********************************************************************************************************************************/ 49 48 /** 50 * Wrapper for the FreeBSD (sleep) mutex.49 * Wrapper for the NetBSD (sleep) mutex. 51 50 */ 52 51 typedef struct RTSEMFASTMUTEXINTERNAL … … 54 53 /** Magic value (RTSEMFASTMUTEX_MAGIC). */ 55 54 uint32_t u32Magic; 56 /** The FreeBSD shared/exclusive lock mutex. */57 struct sx SxLock;55 /** The NetBSD shared/exclusive lock mutex. */ 56 krwlock_t Mtx; 58 57 } RTSEMFASTMUTEXINTERNAL, *PRTSEMFASTMUTEXINTERNAL; 59 58 … … 68 67 { 69 68 pThis->u32Magic = RTSEMFASTMUTEX_MAGIC; 70 sx_init_flags(&pThis->SxLock, "IPRT Fast Mutex Semaphore", SX_DUPOK);69 rw_init(&pThis->Mtx); 71 70 72 71 *phFastMtx = pThis; … … 86 85 87 86 ASMAtomicWriteU32(&pThis->u32Magic, RTSEMFASTMUTEX_MAGIC_DEAD); 88 sx_destroy(&pThis->SxLock);87 rw_destroy(&pThis->Mtx); 89 88 RTMemFree(pThis); 90 89 … … 99 98 AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE); 100 99 101 sx_xlock(&pThis->SxLock);100 rw_enter(&pThis->Mtx, RW_WRITER); 102 101 return VINF_SUCCESS; 103 102 } … … 110 109 AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE); 111 110 112 sx_xunlock(&pThis->SxLock);111 rw_exit(&pThis->Mtx); 113 112 return VINF_SUCCESS; 114 113 } 115 -
trunk/src/VBox/Runtime/r0drv/netbsd/semmutex-r0drv-netbsd.c
r63342 r63345 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Mutex Semaphores, Ring-0 Driver, FreeBSD.3 * IPRT - Mutex Semaphores, Ring-0 Driver, NetBSD. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2010-201 6Oracle Corporation7 * Copyright (C) 2010-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 30 30 *********************************************************************************************************************************/ 31 31 #define RTSEMMUTEX_WITHOUT_REMAPPING 32 #include "the- freebsd-kernel.h"32 #include "the-netbsd-kernel.h" 33 33 #include "internal/iprt.h" 34 34 #include <iprt/semaphore.h> … … 48 48 *********************************************************************************************************************************/ 49 49 /** 50 * Wrapper for the FreeBSD (sleep) mutex.50 * Wrapper for the NetBSD (sleep) mutex. 51 51 */ 52 52 typedef struct RTSEMMUTEXINTERNAL … … 54 54 /** Magic value (RTSEMMUTEX_MAGIC). */ 55 55 uint32_t u32Magic; 56 /** The FreeBSD shared/exclusive lock mutex. */56 /** The NetBSD shared/exclusive lock mutex. */ 57 57 struct sx SxLock; 58 58 } RTSEMMUTEXINTERNAL, *PRTSEMMUTEXINTERNAL; … … 134 134 } 135 135 136 return VINF_SUCCESS;136 return rc; 137 137 } 138 138 … … 187 187 } 188 188 189 return VINF_SUCCESS;189 return rc; 190 190 } 191 191 … … 217 217 return sx_xlocked(&pThis->SxLock); 218 218 } 219 -
trunk/src/VBox/Runtime/r0drv/netbsd/thread-r0drv-netbsd.c
r63342 r63345 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Threads (Part 1), Ring-0 Driver, FreeBSD.3 * IPRT - Threads (Part 1), Ring-0 Driver, NetBSD. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2007-201 6Oracle Corporation7 * Copyright (C) 2007-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 25 25 */ 26 26 27 28 27 /********************************************************************************************************************************* 29 28 * Header Files * 30 29 *********************************************************************************************************************************/ 31 #include "the- freebsd-kernel.h"30 #include "the-netbsd-kernel.h" 32 31 #include "internal/iprt.h" 33 32 #include <iprt/thread.h> … … 43 42 RTDECL(RTNATIVETHREAD) RTThreadNativeSelf(void) 44 43 { 45 return (RTNATIVETHREAD)cur thread;44 return (RTNATIVETHREAD)curlwp; 46 45 } 47 46 48 47 49 static int rtR0Thread FbsdSleepCommon(RTMSINTERVAL cMillies)48 static int rtR0ThreadNbsdSleepCommon(RTMSINTERVAL cMillies) 50 49 { 51 50 int rc; … … 103 102 RTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies) 104 103 { 105 return rtR0Thread FbsdSleepCommon(cMillies);104 return rtR0ThreadNbsdSleepCommon(cMillies); 106 105 } 107 106 … … 109 108 RTDECL(int) RTThreadSleepNoLog(RTMSINTERVAL cMillies) 110 109 { 111 return rtR0Thread FbsdSleepCommon(cMillies);110 return rtR0ThreadNbsdSleepCommon(cMillies); 112 111 } 113 112 … … 115 114 RTDECL(bool) RTThreadYield(void) 116 115 { 117 #if __FreeBSD_version >= 900032 118 kern_yield(curthread->td_user_pri); 119 #else 120 uio_yield(); 121 #endif 122 return false; /** @todo figure this one ... */ 116 yield(); 117 return true; 123 118 } 124 119 … … 128 123 Assert(hThread == NIL_RTTHREAD); 129 124 130 return cur thread->td_critnest == 0131 && ASMIntAreEnabled(); /** @todo is there a native freebsd function/macro for this? */125 return curlwp->l_dopreempt == 0 126 && ASMIntAreEnabled(); /** @todo is there a native netbsd function/macro for this? */ 132 127 } 133 128 … … 137 132 Assert(hThread == NIL_RTTHREAD); 138 133 139 return cur thread->td_owepreempt == 1;134 return curlwp->l_dopreempt; 140 135 } 141 136 … … 154 149 } 155 150 156 157 151 RTDECL(void) RTThreadPreemptDisable(PRTTHREADPREEMPTSTATE pState) 158 152 { 159 153 AssertPtr(pState); 160 Assert(pState->u32Reserved == 0);161 pState->u32Reserved = 42;162 154 163 c ritical_enter();164 RT_ASSERT_PREEMPT_CPUID_DISABLE(pState);155 curlwp->l_nopreempt++; 156 __insn_barrier(); 165 157 } 166 158 … … 168 160 RTDECL(void) RTThreadPreemptRestore(PRTTHREADPREEMPTSTATE pState) 169 161 { 162 170 163 AssertPtr(pState); 171 Assert(pState->u32Reserved == 42); 172 pState->u32Reserved = 0; 173 174 RT_ASSERT_PREEMPT_CPUID_RESTORE(pState); 175 critical_exit(); 164 __insn_barrier(); 165 if (--curlwp->l_nopreempt != 0) 166 return; 167 __insn_barrier(); 168 if (__predict_false(curlwp->l_dopreempt)) 169 kpreempt(0); 170 __insn_barrier(); 176 171 } 177 178 172 179 173 RTDECL(bool) RTThreadIsInInterrupt(RTTHREAD hThread) 180 174 { 181 175 Assert(hThread == NIL_RTTHREAD); NOREF(hThread); 182 /** @todo FreeBSD: Implement RTThreadIsInInterrupt. Required for guest176 /** @todo NetBSD: Implement RTThreadIsInInterrupt. Required for guest 183 177 * additions! */ 184 178 return !ASMIntAreEnabled(); 185 179 } 186 -
trunk/src/VBox/Runtime/r0drv/netbsd/thread2-r0drv-netbsd.c
r63342 r63345 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Threads (Part 2), Ring-0 Driver, FreeBSD.3 * IPRT - Threads (Part 2), Ring-0 Driver, NetBSD. 4 4 */ 5 5 … … 29 29 */ 30 30 31 32 31 /********************************************************************************************************************************* 33 32 * Header Files * 34 33 *********************************************************************************************************************************/ 35 #include "the- freebsd-kernel.h"34 #include "the-netbsd-kernel.h" 36 35 37 36 #include <iprt/thread.h> … … 65 64 case RTTHREADTYPE_MSG_PUMP: iPriority = PZERO - 4; break; 66 65 case RTTHREADTYPE_IO: iPriority = PRIBIO; break; 67 case RTTHREADTYPE_TIMER: iPriority = P RI_MIN_KERN;break;66 case RTTHREADTYPE_TIMER: iPriority = PSWP; break; 68 67 default: 69 68 AssertMsgFailed(("enmType=%d\n", enmType)); … … 71 70 } 72 71 73 #if __FreeBSD_version < 700000 74 /* Do like they're doing in subr_ntoskrnl.c... */ 75 mtx_lock_spin(&sched_lock); 76 #else 77 thread_lock(curthread); 78 #endif 79 sched_prio(curthread, iPriority); 80 #if __FreeBSD_version < 600000 81 curthread->td_base_pri = iPriority; 82 #endif 83 #if __FreeBSD_version < 700000 84 mtx_unlock_spin(&sched_lock); 85 #else 86 thread_unlock(curthread); 87 #endif 72 lwp_lock(curlwp); 73 sched_nice(curproc, iPriority); 74 curlwp->l_priority = iPriority; 75 lwp_unlock(curlwp); 88 76 89 77 return VINF_SUCCESS; … … 97 85 user really better know what he's cooking. */ 98 86 return VINF_SUCCESS; 99 }100 101 102 DECLHIDDEN(void) rtThreadNativeWaitKludge(PRTTHREADINT pThread)103 {104 /** @todo fix RTThreadWait/RTR0Term race on freebsd. */105 RTThreadSleep(1);106 87 } 107 88 … … 120 101 static void rtThreadNativeMain(void *pvThreadInt) 121 102 { 122 const struct thread *Self = curthread;103 const struct lwp *Self = curlwp; 123 104 PRTTHREADINT pThreadInt = (PRTTHREADINT)pvThreadInt; 124 105 int rc; … … 126 107 rc = rtThreadMain(pThreadInt, (RTNATIVETHREAD)Self, &pThreadInt->szName[0]); 127 108 128 #if __FreeBSD_version >= 800002129 kproc_exit(rc);130 #else131 109 kthread_exit(rc); 132 #endif133 110 } 134 111 … … 138 115 int rc; 139 116 struct proc *pProc; 117 struct lwp *l; 140 118 141 #if __FreeBSD_version >= 800002 142 rc = kproc_create(rtThreadNativeMain, pThreadInt, &pProc, RFHIGHPID, 0, "%s", pThreadInt->szName); 143 #else 144 rc = kthread_create(rtThreadNativeMain, pThreadInt, &pProc, RFHIGHPID, 0, "%s", pThreadInt->szName); 145 #endif 119 rc = kthread_create(PRI_NONE, 0, NULL, rtThreadNativeMain, (void *)pThreadInt, &l, "%s", pThreadInt->szName); 120 146 121 if (!rc) 147 122 { 148 *pNativeThread = (RTNATIVETHREAD) FIRST_THREAD_IN_PROC(pProc);123 *pNativeThread = (RTNATIVETHREAD)l; 149 124 rc = VINF_SUCCESS; 150 125 } … … 153 128 return rc; 154 129 } 155 -
trunk/src/VBox/Runtime/r0drv/netbsd/time-r0drv-netbsd.c
r63342 r63345 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Time, Ring-0 Driver, FreeBSD.3 * IPRT - Time, Ring-0 Driver, NetBSD. 4 4 */ 5 5 … … 33 33 * Header Files * 34 34 *********************************************************************************************************************************/ 35 #include "the- freebsd-kernel.h"35 #include "the-netbsd-kernel.h" 36 36 #define RTTIME_INCL_TIMESPEC 37 37 … … 42 42 { 43 43 struct timespec tsp; 44 nano uptime(&tsp);45 return tsp.tv_sec * RT_NS_1SEC_6444 nanotime(&tsp); 45 return tsp.tv_sec * UINT64_C(1000000000) 46 46 + tsp.tv_nsec; 47 47 } … … 50 50 RTDECL(uint64_t) RTTimeMilliTS(void) 51 51 { 52 return RTTimeNanoTS() / RT_NS_1MS;52 return RTTimeNanoTS() / 1000000; 53 53 } 54 54 … … 72 72 return RTTimeSpecSetTimespec(pTime, &tsp); 73 73 } 74
Note:
See TracChangeset
for help on using the changeset viewer.