Changeset 27373 in vbox for trunk/src/VBox/Runtime/r0drv/solaris
- Timestamp:
- Mar 15, 2010 4:11:21 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/solaris/vbi/memobj-r0drv-solaris.c
r27115 r27373 77 77 case RTR0MEMOBJTYPE_CONT: 78 78 case RTR0MEMOBJTYPE_PHYS: 79 vbi_ contig_free(pMemSolaris->Core.pv, pMemSolaris->Core.cb);79 vbi_phys_free(pMemSolaris->Core.pv, pMemSolaris->Core.cb); 80 80 break; 81 81 82 82 case RTR0MEMOBJTYPE_PHYS_NC: 83 LogRel(("MemObjNativeFree virtAddr=%p physAddr=%#x cb=%u\n", pMemSolaris->Core.pv, vbi_va_to_pa(pMemSolaris->Core.pv), (unsigned)pMemSolaris->Core.cb)); 84 #if 0 83 85 vbi_phys_free(pMemSolaris->Core.pv, pMemSolaris->Core.cb); 86 #else 87 ddi_umem_free(pMemSolaris->Cookie); 88 #endif 84 89 break; 85 90 … … 173 178 return VERR_NO_MEMORY; 174 179 175 if (PhysHighest == NIL_RTHCPHYS)176 PhysHighest = UINT64_MAX - 1;177 178 180 /* Allocate physically non-contiguous page-aligned memory. */ 179 181 uint64_t physAddr = PhysHighest; 182 #if 0 180 183 caddr_t virtAddr = vbi_phys_alloc(&physAddr, cb, PAGE_SIZE, 0 /* non-contiguous */); 184 #else 185 caddr_t virtAddr = ddi_umem_alloc(cb, DDI_UMEM_SLEEP, &pMemSolaris->Cookie); 186 #endif 181 187 if (RT_UNLIKELY(virtAddr == NULL)) 182 188 { … … 190 196 pMemSolaris->pvHandle = NULL; 191 197 *ppMem = &pMemSolaris->Core; 198 LogRel(("ddi_umem_alloc virtAddr=%p physAddr=%#x cb=%u\n", virtAddr, physAddr, (unsigned)cb)); 192 199 return VINF_SUCCESS; 193 200 #else … … 202 209 AssertMsgReturn(PhysHighest >= 16 *_1M, ("PhysHigest=%RHp\n", PhysHighest), VERR_NOT_IMPLEMENTED); 203 210 204 /** @todo alignment, vbi currently assumes PAGE_SIZE not even less than PAGE_SIZE */ 211 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_PHYS, NULL, cb); 212 if (!pMemSolaris) 213 return VERR_NO_MEMORY; 214 215 AssertCompile(NIL_RTHCPHYS == UINT64_MAX); 216 217 /* Allocate physically contiguous memory aligned as specified. */ 218 uint64_t physAddr = PhysHighest; 219 caddr_t virtAddr = vbi_phys_alloc(&physAddr, cb, uAlignment, 1 /* contiguous */); 220 if (RT_UNLIKELY(virtAddr == NULL)) 221 { 222 rtR0MemObjDelete(&pMemSolaris->Core); 223 return VERR_NO_CONT_MEMORY; 224 } 225 Assert(!(physAddr & PAGE_OFFSET_MASK)); 226 Assert(physAddr < PhysHighest); 227 Assert(physAddr + cb <= PhysHighest); 228 #if 0 205 229 if (uAlignment != PAGE_SIZE) 206 return VERR_NOT_SUPPORTED; 207 208 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_CONT, NULL, cb); 209 if (!pMemSolaris) 210 return VERR_NO_MEMORY; 211 212 AssertCompile(NIL_RTHCPHYS == UINT64_MAX); 213 214 /* Allocate physically contiguous memory aligned as specified. */ 215 uint64_t physAddr = PhysHighest; 216 caddr_t virtAddr = vbi_phys_alloc(&physAddr, cb, uAlignment, 1 /* contiguous */); 217 if (RT_UNLIKELY(virtAddr == NULL)) 218 { 219 rtR0MemObjDelete(&pMemSolaris->Core); 220 return VERR_NO_CONT_MEMORY; 221 } 222 Assert(!(physAddr & PAGE_OFFSET_MASK)); 223 Assert(physAddr < PhysHighest); 224 Assert(physAddr + cb <= PhysHighest); 225 pMemSolaris->Core.pv = virtAddr; 226 pMemSolaris->Core.u.Cont.Phys = physAddr; 227 pMemSolaris->pvHandle = NULL; 228 *ppMem = &pMemSolaris->Core; 229 return VINF_SUCCESS; 230 { 231 /* uAlignment is always a multiple of PAGE_SIZE */ 232 pgcnt_t cPages = (cb + uAlignment - 1) >> PAGE_SHIFT; 233 void *pvPage = virtAddr; 234 while (cPages-- > 0) 235 { 236 uint64_t u64Page = vbi_va_to_pa(pvPage); 237 if (u64Page & (uAlignment - 1)) 238 { 239 LogRel(("rtR0MemObjNativeAllocPhys: alignment mismatch! cb=%u uAlignment=%u physAddr=%#x\n", cb, uAlignment, u64Page)); 240 vbi_phys_free(virtAddr, cb); 241 rtR0MemObjDelete(&pMemSolaris->Core); 242 return VERR_NO_MEMORY; 243 } 244 pvPage = (void *)((uintptr_t)pvPage + PAGE_SIZE); 245 } 246 } 247 #endif 248 pMemSolaris->Core.pv = virtAddr; 249 pMemSolaris->Core.u.Cont.Phys = physAddr; 250 pMemSolaris->pvHandle = NULL; 251 *ppMem = &pMemSolaris->Core; 252 return VINF_SUCCESS; 230 253 } 231 254
Note:
See TracChangeset
for help on using the changeset viewer.