VirtualBox

儲存庫 vbox 的更動 4474


忽略:
時間撮記:
2007-8-31 下午07:23:49 (17 年 以前)
作者:
vboxsync
訊息:

Solaris.

位置:
trunk
檔案:
新增 1 筆資料
修改 13 筆資料

圖例:

未更動
新增
刪除
  • trunk/Config.kmk

    r4472 r4474  
    516516  VBOX_GCC_TOOL := GXX4MACHO
    517517 else ifeq ($(BUILD_TARGET),solaris)
    518   VBOX_GCC_TOOL := GXX3
     518  VBOX_GCC_TOOL := GXX3PLAIN
    519519 else
    520520  VBOX_GCC_TOOL := GXX3
     
    12461246TEMPLATE_VBOXGC_CFLAGS              = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC32_Wno-variadic-macros) -pipe -Wmissing-prototypes -Wstrict-prototypes $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -fno-strict-aliasing $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_fvisibility-hidden)
    12471247ifeq ($(BUILD_TARGET),solaris)
    1248  TEMPLATE_VBOXGC_LDFLAGS            = -B symbolic
     1248 TEMPLATE_VBOXGC_LDFLAGS            = -r
    12491249else
    12501250 TEMPLATE_VBOXGC_LDFLAGS             = -nostdlib -Bsymbolic
     
    12531253 TEMPLATE_VBOXGC_LDFLAGS.release     = $(if $(VBOX_DO_STRIP_MODULES),-S,)
    12541254endif
     1255ifneq ($(BUILD_TARGET),solaris)
    12551256TEMPLATE_VBOXGC_LIBS                = \
    12561257        $(VBOX_GCC32_LIBGCC) # instricts
     1258endif
    12571259endif
    12581260
     
    13471349TEMPLATE_VBOXR0_CXXFLAGS.amd64      = -m64 -mno-red-zone -mcmodel=kernel -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-asynchronous-unwind-tables
    13481350ifeq ($(BUILD_TARGET),solaris)
    1349  TEMPLATE_VBOXR0_LDFLAGS             = -B symbolic
     1351 TEMPLATE_VBOXR0_LDFLAGS             = -r
    13501352else
    13511353 TEMPLATE_VBOXR0_LDFLAGS             = -nostdlib -Bsymbolic
     
    13551357endif
    13561358
    1357 TEMPLATE_VBOXR0_LIBS                = \
     1359ifneq ($(BUILD_TARGET),solaris)
     1360 TEMPLATE_VBOXR0_LIBS                = \
    13581361        $(VBOX_GCC_LIBGCC) # instricts
     1362endif
    13591363endif
    13601364
  • trunk/src/VBox/HostDrivers/Support/Makefile.kmk

    r4454 r4474  
    2323#
    2424LIBRARIES += SUPR3
    25 ifneq ($(filter-out darwin,$(BUILD_TARGET)),)
     25ifneq ($(filter-out darwin solaris,$(BUILD_TARGET)),)
    2626LIBRARIES += SUPR0
    2727endif
  • trunk/src/VBox/HostDrivers/Support/SUPDRV.h

    r4161 r4474  
    9898
    9999#elif defined(RT_OS_SOLARIS)
     100#   include <sys/cmn_err.h>
    100101#   include <iprt/string.h>
    101102
     
    187188 */
    188189#elif defined(RT_OS_SOLARIS)
    189 # define OSDBGPRINT(a) printf a
     190# define OSDBGPRINT(a) uprintf a
    190191
    191192
  • trunk/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c

    r4287 r4474  
    513513    PSUPDRVIOCTLDATA    pArgData = (PSUPDRVIOCTLDATA)pArgs;
    514514
    515     cmn_err(CE_CONT, "VBoxDrvSolarisIOCtlSlow\n");
    516515   /*
    517516     * Allocate and copy user space input data buffer to kernel space.
     
    528527        }
    529528       
    530         rc = ddi_copyin(pArgData->pvIn, pvBuf, cbBuf, Mode);
     529        rc = ddi_copyin(pArgData->pvIn, pvBuf, pArgData->cbIn, Mode);
    531530       
    532531        if (rc != 0)
    533532        {
    534             OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: ddi_copyin(%p,%d) failed.\n", pArgData->pvIn, cbBuf));
     533            OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: ddi_copyin(%p,%d) failed.\n", pArgData->pvIn, pArgData->cbIn));
    535534
    536535            RTMemTmpFree(pvBuf);
     
    555554            rc = ddi_copyout(pvBuf, pArgData->pvOut, cbOut, Mode);
    556555            if (rc != 0)
     556            {
    557557                OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: ddi_copyout(,%p,%d) failed.\n", pArgData->pvOut, cbBuf));
     558
     559                /** @todo r=bird: why this extra return? setting rc = EFAULT; should do the trick, shouldn't it? */
     560                RTMemTmpFree(pvBuf);
     561                return EFAULT;
     562            }
    558563        }
    559564        else
     
    564569    }
    565570
     571    if (pvBuf)
     572        RTMemTmpFree(pvBuf);
     573   
    566574    OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: returns %d cbOut=%d\n", rc, cbOut));
    567575    return rc;
  • trunk/src/VBox/Runtime/Makefile.kmk

    r4287 r4474  
    681681        os2/sys0.asm
    682682
    683 RuntimeR0_SOURCES.darwin.x86 = \
     683ifeq ($(filter-out darwin solaris,$(BUILD_TARGET)),)
     684RuntimeR0_SOURCES += \
    684685        math/gcc/adddi3.c \
    685686        math/gcc/anddi3.c \
     
    701702        math/gcc/umoddi3.c \
    702703        math/gcc/xordi3.c
    703 
    704 
     704endif
     705       
     706       
    705707string/memchr.cpp_CXXFLAGS.win = -Oi-
    706708string/memcmp.cpp_CXXFLAGS.win = -Oi-
     
    891893        r0drv/solaris/thread2-r0drv-solaris.c \
    892894        r0drv/solaris/time-r0drv-solaris.c \
    893         generic/timer-generic.cpp
     895        r0drv/solaris/timer-r0drv-solaris.c
    894896
    895897## PORTME: Porters create and add their selection of platform specific Ring-0 Driver files here.
     
    992994endif
    993995
    994 RuntimeGC_SOURCES.darwin = \
     996ifeq ($(filter-out darwin solaris,$(BUILD_TARGET)),)
     997RuntimeGC_SOURCES += \
    995998        math/gcc/adddi3.c \
    996999        math/gcc/anddi3.c \
     
    10121015        math/gcc/umoddi3.c \
    10131016        math/gcc/xordi3.c
     1017endif
    10141018
    10151019
  • trunk/src/VBox/Runtime/generic/env-generic.cpp

    r4287 r4474  
    3838 * http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/getenv.c line 50.
    3939 */
    40 extern const char               **environ;
     40extern char **environ;
    4141#endif
    4242
  • trunk/src/VBox/Runtime/math/gcc/quad.h

    r4173 r4474  
    7676   typedef unsigned int u_int;
    7777# endif
     78# if !defined(RT_OS_SOLARIS)
    7879   typedef int64_t quad_t;
     80# else
     81#  define quad_t int64_t
     82# endif
    7983   typedef uint64_t u_quad_t;
    8084   typedef quad_t *qaddr_t;
  • trunk/src/VBox/Runtime/r0drv/solaris/memobj-r0drv-solaris.c

    r4287 r4474  
    4848} RTR0MEMOBJSOLARIS, *PRTR0MEMOBJSOLARIS;
    4949
    50 
    51 /*******************************************************************************
    52 *   Internal Functions                                                         *
    53 *******************************************************************************/
     50/**
     51 * Used for supplying the solaris kernel info. about memory limits
     52 * during contiguous allocations (i_ddi_mem_alloc)
     53 */
     54struct ddi_dma_attr g_SolarisX86PhysMemLimits =
     55{
     56    DMA_ATTR_V0,            /* Version Number */
     57    (uint64_t)0,            /* lower limit */
     58    (uint64_t)0xffffffff,   /* high limit (32-bit PA, 4G) */
     59    (uint64_t)0xffffffff,   /* counter limit */
     60    (uint64_t)PAGE_SIZE,    /* alignment */
     61    (uint64_t)PAGE_SIZE,    /* burst size */
     62    (uint64_t)PAGE_SIZE,    /* effective DMA size */
     63    (uint64_t)0xffffffff,   /* max DMA xfer size */
     64    (uint64_t)0xffffffff,   /* segment boundary */
     65    1,                      /* scatter-gather list length (1 for contiguous) */
     66    1,                      /* device granularity */
     67    0                       /* bus-specific flags */
     68};
     69
     70
     71
     72static uint64_t rtR0MemObjSolarisVirtToPhys(struct hat* hatSpace, caddr_t virtAddr)
     73{
     74    /* We could use paddr_t (more solaris-like) rather than uint64_t but paddr_t isn't defined for 64-bit */
     75    pfn_t pfn = hat_getpfnum(hatSpace, virtAddr);
     76    if (pfn == PFN_INVALID)
     77    {
     78        AssertMsgFailed(("rtR0MemObjSolarisVirtToPhys: hat_getpfnum for %p failed.\n", virtAddr));
     79        return PFN_INVALID;
     80    }
     81
     82    /* Both works, but second will work for non-page aligned virtAddr */
     83#if 0
     84    uint64_t physAddr = PAGE_SIZE * pfn;
     85#else
     86    uint64_t physAddr = ((uint64_t)pfn << MMU_PAGESHIFT) | ((uint64_t)virtAddr & MMU_PAGEOFFSET);
     87#endif
     88    return physAddr;
     89}
    5490
    5591
     
    6197    {
    6298        case RTR0MEMOBJTYPE_CONT:
    63             ddi_mem_free(pMemSolaris->Core.pv);
     99            i_ddi_mem_free(pMemSolaris->Core.pv, NULL);
    64100            break;
    65101
    66102        case RTR0MEMOBJTYPE_PAGE:
    67 #if 0
    68             ddi_umem_free(pMemSolaris->Cookie);
    69 #endif
    70             ddi_mem_free(pMemSolaris->Core.pv);
     103            kmem_free(pMemSolaris->Core.pv, pMemSolaris->Core.cb);
    71104            break;
    72105
    73106        case RTR0MEMOBJTYPE_LOCK:
    74107        {
     108            cmn_err(CE_NOTE, "rtR0MemObjNativeFree: LOCK\n");
    75109            struct as* addrSpace;
    76110            if (pMemSolaris->Core.u.Lock.R0Process == NIL_RTR0PROCESS)
     
    85119        case RTR0MEMOBJTYPE_MAPPING:
    86120        {
     121            struct hat* hatSpace;
     122            struct as* addrSpace;
     123            cmn_err(CE_NOTE, "rtR0MemObjNativeFree: MAPPING\n");
    87124            if (pMemSolaris->Core.u.Mapping.R0Process == NIL_RTR0PROCESS)
    88125            {
    89126                /* Kernel process*/
    90                 hat_unload(kas.a_hat, (caddr_t)pMemSolaris->Core.pv, pMemSolaris->Core.cb, HAT_UNLOAD_UNLOCK);
    91                 vmem_xfree(heap32_arena, (caddr_t)pMemSolaris->Core.pv, pMemSolaris->Core.cb);
     127                cmn_err(CE_NOTE, "rtR0MemObjNativeFree: MAPPING: kernel\n");
     128                hatSpace = kas.a_hat;
     129                addrSpace = &kas;
    92130            }
    93131            else
    94132            {
    95133                /* User process */
    96                 proc_t *p = (proc_t *)pMemSolaris->Core.u.Mapping.R0Process;
    97                 struct as *useras = p->p_as;
    98                 hat_unload(useras->a_hat, (caddr_t)pMemSolaris->Core.pv, pMemSolaris->Core.cb, HAT_UNLOAD_UNLOCK);
     134                cmn_err(CE_NOTE, "rtR0MemObjNativeFree: MAPPING: userProcess\n");
     135                proc_t *userProc = (proc_t *)pMemSolaris->Core.u.Mapping.R0Process;
     136                hatSpace = userProc->p_as->a_hat;
     137                addrSpace = userProc->p_as;
    99138            }
    100            
     139
     140            hat_unload(hatSpace, pMemSolaris->Core.pv, pMemSolaris->Core.cb, HAT_UNLOAD_UNLOCK);
     141            as_unmap(addrSpace, pMemSolaris->Core.pv, pMemSolaris->Core.cb);
     142            cmn_err(CE_NOTE, "rtR0MemObjNativeFree: MAPPING: removed fine\n");
    101143            break;
    102144        }
    103            
     145       
    104146        /* unused */
    105147        case RTR0MEMOBJTYPE_LOW:
     
    121163    if (!pMemSolaris)
    122164        return VERR_NO_MEMORY;
    123 #if 1
    124     /* Allocate physically contiguous page-aligned memory. */
    125     caddr_t virtAddr;
    126     int rc = i_ddi_mem_alloc(NULL, &g_SolarisX86PhysMemLimits, cb, 1, 0, NULL, &virtAddr, NULL, NULL);
    127     if (rc != DDI_SUCCESS)
     165
     166    /** @todo r=bird: The man page says: "The allocated memory is at least double-word aligned, so it can hold any C data structure. No greater alignment can be assumed." */
     167    void* virtAddr = kmem_alloc(cb, KM_SLEEP);
     168    if (!virtAddr)
    128169    {
    129170        rtR0MemObjDelete(&pMemSolaris->Core);
     
    132173   
    133174    pMemSolaris->Core.pv = virtAddr;
    134     pMemSolaris->Core.u.Cont.Phys = PAGE_SIZE * hat_getpfnum(kas.a_hat, virtAddr);
    135     *ppMem = &pMemSolaris->Core;   
    136     cmn_err(CE_NOTE, "xAllocPage success physAddr=%p virt=%p\n", PAGE_SIZE * hat_getpfnum(kas.a_hat, virtAddr), virtAddr);
    137 #endif
    138 #if 0
    139     /* Allocate page-aligned kernel memory */
    140     void *pv = ddi_umem_alloc(cb, DDI_UMEM_SLEEP, &pMemSolaris->Cookie);
    141     if (pv == NULL)
    142     {
    143         rtR0MemObjDelete(&pMemSolaris->Core);
    144         return VERR_NO_MEMORY;
    145     }
    146    
    147     pMemSolaris->Core.pv = pv;
    148     *ppMem = &pMemSolaris->Core;
    149     cmn_err(CE_NOTE, "ddi_umem_alloc, success\n");
    150 #endif       
     175    pMemSolaris->ppShadowPages = NULL;
     176    *ppMem = &pMemSolaris->Core;
    151177    return VINF_SUCCESS;
    152178}
     
    170196            }
    171197    }
    172    
    173198    return rc;
    174199}
     
    192217        return VERR_NO_MEMORY;
    193218    }
    194    
     219
    195220    pMemSolaris->Core.pv = virtAddr;
    196     pMemSolaris->Core.u.Cont.Phys = PAGE_SIZE * hat_getpfnum(kas.a_hat, virtAddr);
     221    pMemSolaris->Core.u.Cont.Phys = rtR0MemObjSolarisVirtToPhys(kas.a_hat, virtAddr);
     222    pMemSolaris->ppShadowPages = NULL;   
    197223    *ppMem = &pMemSolaris->Core;
    198224    return VINF_SUCCESS;
     
    202228int rtR0MemObjNativeAllocPhysNC(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
    203229{
    204     /** @todo rtR0MemObjNativeAllocPhys / solaris */
    205     return rtR0MemObjNativeAllocPhys(ppMem, cb, PhysHighest);
     230    /** @todo rtR0MemObjNativeAllocPhysNC / solaris */
     231    return VERR_NOT_SUPPORTED; /* see the RTR0MemObjAllocPhysNC specs */
    206232}
    207233
     
    222248        return VERR_NO_MEMORY;
    223249   
    224     /* @todo validate Phys as a proper physical address */
    225 
    226250    /* There is no allocation here, it needs to be mapped somewhere first */
    227251    pMemSolaris->Core.u.Phys.fAllocated = false;
     
    235259{
    236260    /* Create the object */
    237     PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_LOCK, (void*)R3Ptr, cb);
    238     if (!pMemSolaris)
    239         return VERR_NO_MEMORY;
    240 
    241     proc_t *userProcess = curproc;
     261    PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_LOCK, (void *)R3Ptr, cb);
     262    if (!pMemSolaris)
     263        return VERR_NO_MEMORY;
     264
     265    proc_t *userproc = curproc;
    242266    if (R0Process != NIL_RTR0PROCESS)
    243         userProcess = (proc_t *)R0Process;
    244    
    245     struct as* userAddrSpace = userProcess->p_as;
    246     caddr_t userAddr = (caddr_t)((uintptr_t)R3Ptr & (uintptr_t)PAGEMASK);
     267        userproc = (proc_t *)R0Process;
     268   
     269    struct as *useras = userproc->p_as;
    247270    page_t **ppl;
    248271
    249     int rc = as_pagelock(userAddrSpace, &ppl, userAddr, cb, S_WRITE);
     272    int rc = as_pagelock(useras, &ppl, (caddr_t)R3Ptr, cb, S_WRITE);
    250273    if (rc != 0)
    251         return VERR_NO_MEMORY;
    252 
    253     pMemSolaris->Core.u.Lock.R0Process = (RTR0PROCESS)userProcess;
     274    {
     275        cmn_err(CE_NOTE,"rtR0MemObjNativeLockUser: as_pagelock failed rc=%d\n", rc);
     276        return VERR_NO_MEMORY;
     277    }
     278
     279    if (!ppl)
     280    {
     281        as_pageunlock(useras, ppl, (caddr_t)R3Ptr, cb, S_WRITE);
     282        cmn_err(CE_NOTE, "rtR0MemObjNativeLockUser: as_pagelock failed to get shadow pages\n");
     283        return VERR_NO_MEMORY;
     284    }
     285   
     286    pMemSolaris->Core.u.Lock.R0Process = (RTR0PROCESS)userproc;
    254287    pMemSolaris->ppShadowPages = ppl;
    255288    *ppMem = &pMemSolaris->Core;
    256    
    257     return VINF_SUCCESS;
    258    
    259 #if 0   
    260     /* Lock down the physical pages of current process' virtual address space */
    261     int rc = ddi_umem_lock(pv, cb, DDI_UMEMLOCK_WRITE, &pMemSolaris->Cookie);
    262     if (rc != 0)
    263     {
    264         rtR0MemObjDelete(&pMemSolaris->Core);
    265         return VERR_NO_MEMORY;  /** @todo fix mach -> vbox error conversion for Solaris. */
    266     }
    267 
    268     pMemSolaris->Core.u.Lock.R0Process = R0Process;
    269     *ppMem = &pMemSolaris->Core;
    270     return VINF_SUCCESS;
    271 #endif   
     289    return VINF_SUCCESS;
    272290}
    273291
     
    280298        return VERR_NO_MEMORY;
    281299
    282     caddr_t userAddr = (caddr_t)((uintptr_t)pv & (uintptr_t)PAGEMASK);
     300    caddr_t virtAddr = (caddr_t)((uintptr_t)pv & (uintptr_t)PAGEMASK);
    283301    page_t **ppl;
    284302   
    285     int rc = as_pagelock(&kas, &ppl, userAddr, cb, S_WRITE);
     303    int rc = as_pagelock(&kas, &ppl, virtAddr, cb, S_WRITE);
    286304    if (rc != 0)
    287305        return VERR_NO_MEMORY;
     306
     307    if (!ppl)
     308    {
     309        as_pageunlock(&kas, ppl, virtAddr, cb, S_WRITE);
     310        cmn_err(CE_NOTE, "rtR0MemObjNativeLockUser: failed to get shadow pages\n");
     311        return VERR_NO_MEMORY;
     312    }
    288313
    289314    pMemSolaris->Core.u.Lock.R0Process = NIL_RTR0PROCESS;   /* means kernel, see rtR0MemObjNativeFree() */
    290315    pMemSolaris->ppShadowPages = ppl;
    291316    *ppMem = &pMemSolaris->Core;
    292    
    293317    return VINF_SUCCESS;
    294318}
     
    309333{
    310334    PRTR0MEMOBJSOLARIS pMemToMapSolaris = (PRTR0MEMOBJSOLARIS)pMemToMap;   
    311     size_t size = P2ROUNDUP(pMemToMapSolaris->Core.cb, PAGE_SIZE);
    312     void* pv = pMemToMapSolaris->Core.pv;
    313    
    314     void* kernVirtAddr = vmem_xalloc(heap32_arena, size, PAGE_SIZE, 0, PAGE_SIZE, NULL, 0, VM_SLEEP);
    315     if (kernVirtAddr == NULL)
    316         return VERR_NO_MEMORY;
    317    
    318     hat_devload(kas.a_hat, (caddr_t)kernVirtAddr, size, hat_getpfnum(kas.a_hat, pv), PROT_READ | PROT_WRITE | PROT_EXEC,
    319                 HAT_STRICTORDER | HAT_LOAD_NOCONSIST | HAT_LOAD_LOCK);
    320    
     335    size_t size = P2ROUNDUP(pMemToMapSolaris->Core.cb, PAGE_SIZE); /* r=bird: not necessary, see the specs / caller implementation. */
     336    void *pv = pMemToMapSolaris->Core.pv;
     337    pgcnt_t cPages = btop(size);
     338    pgcnt_t iPage;
     339    caddr_t addr;
     340    int rc;
     341
    321342    /* Create the mapping object */
    322     PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING,
    323                                                                     kernVirtAddr, pMemToMapSolaris->Core.cb);
    324     if (pMemSolaris == NULL)
    325     {
    326         hat_unload(kas.a_hat, (caddr_t)kernVirtAddr, size, HAT_UNLOAD_UNLOCK);
    327         vmem_xfree(heap32_arena, kernVirtAddr, size);
    328         return VERR_NO_MEMORY;
    329     }
    330 
    331     pMemSolaris->Core.u.Mapping.R0Process = NIL_RTR0PROCESS;    /* NIL_RTR0PROCESS means kernel process */
    332     *ppMem = &pMemSolaris->Core;
     343    PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING, pv, size);
     344    if (!pMemSolaris)
     345        return VERR_NO_MEMORY;
     346
     347    as_rangelock(&kas);
     348    if (pvFixed != (void *)-1)
     349    {
     350        /* Use user specified address */
     351        addr = (caddr_t)pvFixed;
     352       
     353        /* Blow away any previous mapping */
     354        as_unmap(&kas, addr, size);
     355    }
     356    else
     357    {
     358        /* Let the system choose an address */
     359        map_addr(&addr, size, 0, 1, MAP_SHARED | MAP_ANONYMOUS);
     360        if (addr == NULL)
     361        {
     362            as_rangeunlock(&kas);
     363            cmn_err(CE_NOTE, "rtR0MemObjNativeMapKernel: map_addr failed\n");
     364            return VERR_NO_MEMORY;
     365        }
     366        /** @todo r=bird: check address against uAlignment, just fail if it's not matching. */
     367    }
     368   
     369    /* Our protection masks are identical to <sys/mman.h> but we
     370     * need to add PROT_USER for the pages to be accessible by user
     371     */
     372    struct segvn_crargs crArgs = SEGVN_ZFOD_ARGS(fProt | PROT_USER, PROT_ALL);
     373    rc = as_map(&kas, addr, size, segvn_create, &crArgs);
     374    as_rangeunlock(&kas);
     375    if (rc != 0)
     376    {
     377        cmn_err(CE_NOTE, "rtR0MemObjNativeMapKernel: as_map failure.\n");
     378        return VERR_NO_MEMORY;
     379    }
     380   
     381    /* Map each page into kernel space */
     382    caddr_t kernAddr = pv;
     383    caddr_t pageAddr = addr;
     384    for (iPage = 0; iPage < cPages; iPage++)
     385    {
     386        page_t *pp = page_numtopp_nolock(hat_getpfnum(kas.a_hat, kernAddr));
     387        hat_memload(kas.a_hat, pageAddr, pp, (fProt | PROT_USER), HAT_LOAD_LOCK);
     388        pageAddr += ptob(1);
     389        kernAddr += ptob(1);
     390    }
     391
     392    pMemSolaris->Core.u.Mapping.R0Process = NIL_RTR0PROCESS; /* means kernel */
     393    pMemSolaris->Core.pv = addr;
     394    *ppMem = &pMemSolaris->Core;
     395    cmn_err(CE_NOTE, "done rtR0MemObjNativeMapKernel: Core.pv=%p\n", addr);
    333396    return VINF_SUCCESS;
    334397}
     
    338401{
    339402    PRTR0MEMOBJSOLARIS pMemToMapSolaris = (PRTR0MEMOBJSOLARIS)pMemToMap;   
    340     size_t size = P2ROUNDUP(pMemToMapSolaris->Core.cb, PAGE_SIZE);
     403    size_t size = P2ROUNDUP(pMemToMapSolaris->Core.cb, PAGE_SIZE); /** @todo r=bird: this isn't necessary, see the specs. */
    341404    proc_t *userproc = (proc_t *)R0Process;
    342405    struct as *useras = userproc->p_as;
    343406    void *pv = pMemToMapSolaris->Core.pv;
    344     pfn_t pfnum = hat_getpfnum(kas.a_hat, pv);
     407    pgcnt_t cPages = btop(size);
     408    pgcnt_t iPage;
     409    caddr_t addr;
    345410    int rc;
    346    
    347     void* kernVirtAddr = vmem_xalloc(heap32_arena, size, PAGE_SIZE, 0, PAGE_SIZE, NULL, 0, VM_SLEEP);
    348     if (kernVirtAddr == NULL)
    349         return VERR_NO_MEMORY;
    350    
    351     cmn_err(CE_NOTE, "vmem_xalloc successful.\n");
    352    
    353     /* Wrong ones to use: as_map() */
    354     hat_devload(kas.a_hat, (caddr_t)kernVirtAddr, size, pfnum, PROT_READ | PROT_WRITE | PROT_EXEC,
    355                     HAT_STRICTORDER | HAT_LOAD_NOCONSIST | HAT_LOAD_LOCK);
    356    
    357     cmn_err(CE_NOTE, "hat_devload successful.\n");
    358    
     411
    359412    /* Create the mapping object */
    360     PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING,
    361                                                                     pv, pMemToMapSolaris->Core.cb);
    362     if (pMemSolaris == NULL)
    363     {
    364         /* @todo cleanup */
    365         return VERR_NO_MEMORY;
    366     }
    367 
    368     pMemSolaris->Core.u.Mapping.R0Process = R0Process;
    369     *ppMem = &pMemSolaris->Core;
     413    PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING, pv, size);
     414    if (!pMemSolaris)
     415        return VERR_NO_MEMORY;
     416
     417    as_rangelock(useras);
     418    if (R3PtrFixed != (RTR3PTR)-1)
     419    {
     420        /* Use user specified address */
     421        addr = (caddr_t)R3PtrFixed;
     422       
     423        /* Verify user address (a bit paranoid) */
     424        rc = valid_usr_range(addr, size, fProt, useras, (caddr_t)USERLIMIT32);
     425        if (rc != RANGE_OKAY)
     426        {
     427            as_rangeunlock(useras);
     428            cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: valid_usr_range failed, returned %d\n", rc);
     429            return VERR_INVALID_POINTER;
     430        }
     431       
     432        /* Blow away any previous mapping */
     433        as_unmap(useras, addr, size);
     434    }
     435    else
     436    {
     437        /* Let the system choose an address */
     438        map_addr(&addr, size, 0, 1, MAP_SHARED | MAP_ANONYMOUS);
     439        if (addr == NULL)
     440        {
     441            as_rangeunlock(useras);
     442            cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: map_addr failed\n");
     443            return VERR_NO_MEMORY;
     444        }
     445
     446        /** @todo r=bird: check address against uAlignment, just fail if it's not matching. */
     447    }
     448   
     449    /* Our protection masks are identical to <sys/mman.h> but we
     450     * need to add PROT_USER for the pages to be accessible by user
     451     */
     452    struct segvn_crargs crArgs = SEGVN_ZFOD_ARGS(fProt | PROT_USER, PROT_ALL);
     453    rc = as_map(useras, addr, size, segvn_create, &crArgs);
     454    as_rangeunlock(useras);
     455    if (rc != 0)
     456    {
     457        cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: as_map failure.\n");
     458        return VERR_NO_MEMORY;
     459    }
     460
     461#if 0
     462    /* Lock down the pages and get the shadow page list
     463     * In this case we must as_pageunlock if(ppShadowPages) exists while freeing CONT, PAGE
     464     */
     465    rc = as_pagelock(&kas, &pMemToMapSolaris->ppShadowPages, pv, size, S_WRITE);
     466    if (rc != 0 || pMemToMapSolaris->ppShadowPages == NULL)
     467    {
     468        cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: as_pagelock failed\n");
     469        as_unmap(useras, addr, size);
     470        return VERR_NO_MEMORY;
     471    }
     472
     473    /* Map each page into user space */
     474    caddr_t pageAddr = addr;
     475    for (iPage = 0; iPage < cPages; iPage++)
     476    {
     477        hat_memload(useras->a_hat, pageAddr, pMemToMapSolaris->ppShadowPages[iPage], fProt | PROT_USER,
     478                HAT_LOAD_NOCONSIST | HAT_STRICTORDER | HAT_LOAD_LOCK);
     479        pageAddr += ptob(1);
     480    }
     481#else
     482    /* Map each page into user space */
     483    caddr_t kernAddr = pv;
     484    caddr_t pageAddr = addr;
     485    for (iPage = 0; iPage < cPages; iPage++)
     486    {
     487        page_t *pp = page_numtopp_nolock(hat_getpfnum(kas.a_hat, kernAddr));
     488        hat_memload(useras->a_hat, pageAddr, pp, (fProt | PROT_USER), HAT_LOAD_LOCK);
     489        pageAddr += ptob(1);
     490        kernAddr += ptob(1);
     491    }
     492#endif
     493
     494    pMemSolaris->Core.u.Mapping.R0Process = (RTR0PROCESS)userproc;
     495    pMemSolaris->Core.pv = addr;
     496    *ppMem = &pMemSolaris->Core;
     497    cmn_err(CE_NOTE, "done MemObjNativeMapUser: Core.pv=%p\n", addr);
    370498    return VINF_SUCCESS;
    371499}
     
    378506    switch (pMemSolaris->Core.enmType)
    379507    {
    380         case RTR0MEMOBJTYPE_LOCK:
    381         {
    382             /* @todo figure this one out */
    383             return NIL_RTHCPHYS;
    384         }
    385        
    386508        case RTR0MEMOBJTYPE_PAGE:
    387509        case RTR0MEMOBJTYPE_LOW:
     510        case RTR0MEMOBJTYPE_MAPPING:
    388511        {
    389512            uint8_t *pb = (uint8_t *)pMemSolaris->Core.pv + ((size_t)iPage << PAGE_SHIFT);
    390             return PAGE_SIZE * hat_getpfnum(kas.a_hat, pb);
     513            return rtR0MemObjSolarisVirtToPhys(kas.a_hat, pb);
     514        }
     515
     516        case RTR0MEMOBJTYPE_LOCK:
     517        {
     518            struct hat *hatSpace;
     519            if (pMemSolaris->Core.u.Lock.R0Process != NIL_RTR0PROCESS)
     520            {
     521                /* User */
     522                proc_t *userProc = (proc_t *)pMemSolaris->Core.u.Lock.R0Process;
     523                hatSpace = userProc->p_as->a_hat;
     524            }
     525            else    /* Kernel */
     526                hatSpace = kas.a_hat;
     527           
     528            uint8_t *pb = (uint8_t *)pMemSolaris->Core.pv + ((size_t)iPage << PAGE_SHIFT);
     529            return rtR0MemObjSolarisVirtToPhys(hatSpace, pb);
    391530        }
    392531
     
    397536            return pMemSolaris->Core.u.Phys.PhysBase + (iPage << PAGE_SHIFT);
    398537
     538        case RTR0MEMOBJTYPE_PHYS_NC:
     539            AssertFailed(/* not implemented */);
    399540        case RTR0MEMOBJTYPE_RES_VIRT:
    400         case RTR0MEMOBJTYPE_MAPPING:
    401541        default:
    402542            return NIL_RTHCPHYS;
    403543    }
    404544}
     545
  • trunk/src/VBox/Runtime/r0drv/solaris/semfastmutex-r0drv-solaris.c

    r4287 r4474  
    5555    {
    5656        pFastInt->u32Magic = RTSEMFASTMUTEX_MAGIC;
    57         mutex_init (&pFastInt->Mtx, "IPRT Fast Mutex Semaphore", MUTEX_DEFAULT, NULL);
     57        mutex_init (&pFastInt->Mtx, "IPRT Fast Mutex Semaphore", MUTEX_DRIVER, NULL);
    5858        *pMutexSem = pFastInt;
    5959        return VINF_SUCCESS;
  • trunk/src/VBox/Runtime/r0drv/solaris/spinlock-r0drv-solaris.c

    r4178 r4474  
    5959     */
    6060    pSpinlockInt->u32Magic = RTSPINLOCK_MAGIC;
    61     mutex_init(&pSpinlockInt->Mtx, "IPRT Spinlock", MUTEX_SPIN, NULL);
     61    mutex_init(&pSpinlockInt->Mtx, "IPRT Spinlock", MUTEX_DRIVER, NULL);
    6262    *pSpinlock = pSpinlockInt;
    6363    return VINF_SUCCESS;
  • trunk/src/VBox/Runtime/r0drv/solaris/the-solaris-kernel.h

    r4287 r4474  
    2929#include <sys/time.h>
    3030#include <sys/sysmacros.h>
     31#include <sys/vmsystm.h>
     32#include <sys/cyclic.h>
    3133#include <vm/hat.h>
     34#include <vm/seg_vn.h>
    3235#include <vm/seg_kmem.h>
    3336#include <sys/ddi.h>
    3437#include <sys/sunddi.h>
    3538
    36 #include <iprt/param.h> /* for PAGE_SIZE */
     39#include <iprt/cdefs.h>
    3740
    38 /**
    39  * Used in alloc-r0drv-solaris.c and in memobj-r0drv-solaris.cpp
    40  * Basically needs to be used anywhere where contiguous allocation
    41  * is needed.
    42  *
    43  * @todo r=bird: This should be moved out of this header as it will probably
    44  *               be instantiated in all the files using this header and
    45  *               the compiler will bitch about it not being used.
    46  */
    47 static struct ddi_dma_attr g_SolarisX86PhysMemLimits =
    48 {
    49     DMA_ATTR_V0,            /* Version Number */
    50     (uint64_t)0,            /* lower limit */
    51     (uint64_t)0xffffffff,   /* high limit (32-bit PA) */
    52     (uint64_t)0xffffffff,   /* counter limit */
    53     (uint64_t)PAGE_SIZE,    /* alignment */
    54     (uint64_t)PAGE_SIZE,    /* burst size */
    55     (uint64_t)PAGE_SIZE,    /* effective DMA size */
    56     (uint64_t)0xffffffff,   /* max DMA xfer size */
    57     (uint64_t)0xffffffff,   /* segment boundary */
    58     512,                    /* s/g length */
    59     1,                      /* device granularity */
    60     0                       /* bus-specific flags */
    61 };
    62 
    63 /* commented for now
    64 #include <iprt/cdefs.h>
    6541__BEGIN_DECLS
    66 
     42extern struct ddi_dma_attr g_SolarisX86PhysMemLimits;
    6743__END_DECLS
    68 */
    6944
    7045#endif
  • trunk/src/VBox/Runtime/r0drv/solaris/time-r0drv-solaris.c

    r4287 r4474  
    2828RTDECL(uint64_t) RTTimeNanoTS(void)
    2929{
    30     return gethrtime();
     30    return (uint64_t)gethrtime();
    3131}
    3232
  • trunk/src/VBox/VMM/Makefile.kmk

    r4177 r4474  
    165165# VMMGCBuiltin.lib
    166166#
    167 ifneq ($(BUILD_TARGET),darwin)
     167ifneq ($(filter-out solaris darwin,$(BUILD_TARGET)),)
    168168LIBRARIES += VMMGCBuiltin
    169169VMMGCBuiltin_TEMPLATE = VBOXGC
     
    183183# VMMGCImp.lib
    184184#
    185 ifneq ($(BUILD_TARGET),darwin)
     185ifneq ($(filter-out solaris darwin,$(BUILD_TARGET)),)
    186186LIBRARIES += VMMGCImp
    187187VMMGCImp_TEMPLATE = VBOXGC
     
    203203# VMMR0Imp.lib
    204204#
    205 ifneq ($(BUILD_TARGET),darwin)
     205ifneq ($(filter-out solaris darwin,$(BUILD_TARGET)),)
    206206LIBRARIES += VMMR0Imp
    207207VMMR0Imp_TEMPLATE = VBOXR0
     
    371371        $(PATH_LIB)/RuntimeR0$(VBOX_SUFF_LIB) \
    372372        $(PATH_LIB)/DisasmR0$(VBOX_SUFF_LIB)
    373 ifneq ($(BUILD_TARGET),darwin)
     373ifneq ($(filter-out solaris darwin,$(BUILD_TARGET)),)
    374374VMMR0_LIBS += \
    375375        $(PATH_LIB)/SUPR0$(VBOX_SUFF_LIB)
    376 endif
    377 ifeq ($(VBOX_LDR_FMT),elf)
    378 VMMR0_LIBS += \
    379         $(VBOX_GCC_LIBGCC)
    380376endif
    381377
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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