VirtualBox

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

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

mpnotification-r0drv-solaris.c: drop the vbi version check.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/* $Id: mpnotification-r0drv-solaris.c 37274 2011-05-31 11:47:51Z 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 (g_hVbiCpuWatch != NULL)
104 return VERR_WRONG_ORDER;
105
106 /*
107 * Register the callback building the online cpu set as we
108 * do so (current_too = 1).
109 */
110 RTCpuSetEmpty(&g_rtMpSolarisCpuSet);
111 g_hVbiCpuWatch = vbi_watch_cpus(rtMpNotificationSolarisCallback, NULL, 1 /*current_too*/);
112
113 return VINF_SUCCESS;
114}
115
116
117DECLHIDDEN(void) rtR0MpNotificationNativeTerm(void)
118{
119 if (g_hVbiCpuWatch != NULL)
120 vbi_ignore_cpus(g_hVbiCpuWatch);
121 g_hVbiCpuWatch = NULL;
122}
123
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