WinPMC
SUMMARY
This device driver enables and
controls
access to the Performance Monitor Counters and the RDPMC assembly
instruction
on Pentium MMX class processors from a user application.
The driver building and
installation
instructions given here only apply to Windows® 2000.
BUILDING THE DRIVER
Note: To build this driver,
it
is assumed that you have already installed a current version of the
Windows
DDK toolkit. In the past, the toolkit was available at http://www.microsoft.com/ddk/.
Now it can be requested from that website, or found on someone's
subscription to MSDN. There are two ways to build the WinPMC driver.
The first uses the command line. It is the simplest and quickest. The
second requires more setup, but is well integrated with the Microsoft
Visual Studio development environment.
BUILDING WITH THE COMMAND LINE
Click the Free Build
Environment
or Checked Build Environment icon under your Developement Kits program
group to set basic environment variables needed by the build utility.
Change to the directory
containing
the device source code. By default this is:
>CD
C:\papi\src\win2k\winpmc.
The First Time
Run build -ceZ, or use the
macro
BLD.
This behavior invokes the Microsoft make routines that produce log
files
called Buildxxx.log, and also Buildxxx.wrn and Buildxxx.err if there
are
any warnings or errors. Where xxx stands for fre or
chk depending
on the environment chosen. If the build succeeds, the driver WinPMC.sys
will be placed in a platform specific subdirectory of your
%TargetPath%
directory specified in the Sources file. By default, this will be:
>CD
C:\papi\src\win2k\winpmc\sys\[objchk
objfre]\i386\.
Driver Installation
To install the driver, run the
batch
file instpmc.bat found in the winpmc directory. This
batch
file copies the driver to C:\WINNT\system32\drivers, invokes
the
included ntaddsvc application to modify the registry, and
invokes
net
start to load the driver.
Note: It may be necessary
to edit the batch file if your directory structure does not match the
default.
Successive Builds
After the first build and
installation,
use bldpmc.bat within the Checked or Free Build
Environment.
This batch file unloads the current driver; builds a new one; copies it
to the drivers directory; and reloads the driver for execution and
testing.
Note: It may be
necessary
to edit the batch files if your directory structure does not match the
default.
MICROSOFT VISUAL STUDIO
If you are using Microsoft
Visual Studio, you may find the above
process to be clumsy and counter-intuitive. A batch file, ddkbuild.bat,
is available from HollisTech that simplifies this process and
integrates it into the Visual Studio environment. This batch file and
supporting documentation is available here: http://www.hollistech.com/Resources/ddkbuild/ddkbuild.htm.
The batch file itself must be
installed somewhere that Visual Studio can find it. On my computer it's
in C:\Program Files\Microsoft Visual
Studio .NET 2003\Common7\Tools.
In addition, an environment
variable must be defined as specified in the HollisTech documentation.
This variable must point to your installation of the DDK. For
simplicity, the variable I use is WKBASE
== C:\WINDDK\3790. To define this variable, go to Start->Setting->Control
Panel->System->Advanced->Environment Variables and
define a new system variable with a definition appropriate for your
installation.
The third piece of the puzzle
is the modification of the project itself. This has already been done
for the WinPMC project inside the WinPAPI Shell Solution. It is also
described in detail in the HollisTech documentation. As a quick review,
the settings expected for the NMake Configuration Properties of this
project are:
- Build Command Line: ddkbuild -W2K free .
- Rebuild Command Line: ddkbuild -W2K free . /a
- Output: WinPMC.sys
The same settings apply for the
debug version, with the substitution of the word 'checked' for the word
'free'.
To install the newly made
driver, run one of the supplied batch files found at C:\papi\src\win2k\winpmc\[instpmcfre.bat, instpmcchk.bat]. These can be configured as external
tools in the Tools menu of Visual Studio.
TESTING
To test your WinPMC driver, run
the
WinPMCTest application found in the winpmc directory. Items in the Test
menu will exercise various aspects of the PMC driver. Actually, the
WinPMCTest application doesn't exist. I may have intended to write one
at some point, but never did. To really test the driver, build and run
the WinPAPI Shell application and exercise the test functions in the
Diagnostics panel.
RESOURCES
For the latest release of the
Windows
NT device driver kit, see http://www.microsoft.com/ddk/.
For the latest release of the ddkbuild batch file, see http://www.hollistech.com/Resources/ddkbuild/ddkbuild.htm.
Other components mentioned above are part of the PAPI distribution.
CODE TOUR
File Manifest
Directory File Description
winpmc WinPMC.html Build documentation for this driver (this file).
WinPMC.dsp,dsw Project and Workspace files for MS Visual C.
pmclib.c Source file for Driver interface library.
pmclib.h Header file for Driver interface library.
instpmc.bat batch file to install and run the driver.
bldpmc.bat batch file to build and run the driver.
ntaddsvc.exe driver installer called by instpmc.bat.
dirs Tells the build environment where to find Sources.
Sources Generic file list for building the driver.
Makefile Used by the build environment. DON'T TOUCH.
pmc_x86.c Source file for PMC specific functionality.
pmc_x86.h Source file for PMC specific functionality.
WinPMC.c Source file for Windows Driver generic functionality.
WinPMC.h Include file for Windows Driver generic functionality.
Top of page
© 2001 Innovative
Computing
Laboratory, University of Tennessee