Changeset 4038 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Aug 4, 2007 10:50:29 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c
r3977 r4038 66 66 67 67 68 MALLOC_DEFINE(M_IPRTMOBJ, "iprtmobj", "innotek Portable Runtime - R0MemObj"); 69 68 70 /******************************************************************************* 69 71 * Internal Functions * … … 78 80 switch (pMemFreeBSD->Core.enmType) 79 81 { 82 case RTR0MEMOBJTYPE_CONT: 83 contigfree(pMemFreeBSD->Core.pv, pMemFreeBSD->Core.cb, M_IPRTCONT); 84 break; 85 86 #if 0 80 87 case RTR0MEMOBJTYPE_PHYS: 81 if (!pMemFreeBSD->Core.pv) 82 break; 88 //if (!pMemFreeBSD->Core.pv) 89 // break; 90 break 83 91 84 92 case RTR0MEMOBJTYPE_MAPPING: 85 if (pMemFreeBSD->Core.u.Mapping.R0Process == NIL_RTR0PROCESS)86 break;87 88 /* fall thru */93 //if (pMemFreeBSD->Core.u.Mapping.R0Process == NIL_RTR0PROCESS) 94 // break; 95 break; 96 89 97 case RTR0MEMOBJTYPE_PAGE: 90 98 case RTR0MEMOBJTYPE_LOW: 91 case RTR0MEMOBJTYPE_CONT:92 99 //rc = KernVMFree(pMemFreeBSD->Core.pv); 93 100 //AssertMsg(!rc, ("rc=%d type=%d pv=%p cb=%#zx\n", rc, pMemFreeBSD->Core.enmType, pMemFreeBSD->Core.pv, pMemFreeBSD->Core.cb)); … … 100 107 101 108 case RTR0MEMOBJTYPE_RES_VIRT: 109 #endif 102 110 default: 103 111 AssertMsgFailed(("enmType=%d\n", pMemFreeBSD->Core.enmType)); … … 111 119 int rtR0MemObjNativeAllocPage(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable) 112 120 { 113 NOREF(fExecutable); 114 115 #if 0 121 /* malloc or like the linker: http://fxr.watson.org/fxr/source/kern/link_elf.c?v=RELENG62#L701 */ 122 #if 0 116 123 /* create the object. */ 117 124 const ULONG cPages = cb >> PAGE_SHIFT; 118 PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew( RT_OFFSETOF(RTR0MEMOBJOS2, aPages[cPages]), RTR0MEMOBJTYPE_PAGE, NULL, cb);125 PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew(sizeof(*pMemFreeBSD), RTR0MEMOBJTYPE_PAGE, NULL, cb); 119 126 if (!pMemFreeBSD) 120 127 return VERR_NO_MEMORY; … … 135 142 } 136 143 rtR0MemObjDelete(&pMemFreeBSD->Core); 144 NOREF(fExecutable); 137 145 return RTErrConvertFromOS2(rc); 138 #endif 139 return VERR_NOT_IMPLEMENTED; 146 #else 147 return VERR_NOT_IMPLEMENTED; 148 #endif 140 149 } 141 150 … … 143 152 int rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable) 144 153 { 154 /* same as Alloc and hope we're lucky, make sure to verify the physical addresses */ 145 155 NOREF(fExecutable); 146 156 … … 175 185 int rtR0MemObjNativeAllocCont(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable) 176 186 { 177 NOREF(fExecutable);178 179 #if 0180 187 /* create the object. */ 181 PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew( RT_OFFSETOF(RTR0MEMOBJOS2, Lock), RTR0MEMOBJTYPE_CONT, NULL, cb);188 PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew(sizeof(*pMemFreeBSD), RTR0MEMOBJTYPE_CONT, NULL, cb); 182 189 if (!pMemFreeBSD) 183 190 return VERR_NO_MEMORY; 184 191 185 192 /* do the allocation. */ 186 ULONG ulPhys = ~0UL; 187 int rc = KernVMAlloc(cb, VMDHA_FIXED | VMDHA_CONTIG, &pMemFreeBSD->Core.pv, (PPVOID)&ulPhys, NULL); 188 if (!rc) 189 { 190 Assert(ulPhys != ~0UL); 191 pMemFreeBSD->Core.u.Cont.Phys = ulPhys; 193 pMemFreeBSD->Core.pv = contigmalloc(cb, /* size */ 194 M_IPRTMOBJ, /* type */ 195 M_NOWAIT | M_ZERO, /* flags */ 196 0, /* lowest physical address*/ 197 _4G-1, /* highest physical address */ 198 PAGE_SIZE, /* alignment. */ 199 0); /* boundrary */ 200 if (pMemFreeBSD->Core.pv) 201 { 202 pMemFreeBSD->Core.u.Cont.Phys = vtophys(pMemFreeBSD->Core.pv); 192 203 *ppMem = &pMemFreeBSD->Core; 193 204 return VINF_SUCCESS; 194 205 } 206 207 NOREF(fExecutable); 195 208 rtR0MemObjDelete(&pMemFreeBSD->Core); 196 return RTErrConvertFromOS2(rc); 197 #endif 198 return VERR_NOT_IMPLEMENTED; 209 return VERR_NO_MEMORY; 199 210 } 200 211 … … 230 241 int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb) 231 242 { 232 #if 0233 243 /* create the object. */ 234 PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew( RT_OFFSETOF(RTR0MEMOBJOS2, Lock), RTR0MEMOBJTYPE_PHYS, NULL, cb);235 if (!pMemFreeBSD) 236 return VERR_NO_MEMORY; 237 238 /* there is no allocation here, right?it needs to be mapped somewhere first. */244 PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew(sizeof(*pMemFreeBSD), RTR0MEMOBJTYPE_PHYS, NULL, cb); 245 if (!pMemFreeBSD) 246 return VERR_NO_MEMORY; 247 248 /* there is no allocation here, it needs to be mapped somewhere first. */ 239 249 pMemFreeBSD->Core.u.Phys.fAllocated = false; 240 250 pMemFreeBSD->Core.u.Phys.PhysBase = Phys; 241 251 *ppMem = &pMemFreeBSD->Core; 242 252 return VINF_SUCCESS; 243 #endif244 return VERR_NOT_IMPLEMENTED;245 253 } 246 254 … … 248 256 int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, RTR0PROCESS R0Process) 249 257 { 258 /* see vslock and vsunlock */ 250 259 #if 0 251 260 AssertMsgReturn(R0Process == RTR0ProcHandleSelf(), ("%p != %p\n", R0Process, RTR0ProcHandleSelf()), VERR_NOT_SUPPORTED); … … 304 313 int rtR0MemObjNativeReserveKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment) 305 314 { 315 /* see kmem_alloc_nofault */ 306 316 return VERR_NOT_IMPLEMENTED; 307 317 } … … 310 320 int rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process) 311 321 { 322 /* see kmem_alloc_nofault */ 312 323 return VERR_NOT_IMPLEMENTED; 313 324 } … … 318 329 AssertMsgReturn(pvFixed == (void *)-1, ("%p\n", pvFixed), VERR_NOT_SUPPORTED); 319 330 331 /* Phys: see pmap_mapdev in i386/i386/pmap.c (http://fxr.watson.org/fxr/source/i386/i386/pmap.c?v=RELENG62#L2860) */ 332 320 333 #if 0 321 334 /** @todo finish the implementation. */
Note:
See TracChangeset
for help on using the changeset viewer.