What is HW driver?

Knowledge Base Article # Q200192

Read Prior Article Read Next Article
Summary This article discusses how to use the Marvin Test Solutions' HW device driver to obtain information about your PXI system and PXI instruments.
The HW package - MTS (Marvin Test Solutions) Hardware Access Driver, is used by all MTS instrument drivers and ATEasy to access to the PC resources (memory, IO ports, DMA etc), PCI/PXI configuration and more.  The HW package includes libraries used to program and create instrument drivers for PC/PCI/PXI based instruments. A PXI/PCI Explorer utility to configure and display PXI/PC based systems is also included.  The utility includes a VISA configuration utility for PXI and PXI express instruments (similar to NI-MAX) and support for MTS and other vendors PXI chassis, controllers and expanders.

The HW driver supports running on Windows 9x-Windows 8/Server 2012 and support 16, 32 and 64 bit Windows applications.

The following files are installed when running the HwSetup.exe setup for HW:

HwSetup.exe - A command line utility to install, uninstall and check the status of the HW driver.

HwTest.exe - A program to test the HW driver and to read/write to I/O ports, memory and to display PCI resources.

Hw.sys and Hw64.sys - Windows kernel mode device drivers, provides access to I/O ports, memory and PCI resources, installed to the Windows System Drivers directory.

HwDevice.sys and HwDevice64.sys - Windows kernel mode device driver for HW.INF boards, installed to the Windows System Drivers directory.

HwPxiExpress.dll - Provides information to MTS Chassis, Controller and Peripheral PXIe devices, installed to the Windows System directory.

Hw.vxd - Windows 9x/Me virtual device driver provides access for memory and PCI resources, installed to the Windows System directory.

HwCIns16.dll - Windows 9x/Me Class Installer for HW.

HwCIns32.dll and HwClins64.dll - Windows Class Installer for HwDevice.sys and HwDevice64.sys.

HwVdd.dll - VDD for 16 app running on 2000-Vista, installed to the Windows System directory.

Hw.inf - Driver information files for MTS's PXI/PCI boards.  Installed to the Windows System\INF directory.

Hw.cat - Windows digitally signed catalog file.

HwPciExplorer.cpl and HwPciExplorer64.cpl - PXI/PCI Explorer - Windows Control Panel applet to display the current PXI/PCI devices and to assign slot numbers to device resources. Slots numbers are required to identify a PCI/PXI board when using MTS board driver. Installed to the Windows System directory.

Hw.dll and Hw64.Dll -  Library with API defined in hw.h, installed in Windows System folder.

Hw.h -  Include file, to include in your C/C++ project provides functions prototypes to Hw.dll  and Hw64.dll files.

Hw.lib and Hw64.lib -  import library for C/C++ application using the HW.dll and Hw64.dll.

ReadMe.txt - Contains the latest release information about the HW package.

There are many functions within the HW library that are useful for determining the system configuration.  This article discusses the most important procedures, the structHWPCIDEVICE data structure, and provides an example of using the objects listed below for querying the PXI system resources:

Initializes the HW library

PciGetSlotNumbers([Val] Word wVendorId, [Val] Word wDeviceId, Var Short panSlotNumbers[], Var Word pwDevicesFound):
Returns an array of slot number(s) for the devices with the specified Vendor ID and specified Device ID.

PciGetSlotDevice(Val Long lSlot, Var structHWPCIDEVICE pstPciDev):
Returns the device information for the instrument in the specified slot.

Struct structHWPCIDEVICE:
A data type structure that contains information about devices (instruments) installed in a PXI system.  While the procedures above are used to obtain information about a PXI device, it is the structHWPCIDEVICE data structure where that information is stored.  So knowing the structure of the data type is key to fully utilizing the HW driver.  The full structure is provided in the ATEasy HW driver, and provided below for review:

Struct structHWPCIDEVICE
  Dword dwVendorId
  Dword dwDeviceId
  Dword dwBus
  Struct structPciSlotNumber stPciSn
    Dword dwAsUlong
  Struct strictPciCommonConfig stPciCfg
    Word wVendorId
    Word wDeviceId
    Word wCommand
    Word wStatus
    Byte ucRevisionId
    Byte ucProgIf
    Byte ucSubClass
    Byte ucBaseClass
    Byte ucCacheLineSize
    Byte ucLatencyTimer
    Byte ucHeaderType
    Byte ucBIST
    Struct structPciHeaderType0 stType0
      Dword adwBaseAddresses[6]
      Dword dwSubSystem
      Dword dwSubVendorID
      Dword dwROMBaseAddress
      Dword adwReserved2[2]
      Byte ucInterruptLine
      Byte ucInterruptPin
      Byte ucInterruptPin
      Byte ucMinimumGrant
      Byte ucMaxinumLatency
    Byte dwDeviceSpecific[192]
  Struct structCmPartialResourceDescriptor  aResDesc[8]
    Byte ucType
    Byte ucShareDisposition
    Word wFlags
    DWord Address1
    DWord Address2
    DWord Address3
  Struct structHwMemoryDesc aMemDesc[8]
    DWord dwPhAddrLow
    Long lPhAddrHigh
    DWord dwLength
    DWord pvVirtualAddress
  Char szId[256]

To demonstrate the utility of the HW driver, let's review a common task confronting anyone writing a program to control PXI test instruments.  When writing a test program, the programmer is always faced with having to identify what instruments are installed in the PXI chassis.  This information is essential to the test program so it knows how to establish a communication link between the host computer (i.e., the test program) and the instruments.  Instrument identification can take one of several forms; slot numbers can identify instruments, instruments can be identified by a resource descriptor (VISA) and board numbers can be used - these are the most common means of identification.

The HW library also supports a simplified means of referencing a device; by it's Alias.  An alias is a text name that can be assigned to any instrument in a PXI chassis using PXI/PCI Explorer, a PXI resource utility that is installed with the HW package.  A detailed explanation of how to do this is discussed in Knowledge Base article #Q200187.

What is HW driver?
Figure 1:  Using PXI/PCI Explorer to assign an instrument Alias

The typical process for establishing communication with an instrument is to “Initialize” the instrument by passing the iappropriate dentification parameter into an initialization procedure, typically contained in the instrument drivers, and having the procedure return a “handle” that is used as a reference for future communication with the instrument.  This process is very similar to that of opening a file, and using the returned “file handle” for subsequent reading or writing to the file.

Identification of instruments can be done at program design time by hard-coding the instrument identification into the test program, or at run time by querying the system resources and dynamically initializing instruments using the information returned by the system query.  To use procedures contained in HW.DLL to query the system resources and identify installed instruments at run time, the HW Initialize() procedure must be called prior to calling any of the other procedures in the HW driver.

Once initialized, the PciGetSlotNumbers() procedure will return an array of PXI slot numbers that contain instruments matching the search criteria – often the Vendor ID and Device ID.  The PciGetSlotDevice() procedure returns the device information for the instrument in the specified slot.  The device information is contained in the structure structHWPCIDEVICE (listed above).  If, for example, you wanted to know how many GX5290 dynamic digital instruments were installed in a PXI chassis, what are their slot numbers, and the firmware revision of each of those instruments, you could use the following code:

Word wVendorId=0x16E2 ! Geotest Vendor ID
Word wDeviceId=0x5290 ! GX5290 Device ID
Short panSlotNumbers[32] ! Array of slot numbers found
Word pwDevicesFound ! Number of slots matching the Vendor and Device ID’s
structHWPCIDEVICE pstPciDev
String sDeviceInfo
Long i

PciGetSlotNumbers(wVendorId, wDeviceId, panSlotNumbers, pwDevicesFound)
If pwDevicesFound<>0
  For i=0 to pwDevicesFound-1
    PciGetSlotDevice(panSlotNumbers[i], pstPciDev)
    sDeviceInfo= pstPciDev.szId
    Print "Slot "+Format(panSlotNumbers[i],"00")+" Firmware: "+Mid(sDeviceInfo,Pos("SUBSYS_",sDeviceInfo)+7,4)

Once the slot number for an instrument is obtained, it would be a simple matter to initialize the instrument by calling the instrument's Initialize() procedure and passing the slot number obtained by scanning the PXI system using the example above.  

For additional information about how to use the HW driver, review the HW programming example installed with ATEasy (Hw.prj) and the HW files installed the Program Files\Marvin Test Solutions\HW. More information is also avilable in the flowing knowledge base articles: Q182, Q187.
Article Date 3/31/2010 4:50:38 PM     Updated: 5/12/2014 9:04:58 AM
Keywords PXI, PCI, HW Driver, GX5290, ATEasy

1 ratings | 4 out of 5
Read Prior Article Read Next Article