Changeset 50482 in vbox for trunk/src/VBox/GuestHost
- Timestamp:
- Feb 17, 2014 3:23:05 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 92323
- Location:
- trunk/src/VBox/GuestHost/HGSMI
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/HGSMI/HGSMICommon.cpp
r44528 r50482 5 5 6 6 /* 7 * Copyright (C) 2006-201 2Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 189 189 } 190 190 191 void HGSMIHeapSetupUnitialized (HGSMIHEAP *pHeap) 192 { 193 pHeap->u.hPtr = NIL_RTHEAPSIMPLE; 194 pHeap->cRefs = 0; 195 pHeap->area.cbArea = 0; 196 pHeap->area.offBase = HGSMIOFFSET_VOID; 197 pHeap->area.offLast = HGSMIOFFSET_VOID; 198 pHeap->area.pu8Base = 0; 199 pHeap->fOffsetBased = false; 200 } 201 202 bool HGSMIHeapIsItialized (HGSMIHEAP *pHeap) 203 { 204 return pHeap->u.hPtr != NIL_RTHEAPSIMPLE; 191 void HGSMIHeapSetupUninitialized(HGSMIHEAP *pHeap) 192 { 193 RT_ZERO(*pHeap); 194 pHeap->u32HeapType = HGSMI_HEAP_TYPE_NULL; 205 195 } 206 196 207 197 int HGSMIHeapRelocate (HGSMIHEAP *pHeap, 198 uint32_t u32HeapType, 208 199 void *pvBase, 209 200 uint32_t offHeapHandle, … … 211 202 HGSMISIZE cbArea, 212 203 HGSMIOFFSET offBase, 213 bool fOffsetBased 214 ) 204 const HGSMIENV *pEnv) 215 205 { 216 206 if ( !pHeap … … 224 214 if (RT_SUCCESS (rc)) 225 215 { 226 if (fOffsetBased) 216 if (u32HeapType == HGSMI_HEAP_TYPE_MA) 217 { 218 /* @todo rc = HGSMIMAInit(&pHeap->u.ma, &pHeap->area, NULL, 0, 0, pEnv); */ 219 rc = VERR_NOT_IMPLEMENTED; 220 } 221 else if (u32HeapType == HGSMI_HEAP_TYPE_OFFSET) 222 { 227 223 pHeap->u.hOff = (RTHEAPOFFSET)((uint8_t *)pvBase + offHeapHandle); 228 else 224 } 225 else if (u32HeapType == HGSMI_HEAP_TYPE_POINTER) 229 226 { 230 227 pHeap->u.hPtr = (RTHEAPSIMPLE)((uint8_t *)pvBase + offHeapHandle); 231 228 rc = RTHeapSimpleRelocate (pHeap->u.hPtr, offDelta); AssertRC(rc); 232 229 } 233 if (RT_SUCCESS (rc)) 230 else 231 { 232 rc = VERR_NOT_SUPPORTED; 233 } 234 235 if (RT_SUCCESS(rc)) 234 236 { 235 237 pHeap->cRefs = 0; 236 pHeap-> fOffsetBased = fOffsetBased;238 pHeap->u32HeapType = u32HeapType; 237 239 } 238 240 else … … 246 248 247 249 int HGSMIHeapSetup (HGSMIHEAP *pHeap, 250 uint32_t u32HeapType, 248 251 void *pvBase, 249 252 HGSMISIZE cbArea, 250 253 HGSMIOFFSET offBase, 251 bool fOffsetBased)254 const HGSMIENV *pEnv) 252 255 { 253 256 if ( !pHeap … … 261 264 if (RT_SUCCESS (rc)) 262 265 { 263 if (!fOffsetBased) 266 if (u32HeapType == HGSMI_HEAP_TYPE_MA) 267 { 268 rc = HGSMIMAInit(&pHeap->u.ma, &pHeap->area, NULL, 0, 0, pEnv); 269 } 270 else if (u32HeapType == HGSMI_HEAP_TYPE_POINTER) 271 { 264 272 rc = RTHeapSimpleInit (&pHeap->u.hPtr, pvBase, cbArea); 273 } 274 else if (u32HeapType == HGSMI_HEAP_TYPE_OFFSET) 275 { 276 rc = RTHeapOffsetInit (&pHeap->u.hOff, pvBase, cbArea); 277 } 265 278 else 266 rc = RTHeapOffsetInit (&pHeap->u.hOff, pvBase, cbArea); 279 { 280 rc = VERR_NOT_SUPPORTED; 281 } 267 282 268 283 if (RT_SUCCESS (rc)) 269 284 { 270 285 pHeap->cRefs = 0; 271 pHeap-> fOffsetBased = fOffsetBased;286 pHeap->u32HeapType = u32HeapType; 272 287 } 273 288 else … … 284 299 if (pHeap) 285 300 { 301 if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_MA) 302 { 303 HGSMIMAUninit(&pHeap->u.ma); 304 } 286 305 Assert(!pHeap->cRefs); 287 pHeap->u.hPtr = NIL_RTHEAPSIMPLE; 288 HGSMIAreaClear (&pHeap->area); 289 pHeap->cRefs = 0; 306 HGSMIHeapSetupUninitialized(pHeap); 290 307 } 291 308 } … … 296 313 uint16_t u16ChannelInfo) 297 314 { 298 if (pHeap->u.hPtr == NIL_RTHEAPSIMPLE) 299 { 300 return NULL; 301 } 302 303 size_t cbAlloc = HGSMIBufferRequiredSize (cbData); 315 HGSMISIZE cbAlloc = HGSMIBufferRequiredSize (cbData); 304 316 305 317 HGSMIBUFFERHEADER *pHeader = (HGSMIBUFFERHEADER *)HGSMIHeapBufferAlloc (pHeap, cbAlloc); … … 326 338 { 327 339 if ( pvData 328 && pHeap->u .hPtr != NIL_RTHEAPSIMPLE)340 && pHeap->u32HeapType != HGSMI_HEAP_TYPE_NULL) 329 341 { 330 342 HGSMIBUFFERHEADER *pHeader = HGSMIBufferHeaderFromData (pvData); … … 336 348 void* HGSMIHeapBufferAlloc (HGSMIHEAP *pHeap, HGSMISIZE cbBuffer) 337 349 { 338 void* pvBuf; 339 if (!pHeap->fOffsetBased) 350 void* pvBuf = NULL; 351 if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_MA) 352 { 353 pvBuf = HGSMIMAAlloc(&pHeap->u.ma, cbBuffer); 354 } 355 else if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_POINTER) 356 { 340 357 pvBuf = RTHeapSimpleAlloc (pHeap->u.hPtr, cbBuffer, 0); 341 else 358 } 359 else if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_OFFSET) 360 { 342 361 pvBuf = RTHeapOffsetAlloc (pHeap->u.hOff, cbBuffer, 0); 343 344 if (!pvBuf) 345 return NULL; 346 347 ++pHeap->cRefs; 362 } 363 364 if (pvBuf) 365 { 366 ++pHeap->cRefs; 367 } 368 348 369 return pvBuf; 349 370 } 350 371 351 372 void HGSMIHeapBufferFree(HGSMIHEAP *pHeap, 352 void *pvBuf) 353 { 354 if (!pHeap->fOffsetBased) 373 void *pvBuf) 374 { 375 if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_MA) 376 { 377 HGSMIMAFree(&pHeap->u.ma, pvBuf); 378 } 379 else if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_POINTER) 380 { 355 381 RTHeapSimpleFree (pHeap->u.hPtr, pvBuf); 356 else 382 } 383 else if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_OFFSET) 384 { 357 385 RTHeapOffsetFree (pHeap->u.hOff, pvBuf); 386 } 358 387 359 388 --pHeap->cRefs; … … 377 406 } 378 407 379 const HGSMIBUFFERHEADER *pHeader = HGSMIOffsetToPointer (pArea, offBuffer);408 const HGSMIBUFFERHEADER *pHeader = (HGSMIBUFFERHEADER *)HGSMIOffsetToPointer (pArea, offBuffer); 380 409 381 410 /* Quick check of the data size, it should be less than the maximum -
trunk/src/VBox/GuestHost/HGSMI/Makefile.kmk
r41477 r50482 30 30 HGSMIGuestR0Lib_DEFS = 31 31 HGSMIGuestR0Lib_SOURCES = \ 32 HGSMICommon.cpp 32 HGSMICommon.cpp \ 33 HGSMIMemAlloc.cpp 33 34 endif 34 35 … … 40 41 HGSMIHostR3Lib_DEFS = 41 42 HGSMIHostR3Lib_SOURCES = \ 42 HGSMICommon.cpp 43 HGSMICommon.cpp \ 44 HGSMIMemAlloc.cpp 43 45 44 46 include $(FILE_KBUILD_SUB_FOOTER)
Note:
See TracChangeset
for help on using the changeset viewer.