VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/solaris/vbi/mpnotification-r0drv-solaris.c@ 37071

Last change on this file since 37071 was 37071, checked in by vboxsync, 14 years ago

VMM: Online/offine CPUs, solaris debug build fix.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1/* $Id: mpnotification-r0drv-solaris.c 37071 2011-05-13 13:16:15Z vboxsync $ */
2/** @file
3 * IPRT - Multiprocessor Event Notifications, Ring-0 Driver, Solaris.
4 */
5
6/*
7 * Copyright (C) 2008 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.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
27/*******************************************************************************
28* Header Files *
29*******************************************************************************/
30#include "../the-solaris-kernel.h"
31#include "internal/iprt.h"
32
33#include <iprt/err.h>
34#include <iprt/mp.h>
35#include <iprt/cpuset.h>
36#include <iprt/string.h>
37#include <iprt/thread.h>
38#include "r0drv/mp-r0drv.h"
39
40
41/*******************************************************************************
42* Global Variables *
43*******************************************************************************/
44/** CPU watch callback handle. */
45static vbi_cpu_watch_t *g_hVbiCpuWatch = NULL;
46/** Set of online cpus that is maintained by the MP callback.
47 * This avoids locking issues querying the set from the kernel as well as
48 * eliminating any uncertainty regarding the online status during the
49 * callback. */
50RTCPUSET g_rtMpSolarisCpuSet;
51
52
53static void rtMpNotificationSolarisOnCurrentCpu(void *pvArgs, void *uIgnored1, void *uIgnored2)
54{
55 NOREF(uIgnored1);
56 NOREF(uIgnored2);
57
58 PRTMPARGS pArgs = (PRTMPARGS)(pvArgs);
59 AssertRelease(pArgs && pArgs->idCpu == RTMpCpuId());
60 Assert(pArgs->pvUser2);
61 Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
62
63 int online = *(int *)pArgs->pvUser2;
64 if (online)
65 {
66 RTCpuSetAdd(&g_rtMpSolarisCpuSet, pArgs->idCpu);
67 rtMpNotificationDoCallbacks(RTMPEVENT_ONLINE, pArgs->idCpu);
68 }
69 else
70 {
71 RTCpuSetDel(&g_rtMpSolarisCpuSet, pArgs->idCpu);
72 rtMpNotificationDoCallbacks(RTMPEVENT_OFFLINE, pArgs->idCpu);
73 }
74}
75
76
77static void rtMpNotificationSolarisCallback(void *pvUser, int iCpu, int online)
78{
79 vbi_preempt_disable();
80
81 RTMPARGS Args;
82 RT_ZERO(Args);
83 Args.pvUser1 = pvUser;
84 Args.pvUser2 = &online;
85 Args.idCpu = iCpu;
86
87 /*
88 * If we're not on the target CPU, schedule (synchronous) the event notification callback
89 * to run on the target CPU i.e. the one pertaining to the MP event.
90 */
91 bool fRunningOnTargetCpu = iCpu == RTMpCpuId(); /* ASSUMES iCpu == RTCPUID */
92 if (fRunningOnTargetCpu)
93 rtMpNotificationSolarisOnCurrentCpu(&Args, NULL /* pvIgnored1 */, NULL /* pvIgnored2 */);
94 else
95 vbi_execute_on_one(rtMpNotificationSolarisOnCurrentCpu, &Args, iCpu);
96
97 vbi_preempt_enable();
98}
99
100
101DECLHIDDEN(int) rtR0MpNotificationNativeInit(void)
102{
103 if (vbi_revision_level < 2)
104 return VERR_NOT_SUPPORTED;
105 if (g_hVbiCpuWatch != NULL)
106 return VERR_WRONG_ORDER;
107
108 /*
109 * Register the callback building the online cpu set as we
110 * do so (current_too = 1).
111 */
112 RTCpuSetEmpty(&g_rtMpSolarisCpuSet);
113 g_hVbiCpuWatch = vbi_watch_cpus(rtMpNotificationSolarisCallback, NULL, 1 /*current_too*/);
114
115 return VINF_SUCCESS;
116}
117
118
119DECLHIDDEN(void) rtR0MpNotificationNativeTerm(void)
120{
121 if (vbi_revision_level >= 2 && g_hVbiCpuWatch != NULL)
122 vbi_ignore_cpus(g_hVbiCpuWatch);
123 g_hVbiCpuWatch = NULL;
124}
125
Note: See TracBrowser for help on using the repository browser.

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