VirtualBox

Changeset 17305 in vbox for trunk


Ignore:
Timestamp:
Mar 3, 2009 6:19:29 PM (16 years ago)
Author:
vboxsync
Message:

VMM: Register %R[pgmpage] and %R[pgmramrange] (logging builds only).

Location:
trunk
Files:
6 edited

Legend:

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

    r17251 r17305  
    284284      || (enmProt) == PGMROMPROT_READ_ROM_WRITE_RAM )
    285285
    286 
     286VMMDECL(int)        PGMRegisterStringFormatTypes(void);
     287VMMDECL(void)       PGMDeregisterStringFormatTypes(void);
    287288VMMDECL(RTHCPHYS)   PGMGetHyperCR3(PVM pVM);
    288289VMMDECL(RTHCPHYS)   PGMGetNestedCR3(PVM pVM, PGMMODE enmShadowMode);
  • trunk/src/VBox/VMM/PGM.cpp

    r17215 r17305  
    11991199    VMR3AtStateRegister(pVM, pgmR3ResetNoMorePhysWritesFlag, NULL);
    12001200#endif
     1201    PGMRegisterStringFormatTypes();
    12011202
    12021203    /*
     
    22542255VMMR3DECL(int) PGMR3Term(PVM pVM)
    22552256{
     2257    PGMDeregisterStringFormatTypes();
    22562258    return PDMR3CritSectDelete(&pVM->pgm.s.CritSect);
    22572259}
     
    22822284static DECLCALLBACK(int) pgmR3Save(PVM pVM, PSSMHANDLE pSSM)
    22832285{
     2286#ifdef VBOX_WITH_NEW_PHYS_CODE
     2287    AssertReleaseFailed(); /** @todo */
     2288#else
    22842289    PPGM pPGM = &pVM->pgm.s;
    22852290
     
    23612366        }
    23622367    }
     2368#endif /* !VBOX_WITH_NEW_PHYS_CODE */
    23632369    return SSMR3PutU32(pSSM, ~0); /* terminator. */
    23642370}
     
    23752381static DECLCALLBACK(int) pgmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
    23762382{
     2383#ifdef VBOX_WITH_NEW_PHYS_CODE
     2384    AssertReleaseFailed(); /** @todo */
     2385#else
    23772386    /*
    23782387     * Validate version.
     
    26232632
    26242633    return rc;
     2634#endif /* !VBOX_WITH_NEW_PHYS_CODE */
    26252635}
    26262636
  • trunk/src/VBox/VMM/PGMInternal.h

    r17294 r17305  
    545545    /** MMIO2 page. (RWX) */
    546546    PGMPAGETYPE_MMIO2,
     547    /** MMIO2 page aliased over an MMIO page. (RWX)
     548     * See PGMHandlerPhysicalPageAlias(). */
     549    PGMPAGETYPE_MMIO2_ALIAS_MMIO,
    547550    /** Shadowed ROM. (RWX) */
    548551    PGMPAGETYPE_ROM_SHADOW,
     
    554557    PGMPAGETYPE_END
    555558} PGMPAGETYPE;
    556 AssertCompile(PGMPAGETYPE_END < 7);
     559AssertCompile(PGMPAGETYPE_END <= 7);
    557560
    558561/** @name Page type predicates.
     
    578581{
    579582    /** The physical address and a whole lot of other stuff. All bits are used! */
     583#ifdef VBOX_WITH_NEW_PHYS_CODE
     584    RTHCPHYS    HCPhysX;
     585#else
    580586    RTHCPHYS    HCPhys;
    581587#define HCPhysX HCPhys /**< Temporary while in the process of eliminating direct access to PGMPAGE::HCPhys. */
     588#endif
    582589    /** The page state. */
    583590    uint32_t    u2StateX : 2;
  • trunk/src/VBox/VMM/VMMAll/PGMAll.cpp

    r17259 r17305  
    982982}
    983983
     984
    984985/**
    985986 * Gets the pointer to the shadow page directory entry for an address, PAE.
     
    10081009    return VINF_SUCCESS;
    10091010}
    1010 #endif
    1011 
     1011
     1012#endif /* VBOX_WITH_PGMPOOL_PAGING_ONLY */
    10121013#ifndef IN_RC
    10131014
     
    15461547    return pVM->pgm.s.HCPhysShwCR3;
    15471548}
     1549
    15481550
    15491551/**
     
    21962198}
    21972199
    2198 
    21992200# ifdef IN_RC
     2201
    22002202/**
    22012203 * Temporarily maps one host page specified by HC physical address.
     
    22872289}
    22882290
     2291
    22892292/**
    22902293 * Temporarily lock a dynamic page to prevent it from being reused.
     
    23052308}
    23062309
     2310
    23072311/**
    23082312 * Unlock a dynamic page
     
    23232327}
    23242328
    2325 # ifdef VBOX_STRICT
     2329
     2330#  ifdef VBOX_STRICT
    23262331/**
    23272332 * Check for lock leaks.
     
    23342339        Assert(!(pVM->pgm.s.paDynPageMap32BitPTEsGC[i].u & PGM_PTFLAGS_DYN_LOCKED));
    23352340}
     2341#  endif /* VBOX_STRICT */
     2342
     2343# endif /* IN_RC */
     2344#endif /* IN_RC || VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */
     2345
     2346#ifdef LOG_ENABLED
     2347
     2348/** Format handler for PGMPAGE.
     2349 * @copydoc FNRTSTRFORMATTYPE */
     2350static DECLCALLBACK(size_t) pgmFormatTypeHandlerPage(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
     2351                                                    const char *pszType, void const *pvValue,
     2352                                                    int cchWidth, int cchPrecision, unsigned fFlags,
     2353                                                    void *pvUser)
     2354{
     2355    size_t    cch;
     2356    PCPGMPAGE pPage = (PCPGMPAGE)pvValue;
     2357    if (VALID_PTR(pPage))
     2358    {
     2359        char szTmp[80];
     2360        switch (PGM_PAGE_GET_TYPE(pPage))
     2361        {
     2362            case PGMPAGETYPE_RAM:
     2363                cch = RTStrPrintf(szTmp, sizeof(szTmp), "%RHp-RAM", PGM_PAGE_GET_HCPHYS(pPage));
     2364                break;
     2365            case PGMPAGETYPE_MMIO2:
     2366                cch = RTStrPrintf(szTmp, sizeof(szTmp), "%RHp-MMIO2", PGM_PAGE_GET_HCPHYS(pPage));
     2367                break;
     2368            case PGMPAGETYPE_MMIO2_ALIAS_MMIO:
     2369                cch = RTStrPrintf(szTmp, sizeof(szTmp), "%RHp-M2ALI", PGM_PAGE_GET_HCPHYS(pPage));
     2370                break;
     2371            case PGMPAGETYPE_ROM_SHADOW:
     2372                cch = RTStrPrintf(szTmp, sizeof(szTmp), "%RHp-ROMSH", PGM_PAGE_GET_HCPHYS(pPage));
     2373                break;
     2374            case PGMPAGETYPE_ROM:
     2375                cch = RTStrPrintf(szTmp, sizeof(szTmp), "%RHp-ROM", PGM_PAGE_GET_HCPHYS(pPage));
     2376                break;
     2377            case PGMPAGETYPE_MMIO:
     2378                cch = RTStrPrintf(szTmp, sizeof(szTmp), "%RHp-MMIO", PGM_PAGE_GET_HCPHYS(pPage));
     2379                break;
     2380            default:
     2381                cch = RTStrPrintf(szTmp, sizeof(szTmp), "%RHp-%d", PGM_PAGE_GET_HCPHYS(pPage), PGM_PAGE_GET_TYPE(pPage));
     2382                break;
     2383        }
     2384        cch = pfnOutput(pvArgOutput, szTmp, cch);
     2385    }
     2386    else
     2387        cch = pfnOutput(pvArgOutput, "<bad-pgmpage-ptr>", sizeof("<bad-pgmpage-ptr>") - 1);
     2388    return cch;
     2389}
     2390
     2391
     2392/** Format handler for PGMRAMRANGE.
     2393 * @copydoc FNRTSTRFORMATTYPE */
     2394static DECLCALLBACK(size_t) pgmFormatTypeHandlerRamRange(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
     2395                                                         const char *pszType, void const *pvValue,
     2396                                                         int cchWidth, int cchPrecision, unsigned fFlags,
     2397                                                         void *pvUser)
     2398{
     2399    size_t              cch;
     2400    PGMRAMRANGE const  *pRam = (PGMRAMRANGE const *)pvValue;
     2401    if (VALID_PTR(pRam))
     2402    {
     2403        char szTmp[80];
     2404        cch = RTStrPrintf(szTmp, sizeof(szTmp), "%RGp-%RGp", pRam->GCPhys, pRam->GCPhysLast);
     2405        cch = pfnOutput(pvArgOutput, szTmp, cch);
     2406    }
     2407    else
     2408        cch = pfnOutput(pvArgOutput, "<bad-pgmramrange-ptr>", sizeof("<bad-pgmramrange-ptr>") - 1);
     2409    return cch;
     2410}
     2411
     2412/** Format type andlers to be registered/deregistered. */
     2413static const struct
     2414{
     2415    char                szType[24];
     2416    PFNRTSTRFORMATTYPE  pfnHandler;
     2417} g_aPgmFormatTypes[] =
     2418{
     2419    { "pgmpage",        pgmFormatTypeHandlerPage },
     2420    { "pgmramrange",    pgmFormatTypeHandlerRamRange }
     2421};
     2422
     2423#endif /* LOG_ENABLED */
     2424
     2425
     2426/**
     2427 * Registers the global string format types.
     2428 *
     2429 * This should be called at module load time or in some other manner that ensure
     2430 * that it's called exactly one time.
     2431 *
     2432 * @returns IPRT status code on RTStrFormatTypeRegister failure.
     2433 */
     2434VMMDECL(int) PGMRegisterStringFormatTypes(void)
     2435{
     2436#ifdef LOG_ENABLED
     2437    int         rc = VINF_SUCCESS;
     2438    unsigned    i;
     2439    for (i = 0; RT_SUCCESS(rc) && i < RT_ELEMENTS(g_aPgmFormatTypes); i++)
     2440    {
     2441        rc = RTStrFormatTypeRegister(g_aPgmFormatTypes[i].szType, g_aPgmFormatTypes[i].pfnHandler, NULL);
     2442# ifdef IN_RING0
     2443        if (rc == VERR_ALREADY_EXISTS)
     2444        {
     2445            /* in case of cleanup failure in ring-0 */
     2446            RTStrFormatTypeDeregister(g_aPgmFormatTypes[i].szType);
     2447            rc = RTStrFormatTypeRegister(g_aPgmFormatTypes[i].szType, g_aPgmFormatTypes[i].pfnHandler, NULL);
     2448        }
    23362449# endif
    2337 # endif /* IN_RC */
    2338 
    2339 #endif /* IN_RC || VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 */
     2450    }
     2451    if (RT_FAILURE(rc))
     2452        while (i-- > 0)
     2453            RTStrFormatTypeDeregister(g_aPgmFormatTypes[i].szType);
     2454
     2455    return rc;
     2456#else
     2457    return VINF_SUCCESS;
     2458#endif
     2459}
     2460
     2461
     2462/**
     2463 * Deregisters the global string format types.
     2464 *
     2465 * This should be called at module unload time or in some other manner that
     2466 * ensure that it's called exactly one time.
     2467 */
     2468VMMDECL(void) PGMDeregisterStringFormatTypes(void)
     2469{
     2470#ifdef LOG_ENABLED
     2471    for (unsigned i = 0; i < RT_ELEMENTS(g_aPgmFormatTypes); i++)
     2472        RTStrFormatTypeDeregister(g_aPgmFormatTypes[i].szType);
     2473#endif
     2474}
     2475
    23402476#ifdef VBOX_STRICT
    23412477
  • trunk/src/VBox/VMM/VMMGC/VMMGC.cpp

    r17146 r17305  
    2727#include <VBox/vmm.h>
    2828#include <VBox/trpm.h>
     29#include <VBox/pgm.h>
    2930#include "VMMInternal.h"
    3031#include <VBox/vm.h>
     
    8990            int rc = RTRCInit(u64TS);
    9091            Log(("VMMGCEntry: VMMGC_DO_VMMGC_INIT - uArg=%u (svn revision) u64TS=%RX64; rc=%Rrc\n", uArg, u64TS, rc));
     92            AssertRCReturn(rc, rc);
     93
     94            rc = PGMRegisterStringFormatTypes();
    9195            AssertRCReturn(rc, rc);
    9296
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r17284 r17305  
    9191            if (RT_SUCCESS(rc))
    9292            {
    93 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
    94                 rc = PGMR0DynMapInit();
    95 #endif
     93                rc = PGMRegisterStringFormatTypes();
    9694                if (RT_SUCCESS(rc))
    9795                {
    98                     LogFlow(("ModuleInit: g_pIntNet=%p\n", g_pIntNet));
    99                     g_pIntNet = NULL;
    100                     LogFlow(("ModuleInit: g_pIntNet=%p should be NULL now...\n", g_pIntNet));
    101                     rc = INTNETR0Create(&g_pIntNet);
     96#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
     97                    rc = PGMR0DynMapInit();
     98#endif
    10299                    if (RT_SUCCESS(rc))
    103100                    {
    104                         LogFlow(("ModuleInit: returns success. g_pIntNet=%p\n", g_pIntNet));
    105                         return VINF_SUCCESS;
     101                        LogFlow(("ModuleInit: g_pIntNet=%p\n", g_pIntNet));
     102                        g_pIntNet = NULL;
     103                        LogFlow(("ModuleInit: g_pIntNet=%p should be NULL now...\n", g_pIntNet));
     104                        rc = INTNETR0Create(&g_pIntNet);
     105                        if (RT_SUCCESS(rc))
     106                        {
     107                            LogFlow(("ModuleInit: returns success. g_pIntNet=%p\n", g_pIntNet));
     108                            return VINF_SUCCESS;
     109                        }
     110
     111                        /* bail out */
     112                        g_pIntNet = NULL;
     113                        LogFlow(("ModuleTerm: returns %Rrc\n", rc));
     114#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
     115                        PGMR0DynMapTerm();
     116#endif
    106117                    }
    107 
    108                     /* bail out */
    109                     g_pIntNet = NULL;
    110                     LogFlow(("ModuleTerm: returns %Rrc\n", rc));
    111 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
    112                     PGMR0DynMapTerm();
    113 #endif
     118                    PGMDeregisterStringFormatTypes();
    114119                }
    115120                HWACCMR0Term();
     
    149154    PGMR0DynMapTerm();
    150155#endif
     156    PGMDeregisterStringFormatTypes();
    151157    HWACCMR0Term();
    152158
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