📄 irsir.c
字号:
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1995-1998 Microsoft Corporation
Module Name:
irsir.c
Abstract:
This file implements the IrDA Serial IR NDIS MAC driver DLL initialization
functions. This is provided as a sample to platform writers and is
expected to be able to be used without modification on most (if not
all) hardware platforms.
Functions:
DllEntry
DriverEntry
Notes:
--*/
#include "irsirp.h"
//
// Debugging information.
//
#ifdef DEBUG
DBGPARAM dpCurSettings =
{
TEXT("IrSIR"),
{
TEXT("Init"), TEXT("FCS"),
TEXT("Receive"), TEXT("Send"),
TEXT("SetInfo"), TEXT("QueryInfo"),
TEXT("Dongle"), TEXT("Sniffir"),
TEXT("RawRxTx"), TEXT("CommMask"),
TEXT("Undefined"), TEXT("Misc"),
TEXT("Alloc"), TEXT("Function"),
TEXT("Warning"), TEXT("Error")
},
0x0000c000
};
#endif // DEBUG
//
// Memtracking stuff.
//
#ifdef MEMTRACKING
DWORD Irsir_MemTypeId;
#endif // MEMTRACKING
//
// v_rgSupportedBaudRates - Maps speed masks to real value.
// NOTE: The entries in the table must align with the enum BAUDRATES.
//
const
BAUDRATE_INFO v_rgSupportedBaudRates[NUM_BAUDRATES] =
{
// bps IrSIR bit mask Serial bit mask
// ------ ---------------------- ---------------
{2400, NDIS_IRDA_SPEED_2400, BAUD_2400
#ifdef DEBUG
, TEXT("2400 ")
#endif
},
{9600, NDIS_IRDA_SPEED_9600, BAUD_9600
#ifdef DEBUG
, TEXT("9600 ")
#endif
},
{19200, NDIS_IRDA_SPEED_19200, BAUD_19200
#ifdef DEBUG
, TEXT("19200 ")
#endif
},
{38400, NDIS_IRDA_SPEED_38400, BAUD_38400
#ifdef DEBUG
, TEXT("38400 ")
#endif
},
{57600, NDIS_IRDA_SPEED_57600, BAUD_57600
#ifdef DEBUG
, TEXT("57600 ")
#endif
},
{115200, NDIS_IRDA_SPEED_115200, BAUD_115200
#ifdef DEBUG
, TEXT("115200 ")
#endif
},
{576000, NDIS_IRDA_SPEED_576K, BAUD_USER
#ifdef DEBUG
, TEXT("576K ")
#endif
},
{1152000, NDIS_IRDA_SPEED_1152K, BAUD_USER
#ifdef DEBUG
, TEXT("1152K ")
#endif
},
{4000000, NDIS_IRDA_SPEED_4M, BAUD_USER
#ifdef DEBUG
, TEXT("4M ")
#endif
}
};
/*++
Function: DllEntry
Description: Dummy dll entry. DriverEntry is the real initialize
function.
Arguments:
hInstDll -
Op -
lpvReserved -
Returns:
BOOL
Comments:
--*/
BOOL WINAPI
DllEntry(
HANDLE hInstDll,
DWORD Op,
LPVOID lpvReserved
)
{
switch (Op)
{
case DLL_PROCESS_ATTACH:
DEBUGREGISTER((HMODULE)hInstDll);
DEBUGMSG(ZONE_INIT, (TEXT("Irsir: DLL Process Attach.\r\n")));
#ifdef MEMTRACKING
Irsir_MemTypeId = RegisterTrackedItem(TEXT("Irsir Memory"));
#endif // MEMTRACKING
IRSIR_LOG_INIT();
break;
case DLL_PROCESS_DETACH:
DEBUGMSG(ZONE_INIT, (TEXT("Irsir: DLL Process Detach.\r\n")));
break;
default:
break;
}
return (TRUE);
}
/*++
Function: DriverEntry
Description: Register the driver's entry points with NDIS.
Arguments:
pDriverObject - The driver object being initialized.
pRegistryPath - Registry path of the driver.
Returns:
NDIS_STATUS - Status returned by NdisMRegisterMiniport.
Comments:
Mark the DriverEntry function to run once during initialization and then
it is discardable.
--*/
NDIS_STATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath);
#pragma NDIS_INIT_FUNCTION(DriverEntry)
NDIS_STATUS
DriverEntry(
IN PDRIVER_OBJECT pDriverObject,
IN PUNICODE_STRING pRegistryPath
)
{
NDIS_STATUS status;
NDIS40_MINIPORT_CHARACTERISTICS mcIrsir;
NDIS_HANDLE hWrapper;
DEBUGMSG(ZONE_INIT,
(TEXT("Irsir: +DriverEntry(0x%.8X, 0x%.8X)\r\n"),
pDriverObject, pRegistryPath)
);
NdisMInitializeWrapper(
&hWrapper,
pDriverObject,
pRegistryPath,
NULL
);
//
// Initialize the miniport characteristics.
//
NdisZeroMemory(&mcIrsir, sizeof(NDIS40_MINIPORT_CHARACTERISTICS));
mcIrsir.MajorNdisVersion = NDIS_MAJOR_VERSION;
mcIrsir.MinorNdisVersion = NDIS_MINOR_VERSION;
// mcIrsir.Reserved = 0;
mcIrsir.HaltHandler = IrsirHalt;
mcIrsir.InitializeHandler = IrsirInitialize;
mcIrsir.QueryInformationHandler = IrsirQueryInformation;
mcIrsir.SetInformationHandler = IrsirSetInformation;
mcIrsir.ResetHandler = IrsirReset;
// Allow protocol to send only one packet at a time.
mcIrsir.SendHandler = IrsirSend;
// mcIrsir.SendPacketsHandler = NULL;
// We don't use NdisMIndicateXxxReceive functions so we will need
// a return packet handler.
mcIrsir.ReturnPacketHandler = IrsirReturnPacket;
// mcIrsir.TransferDataHandler = NULL;
// NDIS never calls the reconfigure handler.
// mcIrsir.ReconfigureHandler = NULL;
// Let NDIS handle hangs for now.
//
// If a CheckForHangHandler is supplied, NDIS will call it every two
// seconds (by default) or at a driver specified interval.
//
// When not supplied, NDIS will conclude that the miniport is hung:
// 1) a send packet has been pending longer than twice the
// timeout period
// 2) a request to IrsirQueryInformation or IrsirSetInformation
// is not completed in a period equal to twice the timeout
// period.
// NDIS will keep track of the NdisMSendComplete calls and probably do
// a better job of ensuring the miniport is not hung.
//
// If NDIS detects that the miniport is hung, NDIS calls
// IrsirReset.
// mcIrsir.CheckForHangHandler = NULL;
// This miniport does not handle interrupts.
// mcIrsir.HandleInterruptHandler = NULL;
// mcIrsir.ISRHandler = NULL;
// mcIrsir.DisableInterruptHandler = NULL;
// mcIrsir.EnableInterruptHandler = NULL;
// This miniport does not control a DMA busmaster.
// mcIrsir.AllocateCompleteHandler = NULL;
//
// Register the miniport with NDIS.
//
status = NdisMRegisterMiniport(
hWrapper,
&mcIrsir,
sizeof(mcIrsir)
);
if (status != NDIS_STATUS_SUCCESS)
{
DEBUGMSG(ZONE_ERROR,
(TEXT("Irsir: NdisMRegisterMiniport failure [0x%.8X].\r\n"),
status)
);
NdisTerminateWrapper(hWrapper, NULL);
}
DEBUGMSG(ZONE_INIT,
(TEXT("Irsir: -DriverEntry [0x%.8X]\r\n"),
status)
);
return (status);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -