PnP(4)

NAME
pnp - support for PnP devices

SYNOPSIS
controller pnp0

DESCRIPTION
Support for PnP devices in FreeBSD allows the user to override the configuration of PnP cards, and device drivers to fetch/modify parameters in the card's configuration space.

The manual override mechanism requires the kernel to be compiled with the options USERCONFIG. In this case, the kernel keeps a table of fixed size (20 entries as a default) where configuration data are held for PnP devices. Each PnP card can contain several independent devices (5 or 6 is not unusual).

By booting the kernel with the "-c" flag, commands are available to modify the configuration of PnP cards. Commands start with the sequence: pnp CSN LDN where CSN and LDN are the Card Select Number and Logical Device Number associated to the device. Following this sequence any combination of the following commands can be used:

irqN line
    Sets the line user for interrupt 0 or 1. line=0 means the line is unused.

drqN n
    Sets the channel used for DMA 0 or 1. channel=4 means the channel is unused.

portN address
    Sets the base address for the N-th port range (N=0..7). address=0 means that the port is not used.

memN address
    Sets the base address for the N-th memory range (N=0..3). address=0 means that the memory range is not used.

bios
    Makes the PnP device use the configuration set by the BIOS. This is the default, and is generally ok if your BIOS has PnP support. If BIOS is used, then other parameters are ignored except "flags".

os  Makes the PnP device to use the configuration specified in this entry.

enable
    Enables the PnP device.

disable
    Disables the PnP device.

delete
    Frees the entry used for the device, so that it can be used for another device with a different CSN/LDN pair.

flags
    Sets the value of a 32-bit flags entry which is passed to the device driver. It can be used to set special operation modes (e.g. SB vs. WSS emulation on some sound cards, etc.).

The current content of the table can be printed using the ls command in userconfig. In addition to modifications done by the user, the table contains an entry for all logical devices accessed by a PnP device driver.

Modifications to the table will be saved to the boot image on the filesystem by the dset(8) command.

DEVICE DRIVER SUPPORT FOR PnP
PnP devices are automatically recognised and configured by the kernel. A PnP device is identified by the following data structure: struct pnp_device { char *pd_name; char * (*pd_probe ) (u_long csn, u_long vendor_id); void (*pd_attach ) (u_long csn, u_long vend_id, char * name, struct isa_device *dev); u_long *pd_count; u_int *imask ; struct isa_device dev ; };

The probe routine must check that the vendor_id passed to the routine is a recognized one, that any necessary device on the card is enabled, and returns a NULL value in case of failure and a non-NULL value (generally a pointer to the device name) in case of success. In the probe routine, read_pnp_parms() can be used to check that a logical device is enabled.

The attach routine should do all the necessary initialization, enable the PnP card to ISA accesses, fetch the configuration and call the ISA driver for the device.

The following routines and data structures can be used.

struct pnp_cinfo
    This data structure (defined in /sys/i386/isa/pnp.h) contains all informations related to a PnP logical device.

read_pnp_parms(struct pnp_cinfo *d, int ldn)
    This function returns the configuration of the requested logical device. It is not possible to specify a CSN since this function is only meant to be used during probe and attach routines

write_pnp_parms(struct pnp_cinfo *d, int ldn)
    This function sets the parameters of the requested logical device. At the same time, it updates the entry in the kernel override table. Device drivers in general should not modify the configuration of a device, since either the BIOS or the user (through userconfig) should know better what to do. In particular, device driver should not enable a logical device which has been found disabled, since this would defeat the override mechanism in userconfig. Device drivers may disable a logical device, or a port range, etc. but should do so only that particular device or parameter is known to cause troubles.

enable_pnp_card(void)
    This function must be used in the attach routine only, before accessing the card's ISA ports/memory address ranges.

SEE ALSO
dset(8)

BUGS
There is no support for visual configuration of PnP devices. It would be nice to have commands in userconfig to fetch the configuration of PnP devices.

AUTHOR
PnP support was written by Luigi Rizzo, based on initial work done by Sujal Patel.

HISTORY
The pnp driver first appeared in FreeBSD 2.2.5.