📄 adcard_e.cpp
字号:
// adcard_e.cpp - main module for VxD ADCARD_E
#define DEVICE_MAIN
#include "adcard_e.h"
Declare_Virtual_Device(ADCARD_E)
#undef DEVICE_MAIN
#include <vmm.h>
//--------------------全局变量定义
HANDLE hWin32Event;//接收应用程序发来的事件句柄
//vxd私有缓冲类实例应申明为全局变量,因为类Ms_isaDevice和MsHwInt中都会用到它
BuffClass *vBuff;
BYTE win32BuffState=(BYTE)0;//反映第二线程的状态。0表示闲,即等待;1表示忙
OUT_BUFFER_STRUCT outBufStructure;//second buffer
//********************************class Adcard_eDevice
BOOL Adcard_eDevice::OnSysDynamicDeviceInit()
{
dprintf("OnSysDynamicDeviceInit begin\n");
//initialize outBufStructure
outBufStructure.signal=0;//初始化,无操作
for(int i=0;i<BUFFER;i++)
outBufStructure.buffer[i]=(BYTE)0xAA;//缓冲初始化取值
//生成AdVMEvent类实例
if(!VEvent::initEvents())
{
dprintf("AdVMEvent init failed\n");
return FALSE;
}
else
dprintf("AdVMEvent init ok\n");
//生成BuffClass类实例,同时也就生成了缓冲inputBuffer和outputBuffer
/* BuffClass* */vBuff=new BuffClass();
if(!vBuff)
{
dprintf("buffer init failed\n");
return FALSE;
}
else
{
// poin=vBuff;
dprintf("buffer init succeed\n");
}
//生成中断类实例
pMyIRQ=new AdHwInt();
if(!pMyIRQ)
{
dprintf("hardware init failed\n");
return FALSE;
}
else
dprintf("hardware init ok\n");
//挂中断
if(pMyIRQ->hook())
{
dprintf("Interrupt hook succeed\n");
//开中断
pMyIRQ->physicalUnmask();
//初始化
dprintf("OnSysDynamicDeviceInit finished\n");
dprintf("1 the address of vBuff=%x,pMyIRQ=%x\n",vBuff,pMyIRQ);
return TRUE;
}
else
{
dprintf("Interrupt hook failed\n");
return FALSE;
}
}
BOOL Adcard_eDevice::OnSysDynamicDeviceExit()
{
dprintf("OnSysDynamicDeviceExit\n");
delete pMyIRQ;
//AdVMEvent 实例在handler函数返回时自动撤销
delete vBuff;
pMyTimer->Cancel();
delete pMyTimer;
return TRUE;
}
DWORD Adcard_eDevice::OnW32DeviceIoControl(PIOCTLPARAMS pDIOCParams)
{
//应用程序-〉VxD
// vBuff=poin;
dprintf("win32 to VxD\n");
dprintf("2 the address of vBuff=%x,pMyIRQ=%x\n",vBuff,pMyIRQ);
IN_BUFFER_STRUCT *inBufStructure;
switch(pDIOCParams->dioc_IOCtlCode)
{
case DIOC_OPEN:
dprintf("Open device succeed\n");
dprintf("3 the address of vBuff=%x,win32BuffState=%x\n",vBuff,&win32BuffState);
break;
case DIOC_CLOSEHANDLE:
dprintf("Close device succeed\n");
break;
case MY_REGISTER:
//inbuffer
inBufStructure=(IN_BUFFER_STRUCT*)pDIOCParams->dioc_InBuf;
channel=inBufStructure->channel;
frequency=inBufStructure->frequency;
hWin32Event=inBufStructure->eventhandle;
//outbuffer
*(PVOID*)pDIOCParams->dioc_OutBuf=&outBufStructure;
{
_outp(0x281,(BYTE)(channel<<8));
pMyTimer=new AdTimeOut(1000/((int)frequency));//生成时钟钟类实
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -