📄 interrup.c
字号:
/*++
Copyright (c) 1999 SDMC Co., Ltd.
Module Name:
interrup.c
rtsnt.c
Abstract:
This is the main file for the DVB-S fast modem NIC.
This driver conforms to the NDIS 5.0 miniport interface.
The overall structure and much of the code is taken from
the NE2000 driver included in Microsoft NT3.5 DDK.
Environment:
Kernel Mode - Or whatever is the equivalent on OS/2 and DOS.
Revision History:
12/11/96 ----- Vincent
--*/
#include <ndis.h>
#include "RTSNT_SW.H"
#include "bit.h"
//#include "descramble.h"
//
// On debug builds tell the compiler to keep the symbols for
// internal functions, otw throw them out.
//
#if DBG
#define STATIC
#else
#define STATIC static
#endif
#define RESET_BADDATA_NUM 32
/*++
Routine Description:
This routine is used to turn on the interrupt mask.
Arguments:
Context - The adapter for the RTL8139 to start.
Return Value:
None.
--*/
VOID
RTFast_EnableInterrupt(
IN NDIS_HANDLE MiniportAdapterContext
)
{
}
/*++
Routine Description:
This routine is used to turn off the interrupt mask.
Arguments:
Context - The adapter for the RTL8139 to start.
Return Value:
None.
--*/
VOID
RTFast_DisableInterrupt(
IN NDIS_HANDLE MiniportAdapterContext
)
{
}
VOID
RTFast_Isr(
OUT PBOOLEAN InterruptRecognized,
OUT PBOOLEAN QueueDpc,
IN PVOID Context
)
{
PRTFAST_ADAPTER Adapter = ((PRTFAST_ADAPTER)Context);
UCHAR TmpStatus, TmpMask;
#if DBG
//DbgPrint("<<<<--- Enter RTFast Isr !\n");
#endif
*InterruptRecognized = FALSE;
*QueueDpc = FALSE;
return;
}
/*++
Routine Description:
This is the defered processing routine for interrupts. It
reads from the Interrupt Status Register any outstanding
interrupts and handles them.
Arguments:
MiniportAdapterContext - a handle to the adapter block.
Return Value:
NONE.
--*/
VOID
RTFast_HandleInterrupt(
IN NDIS_HANDLE MiniportAdapterContext
)
{
PRTFAST_ADAPTER Adapter = ((PRTFAST_ADAPTER)MiniportAdapterContext);
UCHAR TmpStatus;//, imr_rxovw;
BOOLEAN DidSomething = TRUE;
#if DBG
DbgPrint(" >>"); //"\n-->> Enter RTFast HandleInterrupt !\n");
#endif
return;
}
#define MINDMABUFDATA 564 // 3*188
#define ONCE_DATASIZE 376
//#define MINDMABUFDATA 376 // 2*188
//#define ONCE_DATASIZE 376
/*++
Routine Description:
This is the real interrupt handler for receive/overflow interrupt.
Called when a receive interrupt is received. It first indicates
all packets on the card and finally indicates ReceiveComplete().
Arguments:
Adapter - Pointer to the adapter block.
Return Value:
TRUE if done with all receives, else FALSE.
--*/
BOOLEAN
RTFast_RcvDpc(
IN PRTFAST_ADAPTER Adapter
)
{
return (TRUE); //Done
}
/*++
Routine Description:
Reads a packet off the card -- checking if the CRC is good. This is
a workaround for a bug where bytes in the data portion of the packet
are shifted either left or right by two in some weird 8390 cases.
This routine is a combination of Rtl8139TransferData (to copy up data
from the card), CardCalculateCrc and CardCalculatePacketCrc.
Arguments:
Adapter - pointer to the adapter block.
Return Value:
TRUE if the packet seems ok, else false.
--*/
/*++
Routine Description:
Indicates the first packet on the card to the protocols.
NOTE: For MP, non-x86 architectures, this assumes that the packet has been
read from the card and into Adapter->PacketHeader and Adapter->Lookahead.
NOTE: For UP x86 systems this assumes that the packet header has been
read into Adapter->PacketHeader and the minimal lookahead stored in
Adapter->Lookahead
Arguments:
Adapter - pointer to the adapter block.
Return Value:
CARD_BAD if the card should be reset;
INDICATE_OK otherwise.
--*/
/*++
Routine Description:
A protocol calls the Rtl8139TransferData request (indirectly via
NdisTransferData) from within its Receive event handler
to instruct the driver to copy the contents of the received packet
a specified packet buffer.
Arguments:
MiniportAdapterContext - Context registered with the wrapper, really
a pointer to the adapter.
MiniportReceiveContext - The context value passed by the driver on its call
to NdisMEthIndicateReceive. The driver can use this value to determine
which packet, on which adapter, is being received.
ByteOffset - An unsigned integer specifying the offset within the
received packet at which the copy is to begin. If the entire packet
is to be copied, ByteOffset must be zero.
BytesToTransfer - An unsigned integer specifying the number of bytes
to copy. It is legal to transfer zero bytes; this has no effect. If
the sum of ByteOffset and BytesToTransfer is greater than the size
of the received packet, then the remainder of the packet (starting from
ByteOffset) is transferred, and the trailing portion of the receive
buffer is not modified.
Packet - A pointer to a descriptor for the packet storage into which
the MAC is to copy the received packet.
BytesTransfered - A pointer to an unsigned integer. The MAC writes
the actual number of bytes transferred into this location. This value
is not valid if the return status is STATUS_PENDING.
Notes:
- The MacReceiveContext will be a pointer to the open block for
the packet.
--*/
NDIS_STATUS
RTFast_TransferData(
OUT PNDIS_PACKET Packet,
OUT PUINT BytesTransferred,
IN NDIS_HANDLE MiniportAdapterContext,
IN NDIS_HANDLE MiniportReceiveContext,
IN UINT ByteOffset,
IN UINT BytesToTransfer
)
{
//
// Variables for the number of bytes to copy, how much can be
// copied at this moment, and the total number of bytes to copy.
//
UINT BytesLeft, BytesNow, BytesWanted;
//
// Current NDIS_BUFFER to copy into
//
PNDIS_BUFFER CurBuffer;
//
// Virtual address of the buffer.
//
PUCHAR BufStart;
PUCHAR XferPageStart;
//
// Length and offset into the buffer.
//
UINT BufLen, BufOff;
//
// The adapter to transfer from.
//
PRTFAST_ADAPTER Adapter = (PRTFAST_ADAPTER)MiniportReceiveContext;
MPE_DECODER *CurMPEdec = Adapter->CurMPEdec;
//
// Add the packet header onto the offset.
//
XferPageStart = (UCHAR *)CurMPEdec->IPbuf;
XferPageStart += ByteOffset;
//
// See how much data there is to transfer.
//
if(ByteOffset+BytesToTransfer > CurMPEdec->IPPacketLen)
{
if((CurMPEdec->IPPacketLen) < ByteOffset)
{
*BytesTransferred = 0;
return(NDIS_STATUS_FAILURE);
}
BytesWanted = CurMPEdec->IPPacketLen - ByteOffset;
}
else
{
BytesWanted = BytesToTransfer;
}
//
// Set the number of bytes left to transfer
//
NdisDprAcquireSpinLock(&Adapter->RTFAST_SpinLock);
BytesLeft = BytesWanted;
{
//
// Address on the adapter to copy from
//
PUCHAR CurCardLoc;
//
// Copy data from the card -- it is not completely stored in the
// adapter structure.
//
// Determine where the copying should start.
//
CurCardLoc = XferPageStart;
//
// Get location to copy into
//
NdisQueryPacket(Packet, NULL, NULL, &CurBuffer, NULL);
NdisQueryBuffer(CurBuffer, (PVOID *)&BufStart, &BufLen);
BufOff = 0;
// Loop, filling each buffer in the packet until there
// are no more buffers or the data has all been copied.
while (BytesLeft > 0)
{
// See how much data to read into this buffer.
if((BufLen-BufOff) > BytesLeft)
{
BytesNow = BytesLeft;
}
else
{
BytesNow = (BufLen - BufOff);
}
// Copy up the data.
NdisMoveMemory(BufStart+BufOff, CurCardLoc, BytesNow);
// Update offsets and counts
CurCardLoc += BytesNow;
BytesLeft -= BytesNow;
// Is the transfer done now?
if(BytesLeft == 0)
{
break;
}
// Was the end of this packet buffer reached?
BufOff += BytesNow;
if(BufOff == BufLen)
{
NdisGetNextBuffer(CurBuffer, &CurBuffer);
if(CurBuffer == (PNDIS_BUFFER)NULL)
{
break;
}
NdisQueryBuffer(CurBuffer, (PVOID *)&BufStart, &BufLen);
BufOff = 0;
}
}
NdisDprReleaseSpinLock(&Adapter->RTFAST_SpinLock);
*BytesTransferred = BytesWanted - BytesLeft;
return(NDIS_STATUS_SUCCESS);
}
}
void DecodeIP(IN PRTFAST_ADAPTER Adapter,IN PUCHAR TsBuf)
{
PLIST_ENTRY thisEntry; //, listHead;
MPE_DECODER *CurMPEdec;
USHORT wPID = 0x1FFF & ((TsBuf[1]<<8)|TsBuf[2]);
UCHAR ii = 0;
NdisDprAcquireSpinLock(&Adapter->MPEdecSpinLock);
while(thisEntry = NdisInterlockedRemoveHeadList(
&Adapter->ListMPEdec,
&Adapter->MPEListSpinLock
))
{
CurMPEdec = CONTAINING_RECORD(thisEntry,
MPE_DECODER,
ListEntry);
if(CurMPEdec->wPID == wPID)
{
ToMPESection(Adapter, CurMPEdec, TsBuf);
NdisInterlockedInsertHeadList(
&Adapter->ListMPEdec,
thisEntry,
&Adapter->MPEListSpinLock
);
break;
}
else
NdisInterlockedInsertTailList(
&Adapter->ListMPEdec,
thisEntry,
&Adapter->MPEListSpinLock
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -