glenda.party
term% ls -F
term% pwd
$home/manuals/9front/3/pnp
term% cat index.txt
PNP(3)                     Library Functions Manual                     PNP(3)



NAME
       pnp - Plug 'n' Play ISA and PCI Interfaces

SYNOPSIS
       bind -a '#$' /dev
       /dev/pci/bus.dev.fnctl
       /dev/pci/bus.dev.fnraw
       /dev/pnp/ctl
       /dev/pnp/csnnctl
       /dev/pnp/csnnraw
       ...

DESCRIPTION
       This  device  provides  a limited interface to the PCI bus and Plug 'n'
       Play ISA devices.

   PCI Interface
       PCI devices are addressed logically by a bus number, a device number on
       that bus, and a function number within the device.  The set of all such
       device functions may be enumerated by traversing  the  /dev/pci  direc‐
       tory;  the driver serves two files for each function.  These are a con‐
       trol file which may be read for a textual summary of the  device  func‐
       tion,  and a `raw' file which may be used to read or write the raw con‐
       tents of PCI configuration space.

       The first field of a PCI control file contains the class, sub-class and
       programming  interface  values  for  the  device function, expressed as
       2-digit hexadecimal values, and separated by periods.  The second field
       yields  the vendor ID and device ID, each as 4-digit hex numbers, sepa‐
       rated by a slash.  The third field is the associated interrupt line  in
       decimal.   The  remainder of the line enumerates any valid base address
       registers for the function, using two fields for each.   In  the  first
       field,  the  index of the register is followed by a colon, and then the
       value of the register itself.  The following field gives the associated
       size of the memory (or I/O space) that is mapped by the register.

   Plug 'n' Play
       Plug  'n'  Play  ISA devices are discovered by sending a fixed `unlock'
       sequence over an I/O port, and then  reading  back  data  from  another
       port.   An arbitration algorithm is used to separate out the individual
       cards and enumerate them in turn.  Each card is assigned a unique  num‐
       ber,  called  a  CSN,  in  the  range 1-255 as a result of enumeration.
       Cards also have a fixed 64 bit identification number, set by the  manu‐
       facturer,  which  is  used by the arbitration algorithm to resolve con‐
       flicts.  The first 32 bits describe the type of the card, and the  sec‐
       ond  32  bits  form a serial number for the particular instance of that
       card type.  When formatted textually, it appears as 3  upper-case  let‐
       ters  (typically representing the manufacturer), followed by 4 hex dig‐
       its, then a period, then 8 hex digits.  The substring before the period
       is the card type, and the substring after the period is the serial num‐
       ber.

       The enumeration algorithm needs to be enabled by  specifying  the  port
       number  to write the unlock sequence out on.  This can be configured to
       take place at boot  time  by  adding  a  line  like  the  following  to
       plan9.ini:

              pnp0=port=0x203

       Here  port  should be chosen to not conflict with any existing devices.
       It must be in the range 0x203-0x3ff.  Alternatively, one  can  use  the
       following command:

              echo port 0x203 >/dev/pnp/ctl

       Note  that  a side-effect of PnP enumeration is to reset the configura‐
       tion state of all such cards; any settings made by a Plug and Play BIOS
       will be lost.  Reading the file /dev/pnp/ctl returns one of the strings
       enabled port or disabled.

       For each enumerated card, two files are served in /dev/pnp.  A  control
       file may be read to determine the ID of the card, and a raw file may be
       read to obtain the configuration data associated with the card.  It  is
       intended that the control file should take commands which set the vari‐
       ous configurable resources of the card, but this has  not  been  imple‐
       mented yet.

       A mechanism is provided for configuring cards via plan9.ini(8).  A line
       of the form pnpn=idstring ...  will cause the driver to  look  for  the
       card  named by idstring and, if found, assign it the CSN n.  The inten‐
       tion is that any additional text after the idstring is  interpreted  as
       if  it  was  written to the card's ctl file, but this is not yet imple‐
       mented.

EXAMPLES
       To list all PCI functions:

              cat /dev/pci/*ctl

       To find just the PCI video card (class 3):

              grep '^03' /dev/pci/*ctl

SOURCE
       /sys/src/9/port/devpnp.c

SEE ALSO
       pci(8)

BUGS
       Access to the I/O and memory regions of a PCI device is not provided.

       The ability to set a Plug 'n' Play card's configurable settings has not
       been implemented.

       There should be a user program for identifying and configuring Plug 'n'
       Play cards.



                                                                        PNP(3)