VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/freebsd/mp-r0drv-darwin.cpp@ 15837

Last change on this file since 15837 was 15837, checked in by vboxsync, 16 years ago

Added RTMpIsCpuWorkPending stub.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/* $Id: mp-r0drv-darwin.cpp 15837 2009-01-07 15:50:58Z vboxsync $ */
2/** @file
3 * IPRT - Multiprocessor, Ring-0 Driver, FreeBSD.
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.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 * 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-freebsd-kernel.h"
36
37#include <iprt/mp.h>
38#include <iprt/err.h>
39#include <iprt/asm.h>
40#include "r0drv/mp-r0drv.h"
41
42
43RTDECL(RTCPUID) RTMpCpuId(void)
44{
45 return curcpu; /** @todo is this right? */
46}
47
48RTDECL(bool) RTMpIsCpuWorkPending()
49{
50 /** @todo (not used on non-Windows platforms yet */
51 return false;
52}
53
54
55/**
56 * Wrapper between the native FreeBSD per-cpu callback and PFNRTWORKER
57 * for the RTMpOnAll API.
58 *
59 * @param pvArg Pointer to the RTMPARGS package.
60 */
61static void rtmpOnAllFreeBSDWrapper(void *pvArg)
62{
63 PRTMPARGS pArgs = (PRTMPARGS)pvArg;
64 pArgs->pfnWorker(cpu_number(), pArgs->pvUser1, pArgs->pvUser2);
65}
66
67
68RTDECL(int) RTMpOnAll(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
69{
70 RTMPARGS Args;
71 Args.pfnWorker = pfnWorker;
72 Args.pvUser1 = pvUser1;
73 Args.pvUser2 = pvUser2;
74 Args.idCpu = NIL_RTCPUID;
75 Args.cHits = 0;
76 smp_rendezvous(NULL, rtmpOnAllFreeBSDWrapper, NULL, &Args);
77 return VINF_SUCCESS;
78}
79
80
81/**
82 * Wrapper between the native FreeBSD per-cpu callback and PFNRTWORKER
83 * for the RTMpOnOthers API.
84 *
85 * @param pvArg Pointer to the RTMPARGS package.
86 */
87static void rtmpOnOthersFreeBSDWrapper(void *pvArg)
88{
89 PRTMPARGS pArgs = (PRTMPARGS)pvArg;
90 RTCPUID idCpu = cpu_number();
91 if (pArgs->idCpu != idCpu)
92 pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2);
93}
94
95
96RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
97{
98 int rc;
99 RTMPARGS Args;
100 Args.pfnWorker = pfnWorker;
101 Args.pvUser1 = pvUser1;
102 Args.pvUser2 = pvUser2;
103 Args.idCpu = NIL_RTCPUID;
104 Args.cHits = 0;
105 smp_rendezvous(NULL, rtmpOnOthersFreeBSDWrapper, NULL, &Args);
106 return VINF_SUCCESS;
107}
108
109
110/**
111 * Wrapper between the native FreeBSD per-cpu callback and PFNRTWORKER
112 * for the RTMpOnSpecific API.
113 *
114 * @param pvArg Pointer to the RTMPARGS package.
115 */
116static void rtmpOnSpecificFreeBSDWrapper(void *pvArg)
117{
118 PRTMPARGS pArgs = (PRTMPARGS)pvArg;
119 RTCPUID idCpu = cpu_number();
120 if (pArgs->idCpu == idCpu)
121 {
122 pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2);
123 ASMAtomicIncU32(&pArgs->cHits);
124 }
125}
126
127
128RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
129{
130 int rc;
131 RTMPARGS Args;
132 Args.pfnWorker = pfnWorker;
133 Args.pvUser1 = pvUser1;
134 Args.pvUser2 = pvUser2;
135 Args.idCpu = idCpu;
136 Args.cHits = 0;
137 smp_rendezvous(NULL, rtmpOnSpecificFreeBSDWrapper, NULL, &Args);
138 return Args.cHits == 1
139 ? VINF_SUCCESS
140 : VERR_CPU_NOT_FOUND;
141}
142
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