Changeset 36485 in vbox
- Timestamp:
- Apr 1, 2011 5:04:35 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/rawpci.h
r36460 r36485 36 36 */ 37 37 typedef uint32_t PCIRAWDEVHANDLE; 38 39 /** 40 * Handle for the ISR. 41 */ 42 typedef uint32_t PCIRAWISRHANDLE; 38 43 39 44 /** … … 98 103 { 99 104 /* in */ 100 uint32_t PciAddress;101 uint32_t fFlags;105 uint32_t PciAddress; 106 uint32_t fFlags; 102 107 /* out */ 103 108 PCIRAWDEVHANDLE Device; … … 339 344 * Interrupt service routine callback. 340 345 * 341 * @param pvContext Opaque user data whichto the handler.346 * @param pvContext Opaque user data passed to the handler. 342 347 * @param iIrq Interrupt number. 343 348 */ … … 448 453 * @param pfnHandler Pointer to the handler. 449 454 * @param pIrqContext Context passed to the handler. 450 * @param p iHostIrq Which host IRQ is used.451 */ 452 DECLR0CALLBACKMEMBER(int, pfnRegisterIrqHandler,(PRAWPCIDEVPORT pPort,453 PFNRAWPCIISR pfnHandler,454 void* pIrqContext,455 int32_t *piHostIrq));455 * @param phIsr Handle for the ISR, . 456 */ 457 DECLR0CALLBACKMEMBER(int, pfnRegisterIrqHandler,(PRAWPCIDEVPORT pPort, 458 PFNRAWPCIISR pfnHandler, 459 void* pIrqContext, 460 PCIRAWISRHANDLE *phIsr)); 456 461 457 462 /** … … 459 464 * 460 465 * @param pPort Pointer to this structure. 461 * @param iHostIrq Which host IRQ was used(retured by earlier pfnRegisterIrqHandler).462 */ 463 DECLR0CALLBACKMEMBER(int, pfnUnregisterIrqHandler,(PRAWPCIDEVPORT pPort,464 int32_t iHostIrq));466 * @param hIsr Handle of ISR to unregister (retured by earlier pfnRegisterIrqHandler). 467 */ 468 DECLR0CALLBACKMEMBER(int, pfnUnregisterIrqHandler,(PRAWPCIDEVPORT pPort, 469 PCIRAWISRHANDLE hIsr)); 465 470 466 471 /** … … 479 484 } RAWPCIDEVPORT; 480 485 /** Version number for the RAWPCIDEVPORT::u32Version and RAWPCIIFPORT::u32VersionEnd fields. */ 481 #define RAWPCIDEVPORT_VERSION UINT32_C(0xAFBDCC0 1)486 #define RAWPCIDEVPORT_VERSION UINT32_C(0xAFBDCC02) 482 487 483 488 /** -
trunk/src/VBox/HostDrivers/VBoxPci/VBoxPci.c
r36460 r36485 189 189 int rc; 190 190 191 /* Bit racy, better check under lock. */192 if (pThis->iHostIrq != -1)193 {194 pPort->pfnUnregisterIrqHandler(pPort, pThis->iHostIrq);195 p This->iHostIrq = -1;196 }197 198 vboxPciDevLock(pThis);191 vboxPciDevLock(pThis); 192 193 if (pThis->IrqHandler.pfnIrqHandler) 194 { 195 pPort->pfnUnregisterIrqHandler(pPort, pThis->IrqHandler.iHostIrq); 196 pThis->IrqHandler.iHostIrq = -1; 197 pThis->IrqHandler.pfnIrqHandler = NULL; 198 } 199 199 200 200 rc = vboxPciOsDevDeinit(pThis, fFlags); … … 339 339 } 340 340 341 DECLHIDDEN(int) vboxPciDevRegisterIrqHandler(PRAWPCIDEVPORT pPort, PFNRAWPCIISR pfnHandler, void* pIrqContext, int32_t *piHostIrq) 342 { 343 PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); 344 int rc; 345 346 vboxPciDevLock(pThis); 347 348 pThis->pfnIrqHandler = pfnHandler; 349 pThis->pIrqContext = pIrqContext; 350 rc = vboxPciOsDevRegisterIrqHandler(pThis, pfnHandler, pIrqContext, piHostIrq); 351 if (RT_FAILURE(rc)) 352 { 353 pThis->pfnIrqHandler = NULL; 354 pThis->pIrqContext = NULL; 355 pThis->iHostIrq = -1; 356 *piHostIrq = -1; 341 DECLHIDDEN(int) vboxPciDevRegisterIrqHandler(PRAWPCIDEVPORT pPort, PFNRAWPCIISR pfnHandler, void* pIrqContext, PCIRAWISRHANDLE *phIsr) 342 { 343 PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); 344 int rc; 345 int32_t iHostIrq = 0; 346 347 if (pfnHandler == NULL) 348 return VERR_INVALID_PARAMETER; 349 350 vboxPciDevLock(pThis); 351 352 if (pThis->IrqHandler.pfnIrqHandler) 353 { 354 rc = VERR_ALREADY_EXISTS; 357 355 } 358 356 else 359 pThis->iHostIrq = *piHostIrq; 360 361 vboxPciDevUnlock(pThis); 362 363 return rc; 364 } 365 366 DECLHIDDEN(int) vboxPciDevUnregisterIrqHandler(PRAWPCIDEVPORT pPort, int32_t iHostIrq) 367 { 368 PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); 369 int rc; 370 371 vboxPciDevLock(pThis); 372 373 Assert(iHostIrq == pThis->iHostIrq); 374 rc = vboxPciOsDevUnregisterIrqHandler(pThis, iHostIrq); 357 { 358 rc = vboxPciOsDevRegisterIrqHandler(pThis, pfnHandler, pIrqContext, &iHostIrq); 359 if (RT_SUCCESS(rc)) 360 { 361 *phIsr = 0xcafe0000; 362 pThis->IrqHandler.iHostIrq = iHostIrq; 363 pThis->IrqHandler.pfnIrqHandler = pfnHandler; 364 pThis->IrqHandler.pIrqContext = pIrqContext; 365 } 366 } 367 368 vboxPciDevUnlock(pThis); 369 370 return rc; 371 } 372 373 DECLHIDDEN(int) vboxPciDevUnregisterIrqHandler(PRAWPCIDEVPORT pPort, PCIRAWISRHANDLE hIsr) 374 { 375 PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); 376 int rc; 377 378 if (hIsr != 0xcafe0000) 379 return VERR_INVALID_PARAMETER; 380 381 vboxPciDevLock(pThis); 382 383 rc = vboxPciOsDevUnregisterIrqHandler(pThis, pThis->IrqHandler.iHostIrq); 375 384 if (RT_SUCCESS(rc)) 376 385 { 377 pThis-> pfnIrqHandler = NULL;378 pThis-> pIrqContext = NULL;379 pThis-> iHostIrq = -1;386 pThis->IrqHandler.pfnIrqHandler = NULL; 387 pThis->IrqHandler.pIrqContext = NULL; 388 pThis->IrqHandler.iHostIrq = -1; 380 389 } 381 390 vboxPciDevUnlock(pThis); … … 393 402 rc = vboxPciOsDevPowerStateChange(pThis, aState); 394 403 395 if (aState == PCIRAW_POWER_ON) 396 { 397 /* 398 * Let virtual device know about VM caps. 399 */ 400 *pu64Param = VBOX_DRV_VMDATA(pThis)->pPerVmData->fVmCaps; 401 } 402 else 403 pu64Param = 0; 404 switch (aState) 405 { 406 case PCIRAW_POWER_ON: 407 /* 408 * Let virtual device know about VM caps. 409 */ 410 *pu64Param = VBOX_DRV_VMDATA(pThis)->pPerVmData->fVmCaps; 411 break; 412 default: 413 pu64Param = 0; 414 break; 415 } 404 416 405 417 … … 434 446 pNew->pNext = NULL; 435 447 pNew->HostPciAddress = u32HostAddress; 436 pNew->iHostIrq = -1;437 448 pNew->pVmCtx = pVmCtx; 438 449 -
trunk/src/VBox/HostDrivers/VBoxPci/VBoxPciInternal.h
r36484 r36485 27 27 28 28 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35) 29 //# ifdef DEBUG_nike 30 # define VBOX_WITH_IOMMU 31 //# endif 29 # define VBOX_WITH_IOMMU 32 30 #endif 33 31 … … 45 43 typedef struct VBOXRAWPCIDRVVM *PVBOXRAWPCIDRVVM; 46 44 typedef struct VBOXRAWPCIINS *PVBOXRAWPCIINS; 45 46 typedef struct VBOXRAWPCIISRDESC 47 { 48 /** Handler function. */ 49 PFNRAWPCIISR pfnIrqHandler; 50 /** Handler context. */ 51 void *pIrqContext; 52 /** Host IRQ. */ 53 int32_t iHostIrq; 54 } VBOXRAWPCIISRDESC; 55 typedef struct VBOXRAWPCIISRDESC *PVBOXRAWPCIISRDESC; 47 56 48 57 /** … … 77 86 bool fPad0; 78 87 79 /** Temporary: host IRQ we were given. Assumes single IRQ devices. */80 int32_t iHostIrq;81 82 88 /** Port, given to the outside world. */ 83 89 RAWPCIDEVPORT DevPort; 84 90 85 uint32_t cHandlersCount; 86 PFNRAWPCIISR pfnIrqHandler; 87 void *pIrqContext; 91 /** IRQ handler. */ 92 VBOXRAWPCIISRDESC IrqHandler; 88 93 94 /** Pointer to per-VM context in hypervisor data. */ 89 95 PRAWPCIPERVM pVmCtx; 90 96 } VBOXRAWPCIINS;
Note:
See TracChangeset
for help on using the changeset viewer.