VirtualBox

Changeset 20471 in vbox


Ignore:
Timestamp:
Jun 10, 2009 5:11:49 PM (15 years ago)
Author:
vboxsync
Message:

xtracker 3945 - allow lowmem allocs to be non-contig

Location:
trunk/src/VBox/Runtime/r0drv/solaris/vbi
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/os/vbi.c

    r19998 r20471  
    2020 */
    2121/*
    22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     22 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
    2323 * Use is subject to license terms.
    2424 */
     
    111111 */
    112112static struct modlmisc vbi_modlmisc = {
    113         &mod_miscops, "VirtualBox Interfaces V4"
     113        &mod_miscops, "VirtualBox Interfaces V5"
    114114};
    115115
     
    199199};
    200200
    201 void *
    202 vbi_contig_alloc(uint64_t *phys, size_t size)
     201static void *
     202vbi_internal_alloc(uint64_t *phys, size_t size, int contig)
    203203{
    204204        ddi_dma_attr_t attr;
    205205        pfn_t pfn;
    206206        void *ptr;
     207        uint_t npages;
    207208
    208209        if ((size & PAGEOFFSET) != 0)
    209210                return (NULL);
     211        npages = size >> PAGESHIFT;
     212        if (npages == 0)
     213                return (NULL);
    210214
    211215        attr = base_attr;
    212216        attr.dma_attr_addr_hi = *phys;
     217        if (!contig)
     218                attr.dma_attr_sgllen = npages;
    213219        ptr = contig_alloc(size, &attr, PAGESIZE, 1);
    214220
    215221        if (ptr == NULL) {
    216                 VBI_VERBOSE("vbi_contig_alloc() failure");
     222                VBI_VERBOSE("vbi_internal_alloc() failure");
    217223                return (NULL);
    218224        }
     
    223229        *phys = (uint64_t)pfn << PAGESHIFT;
    224230        return (ptr);
     231}
     232
     233void *
     234vbi_contig_alloc(uint64_t *phys, size_t size)
     235{
     236        return (vbi_internal_alloc(phys, size, 1));
    225237}
    226238
     
    10601072}
    10611073
    1062 /*
    1063  * This is revision 4 of the interface. As more functions are added,
     1074void
     1075vbi_poke_cpu(int c)
     1076{
     1077        if (c < ncpus)
     1078                poke_cpu(c);
     1079}
     1080
     1081/*
     1082 * This is revision 5 of the interface. As more functions are added,
    10641083 * they should go after this point in the file and the revision level
    10651084 * increased. Also change vbi_modlmisc at the top of the file.
    10661085 */
    1067 uint_t vbi_revision_level = 4;
    1068 
    1069 void
    1070 vbi_poke_cpu(int c)
    1071 {
    1072         if (c < ncpus)
    1073                 poke_cpu(c);
    1074 }
     1086uint_t vbi_revision_level = 5;
     1087
     1088void *
     1089vbi_lowmem_alloc(uint64_t phys, size_t size)
     1090{
     1091        return (vbi_internal_alloc(&phys, size, 0));
     1092}
     1093
     1094void
     1095vbi_lowmem_free(void *va, size_t size)
     1096{
     1097        p_contig_free(va, size);
     1098}
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/sys/vbi.h

    r19496 r20471  
    310310/* end of interfaces defined for version 4 */
    311311
     312/* begin interfaces defined for version 5 */
     313/*
     314 * Allocate and free physically limited, page aligned memory. Note that
     315 * the allocated pages are not physically contiguous.
     316 *
     317 * return value is a) NULL if memory below "phys" not available or
     318 * b) virtual address of memory in kernel heap
     319 *
     320 * phys on input is set to the upper boundary of acceptable memory
     321 *
     322 * size is the amount to allocate and must be a multiple of PAGESIZE
     323 */
     324extern void *vbi_lowmem_alloc(uint64_t phys, size_t size);
     325
     326/*
     327 * va is from vbi_lowmem_alloc() return value
     328 * size must match from vbi_lowmem_alloc()
     329 */
     330extern void vbi_lowmem_free(void *va, size_t size);
     331/* end of interfaces defined for version 5 */
     332
    312333#ifdef  __cplusplus
    313334}
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/memobj-r0drv-solaris.c

    r14824 r20471  
    6969    switch (pMemSolaris->Core.enmType)
    7070    {
     71        case RTR0MEMOBJTYPE_LOW:
     72            vbi_lowmem_free(pMemSolaris->Core.pv, pMemSolaris->Core.cb);
     73            break;
     74
    7175        case RTR0MEMOBJTYPE_CONT:
    7276            vbi_contig_free(pMemSolaris->Core.pv, pMemSolaris->Core.cb);
     
    8690
    8791        /* unused */
    88         case RTR0MEMOBJTYPE_LOW:
    8992        case RTR0MEMOBJTYPE_PHYS:
    9093        case RTR0MEMOBJTYPE_RES_VIRT:
     
    121124int rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
    122125{
    123     /* Try page alloc first */
    124     int rc = rtR0MemObjNativeAllocPage(ppMem, cb, fExecutable);
    125     if (RT_SUCCESS(rc))
    126     {
    127         size_t iPage = cb >> PAGE_SHIFT;
    128         while (iPage-- > 0)
    129             if (rtR0MemObjNativeGetPagePhysAddr(*ppMem, iPage) > (_4G - PAGE_SIZE))
    130             {
    131                 /* Failed! Fall back to physical contiguous alloc */
    132                 RTR0MemObjFree(*ppMem, false);
    133                 rc = rtR0MemObjNativeAllocCont(ppMem, cb, fExecutable);
    134                 break;
    135             }
    136     }
    137     return rc;
     126    NOREF(fExecutable);
     127
     128    /* Create the object */
     129    PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_LOW, NULL, cb);
     130    if (!pMemSolaris)
     131        return VERR_NO_MEMORY;
     132
     133    /* Allocate physically low page-aligned memory. */
     134    caddr_t virtAddr;
     135    uint64_t phys = (unsigned)0xffffffff;
     136    virtAddr = vbi_lowmem_alloc(&phys, cb);
     137    if (virtAddr == NULL)
     138    {
     139        rtR0MemObjDelete(&pMemSolaris->Core);
     140        return VERR_NO_LOW_MEMORY;
     141    }
     142    Assert(phys < (uint64_t)1 << 32);
     143    pMemSolaris->Core.pv = virtAddr;
     144    pMemSolaris->handle = NULL;
     145    *ppMem = &pMemSolaris->Core;
     146    return VINF_SUCCESS;
    138147}
    139148
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