VirtualBox

Changeset 9149 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 27, 2008 9:27:29 AM (17 years ago)
Author:
vboxsync
Message:

New VBI code for Solaris.

Location:
trunk/src/VBox/Runtime
Files:
1 edited
17 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r8925 r9149  
    885885RuntimeR0Drv_INCS.linux = \
    886886        r0drv/linux
     887ifdef VBOX_WITH_SOLARIS_VBI
     888 RuntimeR0Drv_INCS.solaris = \
     889        r0drv/solaris/vbi/i86pc
     890endif
    887891
    888892RuntimeR0Drv_SOURCES    = \
     
    10861090        generic/RTAssertDoBreakpoint-generic.cpp \
    10871091        generic/RTTimerCreate-generic.cpp \
    1088         generic/RTMpCpuId-generic.cpp \
    1089         generic/RTMpCpuIdFromSetIndex-generic.cpp \
    1090         generic/RTMpCpuIdToSetIndex-generic.cpp \
    1091         generic/RTMpDoesCpuExist-generic.cpp \
    1092         generic/RTMpGetCount-generic.cpp \
    1093         generic/RTMpGetMaxCpuId-generic.cpp \
    1094         generic/RTMpGetOnlineCount-generic.cpp \
    1095         generic/RTMpGetOnlineSet-generic.cpp \
    1096         generic/RTMpGetSet-generic.cpp \
    1097         generic/RTMpIsCpuOnline-generic.cpp \
    1098         r0drv/generic/RTMpOn-r0drv-generic.cpp \
    1099         r0drv/memobj-r0drv.cpp \
    1100         r0drv/solaris/alloc-r0drv-solaris.c \
    1101         r0drv/solaris/assert-r0drv-solaris.c \
    1102         r0drv/solaris/initterm-r0drv-solaris.c \
    1103         r0drv/solaris/memobj-r0drv-solaris.c \
    1104         r0drv/solaris/process-r0drv-solaris.c \
    1105         r0drv/solaris/RTLogWriteDebugger-r0drv-solaris.c \
    1106         r0drv/solaris/semevent-r0drv-solaris.c \
    1107         r0drv/solaris/semeventmulti-r0drv-solaris.c \
    1108         r0drv/solaris/semfastmutex-r0drv-solaris.c \
    1109         r0drv/solaris/spinlock-r0drv-solaris.c \
    1110         r0drv/solaris/thread-r0drv-solaris.c \
    1111         r0drv/solaris/thread2-r0drv-solaris.c \
    1112         r0drv/solaris/time-r0drv-solaris.c \
    1113         r0drv/solaris/timer-r0drv-solaris.c
     1092        r0drv/memobj-r0drv.cpp
     1093
     1094ifdef VBOX_WITH_SOLARIS_VBI
     1095 RuntimeR0Drv_SOURCES.solaris += \
     1096        r0drv/solaris/vbi/mp-r0drv-solaris.c \
     1097        r0drv/solaris/vbi/alloc-r0drv-solaris.c \
     1098        r0drv/solaris/vbi/assert-r0drv-solaris.c \
     1099        r0drv/solaris/vbi/initterm-r0drv-solaris.c \
     1100        r0drv/solaris/vbi/memobj-r0drv-solaris.c \
     1101        r0drv/solaris/vbi/process-r0drv-solaris.c \
     1102        r0drv/solaris/vbi/RTLogWriteDebugger-r0drv-solaris.c \
     1103        r0drv/solaris/vbi/semevent-r0drv-solaris.c \
     1104        r0drv/solaris/vbi/semeventmulti-r0drv-solaris.c \
     1105        r0drv/solaris/vbi/semfastmutex-r0drv-solaris.c \
     1106        r0drv/solaris/vbi/spinlock-r0drv-solaris.c \
     1107        r0drv/solaris/vbi/thread-r0drv-solaris.c \
     1108        r0drv/solaris/vbi/thread2-r0drv-solaris.c \
     1109        r0drv/solaris/vbi/time-r0drv-solaris.c \
     1110        r0drv/solaris/vbi/timer-r0drv-solaris.c
     1111else  # !VBOX_WITH_SOLARIS_VBI
     1112 RuntimeR0Drv_SOURCES.solaris += \
     1113        generic/RTMpCpuId-generic.cpp \
     1114        generic/RTMpCpuIdFromSetIndex-generic.cpp \
     1115        generic/RTMpCpuIdToSetIndex-generic.cpp \
     1116        generic/RTMpDoesCpuExist-generic.cpp \
     1117        generic/RTMpGetCount-generic.cpp \
     1118        generic/RTMpGetMaxCpuId-generic.cpp \
     1119        generic/RTMpGetOnlineCount-generic.cpp \
     1120        generic/RTMpGetOnlineSet-generic.cpp \
     1121        generic/RTMpGetSet-generic.cpp \
     1122        generic/RTMpIsCpuOnline-generic.cpp \
     1123        r0drv/solaris/alloc-r0drv-solaris.c \
     1124        r0drv/solaris/assert-r0drv-solaris.c \
     1125        r0drv/solaris/initterm-r0drv-solaris.c \
     1126        r0drv/solaris/memobj-r0drv-solaris.c \
     1127        r0drv/solaris/process-r0drv-solaris.c \
     1128        r0drv/solaris/RTLogWriteDebugger-r0drv-solaris.c \
     1129        r0drv/solaris/semevent-r0drv-solaris.c \
     1130        r0drv/solaris/semeventmulti-r0drv-solaris.c \
     1131        r0drv/solaris/semfastmutex-r0drv-solaris.c \
     1132        r0drv/solaris/spinlock-r0drv-solaris.c \
     1133        r0drv/solaris/thread-r0drv-solaris.c \
     1134        r0drv/solaris/thread2-r0drv-solaris.c \
     1135        r0drv/solaris/time-r0drv-solaris.c \
     1136        r0drv/solaris/timer-r0drv-solaris.c
     1137endif # !VBOX_WITH_SOLARIS_VBI
    11141138
    11151139## PORTME: Porters create and add their selection of platform specific Ring-0 Driver files here.
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/alloc-r0drv-solaris.c

    r9145 r9149  
    5353    {
    5454        cbAllocated = RT_ALIGN_Z(cb + sizeof(*pHdr), PAGE_SIZE) - sizeof(*pHdr);
    55         pHdr = (PRTMEMHDR)segkmem_alloc(heaptext_arena, cbAllocated + sizeof(*pHdr), KM_SLEEP);
     55        pHdr = (PRTMEMHDR)vbi_text_alloc(cbAllocated + sizeof(*pHdr));
    5656    }
    5757    else
     
    8282#ifdef RT_ARCH_AMD64
    8383    if (pHdr->fFlags & RTMEMHDR_FLAG_EXEC)
    84         segkmem_free(heaptext_arena, pHdr, pHdr->cb + sizeof(*pHdr));
     84        vbi_text_free(pHdr, pHdr->cb + sizeof(*pHdr));
    8585    else
    8686#endif
     
    9696    /* Allocate physically contiguous page-aligned memory. */
    9797    caddr_t virtAddr;
    98     int rc = i_ddi_mem_alloc(NULL, &g_SolarisX86PhysMemLimits, cb, 1, 0, NULL, &virtAddr, NULL, NULL);
    99     if (rc != DDI_SUCCESS)
     98    uint64_t phys = (unsigned)0xffffffff;       /* insist on below 4Gig */
     99
     100    virtAddr = vbi_contig_alloc(&phys, cb);
     101    if (virtAddr == NULL)
    100102        return NULL;
    101103
    102     *pPhys = PAGE_SIZE * hat_getpfnum(kas.a_hat, virtAddr);
     104    Assert(phys < (uint64_t)1 << 32);
     105
     106    *pPhys = phys;
    103107    return virtAddr;
    104108}
     
    107111RTR0DECL(void) RTMemContFree(void *pv, size_t cb)
    108112{
    109     NOREF(cb);
    110113    if (pv)
    111         i_ddi_mem_free(pv, NULL);
     114        vbi_contig_free(pv, cb);
    112115}
    113116
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/memobj-r0drv-solaris.c

    r9145 r9149  
    5858    ddi_umem_cookie_t   Cookie;
    5959    /** Shadow locked pages. */
    60     page_t              **ppShadowPages;
     60    void              *handle;
    6161} RTR0MEMOBJSOLARIS, *PRTR0MEMOBJSOLARIS;
    6262
    63 /**
    64  * Used for supplying the solaris kernel info. about memory limits
    65  * during contiguous allocations (i_ddi_mem_alloc)
    66  */
    67 struct ddi_dma_attr g_SolarisX86PhysMemLimits =
    68 {
    69     DMA_ATTR_V0,            /* Version Number */
    70     (uint64_t)0,            /* lower limit */
    71     (uint64_t)0xffffffff,   /* high limit (32-bit PA, 4G) */
    72     (uint64_t)0xffffffff,   /* counter limit */
    73     (uint64_t)PAGE_SIZE,    /* alignment */
    74     (uint64_t)PAGE_SIZE,    /* burst size */
    75     (uint64_t)PAGE_SIZE,    /* effective DMA size */
    76     (uint64_t)0xffffffff,   /* max DMA xfer size */
    77     (uint64_t)0xffffffff,   /* segment boundary */
    78     1,                      /* scatter-gather list length (1 for contiguous) */
    79     1,                      /* device granularity */
    80     0                       /* bus-specific flags */
    81 };
    82 
    83 
    84 static uint64_t rtR0MemObjSolarisVirtToPhys(struct hat* hatSpace, caddr_t virtAddr)
    85 {
    86     /* We could use paddr_t (more solaris-like) rather than uint64_t but paddr_t isn't defined for 64-bit */
    87     pfn_t pfn = hat_getpfnum(hatSpace, virtAddr);
    88     if (pfn == PFN_INVALID)
    89     {
    90         AssertMsgFailed(("rtR0MemObjSolarisVirtToPhys: hat_getpfnum for %p failed.\n", virtAddr));
    91         return PFN_INVALID;
    92     }
    93 
    94     uint64_t physAddr = ((uint64_t)pfn << MMU_PAGESHIFT) | ((uintptr_t)virtAddr & MMU_PAGEOFFSET);
    95     return physAddr;
    96 }
    9763
    9864
     
    10470    {
    10571        case RTR0MEMOBJTYPE_CONT:
    106             i_ddi_mem_free(pMemSolaris->Core.pv, NULL);
     72            vbi_contig_free(pMemSolaris->Core.pv, pMemSolaris->Core.cb);
    10773            break;
    10874
     
    11278
    11379        case RTR0MEMOBJTYPE_LOCK:
    114         {
    115             struct as *addrSpace;
    116             if (pMemSolaris->Core.u.Lock.R0Process == NIL_RTR0PROCESS)
    117                 addrSpace = &kas;
    118             else
    119                 addrSpace = ((proc_t *)pMemSolaris->Core.u.Lock.R0Process)->p_as;
    120 
    121             as_pageunlock(addrSpace, pMemSolaris->ppShadowPages, pMemSolaris->Core.pv, pMemSolaris->Core.cb, S_WRITE);
     80            vbi_unlock_va(pMemSolaris->Core.pv, pMemSolaris->Core.cb, pMemSolaris->handle);
    12281            break;
    123         }
    12482
    12583        case RTR0MEMOBJTYPE_MAPPING:
    126         {
    127             struct hat *hatSpace;
    128             struct as *addrSpace;
    129             if (pMemSolaris->Core.u.Mapping.R0Process == NIL_RTR0PROCESS)
    130             {
    131                 /* Kernel process*/
    132                 hatSpace = kas.a_hat;
    133                 addrSpace = &kas;
    134             }
    135             else
    136             {
    137                 /* User process */
    138                 proc_t *userProc = (proc_t *)pMemSolaris->Core.u.Mapping.R0Process;
    139                 hatSpace = userProc->p_as->a_hat;
    140                 addrSpace = userProc->p_as;
    141             }
    142 
    143             rw_enter(&addrSpace->a_lock, RW_READER);
    144             hat_unload(hatSpace, pMemSolaris->Core.pv, pMemSolaris->Core.cb, HAT_UNLOAD_UNLOCK);
    145             rw_exit(&addrSpace->a_lock);
    146             as_unmap(addrSpace, pMemSolaris->Core.pv, pMemSolaris->Core.cb);
     84            vbi_unmap(pMemSolaris->Core.pv, pMemSolaris->Core.cb);
    14785            break;
    148         }
    14986
    15087        /* unused */
     
    176113
    177114    pMemSolaris->Core.pv = virtAddr;
    178     pMemSolaris->ppShadowPages = NULL;
     115    pMemSolaris->handle = NULL;
    179116    *ppMem = &pMemSolaris->Core;
    180117    return VINF_SUCCESS;
     
    213150    /* Allocate physically contiguous page-aligned memory. */
    214151    caddr_t virtAddr;
    215     int rc = i_ddi_mem_alloc(NULL, &g_SolarisX86PhysMemLimits, cb, 1, 0, NULL, &virtAddr, NULL, NULL);
    216     if (rc != DDI_SUCCESS)
     152    uint64_t phys = (unsigned)0xffffffff;
     153    virtAddr = vbi_contig_alloc(&phys, cb);
     154    if (virtAddr == NULL)
    217155    {
    218156        rtR0MemObjDelete(&pMemSolaris->Core);
    219157        return VERR_NO_CONT_MEMORY;
    220158    }
    221 
     159    Assert(phys < (uint64_t)1 << 32);
    222160    pMemSolaris->Core.pv = virtAddr;
    223     pMemSolaris->Core.u.Cont.Phys = rtR0MemObjSolarisVirtToPhys(kas.a_hat, virtAddr);
    224     pMemSolaris->ppShadowPages = NULL;
     161    pMemSolaris->Core.u.Cont.Phys = phys;
     162    pMemSolaris->handle = NULL;
    225163    *ppMem = &pMemSolaris->Core;
    226164    return VINF_SUCCESS;
     
    267205        return VERR_NO_MEMORY;
    268206
    269     proc_t *userproc = (proc_t *)R0Process;
    270     struct as *useras = userproc->p_as;
    271     page_t **ppl;
     207    void *ppl;
    272208
    273209    /* Lock down user pages */
    274     int rc = as_pagelock(useras, &ppl, (caddr_t)R3Ptr, cb, S_WRITE);
    275     if (!rc)
    276     {
    277         if (ppl)
    278         {
    279             pMemSolaris->Core.u.Lock.R0Process = (RTR0PROCESS)userproc;
    280             pMemSolaris->ppShadowPages = ppl;
    281             *ppMem = &pMemSolaris->Core;
    282             return VINF_SUCCESS;
    283         }
    284 
    285         as_pageunlock(useras, ppl, (caddr_t)R3Ptr, cb, S_WRITE);
    286         cmn_err(CE_NOTE, "rtR0MemObjNativeLockUser: as_pagelock failed to get shadow pages\n");
    287     }
    288     else
    289         cmn_err(CE_NOTE,"rtR0MemObjNativeLockUser: as_pagelock failed rc=%d\n", rc);
    290     rtR0MemObjDelete(&pMemSolaris->Core);
    291     return VERR_LOCK_FAILED;
     210    int rc = vbi_lock_va((caddr_t)R3Ptr, cb, &ppl);
     211    if (rc != 0)
     212    {
     213        cmn_err(CE_NOTE,"rtR0MemObjNativeLockUser: vbi_lock_va failed rc=%d\n", rc);
     214        return VERR_LOCK_FAILED;
     215    }
     216
     217    pMemSolaris->Core.u.Lock.R0Process = (RTR0PROCESS)vbi_proc();
     218    pMemSolaris->handle = ppl;
     219    *ppMem = &pMemSolaris->Core;
     220    return VINF_SUCCESS;
    292221}
    293222
     
    295224int rtR0MemObjNativeLockKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb)
    296225{
    297     /* Create the locking object */
    298226    PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_LOCK, pv, cb);
    299227    if (!pMemSolaris)
    300228        return VERR_NO_MEMORY;
    301229
    302     caddr_t virtAddr = (caddr_t)((uintptr_t)pv & (uintptr_t)PAGEMASK);
    303     page_t **ppl;
    304 
    305     /* Lock down kernel pages */
    306     int rc = as_pagelock(&kas, &ppl, virtAddr, cb, S_WRITE);
    307     if (!rc)
    308     {
    309         if (ppl)
    310         {
    311             pMemSolaris->Core.u.Lock.R0Process = NIL_RTR0PROCESS;   /* means kernel, see rtR0MemObjNativeFree() */
    312             pMemSolaris->ppShadowPages = ppl;
    313             *ppMem = &pMemSolaris->Core;
    314             return VINF_SUCCESS;
    315         }
    316 
    317         as_pageunlock(&kas, ppl, virtAddr, cb, S_WRITE);
    318         cmn_err(CE_NOTE, "rtR0MemObjNativeLockKernel: failed to get shadow pages\n");
    319     }
    320     else
    321         cmn_err(CE_NOTE,"rtR0MemObjNativeLockKernel: as_pagelock failed rc=%d\n", rc);
    322     rtR0MemObjDelete(&pMemSolaris->Core);
    323     return VERR_LOCK_FAILED;
     230    void *ppl;
     231    int rc = vbi_lock_va((caddr_t)pv, cb, &ppl);
     232    if (rc != 0)
     233    {
     234        cmn_err(CE_NOTE,"rtR0MemObjNativeLockKernel: vbi_lock_va failed rc=%d\n", rc);
     235        return VERR_LOCK_FAILED;
     236    }
     237
     238    pMemSolaris->Core.u.Lock.R0Process = NIL_RTR0PROCESS;
     239    pMemSolaris->handle = ppl;
     240    *ppMem = &pMemSolaris->Core;
     241    return VINF_SUCCESS;
    324242}
    325243
     
    342260}
    343261
    344 
    345262int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, PRTR0MEMOBJINTERNAL pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
    346263{
    347264    AssertMsgReturn(R3PtrFixed == (RTR3PTR)-1, ("%p\n", R3PtrFixed), VERR_NOT_SUPPORTED);
    348265    AssertMsgReturn(R0Process == RTR0ProcHandleSelf(), ("%p != %p\n", R0Process, RTR0ProcHandleSelf()), VERR_NOT_SUPPORTED);
     266    AssertMsgReturn(uAlignment == 0 || uAlignment == PAGE_SIZE, ("%d\n", uAlignment), VERR_NOT_SUPPORTED);
    349267
    350268    PRTR0MEMOBJSOLARIS pMemToMapSolaris = (PRTR0MEMOBJSOLARIS)pMemToMap;
    351269    size_t size = pMemToMapSolaris->Core.cb;
    352     proc_t *userproc = (proc_t *)R0Process;
    353     struct as *useras = userproc->p_as;
    354270    void *pv = pMemToMapSolaris->Core.pv;
    355     pgcnt_t cPages = btop(size);
     271    pgcnt_t cPages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
    356272    pgcnt_t iPage;
     273    uint64_t *paddrs;
    357274    caddr_t addr;
    358275    int rc;
    359276
    360     /* Request the system for a mapping address. */
    361     as_rangelock(useras);
    362     map_addr(&addr, size, 0 /* offset */, 1 /* vac-align */, MAP_SHARED | MAP_ANONYMOUS);
    363     if (!addr)
    364     {
    365         as_rangeunlock(useras);
    366         cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: map_addr failed\n");
    367         return VERR_MAP_FAILED;
    368     }
    369 
    370     /* Check address against alignment, fail if it doesn't match */
    371     if ((uintptr_t)addr & (uAlignment - 1))
    372     {
    373         as_rangeunlock(useras);
    374         cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: map_addr alignment(%ld) failed.\n", uAlignment);
    375         return VERR_MAP_FAILED;
    376     }
    377 
    378     /* Our protection masks are identical to <sys/mman.h> but we
    379      * need to add PROT_USER for the pages to be accessible by user
    380      */
    381     struct segvn_crargs crArgs = SEGVN_ZFOD_ARGS(fProt | PROT_USER, PROT_ALL);
    382     rc = as_map(useras, addr, size, segvn_create, &crArgs);
    383     as_rangeunlock(useras);
    384     if (rc != 0)
    385     {
    386         cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: as_map failure.\n");
    387         return VERR_MAP_FAILED;
    388     }
    389 
    390277    /* Create the mapping object */
    391278    PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING, pv, size);
    392279    if (!pMemSolaris)
    393     {
    394         /* Undo mapping on failure. */
    395         as_unmap(useras, addr, size);
    396         return VERR_NO_MEMORY;
    397     }
    398 
    399     /* Map each page into user space */
    400     rw_enter(&useras->a_lock, RW_READER);
    401     caddr_t kernAddr = pv;
    402     caddr_t pageAddr = addr;
     280        return VERR_NO_MEMORY;
     281
     282    paddrs = kmem_zalloc(sizeof(uint64_t) * cPages, KM_SLEEP);
    403283    for (iPage = 0; iPage < cPages; iPage++)
    404284    {
    405         page_t *pp = page_numtopp_nolock(hat_getpfnum(kas.a_hat, kernAddr));
    406         hat_memload(useras->a_hat, pageAddr, pp, (fProt | PROT_USER), HAT_LOAD_LOCK);
    407         pageAddr += ptob(1);
    408         kernAddr += ptob(1);
    409     }
    410     rw_exit(&useras->a_lock);
    411 
    412     pMemSolaris->Core.u.Mapping.R0Process = (RTR0PROCESS)userproc;
     285        paddrs[iPage] = vbi_va_to_pa(pv);
     286        if (paddrs[iPage] == -(uint64_t)1)
     287        {
     288            cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: no page to map.\n");
     289            rc = VERR_MAP_FAILED;
     290            goto done;
     291        }
     292        pv = (void *)((uintptr_t)pv + PAGE_SIZE);
     293    }
     294
     295    rc = vbi_user_map(&addr, fProt, paddrs, size);
     296    if (rc != 0)
     297    {
     298        cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: vbi failure.\n");
     299        rc = VERR_MAP_FAILED;
     300        rtR0MemObjDelete(&pMemSolaris->Core);
     301        goto done;
     302    }
     303    else
     304        rc = VINF_SUCCESS;
     305
     306    pMemSolaris->Core.u.Mapping.R0Process = (RTR0PROCESS)vbi_proc();
    413307    pMemSolaris->Core.pv = addr;
    414308    *ppMem = &pMemSolaris->Core;
    415     return VINF_SUCCESS;
     309done:
     310    kmem_free(paddrs, sizeof(uint64_t) * cPages);
     311    return rc;
    416312}
    417313
     
    426322        case RTR0MEMOBJTYPE_LOW:
    427323        case RTR0MEMOBJTYPE_MAPPING:
     324        case RTR0MEMOBJTYPE_LOCK:
    428325        {
    429326            uint8_t *pb = (uint8_t *)pMemSolaris->Core.pv + ((size_t)iPage << PAGE_SHIFT);
    430             return rtR0MemObjSolarisVirtToPhys(kas.a_hat, pb);
    431         }
    432 
    433         case RTR0MEMOBJTYPE_LOCK:
    434         {
    435             struct hat *hatSpace;
    436             if (pMemSolaris->Core.u.Lock.R0Process != NIL_RTR0PROCESS)
    437             {
    438                 /* User */
    439                 proc_t *userProc = (proc_t *)pMemSolaris->Core.u.Lock.R0Process;
    440                 hatSpace = userProc->p_as->a_hat;
    441             }
    442             else    /* Kernel */
    443                 hatSpace = kas.a_hat;
    444 
    445             uint8_t *pb = (uint8_t *)pMemSolaris->Core.pv + ((size_t)iPage << PAGE_SHIFT);
    446             return rtR0MemObjSolarisVirtToPhys(hatSpace, pb);
     327            return vbi_va_to_pa(pb);
    447328        }
    448329
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/mp-r0drv-solaris.c

    r9145 r9149  
    4444RTDECL(RTCPUID) RTMpCpuId(void)
    4545{
    46     return cpuid_get_chipid(CPU); /* is there a better way? */
     46    return vbi_cpu_id();
    4747}
    4848
     
    5050RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu)
    5151{
    52     return idCpu < NCPU ? idCpu : -1;
     52    return idCpu < vbi_cpu_maxcount() ? idCpu : -1;
    5353}
    5454
     
    5656RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu)
    5757{
    58     return (unsigned)iCpu < NCPU ? iCpu : NIL_RTCPUID;
     58    return (unsigned)iCpu < vbi_cpu_maxcount() ? iCpu : NIL_RTCPUID;
    5959}
    6060
     
    6262RTDECL(RTCPUID) RTMpGetMaxCpuId(void)
    6363{
    64     return NCPU - 1;
     64    return vbi_max_cpu_id();
    6565}
    6666
     
    6868RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
    6969{
    70     cpu_t *pCpu = idCpu < NCPU ? cpu_get(idCpu) : NULL;
    71     return pCpu
    72         && cpu_is_online(pCpu);
     70    return idCpu < vbi_cpu_count() && vbi_cpu_online(idCpu);
    7371}
    7472
     
    7674RTDECL(bool) RTMpDoesCpuExist(RTCPUID idCpu)
    7775{
    78     cpu_t *pCpu = idCpu < NCPU ? cpu_get(idCpu) : NULL;
    79     return pCpu != NULL;
     76    return idCpu < vbi_cpu_count();
    8077}
    8178
     
    9996RTDECL(RTCPUID) RTMpGetCount(void)
    10097{
    101     return ncpus;
     98    return vbi_cpu_count();
    10299}
    103100
     
    121118RTDECL(RTCPUID) RTMpGetOnlineCount(void)
    122119{
    123     return ncpus_online;
     120    int c;
     121    int cnt = 0;
     122
     123    for (c = 0; c < vbi_cpu_count(); ++c)
     124    {
     125        if (vbi_cpu_online(c))
     126            ++cnt;
     127    }
     128    return cnt;
    124129}
    125130
     
    134139 * @param   uIgnored2   Ignored.
    135140 */
    136 static int rtmpOnAllSolarisWrapper(xc_arg_t uArg, xc_arg_t uIgnored1, xc_arg_t uIgnored2)
     141static int rtmpOnAllSolarisWrapper(void *uArg, void *uIgnored1, void *uIgnored2)
    137142{
    138143    PRTMPARGS pArgs = (PRTMPARGS)(uArg);
     
    148153RTDECL(int) RTMpOnAll(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
    149154{
    150     cpuset_t Set;
    151155    RTMPARGS Args;
    152156
     
    157161    Args.cHits = 0;
    158162
    159     kpreempt_disable();
    160 
    161     CPUSET_ALL(Set);
    162     xc_call((uintptr_t)&Args, 0, 0, X_CALL_HIPRI, Set, rtmpOnAllSolarisWrapper);
    163 
    164     kpreempt_enable();
     163    vbi_preempt_disable();
     164
     165    vbi_execute_on_all(rtmpOnAllSolarisWrapper, &Args);
     166
     167    vbi_preempt_enable();
    165168
    166169    return VINF_SUCCESS;
     
    176179 * @param   uIgnored2   Ignored.
    177180 */
    178 static int rtmpOnOthersSolarisWrapper(xc_arg_t uArg, xc_arg_t uIgnored1, xc_arg_t uIgnored2)
     181static int rtmpOnOthersSolarisWrapper(void *uArg, void *uIgnored1, void *uIgnored2)
    179182{
    180183    PRTMPARGS pArgs = (PRTMPARGS)(uArg);
     
    193196{
    194197    int rc;
    195     cpuset_t Set;
    196198    RTMPARGS Args;
    197199
     
    202204    Args.cHits = 0;
    203205
    204     kpreempt_disable();
    205 
    206     CPUSET_ALL_BUT(Set, Args.idCpu);
    207     xc_call((uintptr_t)&Args, 0, 0, X_CALL_HIPRI, Set, rtmpOnOthersSolarisWrapper);
    208 
    209     kpreempt_enable();
     206    /* HERE JOE - this looks broken, explain to Knut */
     207    vbi_preempt_disable();
     208
     209    vbi_execute_on_others(rtmpOnOthersSolarisWrapper, &Args);
     210
     211    vbi_preempt_enable();
    210212
    211213    return VINF_SUCCESS;
     
    222224 * @param   uIgnored2   Ignored.
    223225 */
    224 static int rtmpOnSpecificSolarisWrapper(xc_arg_t uArg, xc_arg_t uIgnored1, xc_arg_t uIgnored2)
     226static int rtmpOnSpecificSolarisWrapper(void *uArg, void *uIgnored1, void *uIgnored2)
    225227{
    226228    PRTMPARGS pArgs = (PRTMPARGS)(uArg);
     
    240242{
    241243    int rc;
    242     cpuset_t Set;
    243244    RTMPARGS Args;
    244245
    245     if (idCpu >= NCPU)
     246    if (idCpu >= vbi_cpu_count())
    246247        return VERR_CPU_NOT_FOUND;
    247248
     
    252253    Args.cHits = 0;
    253254
    254     kpreempt_disable();
    255 
    256     CPUSET_ZERO(Set);
    257     CPUSET_ADD(Set, idCpu);
    258 
    259     xc_call((uintptr_t)&Args, 0, 0, X_CALL_HIPRI, Set, rtmpOnSpecificSolarisWrapper);
    260 
    261     kpreempt_enable();
     255    /* TBD HERE JOE again.. perhaps broken */
     256    vbi_preempt_disable();
     257
     258    vbi_execute_on_one(rtmpOnSpecificSolarisWrapper, &Args, idCpu);
     259
     260    vbi_preempt_enable();
    262261
    263262    Assert(ASMAtomicUoReadU32(&Args.cHits) <= 1);
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/process-r0drv-solaris.c

    r9145 r9149  
    3939RTDECL(RTPROCESS) RTProcSelf(void)
    4040{
    41     struct pid *pPidInfo = curproc->p_pidp;
    42     return pPidInfo->pid_id;
     41    return ddi_get_pid();
    4342}
    4443
     
    4645RTR0DECL(RTR0PROCESS) RTR0ProcHandleSelf(void)
    4746{
    48     return (RTR0PROCESS)curproc;
     47    return (RTR0PROCESS)vbi_proc();
    4948}
    5049
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/the-solaris-kernel.h

    r9145 r9149  
    3333
    3434#define _MACHDEP /* needed for cpuset_t and sys/x_call.h */
    35 
    3635#include <sys/kmem.h>
    3736#include <sys/types.h>
     
    4140#include <sys/condvar.h>
    4241#include <sys/sdt.h>
    43 #include <sys/schedctl.h>
    4442#include <sys/time.h>
    4543#include <sys/sysmacros.h>
    4644#include <sys/cmn_err.h>
    4745#include <sys/vmsystm.h>
    48 #include <sys/cyclic.h>
    4946#include <sys/class.h>
    5047#include <sys/cpuvar.h>
    51 #include <sys/x_call.h> /* in platform dir */
    5248#include <sys/x86_archext.h>
    53 #include <vm/hat.h>
    54 #include <vm/seg_vn.h>
    5549#include <vm/seg_kmem.h>
    5650#include <sys/ddi.h>
    5751#include <sys/sunddi.h>
     52#include <sys/vbi.h>
    5853
    5954#undef u /* /usr/include/sys/user.h:249:1 is where this is defined to (curproc->p_user). very cool. */
     
    6156#include <iprt/cdefs.h>
    6257
    63 __BEGIN_DECLS
    64 extern struct ddi_dma_attr g_SolarisX86PhysMemLimits;
    65 __END_DECLS
    66 
    6758#endif
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/thread-r0drv-solaris.c

    r9145 r9149  
    3838#include <iprt/assert.h>
    3939
    40 
    4140RTDECL(RTNATIVETHREAD) RTThreadNativeSelf(void)
    4241{
    43     return (RTNATIVETHREAD)curthread;
     42    return (RTNATIVETHREAD)vbi_curthread();
    4443}
    4544
     
    9493RTDECL(bool) RTThreadYield(void)
    9594{
    96     schedctl_set_yield(curthread, 0);
    97     return true;
     95    return vbi_yield();
    9896}
    9997
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/thread2-r0drv-solaris.c

    r9145 r9149  
    6868    }
    6969
    70     thread_lock(curthread);
    71     thread_change_pri(curthread, iPriority, 0);
    72     thread_unlock(curthread);
     70    vbi_set_priority(vbi_curthread(), iPriority);
    7371    return VINF_SUCCESS;
    7472}
     
    9492    int rc;
    9593
    96     rc = rtThreadMain(pThreadInt, (RTNATIVETHREAD)curthread, &pThreadInt->szName[0]);
    97     thread_exit();
     94    rc = rtThreadMain(pThreadInt, (RTNATIVETHREAD)vbi_curthread(), &pThreadInt->szName[0]);
     95    vbi_thread_exit();
    9896}
    9997
     
    102100{
    103101    int rc;
    104     kthread_t* pKernThread = thread_create(NULL, NULL, rtThreadNativeMain, pThreadInt, 0,
    105                                            curproc, LMS_USER, minclsyspri);
     102    void *pKernThread = vbi_thread_create(rtThreadNativeMain, pThreadInt,
     103                                           sizeof (pThreadInt), minclsyspri);
    106104    if (pKernThread)
    107105    {
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/time-r0drv-solaris.c

    r9145 r9149  
    6565RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPEC pTime)
    6666{
    67     /* timestruc_t is actually just a typedef struct timespec */
    68     timestruc_t tv = tod_get();
    69     return RTTimeSpecSetNano(pTime, (uint64_t)tv.tv_sec * 1000000000 + tv.tv_nsec);
     67    return RTTimeSpecSetNano(pTime, vbi_tod());
    7068}
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/timer-r0drv-solaris.c

    r9145 r9149  
    6464    /** The CPU it must run on if fSpecificCpu is set. */
    6565    uint8_t                 iCpu;
    66     /** The Solaris cyclic structure. */
    67     cyc_handler_t           CyclicInfo;
    68     /** The Solaris cyclic handle. */
    69     cyclic_id_t             CyclicID;
    70     /** Callback. */
    71     PFNRTTIMER              pfnTimer;
    72     /** User argument. */
    73     void                   *pvUser;
    74     /** The timer interval. 0 for one-shot timer */
    75     uint64_t                u64NanoInterval;
     66    /** The Solaris timer handle. */
     67    void                    *handle;
    7668} RTTIMER;
    77 
    78 
    79 /*******************************************************************************
    80 *   Internal Functions                                                         *
    81 *******************************************************************************/
    82 static void rtTimerSolarisCallback(void *pvTimer);
    83 static void rtTimerSolarisStop(PRTTIMER pTimer);
    8469
    8570
     
    10893    pTimer->fSpecificCpu = !!(fFlags & RTTIMER_FLAGS_CPU_SPECIFIC);
    10994    pTimer->iCpu = fFlags & RTTIMER_FLAGS_CPU_MASK;
    110     pTimer->CyclicInfo.cyh_func = rtTimerSolarisCallback;
    111     pTimer->CyclicInfo.cyh_level = CY_LOCK_LEVEL;
    112     pTimer->CyclicInfo.cyh_arg = pTimer;
    113     pTimer->CyclicID = CYCLIC_NONE;
    114     pTimer->u64NanoInterval = u64NanoInterval;
    115     pTimer->pfnTimer = pfnTimer;
    116     pTimer->pvUser = pvUser;
     95    pTimer->handle = vbi_timer_create(pfnTimer, pTimer, pvUser, u64NanoInterval);
    11796
    11897    *ppTimer = pTimer;
     
    146125     */
    147126    pTimer->u32Magic++;
    148     rtTimerSolarisStop(pTimer);
     127    vbi_timer_stop(pTimer->handle);
     128    vbi_timer_destroy(pTimer->handle);
    149129    RTMemFree(pTimer);
    150130    return VINF_SUCCESS;
     
    154134RTDECL(int) RTTimerStart(PRTTIMER pTimer, uint64_t u64First)
    155135{
    156     cyc_time_t timerSpec;
    157 
    158136    if (!rtTimerIsValid(pTimer))
    159137        return VERR_INVALID_HANDLE;
     
    162140
    163141    /*
    164      * Calc when it should start fireing.
     142     * Calc when it should start firing.
    165143     */
    166     u64First += RTTimeNanoTS();
    167 
    168144    pTimer->fSuspended = false;
    169     timerSpec.cyt_when = u64First;
    170     timerSpec.cyt_interval = pTimer->u64NanoInterval == 0 ? u64First : pTimer->u64NanoInterval;
     145    vbi_timer_start(pTimer->handle, u64First);
    171146   
    172     mutex_enter(&cpu_lock);
    173     pTimer->CyclicID = cyclic_add(&pTimer->CyclicInfo, &timerSpec);
    174     mutex_exit(&cpu_lock);
    175 
    176147    return VINF_SUCCESS;
    177148}
     
    189160     */
    190161    pTimer->fSuspended = true;
    191     rtTimerSolarisStop(pTimer);
     162    vbi_timer_stop(pTimer->handle);
    192163   
    193164    return VINF_SUCCESS;
     
    195166
    196167
    197 static void rtTimerSolarisCallback(void *pvTimer)
    198 {
    199     PRTTIMER pTimer = (PRTTIMER)pvTimer;
    200 
    201     /* If this is a one shot timer, call pfnTimer and suspend
    202      * as Solaris does not support 0 interval timers implictly
    203      */
    204     if (!pTimer->u64NanoInterval)
    205     {
    206         pTimer->fSuspended = true;
    207         rtTimerSolarisStop(pTimer);
    208     }
    209 
    210     /* Callback user defined callback function */
    211     pTimer->pfnTimer(pTimer, pTimer->pvUser);
    212 }
    213 
    214 
    215 static void rtTimerSolarisStop(PRTTIMER pTimer)
    216 {
    217     /* Important we check for invalid cyclic object */
    218     if (pTimer->CyclicID != CYCLIC_NONE)
    219     {
    220         mutex_enter(&cpu_lock);
    221         cyclic_remove(pTimer->CyclicID);
    222         mutex_exit(&cpu_lock);
    223         pTimer->CyclicID = CYCLIC_NONE;
    224     }
    225 }
    226 
    227168
    228169RTDECL(uint32_t) RTTimerGetSystemGranularity(void)
    229170{
    230     return nsec_per_tick;
     171    return vbi_timer_granularity();
    231172}
    232173
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