Changeset 81909 in vbox for trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp
- Timestamp:
- Nov 17, 2019 6:23:56 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp
r81850 r81909 3678 3678 3679 3679 /** @interface_method_impl{PDMDEVHLPR3,pfnPICRegister} */ 3680 static DECLCALLBACK(int) pdmR3DevHlp_PICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP R3 *ppPicHlpR3)3680 static DECLCALLBACK(int) pdmR3DevHlp_PICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp) 3681 3681 { 3682 3682 PDMDEV_ASSERT_DEVINS(pDevIns); 3683 3683 VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3); 3684 LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: pPicReg=%p:{.u32Version=%#x, .pfnSetIrqR3=%p, .pfnGetInterruptR3=%p, .pszGetIrqRC=%p:{%s}, .pszGetInterruptRC=%p:{%s}, .pszGetIrqR0=%p:{%s}, .pszGetInterruptR0=%p:{%s} } ppPicHlpR3=%p\n", 3685 pDevIns->pReg->szName, pDevIns->iInstance, pPicReg, pPicReg->u32Version, pPicReg->pfnSetIrqR3, pPicReg->pfnGetInterruptR3, 3686 pPicReg->pszSetIrqRC, pPicReg->pszSetIrqRC, pPicReg->pszGetInterruptRC, pPicReg->pszGetInterruptRC, 3687 pPicReg->pszSetIrqR0, pPicReg->pszSetIrqR0, pPicReg->pszGetInterruptR0, pPicReg->pszGetInterruptR0, 3688 ppPicHlpR3)); 3684 LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: pPicReg=%p:{.u32Version=%#x, .pfnSetIrqR3=%p, .pfnGetInterruptR3=%p, .pszGetIrqRC=%p:{%s}, .pszGetInterruptRC=%p:{%s}, .pszGetIrqR0=%p:{%s}, .pszGetInterruptR0=%p:{%s} } ppPicHlp=%p\n", 3685 pDevIns->pReg->szName, pDevIns->iInstance, pPicReg, pPicReg->u32Version, pPicReg->pfnSetIrq, pPicReg->pfnGetInterrupt, ppPicHlp)); 3686 PVM pVM = pDevIns->Internal.s.pVMR3; 3689 3687 3690 3688 /* 3691 3689 * Validate input. 3692 3690 */ 3693 if (pPicReg->u32Version != PDM_PICREG_VERSION) 3694 { 3695 AssertMsgFailed(("u32Version=%#x expected %#x\n", pPicReg->u32Version, PDM_PICREG_VERSION)); 3696 LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (version)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); 3697 return VERR_INVALID_PARAMETER; 3698 } 3699 if ( !pPicReg->pfnSetIrqR3 3700 || !pPicReg->pfnGetInterruptR3) 3701 { 3702 Assert(pPicReg->pfnSetIrqR3); 3703 Assert(pPicReg->pfnGetInterruptR3); 3704 LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (R3 callbacks)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); 3705 return VERR_INVALID_PARAMETER; 3706 } 3707 if ( ( pPicReg->pszSetIrqRC 3708 || pPicReg->pszGetInterruptRC) 3709 && ( !VALID_PTR(pPicReg->pszSetIrqRC) 3710 || !VALID_PTR(pPicReg->pszGetInterruptRC)) 3711 ) 3712 { 3713 Assert(VALID_PTR(pPicReg->pszSetIrqRC)); 3714 Assert(VALID_PTR(pPicReg->pszGetInterruptRC)); 3715 LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (RC callbacks)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); 3716 return VERR_INVALID_PARAMETER; 3717 } 3718 if ( pPicReg->pszSetIrqRC 3719 && !(pDevIns->pReg->fFlags & PDM_DEVREG_FLAGS_RC)) 3720 { 3721 Assert(pDevIns->pReg->fFlags & PDM_DEVREG_FLAGS_RC); 3722 LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (RC flag)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); 3723 return VERR_INVALID_PARAMETER; 3724 } 3725 if ( pPicReg->pszSetIrqR0 3726 && !(pDevIns->pReg->fFlags & PDM_DEVREG_FLAGS_R0)) 3727 { 3728 Assert(pDevIns->pReg->fFlags & PDM_DEVREG_FLAGS_R0); 3729 LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (R0 flag)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); 3730 return VERR_INVALID_PARAMETER; 3731 } 3732 if (!ppPicHlpR3) 3733 { 3734 Assert(ppPicHlpR3); 3735 LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (ppPicHlpR3)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); 3736 return VERR_INVALID_PARAMETER; 3737 } 3691 AssertMsgReturn(pPicReg->u32Version == PDM_PICREG_VERSION, 3692 ("%s/%d: u32Version=%#x expected %#x\n", pDevIns->pReg->szName, pDevIns->iInstance, pPicReg->u32Version, PDM_PICREG_VERSION), 3693 VERR_INVALID_PARAMETER); 3694 AssertPtrReturn(pPicReg->pfnSetIrq, VERR_INVALID_POINTER); 3695 AssertPtrReturn(pPicReg->pfnGetInterrupt, VERR_INVALID_POINTER); 3696 AssertMsgReturn(pPicReg->u32TheEnd == PDM_PICREG_VERSION, 3697 ("%s/%d: u32TheEnd=%#x expected %#x\n", pDevIns->pReg->szName, pDevIns->iInstance, pPicReg->u32TheEnd, PDM_PICREG_VERSION), 3698 VERR_INVALID_PARAMETER); 3699 AssertPtrReturn(ppPicHlp, VERR_INVALID_POINTER); 3700 3701 VM_ASSERT_STATE_RETURN(pVM, VMSTATE_CREATING, VERR_WRONG_ORDER); 3702 VM_ASSERT_EMT0_RETURN(pVM, VERR_VM_THREAD_NOT_EMT); 3738 3703 3739 3704 /* 3740 3705 * Only one PIC device. 3741 3706 */ 3742 PVM pVM = pDevIns->Internal.s.pVMR3; 3743 if (pVM->pdm.s.Pic.pDevInsR3) 3744 { 3745 AssertMsgFailed(("Only one pic device is supported!\n")); 3746 LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); 3747 return VERR_INVALID_PARAMETER; 3748 } 3749 3750 /* 3751 * RC stuff. 3752 */ 3753 if (pPicReg->pszSetIrqRC) 3754 { 3755 int rc = pdmR3DevGetSymbolRCLazy(pDevIns, pPicReg->pszSetIrqRC, &pVM->pdm.s.Pic.pfnSetIrqRC); 3756 AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pReg->pszRCMod, pPicReg->pszSetIrqRC, rc)); 3757 if (RT_SUCCESS(rc)) 3758 { 3759 rc = pdmR3DevGetSymbolRCLazy(pDevIns, pPicReg->pszGetInterruptRC, &pVM->pdm.s.Pic.pfnGetInterruptRC); 3760 AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pReg->pszRCMod, pPicReg->pszGetInterruptRC, rc)); 3761 } 3762 if (RT_FAILURE(rc)) 3763 { 3764 LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc)); 3765 return rc; 3766 } 3767 pVM->pdm.s.Pic.pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 3768 } 3769 else 3770 { 3771 pVM->pdm.s.Pic.pDevInsRC = 0; 3772 pVM->pdm.s.Pic.pfnSetIrqRC = 0; 3773 pVM->pdm.s.Pic.pfnGetInterruptRC = 0; 3774 } 3775 3776 /* 3777 * R0 stuff. 3778 */ 3779 if (pPicReg->pszSetIrqR0) 3780 { 3781 int rc = pdmR3DevGetSymbolR0Lazy(pDevIns, pPicReg->pszSetIrqR0, &pVM->pdm.s.Pic.pfnSetIrqR0); 3782 AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pReg->pszR0Mod, pPicReg->pszSetIrqR0, rc)); 3783 if (RT_SUCCESS(rc)) 3784 { 3785 rc = pdmR3DevGetSymbolR0Lazy(pDevIns, pPicReg->pszGetInterruptR0, &pVM->pdm.s.Pic.pfnGetInterruptR0); 3786 AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pReg->pszR0Mod, pPicReg->pszGetInterruptR0, rc)); 3787 } 3788 if (RT_FAILURE(rc)) 3789 { 3790 LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc)); 3791 return rc; 3792 } 3793 pVM->pdm.s.Pic.pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 3794 Assert(pVM->pdm.s.Pic.pDevInsR0); 3795 } 3796 else 3797 { 3798 pVM->pdm.s.Pic.pfnSetIrqR0 = 0; 3799 pVM->pdm.s.Pic.pfnGetInterruptR0 = 0; 3800 pVM->pdm.s.Pic.pDevInsR0 = 0; 3801 } 3802 3803 /* 3804 * R3 stuff. 3707 AssertMsgReturn(pVM->pdm.s.Pic.pDevInsR3 == NULL, ("%s/%d: Only one PIC!\n", pDevIns->pReg->szName, pDevIns->iInstance), 3708 VERR_ALREADY_EXISTS); 3709 3710 /* 3711 * Take down the callbacks and instance. 3805 3712 */ 3806 3713 pVM->pdm.s.Pic.pDevInsR3 = pDevIns; 3807 pVM->pdm.s.Pic.pfnSetIrqR3 = pPicReg->pfnSetIrq R3;3808 pVM->pdm.s.Pic.pfnGetInterruptR3 = pPicReg->pfnGetInterrupt R3;3714 pVM->pdm.s.Pic.pfnSetIrqR3 = pPicReg->pfnSetIrq; 3715 pVM->pdm.s.Pic.pfnGetInterruptR3 = pPicReg->pfnGetInterrupt; 3809 3716 Log(("PDM: Registered PIC device '%s'/%d pDevIns=%p\n", pDevIns->pReg->szName, pDevIns->iInstance, pDevIns)); 3810 3717 3811 3718 /* set the helper pointer and return. */ 3812 *ppPicHlp R3= &g_pdmR3DevPicHlp;3719 *ppPicHlp = &g_pdmR3DevPicHlp; 3813 3720 LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, VINF_SUCCESS)); 3814 3721 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.