beautypg.com

Rockwell Automation 2711P Software Development Kit User Manual User Manual

Page 88

background image

Publication 2711P-UM005A-EN-P - March 2007

88 Device Drivers

PDDKISRINFO pdii,

PDDKPCIINFO pdpi

);

#endif // defined(DRV_USE_PCI)

DRV_Deinit(

DWORD hDeviceContext

);

static DWORD WINAPI

IstThreadProc(

LPVOID lpParameter

);

/////////////////////////////////////////////////////////////////////

//

// DRV_Init()

//

// Refer to Microsoft documentation on Device Driver Development for a

// detailed description of this function and its parameters.

//

// NOTE: This function will attempt to initialize a NOP driver that

// will be referred to as "DRV:". If a non-recoverable error occurs

// during the INIT phase this function will call DRV_Deinit(). This

// function is safe to call multiple times. This is done to insure

// proper driver cleanup.

//

/////////////////////////////////////////////////////////////////////

DWORD

DRV_Init(

DWORD dwContext

)

{

#if defined(DRV_USE_PCI)

DWORD dwErr;

#endif // defined(DRV_USE_PCI)

PDRV_DATA pDrvData = NULL;

DEBUGMSG(ZONE_FUNC, (TEXT("DRV_Init+\r\n")));

//

// first, create a memory block to store this drivers' global instance data

//

if (NULL == (pDrvData = (PDRV_DATA)LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT,

sizeof(DRV_DATA))))

{

ERRORMSG(1,(_T("DRV_Init: LocalAlloc failed!\r\n")));

DEBUGMSG(ZONE_FUNC, (TEXT("DRV_Init-\r\n")));


return (0);

}

//

// fill in global info

//

pDrvData->bExitThread = FALSE;

pDrvData->hEvent = INVALID_HANDLE_VALUE;

pDrvData->hThread = INVALID_HANDLE_VALUE;

pDrvData->Gii.SysIntr = 0;