Changeset 19057 in vbox for trunk/src/VBox/Runtime/r0drv/freebsd
- Timestamp:
- Apr 21, 2009 10:54:07 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 46184
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/freebsd/mp-r0drv-freebsd.c
r19000 r19057 50 50 RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu) 51 51 { 52 return (int)idCpu < mp_ncpus? (int)idCpu : -1;52 return idCpu <= mp_maxid ? (int)idCpu : -1; 53 53 } 54 54 … … 56 56 RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu) 57 57 { 58 return iCpu < mp_ncpus ? (RTCPUID)iCpu : NIL_RTCPUID; 59 } 58 return (unsigned)iCpu <= mp_maxid ? (RTCPUID)iCpu : NIL_RTCPUID; 59 } 60 60 61 61 62 RTDECL(RTCPUID) RTMpGetMaxCpuId(void) 62 63 { 63 return mp_ncpus; 64 } 64 return mp_maxid; 65 } 66 65 67 66 68 RTDECL(bool) RTMpIsCpuPossible(RTCPUID idCpu) 67 69 { 68 if (RT_UNLIKELY((int)idCpu > mp_ncpus)) 69 return false; 70 else 71 return true; 72 } 70 return idCpu <= mp_maxid; 71 } 72 73 73 74 74 RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet) … … 89 89 RTDECL(RTCPUID) RTMpGetCount(void) 90 90 { 91 return mp_ ncpus;91 return mp_maxid + 1; 92 92 } 93 93 … … 95 95 RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu) 96 96 { 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 102 101 103 102 RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet) … … 121 120 return mp_ncpus; 122 121 } 122 123 123 124 124 /** … … 165 165 RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2) 166 166 { 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 } 175 186 return VINF_SUCCESS; 176 187 } … … 185 196 static void rtmpOnSpecificFreeBSDWrapper(void *pvArg) 186 197 { 187 PRTMPARGS pArgs = (PRTMPARGS)pvArg;188 RTCPUID idCpu = curcpu;198 PRTMPARGS pArgs = (PRTMPARGS)pvArg; 199 RTCPUID idCpu = curcpu; 189 200 if (pArgs->idCpu == idCpu) 190 201 { … … 197 208 RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2) 198 209 { 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 201 219 Args.pfnWorker = pfnWorker; 202 220 Args.pvUser1 = pvUser1; … … 204 222 Args.idCpu = idCpu; 205 223 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 206 228 smp_rendezvous(NULL, rtmpOnSpecificFreeBSDWrapper, NULL, &Args); 229 #endif 207 230 return Args.cHits == 1 208 231 ? VINF_SUCCESS
Note:
See TracChangeset
for help on using the changeset viewer.