Ejemplo n.º 1
0
//Unload entry for MOUSE driver.
static DWORD E1000Destroy(__COMMON_OBJECT *lpDriver,
                          __COMMON_OBJECT *lpDevice,
                          __DRCB          *lpDrcb)
{
    DisconnectInterrupt(g_hE1kIntHandler);  //Release key board interrupt.
    return 0;
}
Ejemplo n.º 2
0
//Unload entry for COM driver.
static DWORD COMDestroy(__COMMON_OBJECT* lpDriver,
                        __COMMON_OBJECT* lpDevice,
                        __DRCB*          lpDrcb)

{
         __COM_CONTROL_BLOCK* pCtrlBlock = (__COM_CONTROL_BLOCK*)((__DEVICE_OBJECT*)lpDevice)->lpDevExtension;

         if(NULL == pCtrlBlock)
         {
			 return 0;
         }
         //Disconnect interrupt.
         DisconnectInterrupt((HANDLE)pCtrlBlock->hInterrupt);
         //Destroy device object.
         IOManager.DestroyDevice((__COMMON_OBJECT*)&IOManager,
                   (__DEVICE_OBJECT*)lpDevice);
         return 0;
}
Ejemplo n.º 3
0
//Main entry point of COM driver.
BOOL COMDrvEntry(__DRIVER_OBJECT* lpDriverObject)
{
         __DEVICE_OBJECT*      pDevObject[COM_DEVICE_NUM];
         BOOL                  bResult     = FALSE;
         int                   i,j;
 
         //Initialize each COM interface device in ComCtrlBlock array.
         for(i = 0;i < COM_DEVICE_NUM;i ++)
         {
                   pDevObject[i] = IOManager.CreateDevice((__COMMON_OBJECT*)&IOManager,
                            ComCtrlBlock[i].pComName,
                            0,
                            1,
                            1024,
                            1024,
                            &ComCtrlBlock[i],
                            lpDriverObject);
                   if(NULL == pDevObject[i])  //Failed to create device object.
                   {
                            PrintLine("COM Driver: Failed to create device object for COM.");
                            goto __TERMINAL;
                   }
                   //Connect each COM interface's interrupt.
                   ComCtrlBlock[i].hInterrupt = ConnectInterrupt(
                            COMIntHandler,
                            (LPVOID)&ComCtrlBlock[i],
                            ComCtrlBlock[i].IntVector);
                   if(NULL == ComCtrlBlock[i].hInterrupt)  //Can not connect interrupt.
                   {
                            PrintLine("COM Driver: Failed to connect interrupt for a COM device.");
                            goto __TERMINAL;
                   }
                   //Initialize the COM interface controller.
                   if(!InitializeCOM(ComCtrlBlock[i].wBasePort))
                   {
                            goto __TERMINAL;
                   }
         }
 
         //Asign call back functions of driver object.
         lpDriverObject->DeviceDestroy = COMDestroy;
         lpDriverObject->DeviceWrite   = ComDeviceWrite;
         lpDriverObject->DeviceRead    = ComDeviceRead;
         lpDriverObject->DeviceOpen    = ComDeviceOpen;
         lpDriverObject->DeviceClose   = ComDeviceClose;
         
         bResult = TRUE; //Indicate the whole process is successful.
__TERMINAL:
         if(!bResult)  //Should release all resource allocated above.
         {
                   for(j = 0;j <= i;j ++)
                   {
                            if(pDevObject[j])
                            {
                                     //Destroy the device object.
                                     IOManager.DestroyDevice((__COMMON_OBJECT*)&IOManager,
                                               pDevObject[j]);
                            }
                            if(ComCtrlBlock[j].hInterrupt)
                            {
                                     //Disconnect interrupt.
                                     DisconnectInterrupt((HANDLE)ComCtrlBlock[j].hInterrupt);
                            }
                   }
         }
         return bResult;
}