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

📄 interrup.c

📁 这是一个56K MODEM的驱动程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************\
|* Copyright (c) 1994  Microsoft Corporation                               *|
|* Developed for Microsoft by TriplePoint, Inc. Beaverton, Oregon          *|
|*                                                                         *|
|* This file is part of the HT Communications DSU41 WAN Miniport Driver.   *|
\***************************************************************************/
#include "version.h"
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Module Name:

    interrup.c

Abstract:

    This module contains the Miniport interrupt processing routines:
        MiniportCheckForHang()
        MiniportDisableInterrupt()
        MiniportEnableInterrupt()
        MiniportISR()
        MiniportHandleInterrupt()

    This driver conforms to the NDIS 3.0 Miniport interface.

Author:

    Larry Hattery - TriplePoint, Inc. (larryh@tpi.com) Jun-94

Environment:

    Windows NT 3.5 kernel mode Miniport driver or equivalent.

Revision History:

---------------------------------------------------------------------------*/

#define  __FILEID__     3       // Unique file ID for error logging

#include "htdsu.h"


BOOLEAN
HtDsuCheckForHang(
    IN PHTDSU_ADAPTER Adapter
    )

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Functional Description:

    The MiniportCheckForHang request is used by the wrapper to periodically
    have the miniport check if the adapter appears hung.

    The Miniport driver should do nothing more than check the internal state
    and return if the adapter is hung.  The wrapper will then attempt to
    recover the adapter by calling MiniportReset.

    This routine will be called once every two seconds.

    Interrupts will be in any state when called.

Parameters:

    MiniportAdapterContext _ The handle returned from MiniportInitialize.

Return Values:

    TRUE if the driver believes that the underlying hardware is hung,
    FALSE otherwise.

---------------------------------------------------------------------------*/

{
    return (Adapter->NeedReset);
}


VOID
HtDsuDisableInterrupt(
    IN PHTDSU_ADAPTER Adapter
    )

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Functional Description:

    The MiniportDisableInterrupt request is used to disable the adapter
    from generating any interrupts.  Typically this is done by writing a
    mask which disables the adapter from generating hardware interrupts.

    If the underlying hardware does not support enabling and disabling
    interrupts, the Miniport driver will have to register a MiniportISR
    with the wrapper, and the Miniport driver will have to acknowledge
    and save the interrupt information from within the interrupt service
    routine.

    This routine may be called any time interrupts are enabled.  If the
    underlying hardware is required to be in a certain state for this
    routine to execute correctly, the Miniport driver must encapsulate
    all portions of the driver which violate the state and which may be
    called when interrupts are enabled, with a function and call the
    function through the NdisMSynchronizeWithInterrupt service.

    Interrupts will be in any state when called.

Parameters:

    MiniportAdapterContext _ The adapter handle passed to NdisMSetAttributes
                             during MiniportInitialize.

Return Values:

    None.

---------------------------------------------------------------------------*/

{
    DBG_FUNC("HtDsuDisableInterrupt")

    /*
    // Save the current interrupt status on the card.
    */
    USHORT InterruptStatus = CardGetInterrupt(Adapter);

//  DBG_ENTER(Adapter);

    /*
    // Disable the interrupt at the card after saving the current state
    // of the InterruptStatus register -- which will be reset by the clear
    // interrupt command.
    */
    Adapter->InterruptStatusFlag |= InterruptStatus;
    CardClearInterrupt(Adapter);
    CardDisableInterrupt(Adapter);

    DBG_NOTICE(Adapter, ("IntrStatus=%Xh LineStatus=%Xh\n",
               InterruptStatus,
               READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine1)
               ));

//  DBG_LEAVE(Adapter);
}


VOID
HtDsuEnableInterrupt(
    IN PHTDSU_ADAPTER Adapter
    )

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Functional Description:

    The MiniportEnableInterrupt request is used to enable the adapter for
    generating any interrupts.  Typically this is done by writing a mask
    which will reenable adapter interrupts.

    If the underlying hardware does not support enabling and disabling
    interrupts, the Miniport driver will have to register a MiniportISR
    with the wrapper, and the Miniport driver will have to acknowledge
    and save the interrupt information from within the interrupt service
    routine.

    Interrupts will be in any state when called.

Parameters:

    MiniportAdapterContext _ The adapter handle passed to NdisMSetAttributes
                             during MiniportInitialize.

Return Values:

    None.

---------------------------------------------------------------------------*/

{
    DBG_FUNC("HtDsuEnableInterrupt")

    /*
    // Save the current interrupt status on the card.
    */
    USHORT InterruptStatus = CardGetInterrupt(Adapter);

//  DBG_ENTER(Adapter);

    CardEnableInterrupt(Adapter);

    DBG_NOTICE(Adapter, ("IntrStatus=%Xh LineStatus=%Xh\n",
               InterruptStatus,
               READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine1)
               ));

//  DBG_LEAVE(Adapter);
}



VOID
HtDsuISR(
    OUT PBOOLEAN InterruptRecognized,
    OUT PBOOLEAN QueueMiniportHandleInterrupt,
    IN PHTDSU_ADAPTER Adapter
    )

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Functional Description:

    The MiniportISR request is called if the adapter generates an
    interrupt when there is an outstanding call to MiniportInitialize
    or to MiniportReconfigure, if the Miniport driver supports sharing
    its interrupt line with another adapter, or if the Miniport driver
    specifies that the routine must be called for every interrupt (See
    NdisMRegisterInterrupt's RequestIsr and SharedInterrupt parameters).

    This routine runs immediately after an interrupt, at very high priority,
    and is subject to all the limitations of the interrupt service routine
    in the NDIS 3.0 specification.  The driver should do as little work as
    possible in this routine.  It should return TRUE in the parameter
    InterruptRecognized if it recognizes the interrupt as belonging to its
    adapter, or FALSE otherwise.  It should return TRUE in the parameter
    QueueMiniportHandleInterrupt if it needs a call to MiniportHandleInterrupt
    at a lower priority to complete the handling of the interrupt, or FALSE
    otherwise.

    Note that a Dpc will not be queued if the Miniport is currently executing
    in any of the following routines: MiniportHalt, MiniportInitialize,
    MiniportReconfigure.

Parameters:

    InterruptRecognized _ If the Miniport is sharing an interrupt line, it
                          should set this parameter to TRUE if the Miniport
                          driver recognizes that the interrupt came from the
                          adapter it is supporting.

    QueueMiniportHandleInterrupt _ If the Miniport driver is sharing an
                                   interrupt line, it sets this parameter to
                                   TRUE if the driver needs to have
                                   MiniportHandleInterrupt called.

    MiniportAdapterContext _ The adapter handle passed to NdisMSetAttributes
                             during MiniportInitialize.

Return Values:

    None.

---------------------------------------------------------------------------*/

{
    DBG_FUNC("HtDsuISR")

    /*
    // Save the current interrupt status on the card.
    */
    USHORT InterruptStatus;

    DBG_ENTER(Adapter);

    /*
    // This routine should never be called after initialization since we 
    // support the Enable/Disable Interrupt routines.  
    */
    if (InterruptStatus = CardGetInterrupt(Adapter))
    {
        /*
        // The adapter prevents the failure case where additional status
        // bits could be set between the time we read the InterruptStatus
        // and it is reset by the clear interrupt command...
        */
        CardClearInterrupt(Adapter);
        Adapter->InterruptStatusFlag |= InterruptStatus;
        
        /*
        // The card generated an interrupt, we need to service it only if we are
        // interested in it.  In either case it must be dismissed from the card.
        */
        *InterruptRecognized = TRUE;
        *QueueMiniportHandleInterrupt = TRUE;

⌨️ 快捷键说明

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