虚拟设备驱动程序的设计与实现[3]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 someone 的 blog

  ②audcard.cpp

  //audcard.cpp - main module for vxd audcard

  #define device_main

  #include "audcard.h"

  declare_virtual_device(audcard)

  #define wm_user_postvxd 0x1000  //自定义消息

  #undef device_main

  audcardvm::audcardvm(vmhandle hvm) : vvirtualmachine(hvm) {}

  audcardthread::audcardthread(threadhandle hthread) : vthread(hthread) {}

  bool audcarddevice::onsysdynamicdeviceinit() //动态加载时初始化

  {

   ......//硬件初始化

   pmyirq=new myhwint();

  if(pmyirq&&pmyirq->hook()) //挂接中断

  {

   pmyirq->physicalunmask(); //允许中断

   return true;

   }

   else return false;

  }

  bool audcarddevice::onsysdynamicdeviceexit()

  //动态卸载过程

  {

   delete pmyirq;

   return true;

  }

  dword audcarddevice::onw32deviceiocontrol(pioctlparams pdiocparams)

  //与win32应用程序的接口函数

  {

  ......

  }

  void myhwint::onhardwareint(vmhandle hvm)

  {

   ...... // 中断处理

   shell_postmessage(appwnd,wm_user_postvxd ,0,0,0,null);

   //向应用程序窗口发送消息

   sendphysicaleoi(); //通知vpicd中断结束

  }

  (作者地址:南京通信工程学院98信箱 210016 收稿日期:1998.12.03)

本文关键:设备驱动,vxd
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top