VirtualBox

Changeset 7331 in vbox for trunk/src/VBox/Runtime/r0drv


Ignore:
Timestamp:
Mar 6, 2008 4:09:57 PM (17 years ago)
Author:
vboxsync
Message:

Solaris RTMp implementation (untested).

Location:
trunk/src/VBox/Runtime/r0drv/solaris
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/solaris/mp-r0drv-solaris.c

    r7313 r7331  
    3232
    3333#include <iprt/mp.h>
     34#include <iprt/cpuset.h>
    3435#include <iprt/err.h>
    3536#include <iprt/asm.h>
     
    3940RTDECL(RTCPUID) RTMpCpuId(void)
    4041{
    41     return ???;
    42 }
    43 
    44 
    45 /**
    46  * Wrapper between the native solaris per-cpu callback and PFNRTWORKER
     42    return cpuid_get_chipid(CPU); /* is there a better way? */
     43}
     44
     45
     46RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
     47{
     48    cpu_t *pCpu = idCpu < NCPU ? cpu_get(idCpu) : NULL;
     49    return pCpu
     50        && cpu_is_online(pCpu);
     51}
     52
     53
     54RTDECL(bool) RTMpDoesCpuExist(RTCPUID idCpu)
     55{
     56    cpu_t *pCpu = idCpu < NCPU ? cpu_get(idCpu) : NULL;
     57    return pCpu != NULL;
     58}
     59
     60
     61RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu)
     62{
     63    return idCpu < NCPU ? idCpu : -1;
     64}
     65
     66
     67RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu)
     68{
     69    return (unsigned)iCpu < NCPU ? iCpu : NIL_RTCPUID;
     70}
     71
     72
     73RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
     74{
     75    RTCPUID idCpu;
     76
     77    RTCpuSetEmpty(pSet);
     78    idCpu = RTMpGetMaxCpuId(); /* it's inclusive */
     79    do
     80    {
     81        if (RTMpDoesCpuExist(idCpu))
     82            RTCpuSetAdd(pSet, idCpu);
     83    } while (idCpu-- > 0);
     84
     85    return pSet;
     86}
     87
     88
     89RTDECL(RTCPUID) RTMpGetCount(void)
     90{
     91    return ncpus;
     92}
     93
     94
     95RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
     96{
     97    RTCPUID idCpu;
     98
     99    RTCpuSetEmpty(pSet);
     100    idCpu = RTMpGetMaxCpuId(); /* it's inclusive */
     101    do
     102    {
     103        if (RTMpIsCpuOnline(idCpu))
     104            RTCpuSetAdd(pSet, idCpu);
     105    } while (idCpu-- > 0);
     106
     107    return pSet;
     108}
     109
     110
     111RTDECL(RTCPUID) RTMpGetOnlineCount(void)
     112{
     113    return ncpus_online;
     114}
     115
     116
     117
     118/**
     119 * Wrapper between the native solaris per-cpu callback and PFNRTWORKER
    47120 * for the RTMpOnAll API.
    48  *
    49  * @param   u64         Pointer to the RTMPARGS package.
    50  * @param   u64Ignored  Ignored.
    51  */
    52 static void rtmpOnAllSolarisWrapper(uint64_t u64, uint64_t u64Ignored)
    53 {
    54     PRTMPARGS pArgs = (PRTMPARGS)(uintptr_t)u64;
     121 *
     122 * @param   uArgs       Pointer to the RTMPARGS package.
     123 * @param   uIgnored1   Ignored.
     124 * @param   uIgnored2   Ignored.
     125 */
     126static int rtmpOnAllSolarisWrapper(xc_arg_t uArg, xc_arg_t uIgnored1, xc_arg_t uIgnored2)
     127{
     128    PRTMPARGS pArgs = (PRTMPARGS)(uArg);
     129
    55130    pArgs->pfnWorker(RTMpCpuId(), pArgs->pvUser1, pArgs->pvUser2);
    56     NOREF(u64Ignored);
     131
     132    NOREF(uIgnored1);
     133    NOREF(uIgnored2);
     134    return 0;
    57135}
    58136
     
    60138RTDECL(int) RTMpOnAll(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
    61139{
     140    cpuset_t Set;
    62141    RTMPARGS Args;
     142
    63143    Args.pfnWorker = pfnWorker;
    64144    Args.pvUser1 = pvUser1;
     
    66146    Args.idCpu = NIL_RTCPUID;
    67147    Args.cHits = 0;
    68     xt_all(rtmpOnAllSolarisWrapper, (uintptr_t)&Args, 0);
     148
     149    CPUSET_ALL(Set);
     150    xc_call((uintptr_t)&Args, 0, 0, X_CALL_HIPRI, Set, rtmpOnAllSolarisWrapper);
     151
    69152    return VINF_SUCCESS;
    70153}
    71154
    72155
    73 /** 
    74  * Wrapper between the native solaris per-cpu callback and PFNRTWORKER 
     156/**
     157 * Wrapper between the native solaris per-cpu callback and PFNRTWORKER
    75158 * for the RTMpOnOthers API.
    76  *
    77  * @param   u64         Pointer to the RTMPARGS package.
    78  * @param   u64Ignored  Ignored.
    79  */
    80 static void rtmpOnOthersSolarisWrapper(uint64_t u64, uint64_t u64Ignored)
    81 {
    82     PRTMPARGS pArgs = (PRTMPARGS)(uintptr_t)u64;
     159 *
     160 * @param   uArgs       Pointer to the RTMPARGS package.
     161 * @param   uIgnored1   Ignored.
     162 * @param   uIgnored2   Ignored.
     163 */
     164static int rtmpOnOthersSolarisWrapper(xc_arg_t uArg, xc_arg_t uIgnored1, xc_arg_t uIgnored2)
     165{
     166    PRTMPARGS pArgs = (PRTMPARGS)(uArg);
    83167    RTCPUID idCpu = RTMpCpuId();
    84     if (idCpu != pArgs->idCpu)
    85         pArgs->pfnWorker(RTMpCpuId(), pArgs->pvUser1, pArgs->pvUser2);
    86     NOREF(u64Ignored);
     168
     169    Assert(idCpu != pArgs->idCpu);
     170    pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2);
     171
     172    NOREF(uIgnored1);
     173    NOREF(uIgnored2);
     174    return 0;
    87175}
    88176
     
    91179{
    92180    int rc;
     181    cpuset_t Set;
    93182    RTMPARGS Args;
     183
    94184    Args.pfnWorker = pfnWorker;
    95185    Args.pvUser1 = pvUser1;
    96186    Args.pvUser2 = pvUser2;
    97     Args.idCpu = NIL_RTCPUID;
     187    Args.idCpu = RTMpCpuId();
    98188    Args.cHits = 0;
    99     xt_all(rtmpOnOthersSolarisWrapper, (uintptr_t)&Args, 0);
     189
     190    CPUSET_ALL_BUT(Set, Args.idCpu);
     191    xc_call((uintptr_t)&Args, 0, 0, X_CALL_HIPRI, Set, rtmpOnOthersSolarisWrapper);
     192
    100193    return VINF_SUCCESS;
    101194}
    102195
    103196
    104 /** 
    105  * Wrapper between the native solaris per-cpu callback and PFNRTWORKER 
     197/**
     198 * Wrapper between the native solaris per-cpu callback and PFNRTWORKER
    106199 * for the RTMpOnSpecific API.
    107  *
    108  * @param   pvArg   Pointer to the RTMPARGS package.
    109  */
    110 static void rtmpOnSpecificSolarisWrapper(void *pvArg)
    111 {
    112     PRTMPARGS pArgs = (PRTMPARGS)pvArg;
    113     Assert(pArgs->idCpu == RTMpCpuId());
     200 *
     201 *
     202 * @param   uArgs       Pointer to the RTMPARGS package.
     203 * @param   uIgnored1   Ignored.
     204 * @param   uIgnored2   Ignored.
     205 */
     206static int rtmpOnSpecificSolarisWrapper(xc_arg_t uArg, xc_arg_t uIgnored1, xc_arg_t uIgnored2)
     207{
     208    PRTMPARGS pArgs = (PRTMPARGS)(uArg);
     209    RTCPUID idCpu = RTMpCpuId();
     210
     211    Assert(idCpu != pArgs->idCpu);
    114212    pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2);
    115213    ASMAtomicIncU32(&pArgs->cHits);
     214
     215    NOREF(uIgnored1);
     216    NOREF(uIgnored2);
     217    return 0;
    116218}
    117219
     
    120222{
    121223    int rc;
     224    cpuset_t Set;
    122225    RTMPARGS Args;
     226
    123227    Args.pfnWorker = pfnWorker;
    124228    Args.pvUser1 = pvUser1;
     
    126230    Args.idCpu = idCpu;
    127231    Args.cHits = 0;
    128     xt_one(idCpu, rtmpOnSpecificSolarisWrapper, (uintptr_t)&Args, 0);
    129     return Args.cHits == 1
    130          ? VINF_SUCCESS
     232
     233    CPUSET_ZERO(Set);
     234    AssertReturn(idCpu < NCPU, VERR_INVALID_PARAMETER);
     235    CPUSET_ADD(Set, idCpu);
     236
     237    xc_call((uintptr_t)&Args, 0, 0, X_CALL_HIPRI, Set, rtmpOnSpecificSolarisWrapper);
     238    Assert(ASMAtomicUoReadU32(&Args.cHits) <= 1);
     239
     240    return ASMAtomicUoReadU32(&Args.cHits) == 1
     241         ? VINF_SUCCESS
    131242         : VERR_CPU_NOT_FOUND;
    132243}
  • trunk/src/VBox/Runtime/r0drv/solaris/the-solaris-kernel.h

    r6147 r7331  
    2828#define ___the_solaris_kernel_h
    2929
     30#define _MACHDEP /* needed for cpuset_t and sys/x_call.h */
     31
    3032#include <sys/kmem.h>
    3133#include <sys/types.h>
     
    4244#include <sys/cyclic.h>
    4345#include <sys/class.h>
     46#include <sys/cpuvar.h>
     47#include <sys/x_call.h> /* in platform dir */
     48#include <sys/x86_archext.h>
    4449#include <vm/hat.h>
    4550#include <vm/seg_vn.h>
Note: See TracChangeset for help on using the changeset viewer.

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