VirtualBox

Changeset 39303 in vbox


Ignore:
Timestamp:
Nov 15, 2011 10:55:12 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
74857
Message:

VMCPUSET changes.

Location:
trunk
Files:
1 added
8 edited

Legend:

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

    r38549 r39303  
    118118{
    119119    /** The bitmap data.  */
    120     uint32_t    au32Bitmap[256/32];
     120    uint32_t    au32Bitmap[8 /*256/32*/];
    121121} VMCPUSET;
    122122/** Pointer to a Virtual CPU set. */
     
    124124/** Pointer to a const Virtual CPU set. */
    125125typedef VMCPUSET const *PCVMCPUSET;
    126 
    127 /** Tests if a valid CPU ID is present in the set.. */
    128 #define VMCPUSET_IS_PRESENT(pSet, idCpu)    ASMBitTest( &(pSet)->au32Bitmap, (idCpu))
    129 /** Adds a CPU to the set. */
    130 #define VMCPUSET_ADD(pSet, idCpu)           ASMBitSet(  &(pSet)->au32Bitmap, (idCpu))
    131 /** Deletes a CPU from the set. */
    132 #define VMCPUSET_DEL(pSet, idCpu)           ASMBitClear(&(pSet)->au32Bitmap, (idCpu))
    133 /** Empties the set. */
    134 #define VMCPUSET_EMPTY(pSet)                memset(&(pSet)->au32Bitmap[0], '\0', sizeof((pSet)->au32Bitmap))
    135 /** Filles the set. */
    136 #define VMCPUSET_FILL(pSet)                 memset(&(pSet)->au32Bitmap[0], 0xff, sizeof((pSet)->au32Bitmap))
    137 /** Filles the set. */
    138 #define VMCPUSET_IS_EQUAL(pSet1, pSet2)     (memcmp(&(pSet1)->au32Bitmap[0], &(pSet2)->au32Bitmap[0], sizeof((pSet1)->au32Bitmap)) == 0)
    139126
    140127
  • trunk/src/VBox/Devices/PC/DevACPI.cpp

    r39091 r39303  
    2323#include <VBox/vmm/pgm.h>
    2424#include <VBox/vmm/dbgftrace.h>
     25#include <VBox/vmm/vmcpuset.h>
    2526#include <VBox/log.h>
    2627#include <VBox/param.h>
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r39248 r39303  
    17931793
    17941794            InsertConfigNode(pInst, "Config", &pCfg);
    1795 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE   /* not safe here yet. */
     1795#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE   /* not safe here yet. */ /** @todo Make PCNet ring-0 safe on 32-bit mac kernels! */
    17961796            if (pDev == pDevPCNet)
    17971797            {
  • trunk/src/VBox/VMM/VMMAll/VMMAll.cpp

    r39078 r39303  
    2424#include "VMMInternal.h"
    2525#include <VBox/vmm/vm.h>
    26 #include <VBox/vmm/vmm.h>
     26#include <VBox/vmm/vmcpuset.h>
    2727#include <VBox/param.h>
    2828#include <iprt/thread.h>
    2929#include <iprt/mp.h>
     30
     31
     32/*******************************************************************************
     33*   Global Variables                                                           *
     34*******************************************************************************/
     35/** User counter for the vmmInitFormatTypes function (pro forma). */
     36static volatile uint32_t g_cFormatTypeUsers = 0;
     37
     38
     39/**
     40 * Helper that formats a decimal number in the range 0..9999.
     41 *
     42 * @returns The length of the formatted number.
     43 * @param   pszBuf              Output buffer with sufficient space.
     44 * @param   uNum                The number to format.
     45 */
     46static unsigned vmmFormatTypeShortNumber(char *pszBuf, uint32_t uNumber)
     47{
     48    unsigned  off = 0;
     49    if (uNumber >= 10)
     50    {
     51        if (uNumber >= 100)
     52        {
     53            if (uNumber >= 1000)
     54                pszBuf[off++] = ((uNumber / 1000) % 10) + '0';
     55            pszBuf[off++] = ((uNumber / 100) % 10) + '0';
     56        }
     57        pszBuf[off++] = ((uNumber / 10) % 10) + '0';
     58    }
     59    pszBuf[off++] = (uNumber % 10) + '0';
     60    pszBuf[off] = '\0';
     61    return off;
     62}
     63
     64
     65/**
     66 * @callback_method_impl{FNRTSTRFORMATTYPE, vmsetcpu}
     67 */
     68static DECLCALLBACK(size_t) vmmFormatTypeVmCpuSet(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
     69                                                  const char *pszType, void const *pvValue,
     70                                                  int cchWidth, int cchPrecision, unsigned fFlags,
     71                                                  void *pvUser)
     72{
     73    PCVMCPUSET  pSet   = (PCVMCPUSET)pvValue;
     74    uint32_t    cCpus  = 0;
     75    uint32_t    iCpu   = RT_ELEMENTS(pSet->au32Bitmap) * 32;
     76    while (iCpu--)
     77        if (VMCPUSET_IS_PRESENT(pSet, iCpu))
     78            cCpus++;
     79
     80    char szTmp[32];
     81    AssertCompile(RT_ELEMENTS(pSet->au32Bitmap) * 32 < 999);
     82    if (cCpus == 1)
     83    {
     84        iCpu = RT_ELEMENTS(pSet->au32Bitmap) * 32;
     85        while (iCpu--)
     86            if (VMCPUSET_IS_PRESENT(pSet, iCpu))
     87            {
     88                szTmp[0] = 'c';
     89                szTmp[1] = 'p';
     90                szTmp[2] = 'u';
     91                return pfnOutput(pvArgOutput, szTmp, 3 + vmmFormatTypeShortNumber(&szTmp[3], iCpu));
     92            }
     93        cCpus = 0;
     94    }
     95    if (cCpus == 0)
     96        return pfnOutput(pvArgOutput, "<empty>", sizeof("<empty>") - 1);
     97    if (cCpus == RT_ELEMENTS(pSet->au32Bitmap) * 32)
     98        return pfnOutput(pvArgOutput, "<full>", sizeof("<full>") - 1);
     99
     100    /*
     101     * Print cpus that are present: {1,2,7,9 ... }
     102     */
     103    size_t cchRet = pfnOutput(pvArgOutput, "{", 1);
     104
     105    cCpus = 0;
     106    iCpu  = 0;
     107    while (iCpu < RT_ELEMENTS(pSet->au32Bitmap) * 32)
     108    {
     109        if (VMCPUSET_IS_PRESENT(pSet, iCpu))
     110        {
     111            /* Output the first cpu number. */
     112            int off = 0;
     113            if (cCpus != 0)
     114                szTmp[off++] = ',';
     115            off += vmmFormatTypeShortNumber(&szTmp[off], iCpu);
     116
     117            /* Check for sequence. */
     118            uint32_t const iStart = ++iCpu;
     119            while (   iCpu < RT_ELEMENTS(pSet->au32Bitmap) * 32
     120                   && VMCPUSET_IS_PRESENT(pSet, iCpu))
     121                iCpu++;
     122            if (iCpu != iStart)
     123            {
     124                szTmp[off++] = '-';
     125                off += vmmFormatTypeShortNumber(&szTmp[off], iCpu);
     126            }
     127
     128            /* Terminate and output. */
     129            szTmp[off] = '\0';
     130            cchRet += pfnOutput(pvArgOutput, szTmp, off);
     131        }
     132        iCpu++;
     133    }
     134
     135    cchRet += pfnOutput(pvArgOutput, "}", 1);
     136    NOREF(pvUser);
     137    return cchRet;
     138}
     139
     140
     141/**
     142 * Registers the VMM wide format types.
     143 *
     144 * Called by VMMR3Init, VMMR0Init and VMMRCInit.
     145 */
     146int vmmInitFormatTypes(void)
     147{
     148    int rc = VINF_SUCCESS;
     149    if (ASMAtomicIncU32(&g_cFormatTypeUsers) == 1)
     150        rc = RTStrFormatTypeRegister("vmcpuset", vmmFormatTypeVmCpuSet, NULL);
     151    return rc;
     152}
     153
     154
     155#ifndef IN_RC
     156/**
     157 * Counterpart to vmmInitFormatTypes, called by VMMR3Term and VMMR0Term.
     158 */
     159void vmmTermFormatTypes(void)
     160{
     161    if (ASMAtomicDecU32(&g_cFormatTypeUsers) == 0)
     162        RTStrFormatTypeDeregister("vmcpuset");
     163}
     164#endif
    30165
    31166
     
    203338    return pVM->vmm.s.enmSwitcher;
    204339}
     340
  • trunk/src/VBox/VMM/VMMR0/GVMMR0.cpp

    r39078 r39303  
    5656#include <VBox/vmm/gvm.h>
    5757#include <VBox/vmm/vm.h>
     58#include <VBox/vmm/vmcpuset.h>
    5859#include <VBox/vmm/vmm.h>
    5960#include <VBox/param.h>
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r39152 r39303  
    107107
    108108    /*
    109      * Initialize the GVMM, GMM, HWACCM, PGM (Darwin) and INTNET.
    110      */
    111     int rc = GVMMR0Init();
     109     * Initialize the VMM, GVMM, GMM, HWACCM, PGM (Darwin) and INTNET.
     110     */
     111    int rc = vmmInitFormatTypes();
    112112    if (RT_SUCCESS(rc))
    113113    {
    114         rc = GMMR0Init();
     114        rc = GVMMR0Init();
    115115        if (RT_SUCCESS(rc))
    116116        {
    117             rc = HWACCMR0Init();
     117            rc = GMMR0Init();
    118118            if (RT_SUCCESS(rc))
    119119            {
    120                 rc = PGMRegisterStringFormatTypes();
     120                rc = HWACCMR0Init();
    121121                if (RT_SUCCESS(rc))
    122122                {
    123 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
    124                     rc = PGMR0DynMapInit();
    125 #endif
     123                    rc = PGMRegisterStringFormatTypes();
    126124                    if (RT_SUCCESS(rc))
    127125                    {
    128                         rc = IntNetR0Init();
     126#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
     127                        rc = PGMR0DynMapInit();
     128#endif
    129129                        if (RT_SUCCESS(rc))
    130130                        {
    131 #ifdef VBOX_WITH_PCI_PASSTHROUGH
    132                             rc = PciRawR0Init();
    133 #endif
     131                            rc = IntNetR0Init();
    134132                            if (RT_SUCCESS(rc))
    135133                            {
    136                                 rc = CPUMR0ModuleInit();
     134#ifdef VBOX_WITH_PCI_PASSTHROUGH
     135                                rc = PciRawR0Init();
     136#endif
    137137                                if (RT_SUCCESS(rc))
    138138                                {
     139                                    rc = CPUMR0ModuleInit();
     140                                    if (RT_SUCCESS(rc))
     141                                    {
    139142#ifdef VBOX_WITH_TRIPLE_FAULT_HACK
    140                                     rc = vmmR0TripleFaultHackInit();
    141                                     if (RT_SUCCESS(rc))
    142 #endif
    143                                     {
    144                                         LogFlow(("ModuleInit: returns success.\n"));
    145                                         return VINF_SUCCESS;
     143                                        rc = vmmR0TripleFaultHackInit();
     144                                        if (RT_SUCCESS(rc))
     145#endif
     146                                        {
     147                                            LogFlow(("ModuleInit: returns success.\n"));
     148                                            return VINF_SUCCESS;
     149                                        }
     150
     151                                        /*
     152                                         * Bail out.
     153                                         */
     154#ifdef VBOX_WITH_TRIPLE_FAULT_HACK
     155                                        vmmR0TripleFaultHackTerm();
     156#endif
    146157                                    }
    147 
    148                                     /*
    149                                      * Bail out.
    150                                      */
    151 #ifdef VBOX_WITH_TRIPLE_FAULT_HACK
    152                                     vmmR0TripleFaultHackTerm();
     158#ifdef VBOX_WITH_PCI_PASSTHROUGH
     159                                    PciRawR0Term();
    153160#endif
    154161                                }
    155 #ifdef VBOX_WITH_PCI_PASSTHROUGH
    156                                 PciRawR0Term();
    157 #endif
     162                                IntNetR0Term();
    158163                            }
    159                             IntNetR0Term();
     164#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
     165                            PGMR0DynMapTerm();
     166#endif
    160167                        }
    161 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
    162                         PGMR0DynMapTerm();
    163 #endif
     168                        PGMDeregisterStringFormatTypes();
    164169                    }
    165                     PGMDeregisterStringFormatTypes();
     170                    HWACCMR0Term();
    166171                }
    167                 HWACCMR0Term();
     172                GMMR0Term();
    168173            }
    169             GMMR0Term();
    170         }
    171        GVMMR0Term();
     174           GVMMR0Term();
     175        }
     176        vmmTermFormatTypes();
    172177    }
    173178
     
    215220    GMMR0Term();
    216221    GVMMR0Term();
     222
     223    vmmTermFormatTypes();
    217224
    218225    LogFlow(("ModuleTerm: returns\n"));
  • trunk/src/VBox/VMM/VMMR3/VMM.cpp

    r39283 r39303  
    256256                DBGFR3InfoRegisterInternal(pVM, "ff", "Displays the current Forced actions Flags.", vmmR3InfoFF);
    257257                vmmR3InitRegisterStats(pVM);
     258                vmmInitFormatTypes();
    258259
    259260                return VINF_SUCCESS;
     
    767768    }
    768769#endif
     770
     771    vmmTermFormatTypes();
    769772    return rc;
    770773}
  • trunk/src/VBox/VMM/include/VMMInternal.h

    r38954 r39303  
    506506RT_C_DECLS_BEGIN
    507507
     508int  vmmInitFormatTypes(void);
     509void vmmTermFormatTypes(void);
     510
    508511#ifdef IN_RING3
    509512int  vmmR3SwitcherInit(PVM pVM);
Note: See TracChangeset for help on using the changeset viewer.

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