ITek_util.c
资源名称:mac.zip [点击查看]
上传用户:cnfair
上传日期:2007-01-07
资源大小:32k
文件大小:3k
源码类别:
驱动编程
开发平台:
Visual C++
- /////////////////////////////////////////////////////////////////////////
- // atm_util.c
- // any utility routines
- //to use the following functions from standard c-library directly
- #include <string.h>
- #pragma intrinsic(memcpy, memcmp, memset, strcat, strcmp, strcpy, strlen)
- #pragma warning(disable:4201 4514 4100 4127)
- //to include Windows95 DDK header files
- //
- #define WANTVXDWRAPS
- #include <basedef.h>
- #include <vmm.h>
- #include <vxdwraps.h>
- #include <debug.h>
- // copied from Miniport.h for NT3.51
- #define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field))
- #include <ndis.h>
- #include <vwin32.h>
- #include <efilter.h>
- #include "ITek_type.h"
- #include "ITek_init.h"
- #include "ITek_util.h"
- #pragma VxD_LOCKED_CODE_SEG
- #pragma VxD_LOCKED_DATA_SEG
- #ifdef ITEK_TIMER
- VOID NDIS_API
- ITekTimerFunction(
- IN PVOID SystemSpecific1,
- IN PVOID FunctionContext,
- IN PVOID SystemSpecific2,
- IN PVOID SystemSpecific3
- )
- {
- PITEK_ADAPTER pITekAdapter = (PITEK_ADAPTER)FunctionContext;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekTimerFunction() Entryn");
- #endif
- NdisSetTimer(
- &pITekAdapter->NdisTimer,
- ITEK_TIMEOUT_MSEC);
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekTimerFunction() Returnn");
- #endif
- return;
- }
- #endif //ITEK_TIMER
- VOID NDIS_API
- ITekAllocateSharedMemory(
- IN NDIS_HANDLE NdisAdapterHandle,
- IN ULONG Length,
- IN ULONG AlignMask,
- OUT PVOID *VirtualAddress,
- OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress
- )
- {
- ULONG nPages;
- PVOID VirtualAddressLocal;
- PVOID PhysicalAddressLocal;
- nPages = (Length+4095)/4096;
- VirtualAddressLocal = (PVOID)_PageAllocate(
- nPages, //nPages
- PG_SYS, //nType
- (ULONG) 0, //VM
- AlignMask, //AignMask
- (ULONG) 1, //minPhys
- (ULONG)0x0000FFFF, //maxPhys
- (PVOID *)&PhysicalAddressLocal, //
- (ULONG)(PAGECONTIG | PAGEFIXED | PAGEUSEALIGN) //flags
- );
- *VirtualAddress = VirtualAddressLocal;
- *PhysicalAddress = (NDIS_PHYSICAL_ADDRESS)PhysicalAddressLocal;
- return;
- }
- VOID NDIS_API
- ITekFreeSharedMemory(
- IN NDIS_HANDLE NdisAdapterHandle,
- IN PVOID VirtualAddress
- )
- {
- _PageFree(VirtualAddress, 0);
- return;
- }
- VOID NDIS_API
- ITekAllocateMemory(
- OUT PVOID *VirtualMemory,
- IN ULONG nBytes
- )
- {
- PVOID VirtualMemoryLocal;
- VirtualMemoryLocal = (PVOID)_HeapAllocate(
- nBytes,
- (ULONG)(HEAPLOCKEDIFDP|HEAPZEROINIT));
- *VirtualMemory = VirtualMemoryLocal;
- return;
- }
- VOID NDIS_API
- ITekFreeMemory(
- IN PVOID VirtualMemory
- )
- {
- (void)_HeapFree(VirtualMemory, 0);
- return;
- }