VirtualBox

Ignore:
Timestamp:
Apr 21, 2009 10:54:07 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
46184
Message:

IPRT/mp-r0drv-freebsd.c: Fixed a couple of issues. (hope it still works)

File:
1 edited

Legend:

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

    r19000 r19057  
    5050RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu)
    5151{
    52     return (int)idCpu < mp_ncpus ? (int)idCpu : -1;
     52    return idCpu <= mp_maxid ? (int)idCpu : -1;
    5353}
    5454
     
    5656RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu)
    5757{
    58     return iCpu < mp_ncpus ? (RTCPUID)iCpu : NIL_RTCPUID;
    59 }
     58    return (unsigned)iCpu <= mp_maxid ? (RTCPUID)iCpu : NIL_RTCPUID;
     59}
     60
    6061
    6162RTDECL(RTCPUID) RTMpGetMaxCpuId(void)
    6263{
    63     return mp_ncpus;
    64 }
     64    return mp_maxid;
     65}
     66
    6567
    6668RTDECL(bool) RTMpIsCpuPossible(RTCPUID idCpu)
    6769{
    68     if (RT_UNLIKELY((int)idCpu > mp_ncpus))
    69         return false;
    70     else
    71         return true;
    72 }
     70    return idCpu <= mp_maxid;
     71}
     72
    7373
    7474RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
     
    8989RTDECL(RTCPUID) RTMpGetCount(void)
    9090{
    91     return mp_ncpus;
     91    return mp_maxid + 1;
    9292}
    9393
     
    9595RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
    9696{
    97     if (RT_UNLIKELY((int)idCpu > mp_ncpus))
    98         return false;
    99 
    100     return CPU_ABSENT(idCpu) ? false : true;
    101 }
     97    return idCpu <= mp_maxid
     98        && !CPU_ABSENT(idCpu);
     99}
     100
    102101
    103102RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
     
    121120    return mp_ncpus;
    122121}
     122
    123123
    124124/**
     
    165165RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
    166166{
    167     int rc;
    168     RTMPARGS Args;
    169     Args.pfnWorker = pfnWorker;
    170     Args.pvUser1 = pvUser1;
    171     Args.pvUser2 = pvUser2;
    172     Args.idCpu = NIL_RTCPUID;
    173     Args.cHits = 0;
    174     smp_rendezvous(NULL, rtmpOnOthersFreeBSDWrapper, NULL, &Args);
     167    /* Will panic if no rendezvouing cpus, so check up front. */
     168    if (RTMpGetOnlineCount() > 1)
     169    {
     170#if  __FreeBSD_version >= 700000
     171        cpumask_t   Mask = ~(cpumask_t)curcpu;
     172#endif
     173        RTMPARGS    Args;
     174
     175        Args.pfnWorker = pfnWorker;
     176        Args.pvUser1 = pvUser1;
     177        Args.pvUser2 = pvUser2;
     178        Args.idCpu = RTMpCpuId();
     179        Args.cHits = 0;
     180#if __FreeBSD_version >= 700000
     181        smp_rendezvous_cpus(Mask, NULL, rtmpOnOthersFreeBSDWrapper, NULL, &Args);
     182#else
     183        smp_rendezvous(NULL, rtmpOnOthersFreeBSDWrapper, NULL, &Args);
     184#endif
     185    }
    175186    return VINF_SUCCESS;
    176187}
     
    185196static void rtmpOnSpecificFreeBSDWrapper(void *pvArg)
    186197{
    187     PRTMPARGS pArgs = (PRTMPARGS)pvArg;
    188     RTCPUID idCpu = curcpu;
     198    PRTMPARGS   pArgs = (PRTMPARGS)pvArg;
     199    RTCPUID     idCpu = curcpu;
    189200    if (pArgs->idCpu == idCpu)
    190201    {
     
    197208RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
    198209{
    199     int rc;
    200     RTMPARGS Args;
     210#if  __FreeBSD_version >= 700000
     211    cpumask_t   Mask = 1 << idCpu;
     212#endif
     213    RTMPARGS    Args;
     214
     215    /* Will panic if no rendezvouing cpus, so make sure the cpu is online. */
     216    if (!RTMpIsCpuOnline(idCpu))
     217        return VERR_CPU_NOT_FOUND;
     218
    201219    Args.pfnWorker = pfnWorker;
    202220    Args.pvUser1 = pvUser1;
     
    204222    Args.idCpu = idCpu;
    205223    Args.cHits = 0;
     224#if __FreeBSD_version >= 700000
     225    Mask = (cpumask_t)1 << idCpu;
     226    smp_rendezvous_smp(Mask, NULL, rtmpOnSpecificFreeBSDWrapper, NULL, &Args);
     227#else
    206228    smp_rendezvous(NULL, rtmpOnSpecificFreeBSDWrapper, NULL, &Args);
     229#endif
    207230    return Args.cHits == 1
    208231         ? VINF_SUCCESS
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