コード例 #1
0
ファイル: hw_main.c プロジェクト: kcrazy/winekit
VOID
Hw11Restart(
    __in  PHW                     Hw
    )
{
    //
    // Clear the paused flag
    //
    HW_CLEAR_ADAPTER_STATUS(Hw, HW_ADAPTER_PAUSED);

    //
    // Reenable the disabled interrupts
    //
    
    //
    // If receives are available, we would temporarily enable the
    // RDU interrupt to ensure that we get interrupt again. Keeping this
    // interrupt on all the time would cause problems with Reset/Pause 
    // scenarios where we cannot empty the receive descriptors, and
    // so may keep getting interrupted
    //
    if (HwIsReceiveAvailable(Hw, FALSE))
    {
        //
        // New receives are available, but we didnt indicate
        // them in this interrupt. Enable RDU in IntrMask. This would be 
        // reset by the ClearInterrupt routine
        //
        HalInterlockedOrIntrMask(Hw->Hal, HAL_ISR_RX_DS_UNAVAILABLE);
    }    
//    MpTrace(COMP_TESTING, DBG_SERIOUS, ("Hw11Restart \n"));
    HwEnableInterrupt(Hw, HW_ISR_TRACKING_PAUSE);
}
コード例 #2
0
ファイル: hw_phy.c プロジェクト: 340211173/Driver
NDIS_STATUS
HwSetChannel(
    _In_  PHW                     Hw,
    _In_  ULONG                   PhyId,
    _In_  UCHAR                   Channel
    )
{
    // Must only be called for the active phy
    MPASSERT(PhyId == Hw->PhyState.OperatingPhyId);

    // When setting the channel, we dont check if we are not already on that 
    // channel. This is because this may be called after setting a PhyID and
    // that does not necessarily set the channel

    HW_ACQUIRE_HARDWARE_LOCK(Hw, FALSE);
    HW_SET_ADAPTER_STATUS(Hw, HW_ADAPTER_IN_CHANNEL_SWITCH);
    HW_RELEASE_HARDWARE_LOCK(Hw, FALSE);

    // Wait for active send threads to finish. We dont wait
    // for anything else on an HAL reset since some of those
    // operations themselves may be causing the reset (Eg. channel
    // switch of a scan)
    HW_WAIT_FOR_ACTIVE_SENDS_TO_FINISH(Hw);
//    MpTrace(COMP_TESTING, DBG_SERIOUS, ("HwSetChannel \n"));    
    HwDisableInterrupt(Hw, HW_ISR_TRACKING_CHANNEL);

    // Flush the sends
    HwFlushSendEngine(Hw, FALSE);

    HalSwitchChannel(Hw->Hal, 
        PhyId,
        Channel, 
        FALSE
        );

    HwResetSendEngine(Hw, FALSE);
    HwResetReceiveEngine(Hw, FALSE);
    HalStartReceive(Hw->Hal);
//    MpTrace(COMP_TESTING, DBG_SERIOUS, ("HwSetChannel \n"));    
    HwEnableInterrupt(Hw, HW_ISR_TRACKING_CHANNEL);

    HW_CLEAR_ADAPTER_STATUS(Hw, HW_ADAPTER_IN_CHANNEL_SWITCH);

    return NDIS_STATUS_SUCCESS;
}
コード例 #3
0
ファイル: hw_main.c プロジェクト: kcrazy/winekit
//
// Reset Step 3 - Restart the hardware
//
NDIS_STATUS
Hw11NdisResetStep3(
    __in  PHW                     Hw,
    __out PBOOLEAN                AddressingReset
    )
{
    *AddressingReset = FALSE;

    HalStart(Hw->Hal, TRUE);
    
    // Push the new state on the hardware
    HwSetNicState(Hw);

    HalResetEnd(Hw->Hal);
    
    // Renable the interrupts
    HwEnableInterrupt(Hw, HW_ISR_TRACKING_NDIS_RESET);
    
    HW_CLEAR_ADAPTER_STATUS(Hw, HW_ADAPTER_IN_RESET);

    // TODO: Should we return NDIS_STATUS_HARD_ERRORS if we are hung
    
    return NDIS_STATUS_SUCCESS;
}
コード例 #4
0
ファイル: hw_main.c プロジェクト: kcrazy/winekit
NDIS_STATUS
Hw11Start(
    __in  PHW                     Hw,
    __out NDIS_ERROR_CODE*        ErrorCode,
    __out PULONG                  ErrorValue
    )
{
    NDIS_STATUS                 ndisStatus = NDIS_STATUS_SUCCESS;
    BOOLEAN                     interruptRegistered = FALSE, hardwareStarted = FALSE;
    
    //
    // Disable interrupts
    // We should disable interrupts before the are registered.
    // They will be enabled right at the end of Initialize
    //
    HwDisableInterrupt(Hw, HW_ISR_TRACKING_HWSTART);

    do
    {
        //
        // Register interrupt with NDIS
        //
        ndisStatus = HwRegisterInterrupt(
                        Hw,
                        ErrorCode, 
                        ErrorValue
                        );
        if (ndisStatus != NDIS_STATUS_SUCCESS)
        {
            MpTrace(COMP_INIT_PNP, DBG_SERIOUS, ("Failed to register interrupt with NDIS\n"));
            break;
        }
        interruptRegistered = TRUE;
        
        Hw->PhyState.Debug_SoftwareRadioOff = Hw->PhyState.SoftwareRadioOff;
        if (Hw->PhyState.SoftwareRadioOff)
        {
            HalSetRFPowerState(Hw->Hal, RF_SHUT_DOWN);
        }
        else
        {
            HalSetRFPowerState(Hw->Hal, RF_ON);
        }

        //
        // Start the HAL. If anything fails after this point,
        // we must issue a Halt to the HAL before returning
        // from initialize
        //
        ndisStatus = HalStart(Hw->Hal, FALSE);
        if(ndisStatus != NDIS_STATUS_SUCCESS)
        {
            MpTrace(COMP_INIT_PNP, DBG_SERIOUS, ("Failed to start HAL successfully.\n"));
            break;
        }
        hardwareStarted = TRUE;
        
        // Enable the interrupts on the hardware
        HwEnableInterrupt(Hw, HW_ISR_TRACKING_HWSTART);
                
    }while (FALSE);

    if (ndisStatus != NDIS_STATUS_SUCCESS)
    {
        // Disable interrupts and deregister them first
        HwDisableInterrupt(Hw, HW_ISR_TRACKING_HWSTART);
        
        if (interruptRegistered)
            HwDeregisterInterrupt(Hw);

        if (hardwareStarted)
        {
            HalStop(Hw->Hal);
            HalHaltNic(Hw->Hal);
        }
    }

    return ndisStatus;
}
コード例 #5
0
ファイル: hw_main.c プロジェクト: kcrazy/winekit
NDIS_STATUS
HwResetHAL(
    __in  PHW                     Hw,
    __in  PHW_HAL_RESET_PARAMETERS ResetParams,
    __in  BOOLEAN                 DispatchLevel
    )
{
    UNREFERENCED_PARAMETER(ResetParams);
    UNREFERENCED_PARAMETER(DispatchLevel);

    MPASSERT(!DispatchLevel);

    // Since we wait, we cannot be called at dispatch    
    HW_ACQUIRE_HARDWARE_LOCK(Hw, FALSE);
    HW_SET_ADAPTER_STATUS(Hw, HW_ADAPTER_HAL_IN_RESET);
    HW_RELEASE_HARDWARE_LOCK(Hw, FALSE);

    // Wait for active send threads to finish. We dont wait
    // for anything else on an HAL reset since some of those
    // operations themselves may be causing the reset (Eg. channel
    // switch of a scan)
    HW_WAIT_FOR_ACTIVE_SENDS_TO_FINISH(Hw);
    HwDisableInterrupt(Hw, HW_ISR_TRACKING_HAL_RESET);

    if (ResetParams->FullReset)
    {
        // Perform a full reset of the HW
        HalResetStart(Hw->Hal);

        HalStop(Hw->Hal);    

        // Reset the send and receive engine
        HwWaitForPendingReceives(Hw, NULL);
        HwResetSendEngine(Hw, FALSE);
        HwResetReceiveEngine(Hw, FALSE);
        // Remove old keys, etc
        HwClearNicState(Hw);
        
        // Reset our MAC & PHY state
        HwResetSoftwareMacState(Hw);
        HwResetSoftwarePhyState(Hw);

        HalStart(Hw->Hal, TRUE);
        
        // Push the new state on the hardware
        HwSetNicState(Hw);

        HalResetEnd(Hw->Hal);
    }
    else
    {
        // TODO: Currently we are overloading the HalSwitchChannel API for doing a HalReset
        HalSwitchChannel(Hw->Hal, 
            Hw->PhyState.OperatingPhyId,
            HalGetPhyMIB(Hw->Hal, Hw->PhyState.OperatingPhyId)->Channel, 
            FALSE
            );

        HwResetReceiveEngine(Hw, FALSE);
        HwResetSendEngine(Hw, FALSE);
        HalStartReceive(Hw->Hal);
    }
    HwEnableInterrupt(Hw, HW_ISR_TRACKING_HAL_RESET);

    HW_CLEAR_ADAPTER_STATUS(Hw, HW_ADAPTER_HAL_IN_RESET);

    return NDIS_STATUS_SUCCESS;
}