diff options
| author | Michael Meskes <meskes@debian.org> | 2009-06-02 15:31:14 +0200 |
|---|---|---|
| committer | Michael Meskes <meskes@debian.org> | 2009-06-02 15:31:14 +0200 |
| commit | ffd803c5f75d470a7bd301d9fc899703546bedfb (patch) | |
| tree | fb26b245ffdabdd258d0c22b77d678b7d0eaa6c2 /src/VBox/Runtime | |
| parent | 2220b99e2bdc756de31bc9a247f026a5fcf63204 (diff) | |
| download | virtualbox-ffd803c5f75d470a7bd301d9fc899703546bedfb.tar.gz | |
Imported Upstream version 2.2.4-dfsgupstream/2.2.4-dfsg
Diffstat (limited to 'src/VBox/Runtime')
| -rw-r--r-- | src/VBox/Runtime/Makefile.kmk | 6 | ||||
| -rw-r--r-- | src/VBox/Runtime/VBox/VBoxRTDeps.cpp | 6 | ||||
| -rw-r--r-- | src/VBox/Runtime/common/asm/ASMAtomicCmpXchgU64.asm | 69 | ||||
| -rw-r--r-- | src/VBox/Runtime/common/asm/ASMAtomicReadU64.asm | 65 | ||||
| -rw-r--r-- | src/VBox/Runtime/common/misc/zip.cpp | 8 | ||||
| -rw-r--r-- | src/VBox/Runtime/r0drv/solaris/process-r0drv-solaris.c | 10 | ||||
| -rw-r--r-- | src/VBox/Runtime/r0drv/solaris/semeventmulti-r0drv-solaris.c | 2 | ||||
| -rw-r--r-- | src/VBox/Runtime/r0drv/solaris/thread2-r0drv-solaris.c | 3 | ||||
| -rw-r--r-- | src/VBox/Runtime/r0drv/solaris/vbi/32/vbi | bin | 17856 -> 17604 bytes | |||
| -rw-r--r-- | src/VBox/Runtime/r0drv/solaris/vbi/64/vbi | bin | 30320 -> 30136 bytes | |||
| -rw-r--r-- | src/VBox/Runtime/r0drv/solaris/vbi/i86pc/os/vbi.c | 22 | ||||
| -rw-r--r-- | src/VBox/Runtime/r3/dir.cpp | 64 |
12 files changed, 233 insertions, 22 deletions
diff --git a/src/VBox/Runtime/Makefile.kmk b/src/VBox/Runtime/Makefile.kmk index 7132d2095..191c53f01 100644 --- a/src/VBox/Runtime/Makefile.kmk +++ b/src/VBox/Runtime/Makefile.kmk @@ -299,6 +299,11 @@ RuntimeR3_SOURCES = \ RuntimeR3_SOURCES += common/time/timesupref.cpp #endif +# Some versions of GCC might require this. +RuntimeR3_SOURCES.x86 += \ + common/asm/ASMAtomicCmpXchgU64.asm \ + common/asm/ASMAtomicReadU64.asm + ifdef IPRT_WITH_KSTUFF RuntimeR3_SOURCES += \ common/ldr/ldrkStuff.cpp @@ -763,6 +768,7 @@ VBoxRT_SOURCES = \ $(RuntimeR3_SOURCES) VBoxRT_SOURCES.$(KBUILD_TARGET) = $(RuntimeR3_SOURCES.$(KBUILD_TARGET)) VBoxRT_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH) = $(RuntimeR3_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) +VBoxRT_SOURCES.$(KBUILD_TARGET_ARCH) = $(RuntimeR3_SOURCES.$(KBUILD_TARGET_ARCH)) VBoxRT_SOURCES.win += r3/win/dllmain-win.cpp VBoxRT_SOURCES.win.x86 += r3/win/VBoxRT-win32.def VBoxRT_SOURCES.win.amd64 += r3/win/VBoxRT-win64.def diff --git a/src/VBox/Runtime/VBox/VBoxRTDeps.cpp b/src/VBox/Runtime/VBox/VBoxRTDeps.cpp index 6b118d8e2..5a0783114 100644 --- a/src/VBox/Runtime/VBox/VBoxRTDeps.cpp +++ b/src/VBox/Runtime/VBox/VBoxRTDeps.cpp @@ -34,6 +34,7 @@ #include <VBox/sup.h> #include <iprt/system.h> #include <iprt/assert.h> +#include <iprt/asm.h> /******************************************************************************* @@ -43,6 +44,9 @@ PFNRT g_VBoxRTDeps[] = { (PFNRT)SUPR3Init, (PFNRT)SUPPageLock, - (PFNRT)RTAssertShouldPanic + (PFNRT)RTAssertShouldPanic, + (PFNRT)ASMAtomicReadU64, + (PFNRT)ASMAtomicCmpXchgU64, + NULL }; diff --git a/src/VBox/Runtime/common/asm/ASMAtomicCmpXchgU64.asm b/src/VBox/Runtime/common/asm/ASMAtomicCmpXchgU64.asm new file mode 100644 index 000000000..baddf4535 --- /dev/null +++ b/src/VBox/Runtime/common/asm/ASMAtomicCmpXchgU64.asm @@ -0,0 +1,69 @@ +;; @file +; IPRT - ASMAtomicCmpXchgU64(). +; + +; +; Copyright (C) 2006-2009 Sun Microsystems, Inc. +; +; This file is part of VirtualBox Open Source Edition (OSE), as +; available from http://www.virtualbox.org. This file is free software; +; you can redistribute it and/or modify it under the terms of the GNU +; General Public License (GPL) as published by the Free Software +; Foundation, in version 2 as it comes in the "COPYING" file of the +; VirtualBox OSE distribution. VirtualBox OSE is distributed in the +; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. +; +; The contents of this file may alternatively be used under the terms +; of the Common Development and Distribution License Version 1.0 +; (CDDL) only, as it comes in the "COPYING.CDDL" file of the +; VirtualBox OSE distribution, in which case the provisions of the +; CDDL are applicable instead of those of the GPL. +; +; You may elect to license modified versions of this file under the +; terms and conditions of either the GPL or the CDDL or both. +; +; Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa +; Clara, CA 95054 USA or visit http://www.sun.com if you need +; additional information or have any questions. +; + +;******************************************************************************* +;* Header Files * +;******************************************************************************* +%include "iprt/asmdefs.mac" + +BEGINCODE + +;; +; Atomically clears a bit in a bitmap. +; +; @param pu64 x86:ebp+8 +; @param u64New x86:ebp+c +; @param u64Old x86:ebp+14 +; +; +BEGINPROC_EXPORTED ASMAtomicCmpXchgU64 +%ifndef RT_ARCH_X86 + %error port me +%endif + push ebp + mov ebp, esp + push ebx + push edi + + mov ebx, dword [ebp+0ch] + mov ecx, dword [ebp+0ch + 4] + mov edi, [ebp+08h] + mov eax, dword [ebp+14h] + mov edx, dword [ebp+14h + 4] + lock cmpxchg8b [edi] + setz al + movzx eax, al + + pop edi + pop ebx + leave + ret +ENDPROC ASMAtomicCmpXchgU64 + + diff --git a/src/VBox/Runtime/common/asm/ASMAtomicReadU64.asm b/src/VBox/Runtime/common/asm/ASMAtomicReadU64.asm new file mode 100644 index 000000000..ed4027744 --- /dev/null +++ b/src/VBox/Runtime/common/asm/ASMAtomicReadU64.asm @@ -0,0 +1,65 @@ +;; @file +; IPRT - ASMAtomicReadU64(). +; + +; +; Copyright (C) 2006-2009 Sun Microsystems, Inc. +; +; This file is part of VirtualBox Open Source Edition (OSE), as +; available from http://www.virtualbox.org. This file is free software; +; you can redistribute it and/or modify it under the terms of the GNU +; General Public License (GPL) as published by the Free Software +; Foundation, in version 2 as it comes in the "COPYING" file of the +; VirtualBox OSE distribution. VirtualBox OSE is distributed in the +; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. +; +; The contents of this file may alternatively be used under the terms +; of the Common Development and Distribution License Version 1.0 +; (CDDL) only, as it comes in the "COPYING.CDDL" file of the +; VirtualBox OSE distribution, in which case the provisions of the +; CDDL are applicable instead of those of the GPL. +; +; You may elect to license modified versions of this file under the +; terms and conditions of either the GPL or the CDDL or both. +; +; Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa +; Clara, CA 95054 USA or visit http://www.sun.com if you need +; additional information or have any questions. +; + +;******************************************************************************* +;* Header Files * +;******************************************************************************* +%include "iprt/asmdefs.mac" + +BEGINCODE + +;; +; Atomically reads 64-bit value. +; +; @param pu64 x86:ebp+8 +; +; +BEGINPROC_EXPORTED ASMAtomicReadU64 +%ifndef RT_ARCH_X86 + %error port me +%endif + push ebp + mov ebp, esp + push ebx + push edi + + xor eax, eax + xor edx, edx + mov edi, [ebp+08h] + xor ecx, ecx + xor ebx, ebx + lock cmpxchg8b [edi] + + pop edi + pop ebx + leave + ret +ENDPROC ASMAtomicReadU64 + + diff --git a/src/VBox/Runtime/common/misc/zip.cpp b/src/VBox/Runtime/common/misc/zip.cpp index 97afd04c9..c24a5f20a 100644 --- a/src/VBox/Runtime/common/misc/zip.cpp +++ b/src/VBox/Runtime/common/misc/zip.cpp @@ -110,11 +110,7 @@ typedef const RTZIPLZFHDR *PCRTZIPLZFHDR; typedef struct RTZIPCOMP { /** Output buffer. */ -#ifdef RTZIP_USE_LZF - uint8_t abBuffer[128 * 1024]; -#else - uint8_t abBuffer[64 * 1024]; -#endif + uint8_t abBuffer[_128K]; /** Compression output consumer. */ PFNRTZIPOUT pfnOut; /** User argument for the callback. */ @@ -182,7 +178,7 @@ typedef struct RTZIPCOMP typedef struct RTZIPDECOMP { /** Input buffer. */ - uint8_t abBuffer[1024 * 64]; + uint8_t abBuffer[_128K]; /** Decompression input producer. */ PFNRTZIPIN pfnIn; /** User argument for the callback. */ diff --git a/src/VBox/Runtime/r0drv/solaris/process-r0drv-solaris.c b/src/VBox/Runtime/r0drv/solaris/process-r0drv-solaris.c index 11086dc9c..f5dfefd8a 100644 --- a/src/VBox/Runtime/r0drv/solaris/process-r0drv-solaris.c +++ b/src/VBox/Runtime/r0drv/solaris/process-r0drv-solaris.c @@ -38,14 +38,16 @@ RTDECL(RTPROCESS) RTProcSelf(void) { - /* use ddi_get_pid()? */ - struct pid *pPidInfo = curproc->p_pidp; - return pPidInfo->pid_id; + pid_t pid = -1; + drv_getparm(PPID, &pid); + return (RTPROCESS)pid; } RTR0DECL(RTR0PROCESS) RTR0ProcHandleSelf(void) { - return (RTR0PROCESS)curproc; + proc_t *p = NULL; + drv_getparm(UPROCP, &p); + return (RTR0PROCESS)p; } diff --git a/src/VBox/Runtime/r0drv/solaris/semeventmulti-r0drv-solaris.c b/src/VBox/Runtime/r0drv/solaris/semeventmulti-r0drv-solaris.c index 8d2444644..23f6a9a9c 100644 --- a/src/VBox/Runtime/r0drv/solaris/semeventmulti-r0drv-solaris.c +++ b/src/VBox/Runtime/r0drv/solaris/semeventmulti-r0drv-solaris.c @@ -136,7 +136,7 @@ RTDECL(int) RTSemEventMultiSignal(RTSEMEVENTMULTI EventMultiSem) { ASMAtomicXchgU32(&pThis->cWaking, pThis->cWaking + pThis->cWaiters); ASMAtomicXchgU32(&pThis->cWaiters, 0); - cv_signal(&pThis->Cnd); + cv_broadcast(&pThis->Cnd); } mutex_exit(&pThis->Mtx); diff --git a/src/VBox/Runtime/r0drv/solaris/thread2-r0drv-solaris.c b/src/VBox/Runtime/r0drv/solaris/thread2-r0drv-solaris.c index 505fbf734..734ce7c1d 100644 --- a/src/VBox/Runtime/r0drv/solaris/thread2-r0drv-solaris.c +++ b/src/VBox/Runtime/r0drv/solaris/thread2-r0drv-solaris.c @@ -36,6 +36,7 @@ #include <iprt/assert.h> #include <iprt/err.h> #include <iprt/thread.h> +#include <iprt/process.h> #include "internal/thread.h" @@ -102,7 +103,7 @@ int rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread) { int rc; kthread_t* pKernThread = thread_create(NULL, NULL, rtThreadNativeMain, pThreadInt, 0, - curproc, TS_RUN, minclsyspri); + (void *)RTR0ProcHandleSelf(), TS_RUN, minclsyspri); if (pKernThread) { *pNativeThread = (RTNATIVETHREAD)pKernThread; diff --git a/src/VBox/Runtime/r0drv/solaris/vbi/32/vbi b/src/VBox/Runtime/r0drv/solaris/vbi/32/vbi Binary files differindex b5da82bac..affe0024f 100644 --- a/src/VBox/Runtime/r0drv/solaris/vbi/32/vbi +++ b/src/VBox/Runtime/r0drv/solaris/vbi/32/vbi diff --git a/src/VBox/Runtime/r0drv/solaris/vbi/64/vbi b/src/VBox/Runtime/r0drv/solaris/vbi/64/vbi Binary files differindex 2afc52e19..ff911cb2e 100644 --- a/src/VBox/Runtime/r0drv/solaris/vbi/64/vbi +++ b/src/VBox/Runtime/r0drv/solaris/vbi/64/vbi diff --git a/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/os/vbi.c b/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/os/vbi.c index 94ac769bf..cf130c728 100644 --- a/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/os/vbi.c +++ b/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/os/vbi.c @@ -58,6 +58,8 @@ #include "vbi.h" +#define VBIPROC() ((proc_t *)vbi_proc()) + /* * We have to use dl_lookup to find contig_free(). */ @@ -253,7 +255,7 @@ vbi_unmap(void *va, size_t size) hat_unload(kas.a_hat, va, size, HAT_UNLOAD | HAT_UNLOAD_UNLOCK); vmem_free(heap_arena, va, size); } else { - struct as *as = curproc->p_as; + struct as *as = VBIPROC()->p_as; as_rangelock(as); (void) as_unmap(as, va, size); @@ -378,7 +380,9 @@ vbi_tod(void) void * vbi_proc(void) { - return (curproc); + proc_t *p; + drv_getparm(UPROCP, &p); + return (p); } void @@ -397,7 +401,7 @@ vbi_thread_create(void *func, void *arg, size_t len, int priority) kthread_t *t; t = thread_create(NULL, NULL, (void (*)())func, arg, len, - curproc, TS_RUN, priority); + VBIPROC(), TS_RUN, priority); return (t); } @@ -517,7 +521,7 @@ vbi_execute_on_one(void *func, void *arg, int c) for (i = 0; i < VBI_SET_WORDS; ++i) set.words[i] = 0; - BT_SET(set.words, vbi_cpu_id()); + BT_SET(set.words, c); if (use_old) { if (use_old_with_ulong) { p_xc_call((xc_arg_t)arg, 0, 0, X_CALL_HIPRI, @@ -541,7 +545,7 @@ vbi_lock_va(void *addr, size_t len, void **handle) */ *handle = NULL; if (!IS_KERNEL(addr)) { - err = as_fault(curproc->p_as->a_hat, curproc->p_as, + err = as_fault(VBIPROC()->p_as->a_hat, VBIPROC()->p_as, (caddr_t)addr, len, F_SOFTLOCK, S_WRITE); if (err != 0) { VBI_VERBOSE("vbi_lock_va() failed to lock"); @@ -556,8 +560,8 @@ void vbi_unlock_va(void *addr, size_t len, void *handle) { if (!IS_KERNEL(addr)) - as_fault(curproc->p_as->a_hat, curproc->p_as, (caddr_t)addr, - len, F_SOFTUNLOCK, S_WRITE); + as_fault(VBIPROC()->p_as->a_hat, VBIPROC()->p_as, + (caddr_t)addr, len, F_SOFTUNLOCK, S_WRITE); } uint64_t @@ -570,7 +574,7 @@ vbi_va_to_pa(void *addr) if (IS_KERNEL(v)) hat = kas.a_hat; else - hat = curproc->p_as->a_hat; + hat = VBIPROC()->p_as->a_hat; pfn = hat_getpfnum(hat, (caddr_t)(v & PAGEMASK)); if (pfn == PFN_INVALID) return (-(uint64_t)1); @@ -824,7 +828,7 @@ static struct seg_ops segvbi_ops = { int vbi_user_map(caddr_t *va, uint_t prot, uint64_t *palist, size_t len) { - struct as *as = curproc->p_as; + struct as *as = VBIPROC()->p_as; struct segvbi_crargs args; int error = 0; diff --git a/src/VBox/Runtime/r3/dir.cpp b/src/VBox/Runtime/r3/dir.cpp index 6a8d8e779..893a6f4fb 100644 --- a/src/VBox/Runtime/r3/dir.cpp +++ b/src/VBox/Runtime/r3/dir.cpp @@ -42,6 +42,7 @@ #endif #include <iprt/dir.h> +#include <iprt/file.h> #include <iprt/path.h> #include <iprt/alloc.h> #include <iprt/log.h> @@ -714,3 +715,66 @@ RTDECL(int) RTDirOpenFiltered(PRTDIR *ppDir, const char *pszPath, RTDIRFILTER en return rc; } + +RTDECL(int) RTDirRemoveRecursive(const char *pszPath) +{ + int rc; + + if (!RTDirExists(pszPath)) + return VINF_SUCCESS; + + char szAbsPath[RTPATH_MAX]; + /** @todo use RTPathReal here instead? */ + rc = RTPathAbs(pszPath, szAbsPath, sizeof(szAbsPath)); + if (RT_FAILURE(rc)) + return rc; + + PRTDIR pDir = NULL; + rc = RTDirOpen(&pDir, szAbsPath); + if (RT_SUCCESS(rc)) + { + RTDIRENTRY dirEntry; + size_t cbDirEntry = sizeof(dirEntry); + + while ((rc = RTDirRead(pDir, &dirEntry, NULL /* Passing an argument won't work here yet. */)) == VINF_SUCCESS) + { + char* pszEntry = NULL; + rc = RTStrAPrintf(&pszEntry, "%s/%s", szAbsPath, dirEntry.szName); + if( RT_SUCCESS(rc) + && strcmp(dirEntry.szName, ".") + && strcmp(dirEntry.szName, "..")) + { + switch (dirEntry.enmType) + { + case RTDIRENTRYTYPE_FILE: + + rc = RTFileDelete(pszEntry); + break; + + case RTDIRENTRYTYPE_DIRECTORY: + + rc = RTDirRemoveRecursive(pszEntry); + break; + + default: + /** @todo not implemented yet. */ + break; + } + + RTStrFree(pszEntry); + } + + if (RT_FAILURE(rc)) + break; + } + if (rc == VERR_NO_MORE_FILES) + rc = VINF_SUCCESS; + + RTDirClose(pDir); + rc = RTDirRemove(szAbsPath); + } + + LogFlow(("RTDirRemoveRecursive(%p:{%s}): returns %Rrc\n", pszPath, pszPath, rc)); + return rc; +} + |
