コード例 #1
0
/******************************************************************
Registered procedure for filtering if resource requirement
Required when the device supports MSI, but the driver decides - will it work with MSI or not
(currently MSI is supported but does not work, exactly our case).
In this case the resource requirement list must be replaced - we need to remove from it
all the "message interrupt" resources.

When we are ready to work with MSI (VIRTIO_USE_MSIX_INTERRUPT is DEFINED),
we just enumerate allocated resources and do not modify them.
*******************************************************************/
static NDIS_STATUS ParaNdis6_FilterResource(IN NDIS_HANDLE  MiniportAddDeviceContext, IN PIRP  Irp)
{
    DPrintf(0, ("[%s] entered\n", __FUNCTION__));
    PIO_RESOURCE_REQUIREMENTS_LIST prrl = (PIO_RESOURCE_REQUIREMENTS_LIST)(PVOID)Irp->IoStatus.Information;

#ifdef DBG
    PrintPRRL(prrl);
#endif

    PIO_RESOURCE_REQUIREMENTS_LIST newPrrl = ParseFilterResourceIrp(MiniportAddDeviceContext, prrl, BOOLEAN(bDisableMSI));

        if (newPrrl)
        {
            Irp->IoStatus.Information = (ULONG_PTR)newPrrl;
            NdisFreeMemory(prrl, 0, 0);
#ifdef DBG
        PrintPRRL(newPrrl);
#endif
    }
    else
    {
        DPrintf(0, ("[%s] Resource requirement unchanged\n", __FUNCTION__));
    }
    return NDIS_STATUS_SUCCESS;
}
/******************************************************************
Registered procedure for filtering if resource requirement
Required when the device supports MSI, but the driver decides - will it work with MSI or not
(currently MSI is supported but does not work, exactly our case).
In this case the resource requirement list must be replaced - we need to remove from it
all the "message interrupt" resources.

When we are ready to work with MSI (VIRTIO_USE_MSIX_INTERRUPT is DEFINED),
we just enumerate allocated resources and do not modify them.
*******************************************************************/
static NDIS_STATUS ParaNdis6_FilterResource(IN NDIS_HANDLE  MiniportAddDeviceContext, IN PIRP  Irp)
{
    PIO_RESOURCE_REQUIREMENTS_LIST prrl = (PIO_RESOURCE_REQUIREMENTS_LIST)(PVOID)Irp->IoStatus.Information;
    if (bDisableMSI)
    {
        // traverse the resource requirements list, clean up all the MSI resources
        PIO_RESOURCE_REQUIREMENTS_LIST newPrrl = ParseFilterResourceIrp(MiniportAddDeviceContext, prrl, TRUE);
        if (newPrrl)
        {
            Irp->IoStatus.Information = (ULONG_PTR)newPrrl;
            NdisFreeMemory(prrl, 0, 0);
            DPrintf(resourceFilterLevel, ("[%s] Reparsing resources after filtering...\n", __FUNCTION__));
            // just parse and print after MSI cleanup, this time do not remove anything and do not reallocate the list
            ParseFilterResourceIrp(NULL, newPrrl, FALSE);
        }
    }
    else
    {
        // just parse and print, do not remove amything and do not reallocate the list
        ParseFilterResourceIrp(NULL, prrl, FALSE);
    }
    return NDIS_STATUS_SUCCESS;
}