VirtualBox

Changeset 36254 in vbox for trunk/include/VBox/sup.h


Ignore:
Timestamp:
Mar 10, 2011 5:22:08 PM (14 years ago)
Author:
vboxsync
Message:

GIP,++: Lots of CPUs (disabled).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/sup.h

    r36220 r36254  
    3131#include <iprt/assert.h>
    3232#include <iprt/stdarg.h>
     33#include <iprt/cpuset.h>
    3334
    3435RT_C_DECLS_BEGIN
     
    8788} SUPPAGINGMODE;
    8889
    89 
    90 #pragma pack(1) /* paranoia */
     90#ifdef SUP_WITH_LOTS_OF_CPUS
     91# ifndef RT_WITH_LOTS_OF_CPUS
     92#  error "RT_WITH_LOTS_OF_CPUS must be defined with SUP_WITH_LOTS_OF_CPUS"
     93# endif
     94#endif
     95
     96/**
     97 * The CPU state.
     98 */
     99typedef enum SUPGIPCPUSTATE
     100{
     101    /** Invalid CPU state / unused CPU entry. */
     102    SUPGIPCPUSTATE_INVALID = 0,
     103    /** The CPU is not present. */
     104    SUPGIPCPUSTATE_ABSENT,
     105    /** The CPU is offline. */
     106    SUPGIPCPUSTATE_OFFLINE,
     107    /** The CPU is online. */
     108    SUPGIPCPUSTATE_ONLINE,
     109    /** Force 32-bit enum type. */
     110    SUPGIPCPUSTATE_32_BIT_HACK = 0x7fffffff
     111} SUPGIPCPUSTATE;
    91112
    92113/**
    93114 * Per CPU data.
    94  * This is only used when
    95115 */
    96116typedef struct SUPGIPCPU
     
    125145    /** The interval between the last two NanoTS updates. (experiment for now) */
    126146    volatile uint32_t   u32PrevUpdateIntervalNS;
     147
    127148    /** Reserved for future per processor data. */
     149#ifdef SUP_WITH_LOTS_OF_CPUS
     150    volatile uint32_t   au32Reserved[5+5];
     151#else
    128152    volatile uint32_t   au32Reserved[5];
     153#endif
     154
     155    /** @todo Add topology/NUMA info. */
     156#ifdef SUP_WITH_LOTS_OF_CPUS
     157    /** The CPU state. */
     158    SUPGIPCPUSTATE volatile enmState;
     159    /** The host CPU ID of this CPU (the SUPGIPCPU is indexed by APIC ID). */
     160    RTCPUID                 idCpu;
     161    /** The CPU set index of this CPU. */
     162    int16_t                 iCpuSet;
     163    /** The APIC ID of this CPU. */
     164    uint16_t                idApic;
     165#endif
    129166} SUPGIPCPU;
     167#ifdef SUP_WITH_LOTS_OF_CPUS
     168AssertCompileSize(RTCPUID, 4);
     169AssertCompileSize(SUPGIPCPU, 128);
     170#else
    130171AssertCompileSize(SUPGIPCPU, 96);
    131 /*AssertCompileMemberAlignment(SUPGIPCPU, u64TSC, 8); -fixme */
     172#endif
     173AssertCompileMemberAlignment(SUPGIPCPU, u64NanoTS, 8);
     174AssertCompileMemberAlignment(SUPGIPCPU, u64TSC, 8);
    132175
    133176/** Pointer to per cpu data.
     
    135178typedef SUPGIPCPU *PSUPGIPCPU;
    136179
     180
     181
     182#ifndef SUP_WITH_LOTS_OF_CPUS
    137183/** The number of CPUs covered by the GIP.
    138184 * @remarks Must be a power of two! */
    139 #define SUPGLOBALINFOPAGE_CPUS      32
     185# define SUPGLOBALINFOPAGE_CPUS     32
     186#endif
    140187
    141188/**
     
    155202    /** The GIP update mode, see SUPGIPMODE. */
    156203    uint32_t            u32Mode;
     204#ifdef SUP_WITH_LOTS_OF_CPUS
     205    /** The number of entries in the CPU table.
     206     * (This can work as RTMpGetArraySize().)  */
     207    uint16_t            cCpus;
     208    /** The size of the GIP in pages. */
     209    uint16_t            cPages;
     210#else
    157211    /** Reserved / padding. */
    158212    uint32_t            u32Padding0;
     213#endif
    159214    /** The update frequency of the of the NanoTS. */
    160215    volatile uint32_t   u32UpdateHz;
     
    163218    /** The timestamp of the last time we update the update frequency. */
    164219    volatile uint64_t   u64NanoTSLastUpdateHz;
     220#ifdef SUP_WITH_LOTS_OF_CPUS
     221    /** The set of online CPUs. */
     222    RTCPUSET            OnlineCpuSet;
     223    /** The number of CPUs that are online. */
     224    volatile uint32_t   cOnlineCpus;
     225    /** The number of CPUs present in the system. */
     226    volatile uint32_t   cPresentCpus;
     227    /** The set of present CPUs. */
     228    RTCPUSET            PresentCpuSet;
     229    /** The set of possible CPUs. */
     230    RTCPUSET            PossibleCpuSet;
     231    /** The highest number of CPUs possible. */
     232    uint32_t            cPossibleCpus;
     233    /** The max CPU ID (RTMpGetMaxCpuId). */
     234    RTCPUID             idCpuMax;
     235#endif
    165236
    166237    /** Padding / reserved space for future data. */
     238#ifdef SUP_WITH_LOTS_OF_CPUS
     239    uint32_t            au32Padding1[28];
     240#else
    167241    uint32_t            au32Padding1[56];
    168 
     242#endif
     243
     244#ifdef SUP_WITH_LOTS_OF_CPUS
     245    /** Table indexed by the CPU APIC ID to get the CPU table index. */
     246    uint16_t             aiCpuFromApicId[256];
     247    /** CPU set index to CPU table index. */
     248    uint16_t             aiCpuFromCpuSetIdx[RTCPUSET_MAX_CPUS];
     249#endif
     250
     251#ifdef SUP_WITH_LOTS_OF_CPUS
     252    /** Array of per-cpu data.
     253     * This is index by ApicId via the aiCpuFromApicId table.
     254     *
     255     * The clock and frequency information is updated for all CPUs if u32Mode
     256     * is SUPGIPMODE_ASYNC_TSC, otherwise (SUPGIPMODE_SYNC_TSC) only the first
     257     * entry is updated. */
     258    SUPGIPCPU           aCPUs[1];
     259#else
    169260    /** Array of per-cpu data.
    170261     * If u32Mode == SUPGIPMODE_SYNC_TSC then only the first entry is used.
     
    172263     * index into the array. */
    173264    SUPGIPCPU           aCPUs[SUPGLOBALINFOPAGE_CPUS];
     265#endif
    174266} SUPGLOBALINFOPAGE;
     267#ifndef SUP_WITH_LOTS_OF_CPUS
    175268AssertCompile(sizeof(SUPGLOBALINFOPAGE) <= 0x1000);
    176 /* AssertCompileMemberAlignment(SUPGLOBALINFOPAGE, aCPU, 32); - fixme */
     269#endif
     270#ifdef SUP_WITH_LOTS_OF_CPUS
     271AssertCompileMemberAlignment(SUPGLOBALINFOPAGE, u64NanoTSLastUpdateHz, 8);
     272AssertCompileMemberAlignment(SUPGLOBALINFOPAGE, aCPUs[0], 256);
     273AssertCompileMemberAlignment(SUPGLOBALINFOPAGE, aCPUs[1], 128);
     274#endif
    177275
    178276/** Pointer to the global info page.
     
    180278typedef SUPGLOBALINFOPAGE *PSUPGLOBALINFOPAGE;
    181279
    182 #pragma pack() /* end of paranoia */
    183280
    184281/** The value of the SUPGLOBALINFOPAGE::u32Magic field. (Soryo Fuyumi) */
     
    187284 * Upper 16 bits is the major version. Major version is only changed with
    188285 * incompatible changes in the GIP. */
    189 #define SUPGLOBALINFOPAGE_VERSION   0x00020000
     286#ifdef SUP_WITH_LOTS_OF_CPUS
     287# define SUPGLOBALINFOPAGE_VERSION   0x00030000
     288#else
     289# define SUPGLOBALINFOPAGE_VERSION   0x00020000
     290#endif
    190291
    191292/**
     
    254355 * Gets the TSC frequency of the calling CPU.
    255356 *
    256  * @returns TSC frequency.
     357 * @returns TSC frequency, UINT64_MAX on failure.
    257358 * @param   pGip        The GIP pointer.
    258359 */
     
    262363
    263364    if (RT_UNLIKELY(!pGip || pGip->u32Magic != SUPGLOBALINFOPAGE_MAGIC))
    264         return ~(uint64_t)0;
     365        return UINT64_MAX;
    265366
    266367    if (pGip->u32Mode != SUPGIPMODE_ASYNC_TSC)
     
    268369    else
    269370    {
     371# ifdef SUP_WITH_LOTS_OF_CPUS
     372        iCpu = pGip->aiCpuFromApicId[ASMGetApicId()];
     373        if (iCpu >= pGip->cCpus)
     374            return UINT64_MAX;
     375# else
    270376        iCpu = ASMGetApicId();
    271377        if (RT_UNLIKELY(iCpu >= RT_ELEMENTS(pGip->aCPUs)))
    272             return ~(uint64_t)0;
     378            return UINT64_MAX;
     379# endif
    273380    }
    274381
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