⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adapter.cpp

📁 winddk src目录下的WDM源码压缩!
💻 CPP
📖 第 1 页 / 共 3 页
字号:
            detectedUart    = TRUE;
            detectedFmSynth = TRUE;
        }
        break;

    default:
        ntStatus = STATUS_DEVICE_CONFIGURATION_ERROR;
        break;
    }

    //
    // Build the resource list for the SB wave I/O.
    //
    *ResourceListWave = NULL;
    if (NT_SUCCESS(ntStatus))
    {
        ntStatus =
            PcNewResourceSublist
            (
                ResourceListWave,
                NULL,
                PagedPool,
                ResourceList,
                countDMA + countIRQ + 1
            );

        if (NT_SUCCESS(ntStatus))
        {
            ULONG i;

            //
            // Add the base address
            //
            ntStatus = (*ResourceListWave)->
                AddPortFromParent(ResourceList,0);

            //
            // Add the DMA channel(s).
            //
            if (NT_SUCCESS(ntStatus))
            {
                for (i = 0; i < countDMA; i++)
                {
                    ntStatus = (*ResourceListWave)->
                        AddDmaFromParent(ResourceList,i);
                }
            }

            //
            // Add the IRQ lines.
            //
            if (NT_SUCCESS(ntStatus))
            {
                for (i = 0; i < countIRQ; i++)
                {
                    SUCCEEDS((*ResourceListWave)->
                        AddInterruptFromParent(ResourceList,i));
                }
            }
        }
    }

    //
    // Build list of resources for wave table.
    //
    *ResourceListWaveTable = NULL;
    if (NT_SUCCESS(ntStatus) && detectedWaveTable)
    {
        //
        // TODO:  Assign wave table resources.
        //
    }

    //
    // Build list of resources for UART.
    //
    *ResourceListUart = NULL;
    if (NT_SUCCESS(ntStatus) && detectedUart)
    {
        ntStatus =
            PcNewResourceSublist
            (
                ResourceListUart,
                NULL,
                PagedPool,
                ResourceList,
                2
            );

        if (NT_SUCCESS(ntStatus))
        {
            ntStatus = (*ResourceListUart)->
                AddPortFromParent(ResourceList,1);
            
            if (NT_SUCCESS(ntStatus))
            {
                ntStatus = (*ResourceListUart)->
                    AddInterruptFromParent(ResourceList,0);
            }
        }
    }

    //
    // Build list of resources for FM synth.
    //
    *ResourceListFmSynth = NULL;
    if (NT_SUCCESS(ntStatus) && detectedFmSynth)
    {
        ntStatus =
            PcNewResourceSublist
            (
                ResourceListFmSynth,
                NULL,
                PagedPool,
                ResourceList,
                1
            );

        if (NT_SUCCESS(ntStatus))
        {
            ntStatus = (*ResourceListFmSynth)->
                AddPortFromParent(ResourceList,detectedUart ? 2 : 1);
        }
    }

    //
    // Build list of resources for the adapter.
    //
    *ResourceListAdapter = NULL;
    if (NT_SUCCESS(ntStatus))
    {
        ntStatus =
            PcNewResourceSublist
            (
                ResourceListAdapter,
                NULL,
                PagedPool,
                ResourceList,
                3
            );

        if (NT_SUCCESS(ntStatus))
        {
            //
            // The interrupt to share.
            //
            ntStatus = (*ResourceListAdapter)->
                AddInterruptFromParent(ResourceList,0);

            //
            // The base IO port (to tell who's interrupt it is)
            //
            if (NT_SUCCESS(ntStatus))
            {
                ntStatus = (*ResourceListAdapter)->
                    AddPortFromParent(ResourceList,0);
            }

            if (detectedUart && NT_SUCCESS(ntStatus))
            {
                //
                // The Uart port
                //
                ntStatus = (*ResourceListAdapter)->
                    AddPortFromParent(ResourceList,1);
            }
        }
    }

    //
    // Clean up if failure occurred.
    //
    if (! NT_SUCCESS(ntStatus))
    {
        if (*ResourceListWave)
        {
            (*ResourceListWave)->Release();
            *ResourceListWave = NULL;
        }
        if (*ResourceListWaveTable)
        {
            (*ResourceListWaveTable)->Release();
            *ResourceListWaveTable = NULL;
        }
        if (*ResourceListUart)
        {
            (*ResourceListUart)->Release();
            *ResourceListUart = NULL;
        }
        if (*ResourceListFmSynth)
        {
            (*ResourceListFmSynth)->Release();
            *ResourceListFmSynth = NULL;
        }
        if(*ResourceListAdapter)
        {
            (*ResourceListAdapter)->Release();
            *ResourceListAdapter = NULL;
        }
    }


    return ntStatus;
}

#ifdef DO_RESOURCE_FILTERING

/*****************************************************************************
 * AdapterDispatchPnp()
 *****************************************************************************
 * Supplying your PnP resource filtering needs.
 */
extern "C"
NTSTATUS
AdapterDispatchPnp
(
    IN      PDEVICE_OBJECT  pDeviceObject,
    IN      PIRP            pIrp
)
{
    PAGED_CODE();

    ASSERT(pDeviceObject);
    ASSERT(pIrp);

    NTSTATUS ntStatus = STATUS_SUCCESS;

    PIO_STACK_LOCATION pIrpStack =
        IoGetCurrentIrpStackLocation(pIrp);

    if( pIrpStack->MinorFunction == IRP_MN_FILTER_RESOURCE_REQUIREMENTS )
    {
        //
        // Do your resource requirements filtering here!!
        //
        _DbgPrintF(DEBUGLVL_VERBOSE,("[AdapterDispatchPnp] - IRP_MN_FILTER_RESOURCE_REQUIREMENTS"));

        // set the return status
        pIrp->IoStatus.Status = ntStatus;

    }

    //
    // Pass the IRPs on to PortCls
    //
    ntStatus = PcDispatchIrp( pDeviceObject,
                              pIrp );

    return ntStatus;
}

#endif


/*****************************************************************************
 * DeterminePlatform()
 *****************************************************************************
 * Figure out which WDM platform we are currently running on.
 * Note: the Port parameter could be WAVECYCLIC, WAVEPCI, DMUS or MIDI instead.
 *
 * TODO: Make this work on old DDK.
 *
 */
DWORD DeterminePlatform(PPORTTOPOLOGY Port)
{
    PAGED_CODE();
    ASSERT(Port);

    //
    // The generally accepted way of determining audio stack vintage:
    //
    PPORTCLSVERSION pPortClsVersion=NULL;
    PDRMPORT        pDrmPort=NULL;
    PPORTEVENTS     pPortEvents=NULL;
    DWORD           dwVersion;

    (void) Port->QueryInterface( IID_IPortClsVersion, (PVOID *) &pPortClsVersion);

    //
    //  Try for the exact release (Win98SE QFE3, WinME QFE, Win2KSP2, WinXP, or later).
    //
    if (pPortClsVersion)
    {
        dwVersion = pPortClsVersion->GetVersion();
        pPortClsVersion->Release();
        return dwVersion;
    } 
    
    (void) Port->QueryInterface( IID_IDrmPort,        (PVOID *) &pDrmPort);
       
    if (pDrmPort)    //  Try for WinME
    {
        dwVersion = kVersionWinME;
        ASSERT(IoIsWdmVersionAvailable(0x01,0x05));
        //
        //  TODO: Look for registry entries that denote WinME QFEs
        //  HKLM\Software\Microsoft\Windows\CurrentVersion\Setup\Updates\..., etc.
        //
        pDrmPort->Release();
        return dwVersion;

    } 
    
    //  Try for Win2K family.
    //  Note that SP1 contains no real audio stack changes, 
    //  while SP2 contains non-PCM support and other fixes.
    if (IoIsWdmVersionAvailable(0x01,0x10))    
    {                                                  
        //
        dwVersion = kVersionWin2K;
        //
        //  TODO: Detect whether SP1 or earlier.
        //
        return dwVersion;
    }
    //
    //  Must be Win98 or Win98SE.  
    //  IPortEvents was new in Win98SE.
    //
    (void) Port->QueryInterface( IID_IPortEvents,     (PVOID *) &pPortEvents);
    if (pPortEvents)
    {
        dwVersion = kVersionWin98SE; // or older QFEs
        //
        //  TODO: Look for registry entries that denote older Win98SE QFEs
        //  HKLM\Software\Microsoft\Windows\CurrentVersion\Setup\Updates\W98.SE\UPD\269601, etc.
        //
        pPortEvents->Release();
        return dwVersion;
    }
    //
    //  Process of elimination tells us it is Win98.
    //
    dwVersion = kVersionWin98;

    //
    //  TODO: Look for registry entries that denote older Win98 QFEs
    //  HKLM\Software\Microsoft\Windows\CurrentVersion\Setup\Updates\..., etc.
    // 
  
    return dwVersion;
}

#pragma code_seg()

/*****************************************************************************
 * _purecall()
 *****************************************************************************
 * The C++ compiler loves me.
 * TODO: Figure out how to put this into portcls.sys
 */
int __cdecl
_purecall( void )
{
    ASSERT( !"Pure virutal function called" );
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -