Changeset 27009 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Mar 4, 2010 10:49:38 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 58318
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/solaris/vbi/memobj-r0drv-solaris.c
r27003 r27009 45 45 #include "internal/memobj.h" 46 46 47 48 47 /******************************************************************************* 49 48 * Structures and Typedefs * … … 117 116 int rtR0MemObjNativeAllocPage(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable) 118 117 { 119 /* Create the object */118 /* Create the object. */ 120 119 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_PAGE, NULL, cb); 121 120 if (!pMemSolaris) … … 146 145 147 146 /* Allocate physically low page-aligned memory. */ 148 caddr_t virtAddr; 149 uint64_t phys = (unsigned)0xffffffff; 150 virtAddr = vbi_lowmem_alloc(phys, cb); 147 uint64_t physAddr = _4G - 1; 148 caddr_t virtAddr = vbi_lowmem_alloc(physAddr, cb); 151 149 if (virtAddr == NULL) 152 150 { … … 164 162 { 165 163 NOREF(fExecutable); 166 return rtR0MemObjNativeAllocPhys(ppMem, cb, (uint64_t)0xffffffff /* highest address */, PAGE_SIZE /* alignment */);164 return rtR0MemObjNativeAllocPhys(ppMem, cb, NIL_RTHCPHYS, PAGE_SIZE /* alignment */); 167 165 } 168 166 … … 176 174 177 175 if (PhysHighest == NIL_RTHCPHYS) 178 PhysHighest = (uint64_t)0xffffffff;176 PhysHighest = UINT64_MAX - 1; 179 177 180 178 /* Allocate physically non-contiguous page-aligned memory. */ 181 caddr_t virtAddr; 182 uint64_t phys = PhysHighest; 183 virtAddr = vbi_phys_alloc(&phys, cb, PAGE_SIZE, 0 /* non-contiguous */); 184 if (virtAddr == NULL) 185 { 186 rtR0MemObjDelete(&pMemSolaris->Core); 187 return VERR_NO_MEMORY; 188 } 189 Assert(phys < (uint64_t)1 << 32); 179 uint64_t physAddr = PhysHighest; 180 caddr_t virtAddr = vbi_phys_alloc(&physAddr, cb, PAGE_SIZE, 0 /* non-contiguous */); 181 if (RT_UNLIKELY(virtAddr == NULL)) 182 { 183 rtR0MemObjDelete(&pMemSolaris->Core); 184 return VERR_NO_MEMORY; 185 } 186 Assert(physAddr < UINT64_MAX); 190 187 pMemSolaris->Core.pv = virtAddr; 191 pMemSolaris->Core.u.Phys.PhysBase = phys ;188 pMemSolaris->Core.u.Phys.PhysBase = physAddr; 192 189 pMemSolaris->Core.u.Phys.fAllocated = true; 193 190 pMemSolaris->pvHandle = NULL; … … 209 206 return VERR_NOT_SUPPORTED; 210 207 211 if (PhysHighest == NIL_RTHCPHYS)212 PhysHighest = (uint64_t)0xffffffff;213 214 208 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_CONT, NULL, cb); 215 209 if (!pMemSolaris) 216 210 return VERR_NO_MEMORY; 217 211 212 if (PhysHighest == NIL_RTHCPHYS) 213 PhysHighest = UINT64_MAX - 1; 214 218 215 /* Allocate physically contiguous memory aligned as specified. */ 219 caddr_t virtAddr; 220 uint64_t phys = PhysHighest; 221 virtAddr = vbi_phys_alloc(&phys, cb, uAlignment, 1 /* contiguous */); 222 if (virtAddr == NULL) 216 uint64_t physAddr = PhysHighest; 217 caddr_t virtAddr = vbi_phys_alloc(&physAddr, cb, uAlignment, 1 /* contiguous */); 218 if (RT_UNLIKELY(virtAddr == NULL)) 223 219 { 224 220 rtR0MemObjDelete(&pMemSolaris->Core); 225 221 return VERR_NO_CONT_MEMORY; 226 222 } 227 Assert(phys < (uint64_t)1 << 32);223 Assert(physAddr < UINT64_MAX); 228 224 pMemSolaris->Core.pv = virtAddr; 229 pMemSolaris->Core.u.Cont.Phys = phys ;225 pMemSolaris->Core.u.Cont.Phys = physAddr; 230 226 pMemSolaris->pvHandle = NULL; 231 227 *ppMem = &pMemSolaris->Core; … … 236 232 int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb) 237 233 { 238 /* Create the object */234 /* Create the object. */ 239 235 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_PHYS, NULL, cb); 240 236 if (!pMemSolaris) 241 237 return VERR_NO_MEMORY; 242 238 243 /* There is no allocation here, it needs to be mapped somewhere first */239 /* There is no allocation here, it needs to be mapped somewhere first. */ 244 240 pMemSolaris->Core.u.Phys.fAllocated = false; 245 241 pMemSolaris->Core.u.Phys.PhysBase = Phys; … … 318 314 void *pv; 319 315 316 /* Create the object. */ 317 pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_RES_VIRT, pv, cb); 318 if (!pMemSolaris) 319 return VERR_NO_MEMORY; 320 320 321 /* 321 322 * Use xalloc. … … 323 324 pv = vmem_xalloc(heap_arena, cb, uAlignment, 0 /*phase*/, 0 /*nocross*/, 324 325 NULL /*minaddr*/, NULL /*maxaddr*/, VM_SLEEP); 325 if (!pv) 326 return VERR_NO_MEMORY; 327 pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_RES_VIRT, pv, cb); 328 if (!pMemSolaris) 329 { 330 vmem_xfree(heap_arena, pv, cb); 326 if (RT_UNLIKELY(!pv)) 327 { 328 rtR0MemObjDelete(&pMemSolaris->Core); 331 329 return VERR_NO_MEMORY; 332 330 }
Note:
See TracChangeset
for help on using the changeset viewer.