wiki:IoPorts
close Warning: Can't synchronize with repository "(default)" (/project/movitz/svn does not appear to be a Subversion repository.). Look in the Trac log for more information.

When accessing the hardware directly, one of the most common operations is to read and write to hardware IO ports.

There is an accessor function (and compiler-macro) located in losp/muerte/io-ports.lisp. This accessor establishes an easy to use method of using IO ports.

Reading from an IO port is accomplished through the following function call:

(io-port <address> <data-type>)

Where:

  • <address> is the io-port address.
  • <data-type> is one of the following:
    • :unsigned-byte8 - an 8-bit integer (using inb/outb).
    • :unsigned-byte16 - a 16-bit integer (inw/outw).
    • :unsigned-byte32 - a 32-bit integer (ind/outd).
    • :character - an 8-bit character (inb/outb).
    • :location - a fixnum, i.e. a lispval whose lower two bits are forced to zero (ind/outd).

To write to an IO port you use the following construction

(setf (io-port <address> <data-type>) <value>)

Where <address> and <data-type> are from the same types are IO port reads and <value> is the data you wish to write to the port.

Last modified 12 years ago Last modified on 04/07/07 20:12:12