beautypg.com

Rockwell Automation 2711P Software Development Kit User Manual User Manual

Page 90

background image

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

90 Device Drivers

//

// Attempt to use lower level DDK function to get

// information directly from the PCI controller.

//

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

//

// Normally you would code a loop here that would be

// used to search the PCI Bus for the desired device,

// but for this example we are just going to assume

// we know the BUS, Slot and Function number.

//

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

Sn.u.bits.DeviceNumber = DRV_DEVICE_NUM;

Sn.u.bits.FunctionNumber = DRV_FUNC_NUM;

// DDK call to query for PCI information

dwLength = HalGetBusDataByOffset(PCIConfiguration, DRV_BUS_NUM,

Sn.u.AsULONG,

&Pcc, 0,

sizeof(PCI_COMMON_CONFIG));

//

// check to see if the call was successful

//

if (sizeof(PCI_COMMON_CONFIG) == dwLength)

{

pDrvData->Dii.dwIrq = Pcc.u.type2.InterruptLine;

}

else

{

DEBUGMSG(ZONE_INIT,(_T("DRV_Init: HalGetBusDataByOffset()")

_T(" call failed!\r\n")));

}

#endif // defined(DRV_USE_PCI)

}

//

// If the SYSINTR has not been assigned yet, try and ask the HAL

// if it has or can assign a SYSINTR for you.

//

if (0 == pDrvData->Gii.SysIntr)

{

if (!REQUEST_SYSINTR(pDrvData->Dii.dwIrq,pDrvData->Gii.SysIntr))

{

pDrvData->Gii.SysIntr = DRV_SYSINTR;

}

}