Changeset 1460 in vbox for trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp
- Timestamp:
- Mar 14, 2007 3:45:32 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp
r394 r1460 81 81 switch (pMemDarwin->Core.enmType) 82 82 { 83 case RTR0MEMOBJTYPE_LOW: 83 84 case RTR0MEMOBJTYPE_PAGE: 84 85 IOFreeAligned(pMemDarwin->Core.pv, pMemDarwin->Core.cb); 85 86 break; 86 87 /*case RTR0MEMOBJTYPE_LOW: => RTR0MEMOBJTYPE_CONT88 break;*/89 87 90 88 case RTR0MEMOBJTYPE_CONT: … … 168 166 int rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable) 169 167 { 168 #if 1 169 /* 170 * Allocating 128KB for the low page pool can bit a bit exhausting on the kernel, 171 * it frequnetly causes the entire box to lock up on startup. 172 * 173 * So, try allocate the memory using IOMallocAligned first and if we get any high 174 * physical memory we'll release it and fall back on IOMAllocContiguous. 175 */ 176 int rc = VERR_NO_PAGE_MEMORY; 177 AssertCompile(sizeof(IOPhysicalAddress) == 4); 178 void *pv = IOMallocAligned(cb, PAGE_SIZE); 179 if (pv) 180 { 181 IOMemoryDescriptor *pMemDesc = IOMemoryDescriptor::withAddress((vm_address_t)pv, cb, kIODirectionInOut, kernel_task); 182 if (pMemDesc) 183 { 184 /* 185 * Check if it's all below 4GB. 186 */ 187 for (IOByteCount off = 0; off < cb; off += PAGE_SIZE) 188 { 189 addr64_t Addr = pMemDesc->getPhysicalSegment64(off, NULL); 190 if (Addr > (uint32_t)(_4G - PAGE_SIZE)) 191 { 192 /* Ok, we failed, fall back on contiguous allocation. */ 193 pMemDesc->release(); 194 IOFreeAligned(pv, cb); 195 return rtR0MemObjNativeAllocCont(ppMem, cb, fExecutable); 196 } 197 } 198 199 /* 200 * Create the IPRT memory object. 201 */ 202 PRTR0MEMOBJDARWIN pMemDarwin = (PRTR0MEMOBJDARWIN)rtR0MemObjNew(sizeof(*pMemDarwin), RTR0MEMOBJTYPE_LOW, pv, cb); 203 if (pMemDarwin) 204 { 205 pMemDarwin->pMemDesc = pMemDesc; 206 *ppMem = &pMemDarwin->Core; 207 return VINF_SUCCESS; 208 } 209 210 rc = VERR_NO_MEMORY; 211 pMemDesc->release(); 212 } 213 else 214 rc = VERR_MEMOBJ_INIT_FAILED; 215 IOFreeAligned(pv, cb); 216 } 217 return rc; 218 219 #else 220 170 221 /* 171 222 * IOMallocContiguous is the most suitable API. 172 223 */ 173 224 return rtR0MemObjNativeAllocCont(ppMem, cb, fExecutable); 225 #endif 174 226 } 175 227 … … 289 341 290 342 /* 291 * Just in case IOMallocContigu s doesn't work right, we can try fall back343 * Just in case IOMallocContiguous doesn't work right, we can try fall back 292 344 * on a contiguous allcation. 293 345 */
Note:
See TracChangeset
for help on using the changeset viewer.