Changeset 20471 in vbox
- Timestamp:
- Jun 10, 2009 5:11:49 PM (15 years ago)
- Location:
- trunk/src/VBox/Runtime/r0drv/solaris/vbi
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/os/vbi.c
r19998 r20471 20 20 */ 21 21 /* 22 * Copyright 200 8Sun Microsystems, Inc. All rights reserved.22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 23 * Use is subject to license terms. 24 24 */ … … 111 111 */ 112 112 static struct modlmisc vbi_modlmisc = { 113 &mod_miscops, "VirtualBox Interfaces V 4"113 &mod_miscops, "VirtualBox Interfaces V5" 114 114 }; 115 115 … … 199 199 }; 200 200 201 void *202 vbi_ contig_alloc(uint64_t *phys, size_t size)201 static void * 202 vbi_internal_alloc(uint64_t *phys, size_t size, int contig) 203 203 { 204 204 ddi_dma_attr_t attr; 205 205 pfn_t pfn; 206 206 void *ptr; 207 uint_t npages; 207 208 208 209 if ((size & PAGEOFFSET) != 0) 209 210 return (NULL); 211 npages = size >> PAGESHIFT; 212 if (npages == 0) 213 return (NULL); 210 214 211 215 attr = base_attr; 212 216 attr.dma_attr_addr_hi = *phys; 217 if (!contig) 218 attr.dma_attr_sgllen = npages; 213 219 ptr = contig_alloc(size, &attr, PAGESIZE, 1); 214 220 215 221 if (ptr == NULL) { 216 VBI_VERBOSE("vbi_ contig_alloc() failure");222 VBI_VERBOSE("vbi_internal_alloc() failure"); 217 223 return (NULL); 218 224 } … … 223 229 *phys = (uint64_t)pfn << PAGESHIFT; 224 230 return (ptr); 231 } 232 233 void * 234 vbi_contig_alloc(uint64_t *phys, size_t size) 235 { 236 return (vbi_internal_alloc(phys, size, 1)); 225 237 } 226 238 … … 1060 1072 } 1061 1073 1062 /* 1063 * This is revision 4 of the interface. As more functions are added, 1074 void 1075 vbi_poke_cpu(int c) 1076 { 1077 if (c < ncpus) 1078 poke_cpu(c); 1079 } 1080 1081 /* 1082 * This is revision 5 of the interface. As more functions are added, 1064 1083 * they should go after this point in the file and the revision level 1065 1084 * increased. Also change vbi_modlmisc at the top of the file. 1066 1085 */ 1067 uint_t vbi_revision_level = 4; 1068 1069 void 1070 vbi_poke_cpu(int c) 1071 { 1072 if (c < ncpus) 1073 poke_cpu(c); 1074 } 1086 uint_t vbi_revision_level = 5; 1087 1088 void * 1089 vbi_lowmem_alloc(uint64_t phys, size_t size) 1090 { 1091 return (vbi_internal_alloc(&phys, size, 0)); 1092 } 1093 1094 void 1095 vbi_lowmem_free(void *va, size_t size) 1096 { 1097 p_contig_free(va, size); 1098 } -
trunk/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/sys/vbi.h
r19496 r20471 310 310 /* end of interfaces defined for version 4 */ 311 311 312 /* begin interfaces defined for version 5 */ 313 /* 314 * Allocate and free physically limited, page aligned memory. Note that 315 * the allocated pages are not physically contiguous. 316 * 317 * return value is a) NULL if memory below "phys" not available or 318 * b) virtual address of memory in kernel heap 319 * 320 * phys on input is set to the upper boundary of acceptable memory 321 * 322 * size is the amount to allocate and must be a multiple of PAGESIZE 323 */ 324 extern void *vbi_lowmem_alloc(uint64_t phys, size_t size); 325 326 /* 327 * va is from vbi_lowmem_alloc() return value 328 * size must match from vbi_lowmem_alloc() 329 */ 330 extern void vbi_lowmem_free(void *va, size_t size); 331 /* end of interfaces defined for version 5 */ 332 312 333 #ifdef __cplusplus 313 334 } -
trunk/src/VBox/Runtime/r0drv/solaris/vbi/memobj-r0drv-solaris.c
r14824 r20471 69 69 switch (pMemSolaris->Core.enmType) 70 70 { 71 case RTR0MEMOBJTYPE_LOW: 72 vbi_lowmem_free(pMemSolaris->Core.pv, pMemSolaris->Core.cb); 73 break; 74 71 75 case RTR0MEMOBJTYPE_CONT: 72 76 vbi_contig_free(pMemSolaris->Core.pv, pMemSolaris->Core.cb); … … 86 90 87 91 /* unused */ 88 case RTR0MEMOBJTYPE_LOW:89 92 case RTR0MEMOBJTYPE_PHYS: 90 93 case RTR0MEMOBJTYPE_RES_VIRT: … … 121 124 int rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable) 122 125 { 123 /* Try page alloc first */ 124 int rc = rtR0MemObjNativeAllocPage(ppMem, cb, fExecutable); 125 if (RT_SUCCESS(rc)) 126 { 127 size_t iPage = cb >> PAGE_SHIFT; 128 while (iPage-- > 0) 129 if (rtR0MemObjNativeGetPagePhysAddr(*ppMem, iPage) > (_4G - PAGE_SIZE)) 130 { 131 /* Failed! Fall back to physical contiguous alloc */ 132 RTR0MemObjFree(*ppMem, false); 133 rc = rtR0MemObjNativeAllocCont(ppMem, cb, fExecutable); 134 break; 135 } 136 } 137 return rc; 126 NOREF(fExecutable); 127 128 /* Create the object */ 129 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_LOW, NULL, cb); 130 if (!pMemSolaris) 131 return VERR_NO_MEMORY; 132 133 /* Allocate physically low page-aligned memory. */ 134 caddr_t virtAddr; 135 uint64_t phys = (unsigned)0xffffffff; 136 virtAddr = vbi_lowmem_alloc(&phys, cb); 137 if (virtAddr == NULL) 138 { 139 rtR0MemObjDelete(&pMemSolaris->Core); 140 return VERR_NO_LOW_MEMORY; 141 } 142 Assert(phys < (uint64_t)1 << 32); 143 pMemSolaris->Core.pv = virtAddr; 144 pMemSolaris->handle = NULL; 145 *ppMem = &pMemSolaris->Core; 146 return VINF_SUCCESS; 138 147 } 139 148
Note:
See TracChangeset
for help on using the changeset viewer.