VirtualBox

Changeset 29027 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
May 4, 2010 2:33:41 PM (15 years ago)
Author:
vboxsync
Message:

RTR0MemObjEnterPhys/rtR0MemObjNativeEnterPhys: Validate the cache policy in the common code. Use uint32_t as parameter type. All native implementations must set the policy member.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/include/internal/memobj.h

    r28800 r29027  
    188188            bool        fAllocated;
    189189            /** See RTMEM_CACHE_POLICY_XXX constants */
    190             unsigned    CachePolicy;
     190            uint32_t    uCachePolicy;
    191191        } Phys;
    192192
     
    385385 * @param   Phys            The physical address to start at, page aligned.
    386386 * @param   cb              The size of the object in bytes, page aligned.
    387  * @param   CachePolicy     One of the RTMEM_CACHE_XXX modes.
    388  */
    389 int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, unsigned CachePolicy);
     387 * @param   uCachePolicy    One of the RTMEM_CACHE_XXX modes.
     388 */
     389int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy);
    390390
    391391/**
  • trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp

    r28800 r29027  
    604604
    605605
    606 int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, unsigned CachePolicy)
    607 {
    608     AssertReturn(CachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_IMPLEMENTED);
     606int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy)
     607{
     608    AssertReturn(uCachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_IMPLEMENTED);
    609609
    610610    /*
     
    635635                pMemDarwin->Core.u.Phys.PhysBase = Phys;
    636636                pMemDarwin->Core.u.Phys.fAllocated = false;
     637                pMemDarwin->Core.u.Phys.uCachePolicy = uCachePolicy;
    637638                pMemDarwin->pMemDesc = pMemDesc;
    638639                *ppMem = &pMemDarwin->Core;
  • trunk/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c

    r28777 r29027  
    496496
    497497
    498 int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, unsigned CachePolicy)
    499 {
    500     AssertReturn(CachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_IMPLEMENTED);
     498int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy)
     499{
     500    AssertReturn(uCachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_IMPLEMENTED);
    501501
    502502    /* create the object. */
     
    508508    pMemFreeBSD->Core.u.Phys.fAllocated = false;
    509509    pMemFreeBSD->Core.u.Phys.PhysBase = Phys;
     510    pMemFreeBSD->Core.u.Phys.uCachePolicy = uCachePolicy;
    510511    *ppMem = &pMemFreeBSD->Core;
    511512    return VINF_SUCCESS;
  • trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c

    r28800 r29027  
    743743
    744744
    745 int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, unsigned CachePolicy)
     745int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy)
    746746{
    747747    /*
     
    759759    pMemLnx->Core.u.Phys.PhysBase = PhysAddr;
    760760    pMemLnx->Core.u.Phys.fAllocated = false;
    761     pMemLnx->Core.u.Phys.CachePolicy = CachePolicy;
     761    pMemLnx->Core.u.Phys.uCachePolicy = uCachePolicy;
    762762    Assert(!pMemLnx->cPages);
    763763    *ppMem = &pMemLnx->Core;
     
    11661166             */
    11671167            Assert(pMemLnxToMap->Core.enmType == RTR0MEMOBJTYPE_PHYS && !pMemLnxToMap->Core.u.Phys.fAllocated);
    1168             pMemLnx->Core.pv = (pMemLnxToMap->Core.u.Phys.CachePolicy == RTMEM_CACHE_POLICY_MMIO)
    1169                                    ? ioremap_nocache(pMemLnxToMap->Core.u.Phys.PhysBase, pMemLnxToMap->Core.cb)
    1170                                    : ioremap(pMemLnxToMap->Core.u.Phys.PhysBase, pMemLnxToMap->Core.cb);
     1168            pMemLnx->Core.pv = pMemLnxToMap->Core.u.Phys.uCachePolicy == RTMEM_CACHE_POLICY_MMIO
     1169                             ? ioremap_nocache(pMemLnxToMap->Core.u.Phys.PhysBase, pMemLnxToMap->Core.cb)
     1170                             : ioremap(pMemLnxToMap->Core.u.Phys.PhysBase, pMemLnxToMap->Core.cb);
    11711171            if (pMemLnx->Core.pv)
    11721172            {
  • trunk/src/VBox/Runtime/r0drv/memobj-r0drv.cpp

    r28800 r29027  
    661661 *                          nearest page boundrary.
    662662 * @param   cb              The size of the object in bytes. This is rounded up to nearest page boundrary.
    663  * @param   CachePolicy     One of the RTMEM_CACHE_XXX modes.
    664  */
    665 RTR0DECL(int) RTR0MemObjEnterPhys(PRTR0MEMOBJ pMemObj, RTHCPHYS Phys, size_t cb, unsigned CachePolicy)
     663 * @param   uCachePolicy    One of the RTMEM_CACHE_XXX modes.
     664 */
     665RTR0DECL(int) RTR0MemObjEnterPhys(PRTR0MEMOBJ pMemObj, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy)
    666666{
    667667    /* sanity checks. */
     
    673673    AssertReturn(cb <= cbAligned, VERR_INVALID_PARAMETER);
    674674    AssertReturn(Phys != NIL_RTHCPHYS, VERR_INVALID_PARAMETER);
     675    AssertReturn(   uCachePolicy == RTMEM_CACHE_POLICY_DONT_CARE
     676                 || uCachePolicy == RTMEM_CACHE_POLICY_MMIO,
     677                 VERR_INVALID_PARAMETER);
    675678    RT_ASSERT_PREEMPTIBLE();
    676679
    677680    /* do the allocation. */
    678     return rtR0MemObjNativeEnterPhys(pMemObj, PhysAligned, cbAligned, CachePolicy);
     681    return rtR0MemObjNativeEnterPhys(pMemObj, PhysAligned, cbAligned, uCachePolicy);
    679682}
    680683RT_EXPORT_SYMBOL(RTR0MemObjEnterPhys);
  • trunk/src/VBox/Runtime/r0drv/nt/memobj-r0drv-nt.cpp

    r28800 r29027  
    484484
    485485
    486 int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, unsigned CachePolicy)
    487 {
    488     AssertReturn(CachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_IMPLEMENTED);
     486int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy)
     487{
     488    AssertReturn(uCachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_IMPLEMENTED);
    489489
    490490    /*
     
    503503        pMemNt->Core.u.Phys.PhysBase = Phys;
    504504        pMemNt->Core.u.Phys.fAllocated = false;
     505        pMemNt->Core.u.Phys.uCachePolicy = uCachePolicy;
    505506        *ppMem = &pMemNt->Core;
    506507        return VINF_SUCCESS;
  • trunk/src/VBox/Runtime/r0drv/os2/memobj-r0drv-os2.cpp

    r28777 r29027  
    231231
    232232
    233 int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, unsigned CachePolicy)
    234 {
    235     AssertReturn(CachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_IMPLEMENTED);
     233int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy)
     234{
     235    AssertReturn(uCachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_IMPLEMENTED);
    236236
    237237    /* create the object. */
     
    243243    pMemOs2->Core.u.Phys.fAllocated = false;
    244244    pMemOs2->Core.u.Phys.PhysBase = Phys;
     245    pMemOs2->Core.u.Phys.uCachePolicy = uCachePolicy;
    245246    *ppMem = &pMemOs2->Core;
    246247    return VINF_SUCCESS;
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/memobj-r0drv-solaris.c

    r28800 r29027  
    267267
    268268
    269 int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, unsigned CachePolicy)
    270 {
    271     AssertReturn(CachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_IMPLEMENTED);
     269int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy)
     270{
     271    AssertReturn(uCachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_IMPLEMENTED);
    272272
    273273    /* Create the object. */
     
    279279    pMemSolaris->Core.u.Phys.fAllocated = false;
    280280    pMemSolaris->Core.u.Phys.PhysBase = Phys;
     281    pMemSolaris->Core.u.Phys.uCachePolicy = uCachePolicy;
    281282    *ppMem = &pMemSolaris->Core;
    282283    return VINF_SUCCESS;
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