阅读:1509回复:0
请教AC97音频驱动问题
不明白下面这个结构体是什么作用,什么时候调用? MSDN中解释说CallSynchronizedRoutine函数是用来ISR和非ISR例程同步。
// Do nothing emulation of WDM InteruptSync interface // typedef LONG NTSTATUS; typedef NTSTATUS (*PINTERRUPTSYNCROUTINE) ( IN struct IInterruptSync_WinCeStub* InterruptSync, IN PVOID DynamicContext ); struct IInterruptSync_WinCeStub { STDMETHOD(CallSynchronizedRoutine)(PINTERRUPTSYNCROUTINE Routine, PVOID DynamicContext) { return Routine(NULL,DynamicContext); } }; typedef IInterruptSync_WinCeStub *PINTERRUPTSYNC; CES1371::CES1371 (void) { m_pInterruptSync = (IInterruptSync_WinCeStub*)new IInterruptSync_WinCeStub; m_fIsMapped = FALSE; m_refcount = 0; m_ulPowerState = 0; } Windows Driver Kit: Audio Devices IInterruptSync The IInterruptSync interface represents an interrupt sync object that synchronizes the execution of a list of interrupt service routines (ISRs) with non-ISR routines. In Windows 98/Me and in Windows 2000 and later, the PortCls system driver implements this interface and exposes it to the adapter driver. A miniport driver obtains a reference to an IInterruptSync object by calling the PortCls function PcNewInterruptSync, which creates a new IInterruptSync object that connects to an interrupt resource. IInterruptSync inherits from the IUnknown interface. The IInterruptSync::RegisterServiceRoutine method associates an ISR with a sync object. More than one ISR can be associated with a single sync object. When the interrupt occurs, the sync object executes the ISRs in the list in a specified order and manner according to the PcNewInterruptSync function's Mode parameter. Another facet of IInterruptSync is its ability to synchronize execution of ISRs with other routines that are not ISRs. Once a non-ISR routine is passed to IInterruptSync::CallSynchronizedRoutine and begins running, execution of any ISRs that are registered with the sync object is guaranteed to be held off until that routine has finished running. Both the RegisterServiceRoutine and CallSynchronizedRoutine methods accept function pointers of type PINTERRUPTSYNCROUTINE, which is defined as follows: typedef NTSTATUS (*PINTERRUPTSYNCROUTINE) ( IN struct IInterruptSync *InterruptSync, IN PVOID DynamicContext ); The InterruptSync member is a pointer to the sync object. The DynamicContext member contains a context value that is passed to the routine when it is called. ////// IInterruptSync::CallSynchronizedRoutine The CallSynchronizedRoutine method calls a routine that is not an interrupt service routine (ISR) but whose execution needs to be synchronized with ISRs. NTSTATUS CallSynchronizedRoutine( IN PINTERRUPTSYNCROUTINE Routine, IN PVOID DynamicContext )Parameters Routine Pointer to the routine that is to be called. This routine will run exclusive of the object's ISR and all other routines that are synchronized through the object. Even on multiple-processor machines, routines that are synchronized by a given object will not run concurrently. This parameter is a function pointer of type PINTERRUPTSYNCROUTINE (see IInterruptSync). DynamicContext A context value to be passed to the routine. Return Value CallSynchronizedRoutine returns STATUS_SUCCESS if the call was successful. Otherwise, the method returns an appropriate error code. |
|