Changeset 9149 in vbox for trunk/src/VBox
- Timestamp:
- May 27, 2008 9:27:29 AM (17 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 1 edited
- 17 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/Makefile.kmk
r8925 r9149 885 885 RuntimeR0Drv_INCS.linux = \ 886 886 r0drv/linux 887 ifdef VBOX_WITH_SOLARIS_VBI 888 RuntimeR0Drv_INCS.solaris = \ 889 r0drv/solaris/vbi/i86pc 890 endif 887 891 888 892 RuntimeR0Drv_SOURCES = \ … … 1086 1090 generic/RTAssertDoBreakpoint-generic.cpp \ 1087 1091 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 1094 ifdef 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 1111 else # !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 1137 endif # !VBOX_WITH_SOLARIS_VBI 1114 1138 1115 1139 ## 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 53 53 { 54 54 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)); 56 56 } 57 57 else … … 82 82 #ifdef RT_ARCH_AMD64 83 83 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)); 85 85 else 86 86 #endif … … 96 96 /* Allocate physically contiguous page-aligned memory. */ 97 97 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) 100 102 return NULL; 101 103 102 *pPhys = PAGE_SIZE * hat_getpfnum(kas.a_hat, virtAddr); 104 Assert(phys < (uint64_t)1 << 32); 105 106 *pPhys = phys; 103 107 return virtAddr; 104 108 } … … 107 111 RTR0DECL(void) RTMemContFree(void *pv, size_t cb) 108 112 { 109 NOREF(cb);110 113 if (pv) 111 i_ddi_mem_free(pv, NULL);114 vbi_contig_free(pv, cb); 112 115 } 113 116 -
trunk/src/VBox/Runtime/r0drv/solaris/vbi/memobj-r0drv-solaris.c
r9145 r9149 58 58 ddi_umem_cookie_t Cookie; 59 59 /** Shadow locked pages. */ 60 page_t **ppShadowPages;60 void *handle; 61 61 } RTR0MEMOBJSOLARIS, *PRTR0MEMOBJSOLARIS; 62 62 63 /**64 * Used for supplying the solaris kernel info. about memory limits65 * 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 }97 63 98 64 … … 104 70 { 105 71 case RTR0MEMOBJTYPE_CONT: 106 i_ddi_mem_free(pMemSolaris->Core.pv, NULL);72 vbi_contig_free(pMemSolaris->Core.pv, pMemSolaris->Core.cb); 107 73 break; 108 74 … … 112 78 113 79 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); 122 81 break; 123 }124 82 125 83 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); 147 85 break; 148 }149 86 150 87 /* unused */ … … 176 113 177 114 pMemSolaris->Core.pv = virtAddr; 178 pMemSolaris-> ppShadowPages= NULL;115 pMemSolaris->handle = NULL; 179 116 *ppMem = &pMemSolaris->Core; 180 117 return VINF_SUCCESS; … … 213 150 /* Allocate physically contiguous page-aligned memory. */ 214 151 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) 217 155 { 218 156 rtR0MemObjDelete(&pMemSolaris->Core); 219 157 return VERR_NO_CONT_MEMORY; 220 158 } 221 159 Assert(phys < (uint64_t)1 << 32); 222 160 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; 225 163 *ppMem = &pMemSolaris->Core; 226 164 return VINF_SUCCESS; … … 267 205 return VERR_NO_MEMORY; 268 206 269 proc_t *userproc = (proc_t *)R0Process; 270 struct as *useras = userproc->p_as; 271 page_t **ppl; 207 void *ppl; 272 208 273 209 /* 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; 292 221 } 293 222 … … 295 224 int rtR0MemObjNativeLockKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb) 296 225 { 297 /* Create the locking object */298 226 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_LOCK, pv, cb); 299 227 if (!pMemSolaris) 300 228 return VERR_NO_MEMORY; 301 229 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; 324 242 } 325 243 … … 342 260 } 343 261 344 345 262 int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, PRTR0MEMOBJINTERNAL pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process) 346 263 { 347 264 AssertMsgReturn(R3PtrFixed == (RTR3PTR)-1, ("%p\n", R3PtrFixed), VERR_NOT_SUPPORTED); 348 265 AssertMsgReturn(R0Process == RTR0ProcHandleSelf(), ("%p != %p\n", R0Process, RTR0ProcHandleSelf()), VERR_NOT_SUPPORTED); 266 AssertMsgReturn(uAlignment == 0 || uAlignment == PAGE_SIZE, ("%d\n", uAlignment), VERR_NOT_SUPPORTED); 349 267 350 268 PRTR0MEMOBJSOLARIS pMemToMapSolaris = (PRTR0MEMOBJSOLARIS)pMemToMap; 351 269 size_t size = pMemToMapSolaris->Core.cb; 352 proc_t *userproc = (proc_t *)R0Process;353 struct as *useras = userproc->p_as;354 270 void *pv = pMemToMapSolaris->Core.pv; 355 pgcnt_t cPages = btop(size);271 pgcnt_t cPages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; 356 272 pgcnt_t iPage; 273 uint64_t *paddrs; 357 274 caddr_t addr; 358 275 int rc; 359 276 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 we379 * need to add PROT_USER for the pages to be accessible by user380 */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 390 277 /* Create the mapping object */ 391 278 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING, pv, size); 392 279 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); 403 283 for (iPage = 0; iPage < cPages; iPage++) 404 284 { 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(); 413 307 pMemSolaris->Core.pv = addr; 414 308 *ppMem = &pMemSolaris->Core; 415 return VINF_SUCCESS; 309 done: 310 kmem_free(paddrs, sizeof(uint64_t) * cPages); 311 return rc; 416 312 } 417 313 … … 426 322 case RTR0MEMOBJTYPE_LOW: 427 323 case RTR0MEMOBJTYPE_MAPPING: 324 case RTR0MEMOBJTYPE_LOCK: 428 325 { 429 326 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); 447 328 } 448 329 -
trunk/src/VBox/Runtime/r0drv/solaris/vbi/mp-r0drv-solaris.c
r9145 r9149 44 44 RTDECL(RTCPUID) RTMpCpuId(void) 45 45 { 46 return cpuid_get_chipid(CPU); /* is there a better way? */46 return vbi_cpu_id(); 47 47 } 48 48 … … 50 50 RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu) 51 51 { 52 return idCpu < NCPU? idCpu : -1;52 return idCpu < vbi_cpu_maxcount() ? idCpu : -1; 53 53 } 54 54 … … 56 56 RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu) 57 57 { 58 return (unsigned)iCpu < NCPU? iCpu : NIL_RTCPUID;58 return (unsigned)iCpu < vbi_cpu_maxcount() ? iCpu : NIL_RTCPUID; 59 59 } 60 60 … … 62 62 RTDECL(RTCPUID) RTMpGetMaxCpuId(void) 63 63 { 64 return NCPU - 1;64 return vbi_max_cpu_id(); 65 65 } 66 66 … … 68 68 RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu) 69 69 { 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); 73 71 } 74 72 … … 76 74 RTDECL(bool) RTMpDoesCpuExist(RTCPUID idCpu) 77 75 { 78 cpu_t *pCpu = idCpu < NCPU ? cpu_get(idCpu) : NULL; 79 return pCpu != NULL; 76 return idCpu < vbi_cpu_count(); 80 77 } 81 78 … … 99 96 RTDECL(RTCPUID) RTMpGetCount(void) 100 97 { 101 return ncpus;98 return vbi_cpu_count(); 102 99 } 103 100 … … 121 118 RTDECL(RTCPUID) RTMpGetOnlineCount(void) 122 119 { 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; 124 129 } 125 130 … … 134 139 * @param uIgnored2 Ignored. 135 140 */ 136 static int rtmpOnAllSolarisWrapper( xc_arg_t uArg, xc_arg_t uIgnored1, xc_arg_tuIgnored2)141 static int rtmpOnAllSolarisWrapper(void *uArg, void *uIgnored1, void *uIgnored2) 137 142 { 138 143 PRTMPARGS pArgs = (PRTMPARGS)(uArg); … … 148 153 RTDECL(int) RTMpOnAll(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2) 149 154 { 150 cpuset_t Set;151 155 RTMPARGS Args; 152 156 … … 157 161 Args.cHits = 0; 158 162 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(); 165 168 166 169 return VINF_SUCCESS; … … 176 179 * @param uIgnored2 Ignored. 177 180 */ 178 static int rtmpOnOthersSolarisWrapper( xc_arg_t uArg, xc_arg_t uIgnored1, xc_arg_tuIgnored2)181 static int rtmpOnOthersSolarisWrapper(void *uArg, void *uIgnored1, void *uIgnored2) 179 182 { 180 183 PRTMPARGS pArgs = (PRTMPARGS)(uArg); … … 193 196 { 194 197 int rc; 195 cpuset_t Set;196 198 RTMPARGS Args; 197 199 … … 202 204 Args.cHits = 0; 203 205 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(); 210 212 211 213 return VINF_SUCCESS; … … 222 224 * @param uIgnored2 Ignored. 223 225 */ 224 static int rtmpOnSpecificSolarisWrapper( xc_arg_t uArg, xc_arg_t uIgnored1, xc_arg_tuIgnored2)226 static int rtmpOnSpecificSolarisWrapper(void *uArg, void *uIgnored1, void *uIgnored2) 225 227 { 226 228 PRTMPARGS pArgs = (PRTMPARGS)(uArg); … … 240 242 { 241 243 int rc; 242 cpuset_t Set;243 244 RTMPARGS Args; 244 245 245 if (idCpu >= NCPU)246 if (idCpu >= vbi_cpu_count()) 246 247 return VERR_CPU_NOT_FOUND; 247 248 … … 252 253 Args.cHits = 0; 253 254 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(); 262 261 263 262 Assert(ASMAtomicUoReadU32(&Args.cHits) <= 1); -
trunk/src/VBox/Runtime/r0drv/solaris/vbi/process-r0drv-solaris.c
r9145 r9149 39 39 RTDECL(RTPROCESS) RTProcSelf(void) 40 40 { 41 struct pid *pPidInfo = curproc->p_pidp; 42 return pPidInfo->pid_id; 41 return ddi_get_pid(); 43 42 } 44 43 … … 46 45 RTR0DECL(RTR0PROCESS) RTR0ProcHandleSelf(void) 47 46 { 48 return (RTR0PROCESS) curproc;47 return (RTR0PROCESS)vbi_proc(); 49 48 } 50 49 -
trunk/src/VBox/Runtime/r0drv/solaris/vbi/the-solaris-kernel.h
r9145 r9149 33 33 34 34 #define _MACHDEP /* needed for cpuset_t and sys/x_call.h */ 35 36 35 #include <sys/kmem.h> 37 36 #include <sys/types.h> … … 41 40 #include <sys/condvar.h> 42 41 #include <sys/sdt.h> 43 #include <sys/schedctl.h>44 42 #include <sys/time.h> 45 43 #include <sys/sysmacros.h> 46 44 #include <sys/cmn_err.h> 47 45 #include <sys/vmsystm.h> 48 #include <sys/cyclic.h>49 46 #include <sys/class.h> 50 47 #include <sys/cpuvar.h> 51 #include <sys/x_call.h> /* in platform dir */52 48 #include <sys/x86_archext.h> 53 #include <vm/hat.h>54 #include <vm/seg_vn.h>55 49 #include <vm/seg_kmem.h> 56 50 #include <sys/ddi.h> 57 51 #include <sys/sunddi.h> 52 #include <sys/vbi.h> 58 53 59 54 #undef u /* /usr/include/sys/user.h:249:1 is where this is defined to (curproc->p_user). very cool. */ … … 61 56 #include <iprt/cdefs.h> 62 57 63 __BEGIN_DECLS64 extern struct ddi_dma_attr g_SolarisX86PhysMemLimits;65 __END_DECLS66 67 58 #endif -
trunk/src/VBox/Runtime/r0drv/solaris/vbi/thread-r0drv-solaris.c
r9145 r9149 38 38 #include <iprt/assert.h> 39 39 40 41 40 RTDECL(RTNATIVETHREAD) RTThreadNativeSelf(void) 42 41 { 43 return (RTNATIVETHREAD) curthread;42 return (RTNATIVETHREAD)vbi_curthread(); 44 43 } 45 44 … … 94 93 RTDECL(bool) RTThreadYield(void) 95 94 { 96 schedctl_set_yield(curthread, 0); 97 return true; 95 return vbi_yield(); 98 96 } 99 97 -
trunk/src/VBox/Runtime/r0drv/solaris/vbi/thread2-r0drv-solaris.c
r9145 r9149 68 68 } 69 69 70 thread_lock(curthread); 71 thread_change_pri(curthread, iPriority, 0); 72 thread_unlock(curthread); 70 vbi_set_priority(vbi_curthread(), iPriority); 73 71 return VINF_SUCCESS; 74 72 } … … 94 92 int rc; 95 93 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(); 98 96 } 99 97 … … 102 100 { 103 101 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); 106 104 if (pKernThread) 107 105 { -
trunk/src/VBox/Runtime/r0drv/solaris/vbi/time-r0drv-solaris.c
r9145 r9149 65 65 RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPEC pTime) 66 66 { 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()); 70 68 } -
trunk/src/VBox/Runtime/r0drv/solaris/vbi/timer-r0drv-solaris.c
r9145 r9149 64 64 /** The CPU it must run on if fSpecificCpu is set. */ 65 65 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; 76 68 } RTTIMER; 77 78 79 /*******************************************************************************80 * Internal Functions *81 *******************************************************************************/82 static void rtTimerSolarisCallback(void *pvTimer);83 static void rtTimerSolarisStop(PRTTIMER pTimer);84 69 85 70 … … 108 93 pTimer->fSpecificCpu = !!(fFlags & RTTIMER_FLAGS_CPU_SPECIFIC); 109 94 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); 117 96 118 97 *ppTimer = pTimer; … … 146 125 */ 147 126 pTimer->u32Magic++; 148 rtTimerSolarisStop(pTimer); 127 vbi_timer_stop(pTimer->handle); 128 vbi_timer_destroy(pTimer->handle); 149 129 RTMemFree(pTimer); 150 130 return VINF_SUCCESS; … … 154 134 RTDECL(int) RTTimerStart(PRTTIMER pTimer, uint64_t u64First) 155 135 { 156 cyc_time_t timerSpec;157 158 136 if (!rtTimerIsValid(pTimer)) 159 137 return VERR_INVALID_HANDLE; … … 162 140 163 141 /* 164 * Calc when it should start fir eing.142 * Calc when it should start firing. 165 143 */ 166 u64First += RTTimeNanoTS();167 168 144 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); 171 146 172 mutex_enter(&cpu_lock);173 pTimer->CyclicID = cyclic_add(&pTimer->CyclicInfo, &timerSpec);174 mutex_exit(&cpu_lock);175 176 147 return VINF_SUCCESS; 177 148 } … … 189 160 */ 190 161 pTimer->fSuspended = true; 191 rtTimerSolarisStop(pTimer);162 vbi_timer_stop(pTimer->handle); 192 163 193 164 return VINF_SUCCESS; … … 195 166 196 167 197 static void rtTimerSolarisCallback(void *pvTimer)198 {199 PRTTIMER pTimer = (PRTTIMER)pvTimer;200 201 /* If this is a one shot timer, call pfnTimer and suspend202 * as Solaris does not support 0 interval timers implictly203 */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 227 168 228 169 RTDECL(uint32_t) RTTimerGetSystemGranularity(void) 229 170 { 230 return nsec_per_tick;171 return vbi_timer_granularity(); 231 172 } 232 173
Note:
See TracChangeset
for help on using the changeset viewer.