* Overview

* Hw_script
* Preload
* Musplay
* Mixer
* Cdman
* Tgt-edif
* fx2_programmer
* Software Radio
* LIGO viewer
* DAQ system

* Status
* Download

* About me

Hw_script is a small extension to Tcl/Tk that provides direct access to pci devices via memory mapped apertures. You need to be root to do that. This is very dangerous ! You may screw up a lot of things ! Needless to say you must know what you are doing... So please - experts only, at your own risk.

How to use:

Take a look in /proc/pci and locate apertures of the device you want to access. You need to know the starting address and the length of the aperture (in bytes). Alternatively you can use scan_pci command to do this in a script.

Next start hw_script (or hw_script_tk) and type in:

ioremap "file" your_aperture_name start_address width_in_bytes

"file" is the location of the file you want to memory map. In Linux use "/dev/mem" for memory apertures and "/dev/ioport" for IO apertures. your_aperture_name can be any string - it is used to identify your aperture (so you may have more than one open). start_address and width can be either decimal or hexadecimal numbers.

Now you can access your aperture by using read_long to read 32-bit values:

read_long your_aperture_name register_address

and write_long to write 32-bit values:

write_long your_aperture_name register_address value

read_byte and write_byte do the same thing with bytes.

register_address is specified in bytes relative to the start of the aperture - and it does not have to be a register..

There are also a few auxiliary functions that do not affect the apertures:

long_to_hex value

long_to_binary value

long_to_char value

scan_pci {puts "hello"}

long_to_hex formats an integer as a 32-bit hex value.
long_to_binary prints an integer in binary, with the highest bit first,in groups of 4 bits.
long_to_char converts (as much as it can) of it into ASCII - eliminating non-printable characters.
scan_pci scans pci bus - for example take a look at read_pci.scp

And, of course, you can write a Tcl/Tk program using the commands above - just remember to replace the top line with either





  • no way to do 16-bit access (yet)
  • your mileage on OS-es other then Linux will vary.

SourceForge Logo http://volodya-project.sourceforge.net/hw_script.php was last modified 4:16pm Monday, April 22nd 2002