VirtualBox

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


Ignore:
Timestamp:
Jun 5, 2008 3:22:37 PM (17 years ago)
Author:
vboxsync
Message:

RTMpDoesCpuExist -> RTMpIsCpuPossible. Changed the RTMpGetCount and RTMpGetSet specification to include all possible cpus.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/linux/mp-r0drv-linux.c

    r8245 r9429  
    6666
    6767
    68 RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
    69 {
    70 #ifdef CONFIG_SMP
     68RTDECL(bool) RTMpIsCpuPossible(RTCPUID idCpu)
     69{
     70#if defined(CONFIG_SMP)
    7171    if (RT_UNLIKELY(idCpu >= NR_CPUS))
    7272        return false;
    73 # ifdef cpu_online
    74     return cpu_online(idCpu);
    75 # else /* 2.4: */
    76     return cpu_online_map & RT_BIT_64(idCpu);
    77 # endif
    78 #else
    79     return idCpu == RTMpCpuId();
    80 #endif
    81 }
    82 
    83 
    84 RTDECL(bool) RTMpDoesCpuExist(RTCPUID idCpu)
    85 {
    86 #ifdef CONFIG_SMP
    87     if (RT_UNLIKELY(idCpu >= NR_CPUS))
    88         return false;
    89 # ifdef CONFIG_HOTPLUG_CPU /* introduced & uses cpu_present */
    90     return cpu_present(idCpu);
    91 # elif defined(cpu_possible)
     73
     74# if defined(cpu_possible)
    9275    return cpu_possible(idCpu);
    93 # else /* 2.4: */
     76# else /* < 2.5.29 */
    9477    return idCpu < (RTCPUID)smp_num_cpus;
    9578# endif
     
    10891    do
    10992    {
    110         if (RTMpDoesCpuExist(idCpu))
     93        if (RTMpIsCpuPossible(idCpu))
    11194            RTCpuSetAdd(pSet, idCpu);
    11295    } while (idCpu-- > 0);
     
    135118
    136119
     120RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
     121{
     122#ifdef CONFIG_SMP
     123    if (RT_UNLIKELY(idCpu >= NR_CPUS))
     124        return false;
     125# ifdef cpu_online
     126    return cpu_online(idCpu);
     127# else /* 2.4: */
     128    return cpu_online_map & RT_BIT_64(idCpu);
     129# endif
     130#else
     131    return idCpu == RTMpCpuId();
     132#endif
     133}
     134
     135
    137136RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
    138137{
     
    272271    Args.cHits = 0;
    273272
    274     if (!RTMpDoesCpuExist(idCpu))
     273    if (!RTMpIsCpuPossible(idCpu))
    275274        return VERR_CPU_NOT_FOUND;
    276275
  • trunk/src/VBox/Runtime/r0drv/nt/mp-r0drv-nt.cpp

    r8840 r9429  
    9595        return false;
    9696
     97    /** @todo this must be done at init time as it's not safe under all circumstances (braindead OS design). */
    9798    KAFFINITY Mask = KeQueryActiveProcessors();
    9899    return !!(Mask & RT_BIT_64(idCpu));
     
    100101
    101102
    102 RTDECL(bool) RTMpDoesCpuExist(RTCPUID idCpu)
     103RTDECL(bool) RTMpIsCpuPresent(RTCPUID idCpu)
    103104{
    104105    /* Cannot easily distinguish between online and offline cpus. */
     106    /** @todo online/present cpu stuff must be corrected for proper W2K8 support. */
    105107    return RTMpIsCpuOnline(idCpu);
    106108}
     
    109111RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
    110112{
     113    /** @todo online/present cpu stuff must be corrected for proper W2K8 support. */
    111114    return RTMpGetOnlineSet(pSet);
    112115}
     
    115118RTDECL(RTCPUID) RTMpGetCount(void)
    116119{
     120    /** @todo online/present cpu stuff must be corrected for proper W2K8 support. */
    117121    return RTMpGetOnlineCount();
    118122}
     
    167171#if 0
    168172    /* KeFlushQueuedDpcs must be run at IRQL PASSIVE_LEVEL according to MSDN, but the
    169      * driver verifier doesn't complain... 
     173     * driver verifier doesn't complain...
    170174     */
    171175    AssertMsg(KeGetCurrentIrql() == PASSIVE_LEVEL, ("%d != %d (PASSIVE_LEVEL)\n", KeGetCurrentIrql(), PASSIVE_LEVEL));
     
    173177
    174178    KAFFINITY Mask = KeQueryActiveProcessors();
    175 
    176     if (    enmCpuid == RT_NT_CPUID_SPECIFIC
    177         &&  (   idCpu >= 64
    178              || !(Mask & RT_BIT_64(idCpu))))
    179         return VERR_CPU_NOT_FOUND;  /* can't distinguish between cpu not present or offline */
    180179
    181180    /* KeFlushQueuedDpcs is not present in Windows 2000; import it dynamically so we can just fail this call. */
     
    244243        }
    245244        if (enmCpuid != RT_NT_CPUID_OTHERS)
    246         {
    247245            pfnWorker(iSelf, pvUser1, pvUser2);
    248         }
    249246    }
    250247
     
    270267RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
    271268{
     269    if (RTMpIsCpuOnline(idCpu);
     270        return !RTMpIsCpuPossible(idCpu) ? VERR_CPU_NOT_FOUND : VERR_CPU_OFFLINE;
     271
    272272    return rtMpCall(pfnWorker, pvUser1, pvUser2, RT_NT_CPUID_SPECIFIC, idCpu);
    273273}
  • trunk/src/VBox/Runtime/r0drv/solaris/mp-r0drv-solaris.c

    r8245 r9429  
    6666
    6767
    68 RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
    69 {
    70     cpu_t *pCpu = idCpu < NCPU ? cpu_get(idCpu) : NULL;
    71     return pCpu
    72         && cpu_is_online(pCpu);
    73 }
    74 
    75 
    76 RTDECL(bool) RTMpDoesCpuExist(RTCPUID idCpu)
     68RTDECL(bool) RTMpIsCpuPossible(RTCPUID idCpu)
    7769{
    7870    cpu_t *pCpu = idCpu < NCPU ? cpu_get(idCpu) : NULL;
     
    8981    do
    9082    {
    91         if (RTMpDoesCpuExist(idCpu))
     83        if (RTMpIsCpuPossible(idCpu))
    9284            RTCpuSetAdd(pSet, idCpu);
    9385    } while (idCpu-- > 0);
     
    10092{
    10193    return ncpus;
     94}
     95
     96
     97RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
     98{
     99    cpu_t *pCpu = idCpu < NCPU ? cpu_get(idCpu) : NULL;
     100    return pCpu
     101        && cpu_is_online(pCpu);
    102102}
    103103
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/mp-r0drv-solaris.c

    r9149 r9429  
    7272
    7373
    74 RTDECL(bool) RTMpDoesCpuExist(RTCPUID idCpu)
     74RTDECL(bool) RTMpIsCpuPossible(RTCPUID idCpu)
    7575{
    7676    return idCpu < vbi_cpu_count();
     
    8686    do
    8787    {
    88         if (RTMpDoesCpuExist(idCpu))
     88        if (RTMpIsCpuPossible(idCpu))
    8989            RTCpuSetAdd(pSet, idCpu);
    9090    } while (idCpu-- > 0);
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