📄 htdsu.c
字号:
/*
// We only support point to point framing, and we don't need to see the
// address or control fields. The TAPI_PROVIDER bit is set to indicate
// that we can accept the TAPI OID requests.
*/
Adapter->WanInfo.FramingBits = PPP_FRAMING |
PPP_COMPRESS_ADDRESS_CONTROL |
PPP_COMPRESS_PROTOCOL_FIELD |
TAPI_PROVIDER;
/*
// This value is ignored by this driver, but its default behavior is such
// that all these control bytes would appear to be handled transparently.
*/
Adapter->WanInfo.DesiredACCM = 0;
/*
// Inform the wrapper of the physical attributes of this adapter.
// This must be called before any NdisMRegister functions!
// This call also associates the MiniportAdapterHandle with this Adapter.
*/
NdisMSetAttributes(
Adapter->MiniportAdapterHandle,
(NDIS_HANDLE)Adapter,
FALSE, // Not a BusMaster
NdisInterfaceIsa
);
/*
// Map the adapter's physical location into the system address space.
*/
Status = NdisMMapIoSpace(
&Adapter->VirtualAddress,
Adapter->MiniportAdapterHandle,
Adapter->PhysicalAddress,
Adapter->MemorySize
);
DBG_NOTICE(Adapter, ("NdisMMapIoSpace(\n"
"VirtualAddress =%Xh\n"
"MiniportAdapterHandle=%Xh\n"
"PhysicalAddress =%X:%Xh\n"
"MemorySize =%Xh\n",
Adapter->VirtualAddress,
Adapter->MiniportAdapterHandle,
Adapter->PhysicalAddress,
Adapter->MemorySize
));
if (Status != NDIS_STATUS_SUCCESS)
{
DBG_ERROR(Adapter,("NdisMMapIoSpace failed (status=%Xh)\n",Status));
/*
// Log error message and exit.
*/
NdisWriteErrorLogEntry(
Adapter->MiniportAdapterHandle,
NDIS_ERROR_CODE_OUT_OF_RESOURCES,
3,
Status,
__FILEID__,
__LINE__
);
goto EarlyOut;
}
Adapter->AdapterRam = (PHTDSU_REGISTERS) Adapter->VirtualAddress;
/*
// This is how we protect the driver from being re-entered when
// it's not safe to do so. Such as on a timer thread. Normally,
// the wrapper provides protection from re-entrancy, so SpinLocks
// are not needed. However, if your adapter requires asynchronous
// timer support routines, you will have to provide your own
// synchronization.
*/
NdisAllocateSpinLock(&Adapter->Lock);
/*
// Set both the transmit busy and transmit idle lists to empty.
*/
InitializeListHead(&Adapter->TransmitIdleList);
InitializeListHead(&Adapter->TransmitBusyList);
/*
// Initialize the interrupt - it can be disabled, but cannot be shared.
*/
Status = NdisMRegisterInterrupt(
&Adapter->Interrupt,
Adapter->MiniportAdapterHandle,
Adapter->InterruptNumber,
Adapter->InterruptNumber,
FALSE, /* We don't need a call to the ISR */
FALSE, /* Interrupt is not sharable */
NdisInterruptLatched
);
if (Status != NDIS_STATUS_SUCCESS)
{
DBG_ERROR(Adapter,("NdisMRegisterInterrupt failed (status=%Xh)\n",Status));
/*
// Log error message and exit.
*/
NdisWriteErrorLogEntry(
Adapter->MiniportAdapterHandle,
NDIS_ERROR_CODE_INTERRUPT_CONNECT,
3,
Status,
__FILEID__,
__LINE__
);
goto EarlyOut;
}
/*
// Try to initialize the adapter hardware.
*/
#if DBG
Status = CardInitialize(Adapter,
(BOOLEAN) ((Adapter->DbgFlags & DBG_HWTEST_ON) ?
TRUE : FALSE));
#else
Status = CardInitialize(Adapter, FALSE);
#endif
if (Status != NDIS_STATUS_SUCCESS)
{
DBG_ERROR(Adapter,("CardInitialize failed (status=%Xh)\n",Status));
/*
// Error message was already logged.
*/
goto EarlyOut;
}
/*
// Initialize the adapter link structures.
*/
LinkInitialize(Adapter, AddressList);
#ifdef USE_LEASED_LINE
if (Adapter->LineType == HTDSU_LINEMODE_LEASED)
{
/*
// Go ahead and allocate the lines and indicate them as up so we can
// work with leased line mode.
*/
PHTDSU_LINK Link;
if (CardStatusOnLine(Adapter, HTDSU_CMD_LINE1))
{
Link = LinkAllocate(Adapter, NULL, HTDSU_LINE1_ID);
LinkLineUp(Link);
}
if ((Adapter->NumLineDevs == HTDSU_NUM_LINKS) &&
CardStatusOnLine(Adapter, HTDSU_CMD_LINE2))
{
Link = LinkAllocate(Adapter, NULL, HTDSU_LINE2_ID);
LinkLineUp(Link);
}
}
#endif // USE_LEASED_LINE
EarlyOut:
DBG_LEAVE(Adapter);
return Status;
}
VOID
HtDsuHalt(
IN PHTDSU_ADAPTER Adapter
)
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Functional Description:
The MiniportHalt request is used to halt the adapter such that it is
no longer functioning. The Miniport driver should stop the adapter
and deregister all of its resources before returning from this routine.
It is not necessary for the Miniport to complete all outstanding
requests and no other requests will be submitted to the Miniport
until the operation is completed.
Interrupts are enabled during the call to this routine.
Parameters:
MiniportAdapterContext _ The adapter handle passed to NdisMSetAttributes
during MiniportInitialize.
Return Values:
None.
---------------------------------------------------------------------------*/
{
DBG_FUNC("HtDsuHalt")
/*
// We use this message to make sure TAPI is cleaned up.
*/
NDIS_TAPI_PROVIDER_SHUTDOWN TapiShutDown;
DBG_ENTER(Adapter);
/*
// Make sure all the lines are hungup and indicated.
// This should already be the case, but let's be sure.
*/
TapiShutDown.ulRequestID = OID_TAPI_PROVIDER_SHUTDOWN;
HtTapiProviderShutdown(Adapter, &TapiShutDown);
/*
// Disconnect the interrupt line.
*/
if (*(PULONG)&(Adapter->Interrupt))
{
NdisMDeregisterInterrupt(&Adapter->Interrupt);
}
/*
// Unmap the adapter memory from the system.
*/
if (Adapter->VirtualAddress != NULL)
{
NdisMUnmapIoSpace(
Adapter->MiniportAdapterHandle,
Adapter->VirtualAddress,
Adapter->MemorySize
);
}
/*
// Free the lock we aquired at startup.
*/
if (*(PULONG)&(Adapter->Lock))
{
// not required anymore
// NdisFreeSpinLock(&Adapter->Lock);
}
DBG_LEAVE(Adapter);
/*
// Free adapter instance.
*/
--HtDsuAdapterCount;
NdisFreeMemory(Adapter, sizeof(*Adapter), 0);
}
#ifdef RECONFIGURE_SUPPORTED
NDIS_STATUS
HtDsuReconfigure(
OUT PNDIS_STATUS OpenErrorStatus,
IN PHTDSU_ADAPTER Adapter,
IN NDIS_HANDLE WrapperConfigurationContext
)
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Functional Description:
This routine is called to have the Miniport reconfigure the adapter
to the new parameters available via the NDIS configuration routines.
Used to support plug and play adapters and software configurable
adapters, which may have the parameters changed during runtime. If
the Miniport driver does not support dynamic reconfiguration, then
the entry for W_RECONFIGURE_HANDLER in the NDIS_WIDGET_CHARACTERISTICS
should be NULL.
No other request will be outstanding on the Miniport when this routine
is called. No other request will be submitted to the Miniport until
the operation is completed.
The status value NDIS_STATUS_OPEN_ERROR has a special meaning. It
indicates that the OpenErrorStatus parameter has returned a valid
status which the wrapper can examine to obtain more information about
the error.
This routine is called with interrupts enabled, and a call to MiniportISR
will occur if the adapter generates any interrupts. As long as this
routine is executing MiniportDisableInterrupt and MiniportEnableInterrupt
will not be called, so it is the responsibility of the Miniport driver
to acknowledge and clear any interrupts generated.
Parameters:
OpenErrorStatus _ Returns more information about the reason for the
failure. Currently, the only values defined match
those specified as Open Error Codes in Appendix B
of the IBM Local Area Network Technical Reference.
MiniportAdapterContext _ The adapter handle passed to NdisMSetAttributes
during MiniportInitialize.
WrapperConfigurationContext _ The handle to use for calls to
NdisOpenConfiguration, and the routines
in section 4 of this document.
Return Values:
NDIS_STATUS_FAILURE
NDIS_STATUS_NOT_ACCEPTED
NDIS_STATUS_SUCCESS
---------------------------------------------------------------------------*/
{
return (NDIS_STATUS_NOT_ACCEPTED);
}
#endif // RECONFIGURE_SUPPORTED
NDIS_STATUS
HtDsuReset(
OUT PBOOLEAN AddressingReset,
IN PHTDSU_ADAPTER Adapter
)
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Functional Description:
The MiniportReset request instructs the Miniport driver to issue a
hardware reset to the network adapter. The Miniport driver also
resets its software state.
The MiniportReset request may also reset the parameters of the adapter.
If a hardware reset of the adapter resets the current station address
to a value other than what it is currently configured to, the Miniport
driver automatically restores the current station address following the
reset. Any multicast or functional addressing masks reset by the
hardware do not have to be reprogrammed by the Miniport.
NOTE: This is change from the NDIS 3.0 driver specification. If the
multicast or functional addressing information, the packet filter, the
lookahead size, and so on, needs to be restored, the Miniport indicates
this with setting the flag AddressingReset to TRUE.
It is not necessary for the Miniport to complete all outstanding requests
and no other requests will be submitted to the Miniport until the
operation is completed. Also, the Miniport does not have to signal
the beginning and ending of the reset with NdisMIndicateStatus.
NOTE: These are different than the NDIS 3.0 driver specification.
The Miniport driver must complete the original request, if the orginal
call to MiniportReset return NDIS_STATUS_PENDING, by calling
NdisMResetComplete.
If the underlying hardware does not provide a reset function under
software control, then this request completes abnormally with
NDIS_STATUS_NOT_RESETTABLE. If the underlying hardware attempts a
reset and finds recoverable errors, the request completes successfully
with NDIS_STATUS_SOFT_ERRORS. If the underlying hardware resets and,
in the process, finds nonrecoverable errors, the request completes
successfully with the status NDIS_STATUS_HARD_ERRORS. If the
underlying hardware reset is accomplished without any errors,
the request completes successfully with the status NDIS_STATUS_SUCCESS.
Interrupts are in any state during this call.
Parameters:
MiniportAdapterContext _ The adapter handle passed to NdisMSetAttributes
during MiniportInitialize.
AddressingReset _ The Miniport indicates if the wrapper needs to call
MiniportSetInformation to restore the addressing
information to the current values by setting this
value to TRUE.
Return Values:
NDIS_STATUS_HARD_ERRORS
NDIS_STATUS_NOT_ACCEPTED
NDIS_STATUS_NOT_RESETTABLE
NDIS_STATUS_PENDING
NDIS_STATUS_SOFT_ERRORS
NDIS_STATUS_SUCCESS
---------------------------------------------------------------------------*/
{
DBG_FUNC("HtDsuReset")
/*
// Holds the status result returned from an NDIS function call.
*/
NDIS_STATUS Status;
DBG_ENTER(Adapter);
DBG_BREAK(Adapter);
if (Adapter->NeedReset)
{
NdisAcquireSpinLock(&Adapter->Lock);
/*
// Make sure TAPI is aware of the state change so it can do the
// right things.
*/
HtTapiResetHandler(Adapter);
/*
// Attempt to issue a software reset on the adapter.
// It will only fail if the hardware is hung forever.
*/
Adapter->NeedReset = FALSE;
Status = CardInitialize(Adapter, FALSE);
/*
// If anything gose wrong here, it's very likely an unrecoverable
// hardware failure. So we'll just shut this thing down for good.
*/
if (Status != NDIS_STATUS_SUCCESS)
{
DBG_ERROR(Adapter,("RESET Failed\n"));
Status = NDIS_STATUS_HARD_ERRORS;
}
else
{
DBG_WARNING(Adapter,("RESET Complete\n"));
*AddressingReset = TRUE;
}
NdisReleaseSpinLock(&Adapter->Lock);
}
else
{
DBG_WARNING(Adapter, ("RESET Not Needed\n"));
}
DBG_LEAVE(Adapter);
return (Status);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -