VirtualBox

Changeset 70151 in vbox for trunk/src/VBox/Runtime/r0drv


Ignore:
Timestamp:
Dec 15, 2017 2:34:43 PM (7 years ago)
Author:
vboxsync
Message:

iprt/r0drv/nt: Reduce #ifdef'ing TARGET_NT4.

Location:
trunk/src/VBox/Runtime/r0drv/nt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/nt/initterm-r0drv-nt.cpp

    r70149 r70151  
    117117uint32_t                                g_uRtNtBuildNo;
    118118
     119/** Pointer to the MmHighestUserAddress kernel variable - can be NULL. */
     120uintptr_t const                        *g_puRtMmHighestUserAddress;
     121/** Pointer to the MmSystemRangeStart kernel variable - can be NULL. */
     122uintptr_t const                        *g_puRtMmSystemRangeStart;
     123
    119124
    120125/**
     
    288293    g_pfnrtHalRequestIpiW7Plus = (PFNHALREQUESTIPI_W7PLUS)RTR0DbgKrnlInfoGetSymbol(hKrnlInfo, NULL, "HalRequestIpi");
    289294    g_pfnrtHalRequestIpiPreW7 = (PFNHALREQUESTIPI_PRE_W7)g_pfnrtHalRequestIpiW7Plus;
     295
     296    g_puRtMmHighestUserAddress = (uintptr_t const *)RTR0DbgKrnlInfoGetSymbol(hKrnlInfo, NULL, "MmHighestUserAddress");
     297    g_puRtMmSystemRangeStart   = (uintptr_t const *)RTR0DbgKrnlInfoGetSymbol(hKrnlInfo, NULL, "MmSystemRangeStart");
    290298
    291299    RTR0DbgKrnlInfoRelease(hKrnlInfo);
  • trunk/src/VBox/Runtime/r0drv/nt/internal-r0drv-nt.h

    r70150 r70151  
    101101extern uint32_t                                g_uRtNtBuildNo;
    102102
     103extern uintptr_t const                        *g_puRtMmHighestUserAddress;
     104extern uintptr_t const                        *g_puRtMmSystemRangeStart;
     105
    103106
    104107int __stdcall rtMpPokeCpuUsingDpc(RTCPUID idCpu);
  • trunk/src/VBox/Runtime/r0drv/nt/memuserkernel-r0drv-nt.cpp

    r69111 r70151  
    3434#include <iprt/err.h>
    3535
     36#include "internal-r0drv-nt.h"
     37
    3638
    3739RTR0DECL(int) RTR0MemUserCopyFrom(void *pvDst, RTR3PTR R3PtrSrc, size_t cb)
     
    6870{
    6971#ifdef IPRT_TARGET_NT4
    70     /* Play safe+wrong... it used to be a constant, but in w2k+ is a variable. */
    71     return R3Ptr < _2G;
     72    uintptr_t const uLast = g_puRtMmHighestUserAddress ? *g_puRtMmHighestUserAddress : ~(uintptr_t)0 / 2;
    7273#else
    73     return R3Ptr <= (uintptr_t)MM_HIGHEST_USER_ADDRESS;
     74    uintptr_t const uLast = (uintptr_t)MM_HIGHEST_USER_ADDRESS;
    7475#endif
     76    return R3Ptr <= uLast;
    7577}
    7678
     
    7981{
    8082#ifdef IPRT_TARGET_NT4
    81     /* Play safe+wrong... it used to be a constant, but in w2k+ is a variable. */
    82     return (uintptr_t)pv >= _2G;
     83    uintptr_t const uFirst = g_puRtMmSystemRangeStart ? *g_puRtMmSystemRangeStart : ~(uintptr_t)0 / 2 + 1;
    8384#else
    84     return (uintptr_t)pv >= (uintptr_t)MM_SYSTEM_RANGE_START;
     85    uintptr_t const uFirst = (uintptr_t)MM_SYSTEM_RANGE_START;
    8586#endif
     87    return (uintptr_t)pv >= uFirst;
    8688}
    8789
  • trunk/src/VBox/Runtime/r0drv/nt/mp-r0drv-nt.cpp

    r69111 r70151  
    594594
    595595    g_pfnrtMpPokeCpuWorker = rtMpPokeCpuUsingDpc;
    596 #ifndef IPRT_TARGET_NT4
    597596    if (   g_pfnrtHalRequestIpiW7Plus
    598597        && g_pfnrtKeInitializeAffinityEx
     
    611610        DbgPrint("IPRT: RTMpPoke => rtMpPokeCpuUsingDpc\n");
    612611    /* else: Windows XP should send always send an IPI -> VERIFY */
    613 #endif
    614612
    615613    return VINF_SUCCESS;
     
    13621360                             RT_NT_CPUID enmCpuid, RTCPUID idCpu, RTCPUID idCpu2, uint32_t *pcHits)
    13631361{
    1364 #ifdef IPRT_TARGET_NT4
    1365     RT_NOREF(pfnWorker, pvUser1, pvUser2, enmCpuid, idCpu, idCpu2, pcHits);
    1366     /* g_pfnrtNt* are not present on NT anyway. */
    1367     return VERR_NOT_SUPPORTED;
    1368 
    1369 #else  /* !IPRT_TARGET_NT4 */
    1370 # if 0
     1362#if 0
    13711363    /* KeFlushQueuedDpcs must be run at IRQL PASSIVE_LEVEL according to MSDN, but the
    13721364     * driver verifier doesn't complain...
    13731365     */
    13741366    AssertMsg(KeGetCurrentIrql() == PASSIVE_LEVEL, ("%d != %d (PASSIVE_LEVEL)\n", KeGetCurrentIrql(), PASSIVE_LEVEL));
    1375 # endif
     1367#endif
    13761368    /* KeFlushQueuedDpcs is not present in Windows 2000; import it dynamically so we can just fail this call. */
    13771369    if (!g_pfnrtNtKeFlushQueuedDpcs)
     
    15121504     *        executed. Seen pArgs being freed while some CPU was using it before
    15131505     *        cRefs was added. */
    1514     g_pfnrtNtKeFlushQueuedDpcs();
     1506    if (g_pfnrtNtKeFlushQueuedDpcs)
     1507        g_pfnrtNtKeFlushQueuedDpcs();
    15151508
    15161509    if (pcHits)
     
    15241517
    15251518    return VINF_SUCCESS;
    1526 #endif /* !IPRT_TARGET_NT4 */
    15271519}
    15281520
     
    17641756        if (rcNt == STATUS_TIMEOUT)
    17651757        {
    1766 #ifndef IPRT_TARGET_NT4
    17671758            if (   !pArgs->fExecuting
    17681759                && (   g_pfnrtMpPokeCpuWorker == rtMpPokeCpuUsingHalReqestIpiW7Plus
    17691760                    || g_pfnrtMpPokeCpuWorker == rtMpPokeCpuUsingHalReqestIpiPreW7))
    17701761                RTMpPokeCpu(idCpu);
    1771 #endif
    17721762
    17731763            Timeout.QuadPart = -1280000; /* 128ms */
     
    18231813}
    18241814
    1825 #ifndef IPRT_TARGET_NT4
    18261815
    18271816/** Callback used by rtMpPokeCpuUsingBroadcastIpi. */
     
    18811870    return VINF_SUCCESS;
    18821871}
    1883 
    1884 #endif /* !IPRT_TARGET_NT4 */
    18851872
    18861873
     
    19101897
    19111898    /* Raise the IRQL to DISPATCH_LEVEL so we can't be rescheduled to another cpu.
    1912      * KeInsertQueueDpc must also be executed at IRQL >= DISPATCH_LEVEL.
    1913      */
     1899       KeInsertQueueDpc must also be executed at IRQL >= DISPATCH_LEVEL. */
    19141900    KIRQL oldIrql;
    19151901    KeRaiseIrql(DISPATCH_LEVEL, &oldIrql);
     
    19191905
    19201906    /* Assuming here that high importance DPCs will be delivered immediately; or at least an IPI will be sent immediately.
    1921      * @note: not true on at least Vista & Windows 7
    1922      */
    1923     BOOLEAN bRet = KeInsertQueueDpc(&s_aPokeDpcs[idCpu], 0, 0);
     1907       Note! Not true on at least Vista & Windows 7 */
     1908    BOOLEAN fRet = KeInsertQueueDpc(&s_aPokeDpcs[idCpu], 0, 0);
    19241909
    19251910    KeLowerIrql(oldIrql);
    1926     return (bRet == TRUE) ? VINF_SUCCESS : VERR_ACCESS_DENIED /* already queued */;
     1911    return fRet == TRUE ? VINF_SUCCESS : VERR_ACCESS_DENIED /* already queued */;
    19271912}
    19281913
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette