VirtualBox

Changeset 14338 in vbox for trunk


Ignore:
Timestamp:
Nov 18, 2008 11:38:52 PM (16 years ago)
Author:
vboxsync
Message:

IPRT: Basic implementation of the MP API for ring-0 Darwin.

Location:
trunk/src/VBox/Runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r14035 r14338  
    10791079        darwin/RTErrConvertFromDarwinKern.cpp \
    10801080        generic/RTAssertShouldPanic-generic.cpp \
    1081         generic/RTMpCpuId-generic.cpp \
    1082         generic/RTMpCpuIdFromSetIndex-generic.cpp \
    1083         generic/RTMpCpuIdToSetIndex-generic.cpp \
    1084         generic/RTMpIsCpuPossible-generic.cpp \
    1085         generic/RTMpGetCount-generic.cpp \
    1086         generic/RTMpGetMaxCpuId-generic.cpp \
    1087         generic/RTMpGetOnlineCount-generic.cpp \
    1088         generic/RTMpGetOnlineSet-generic.cpp \
    1089         generic/RTMpGetSet-generic.cpp \
    1090         generic/RTMpIsCpuOnline-generic.cpp \
    10911081        generic/RTTimerCreate-generic.cpp \
    10921082        generic/mppresent-generic.cpp \
    10931083        generic/timer-generic.cpp \
    1094         r0drv/generic/RTMpOn-r0drv-generic.cpp \
    10951084        r0drv/generic/RTThreadPreemptIsEnabled-r0drv-generic.cpp \
    10961085        r0drv/generic/RTThreadPreemptDisable-r0drv-generic.cpp \
     
    11011090        r0drv/darwin/initterm-r0drv-darwin.cpp \
    11021091        r0drv/darwin/memobj-r0drv-darwin.cpp \
     1092        r0drv/darwin/mp-r0drv-darwin.cpp \
    11031093        r0drv/darwin/process-r0drv-darwin.cpp \
    11041094        r0drv/darwin/RTLogWriteDebugger-r0drv-darwin.cpp \
  • trunk/src/VBox/Runtime/r0drv/darwin/mp-r0drv-darwin.cpp

    r8245 r14338  
    4040#include "r0drv/mp-r0drv.h"
    4141
     42#define MY_DARWIN_MAX_CPUS      (0xf + 1) /* see MAX_CPUS */
     43
     44
     45DECLINLINE(int) rtMpDarwinMaxCpus(void)
     46{
     47    return ml_get_max_cpus();
     48}
     49
    4250
    4351RTDECL(RTCPUID) RTMpCpuId(void)
     
    4755
    4856
    49 /**
    50  * Wrapper between the native darwin per-cpu callback and PFNRTWORKER
     57RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu)
     58{
     59    return idCpu < MY_DARWIN_MAX_CPUS ? (int)idCpu : -1;
     60}
     61
     62
     63RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu)
     64{
     65    return (unsigned)iCpu < MY_DARWIN_MAX_CPUS ? (RTCPUID)iCpu : NIL_RTCPUID;
     66}
     67
     68
     69RTDECL(RTCPUID) RTMpGetMaxCpuId(void)
     70{
     71    return rtMpDarwinMaxCpus() - 1;
     72}
     73
     74
     75RTDECL(bool) RTMpIsCpuPossible(RTCPUID idCpu)
     76{
     77    return idCpu < MY_DARWIN_MAX_CPUS
     78        && idCpu < (RTCPUID)rtMpDarwinMaxCpus();
     79}
     80
     81
     82RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
     83{
     84
     85}
     86
     87
     88RTDECL(RTCPUID) RTMpGetCount(void)
     89{
     90    return rtMpDarwinMaxCpus();
     91}
     92
     93
     94RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
     95{
     96    /** @todo darwin R0 MP */
     97    return RTMpGetSet(pSet);
     98}
     99
     100
     101RTDECL(RTCPUID) RTMpGetOnlineCount(void)
     102{
     103    /** @todo darwin R0 MP */
     104    return RTMpGetCount();
     105}
     106
     107
     108RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
     109{
     110    /** @todo darwin R0 MP */
     111    return RTMpIsCpuPossible(idCpu);
     112}
     113
     114
     115RTDECL(PRTCPUSET) RTMpGetPresentSet(PRTCPUSET pSet)
     116{
     117    return RTMpGetSet(pSet);
     118}
     119
     120
     121RTDECL(RTCPUID) RTMpGetPresentCount(void)
     122{
     123    return RTMpGetCount();
     124}
     125
     126
     127RTDECL(bool) RTMpIsCpuPresent(RTCPUID idCpu)
     128{
     129    return RTMpIsCpuPossible(idCpu);
     130}
     131
     132
     133RTDECL(uint32_t) RTMpGetCurFrequency(RTCPUID idCpu)
     134{
     135    /** @todo darwin R0 MP (rainy day) */
     136    return 0;
     137}
     138
     139
     140RTDECL(uint32_t) RTMpGetMaxFrequency(RTCPUID idCpu)
     141{
     142    /** @todo darwin R0 MP (rainy day) */
     143    return 0;
     144}
     145
     146
     147/**
     148 * Wrapper between the native darwin per-cpu callback and PFNRTWORKER
    51149 * for the RTMpOnAll API.
    52  * 
     150 *
    53151 * @param   pvArg   Pointer to the RTMPARGS package.
    54152 */
     
    68166    Args.idCpu = NIL_RTCPUID;
    69167    Args.cHits = 0;
    70     mp_rendezvous(NULL, rtmpOnAllDarwinWrapper, NULL, &Args);
     168    mp_rendezvous_no_intrs(rtmpOnAllDarwinWrapper, &Args);
    71169    return VINF_SUCCESS;
    72170}
    73171
    74172
    75 /** 
    76  * Wrapper between the native darwin per-cpu callback and PFNRTWORKER 
     173/**
     174 * Wrapper between the native darwin per-cpu callback and PFNRTWORKER
    77175 * for the RTMpOnOthers API.
    78  * 
     176 *
    79177 * @param   pvArg   Pointer to the RTMPARGS package.
    80178 */
     
    97195    Args.idCpu = NIL_RTCPUID;
    98196    Args.cHits = 0;
    99     mp_rendezvous(NULL, rtmpOnOthersDarwinWrapper, NULL, &Args);
     197    mp_rendezvous_no_intrs(rtmpOnOthersDarwinWrapper, &Args);
    100198    return VINF_SUCCESS;
    101199}
    102200
    103201
    104 /** 
    105  * Wrapper between the native darwin per-cpu callback and PFNRTWORKER 
     202/**
     203 * Wrapper between the native darwin per-cpu callback and PFNRTWORKER
    106204 * for the RTMpOnSpecific API.
    107  * 
     205 *
    108206 * @param   pvArg   Pointer to the RTMPARGS package.
    109207 */
     
    129227    Args.idCpu = idCpu;
    130228    Args.cHits = 0;
    131     mp_rendezvous(NULL, rtmpOnSpecificDarwinWrapper, NULL, &Args);
    132     return Args.cHits == 1 
    133          ? VINF_SUCCESS 
     229    mp_rendezvous_no_intrs(rtmpOnSpecificDarwinWrapper, &Args);
     230    return Args.cHits == 1
     231         ? VINF_SUCCESS
    134232         : VERR_CPU_NOT_FOUND;
    135233}
  • trunk/src/VBox/Runtime/r0drv/darwin/the-darwin-kernel.h

    r8245 r14338  
    5959#include <kern/sched_prim.h>
    6060#include <kern/locks.h>
     61#include <i386/mp_events.h>
    6162#include <libkern/libkern.h>
    6263#include <mach/thread_act.h>
     
    9697/* mach/i386/thread_act.h */
    9798extern kern_return_t thread_terminate(thread_t);
     99
     100/* osfmk/i386/mp.h */
     101extern void mp_rendezvous(void (*)(void *), void (*)(void *), void (*)(void *), void *);
     102extern void mp_rendezvous_no_intrs(void (*)(void *), void *);
     103
     104/* osfmk/i386/cpu_number.h */
     105extern int cpu_number(void);
     106
     107/* i386/machine_routines.h */
     108extern int ml_get_max_cpus(void);
     109
    98110__END_DECLS
    99111
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