VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/solaris/vbi/mp-r0drv-solaris.c@ 25720

最後變更 在這個檔案從25720是 25183,由 vboxsync 提交於 15 年 前

r0drv/Solaris: fix warnings.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 6.6 KB
 
1/* $Id: mp-r0drv-solaris.c 25183 2009-12-04 11:03:05Z vboxsync $ */
2/** @file
3 * IPRT - Multiprocessor, Ring-0 Driver, Solaris.
4 */
5
6/*
7 * Copyright (C) 2008 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.alldomusa.eu.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31
32/*******************************************************************************
33* Header Files *
34*******************************************************************************/
35#include "../the-solaris-kernel.h"
36#include "internal/iprt.h"
37#include <iprt/mp.h>
38#include <iprt/cpuset.h>
39
40#include <iprt/asm.h>
41#include <iprt/err.h>
42#include "r0drv/mp-r0drv.h"
43
44
45
46RTDECL(bool) RTMpIsCpuWorkPending(void)
47{
48 return false;
49}
50
51
52RTDECL(RTCPUID) RTMpCpuId(void)
53{
54 return vbi_cpu_id();
55}
56
57
58RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu)
59{
60 return idCpu < vbi_cpu_maxcount() ? idCpu : -1;
61}
62
63
64RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu)
65{
66 return (unsigned)iCpu < vbi_cpu_maxcount() ? iCpu : NIL_RTCPUID;
67}
68
69
70RTDECL(RTCPUID) RTMpGetMaxCpuId(void)
71{
72 return vbi_max_cpu_id();
73}
74
75
76RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
77{
78 /*
79 * We cannot query CPU status recursively, check cpu member from cached set.
80 */
81 if (idCpu >= vbi_cpu_count())
82 return false;
83
84 return RTCpuSetIsMember(&g_rtMpSolarisCpuSet, idCpu);
85
86#if 0
87 return idCpu < vbi_cpu_count() && vbi_cpu_online(idCpu);
88#endif
89}
90
91
92RTDECL(bool) RTMpIsCpuPossible(RTCPUID idCpu)
93{
94 return idCpu < vbi_cpu_count();
95}
96
97
98RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
99{
100 RTCPUID idCpu;
101
102 RTCpuSetEmpty(pSet);
103 idCpu = RTMpGetMaxCpuId(); /* it's inclusive */
104 do
105 {
106 if (RTMpIsCpuPossible(idCpu))
107 RTCpuSetAdd(pSet, idCpu);
108 } while (idCpu-- > 0);
109
110 return pSet;
111}
112
113
114RTDECL(RTCPUID) RTMpGetCount(void)
115{
116 return vbi_cpu_count();
117}
118
119
120RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
121{
122 /*
123 * We cannot query CPU status recursively, return the cached set.
124 */
125 *pSet = g_rtMpSolarisCpuSet;
126 return pSet;
127
128#if 0
129 RTCPUID idCpu;
130
131 RTCpuSetEmpty(pSet);
132 idCpu = RTMpGetMaxCpuId(); /* it's inclusive */
133 do
134 {
135 if (RTMpIsCpuOnline(idCpu))
136 RTCpuSetAdd(pSet, idCpu);
137 } while (idCpu-- > 0);
138
139 return pSet;
140#endif
141}
142
143
144RTDECL(RTCPUID) RTMpGetOnlineCount(void)
145{
146 RTCPUSET Set;
147 RTMpGetOnlineSet(&Set);
148 return RTCpuSetCount(&Set);
149
150#if 0
151 int c;
152 int cnt = 0;
153
154 for (c = 0; c < vbi_cpu_count(); ++c)
155 {
156 if (vbi_cpu_online(c))
157 ++cnt;
158 }
159 return cnt;
160#endif
161}
162
163
164
165/**
166 * Wrapper between the native solaris per-cpu callback and PFNRTWORKER
167 * for the RTMpOnAll API.
168 *
169 * @param uArgs Pointer to the RTMPARGS package.
170 * @param uIgnored1 Ignored.
171 * @param uIgnored2 Ignored.
172 */
173static int rtmpOnAllSolarisWrapper(void *uArg, void *uIgnored1, void *uIgnored2)
174{
175 PRTMPARGS pArgs = (PRTMPARGS)(uArg);
176
177 pArgs->pfnWorker(RTMpCpuId(), pArgs->pvUser1, pArgs->pvUser2);
178
179 NOREF(uIgnored1);
180 NOREF(uIgnored2);
181 return 0;
182}
183
184
185RTDECL(int) RTMpOnAll(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
186{
187 RTMPARGS Args;
188 RT_ASSERT_INTS_ON();
189
190 Args.pfnWorker = pfnWorker;
191 Args.pvUser1 = pvUser1;
192 Args.pvUser2 = pvUser2;
193 Args.idCpu = NIL_RTCPUID;
194 Args.cHits = 0;
195
196 vbi_preempt_disable();
197
198 vbi_execute_on_all(rtmpOnAllSolarisWrapper, &Args);
199
200 vbi_preempt_enable();
201
202 return VINF_SUCCESS;
203}
204
205
206/**
207 * Wrapper between the native solaris per-cpu callback and PFNRTWORKER
208 * for the RTMpOnOthers API.
209 *
210 * @param uArgs Pointer to the RTMPARGS package.
211 * @param uIgnored1 Ignored.
212 * @param uIgnored2 Ignored.
213 */
214static int rtmpOnOthersSolarisWrapper(void *uArg, void *uIgnored1, void *uIgnored2)
215{
216 PRTMPARGS pArgs = (PRTMPARGS)(uArg);
217 RTCPUID idCpu = RTMpCpuId();
218
219 Assert(idCpu != pArgs->idCpu);
220 pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2);
221
222 NOREF(uIgnored1);
223 NOREF(uIgnored2);
224 return 0;
225}
226
227
228RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
229{
230 RTMPARGS Args;
231 RT_ASSERT_INTS_ON();
232
233 /* The caller is supposed to have disabled preemption, but take no chances. */
234 vbi_preempt_disable();
235
236 Args.pfnWorker = pfnWorker;
237 Args.pvUser1 = pvUser1;
238 Args.pvUser2 = pvUser2;
239 Args.idCpu = RTMpCpuId();
240 Args.cHits = 0;
241
242 vbi_execute_on_others(rtmpOnOthersSolarisWrapper, &Args);
243
244 vbi_preempt_enable();
245
246 return VINF_SUCCESS;
247}
248
249
250/**
251 * Wrapper between the native solaris per-cpu callback and PFNRTWORKER
252 * for the RTMpOnSpecific API.
253 *
254 *
255 * @param uArgs Pointer to the RTMPARGS package.
256 * @param uIgnored1 Ignored.
257 * @param uIgnored2 Ignored.
258 */
259static int rtmpOnSpecificSolarisWrapper(void *uArg, void *uIgnored1, void *uIgnored2)
260{
261 PRTMPARGS pArgs = (PRTMPARGS)(uArg);
262 RTCPUID idCpu = RTMpCpuId();
263
264 Assert(idCpu == pArgs->idCpu);
265 pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2);
266 ASMAtomicIncU32(&pArgs->cHits);
267
268 NOREF(uIgnored1);
269 NOREF(uIgnored2);
270 return 0;
271}
272
273
274RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
275{
276 RTMPARGS Args;
277 RT_ASSERT_INTS_ON();
278
279 if (idCpu >= vbi_cpu_count())
280 return VERR_CPU_NOT_FOUND;
281
282 Args.pfnWorker = pfnWorker;
283 Args.pvUser1 = pvUser1;
284 Args.pvUser2 = pvUser2;
285 Args.idCpu = idCpu;
286 Args.cHits = 0;
287
288 vbi_preempt_disable();
289
290 vbi_execute_on_one(rtmpOnSpecificSolarisWrapper, &Args, idCpu);
291
292 vbi_preempt_enable();
293
294 Assert(ASMAtomicUoReadU32(&Args.cHits) <= 1);
295
296 return ASMAtomicUoReadU32(&Args.cHits) == 1
297 ? VINF_SUCCESS
298 : VERR_CPU_NOT_FOUND;
299}
300
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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