[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: hardware detection using libpci

        Corel has created a modular detection system which detects
hardware by probing what the kernel has found and by looking for
hardware itself. We are in the finishing stage and will be releasing it
to the open source community shortly.

        In the meantime, please read the attached document for more

Robert S. Young

Glenn McGrath wrote:
> Ive been thinking about hardware detection. I think hardware detection
> should be a dependency on the fetch method it applies to.
> e.g. the http/ftp/nfs retriever should depend on network and modem
> hardware detection.
> This way, if a network retriever is to be used, the hardware detection
> component of it should have already detected the relevent hardware and
> determined what kernel modules are needed to support it.
> Say for example im using a weirdo network card that isnt support on the
> boot disk due to space constraints,
>  and that i want to do a net install, if i can detect what kernel
> modules i need then i can use another fetch method (.e.g. floppy
> retriever) to fetch that kernel module.
> Splitting detection up like this seems to me to be the most space
> efficient way of doing it as well.
> Yesterday i started hacking together a small program that uses libpci to
> detect the required ethernet kernel modules, it is attached.
> Its really only serves as a demonstration at the moment to get some
> feedback,
> Its limitations;
> 1) It only detectes hardware for the following modules, 3c59x.o rtl8139,
> ne2k-pci. Its fairly simple to add support for other modules, just a
> matter of doing it, no thinking involved.
> 2) Its obviously limited to PCI devices, seperate programs will have to
> be used for ISAPNP, PCMCIA etc
> Its good points;
> 1) its small, looks like that with libdetect the hardware list is a
> significant proportion os its total size, ive just ignore things like
> the cards name, just care about the card PCI id and the kernel module
> that it needs. Focusing on detecting the hardware required for specific
> kernel modules, rather than detcting evberything and then mapping it to
> kernel modules should make it more modular and smaller.
> 2) libpci is from pci-utilities, its fairly portable, can either use
> /proc to get pci ids or probe hardware directly, the later making it
> portable to other OS's
> What do you think?
> Glenn
>   ------------------------------------------------------------------------
>                        Name: detect-pci-net.c
>    detect-pci-net.c    Type: Plain Text (text/plain)
>                    Encoding: 7bit
Title: devices-overview - Hardware Detection and Discovery

devices-overview - Hardware Detection and Discovery


devices-overview - Hardware Detection and Discovery
Updated: 09 November 2000


Create a central repository for recording information about system hardware. This system, should be field extensible; that is, a third party should be able to augment the system without affecting other third party additions. To be field extensible, the system is modular; this has a side benefit of allowing pieces to be upgraded independently.


At boot time, the detection system runs as /etc/rcS.d/S90detector, the script assumes that the file system is stable. The systems executes a series of scripts to scan all known hardware and stores this information in a new file. Next, the system compares the new detection with the previous detection and executes scripts to configure different aspects of the system.


/etc/devicesThe root of the detection system
/etc/devices/devices.infThe current state of the hardware on the machine
/etc/devices/devices.newHardware detected at boot time
/etc/devices/devices.bakHardware state before boot
/etc/devices/devices.ovrOverrides detected hardware parameters in devices.inf
/etc/devices/det_util/Scripts for detecting the hardware
/etc/devices/det_order/Symlinks to /etc/devices/det_util to indicate the order of hardware detection, see below
/etc/devices/conf_util/Scripts for configuring hardware when a change is detected
/var/log/devices.logLog of detection process; this is created every time the detect script is run

Component Details


This file contains information about all known devices. Each device starts with an class identifier in square brackets followed by tag = value pairs.
hwaddr = 00:90:27:58:63:6C
driver = eepro100.o
manu = Intel Corporation
desc = Intel EtherExpress PRO/100 PCI (82557)
pci = 0x8086, 0x1229, 14

Common device classes are:

networkNetwork card
diskhard drive
cdromCD-ROM or CD-RW
zipzip, jazz or ditto (removable mass storage)
ideIDE controller (hard disk interface)
scsiSCSI controller
audioSound card
usb-stackUSB controller
usbhubUSB hub plugged into USB controller
bootControl over LILO boot image
floppyFloppy drive
videoVideo card
monitorMonitor connected to video card
displaya virtual device, this controls resolution and refresh rates
NOTE: this list is incomplete, any device class may be added
Common device tags are:
descDescription of device
manuManufacturer of device
modelModel of device
driverDriver required to access device
deviceLINUX device
pciPCI bus information
NOTE: all tags are optional


This is a collection of shell and Perl scripts that detect hardware. The script should report discovered hardware by printing the information to stdout in the same format as the devices.inf file. The script that invokes the det_util scripts gathers the information and builds one file, devices.new. Some scripts call programs which may probe hardware, other scripts discover information already detected by the kernel or by looking for specific files. A script must be in this directory to be included in the det_order directory.

detect_bootLook for files used to generate the LILO config file
Device class: boot
detect_disksDetect mass storage devices on the IDE, SCSI and PCMCIA busses.
Device classes: disk, cdrom, zip
detect_floppyScan the Kernel messages looking for information about the floppy drives.
Device class: floppy
detect_kbdRead information from /etc/kbd/keymapping
Device class: keyboard
detect_monitorCurrently, this produces a canned list of most VESA modes.Comming soon . . . we are working on reading the DDC information from the monitor.
Device class: monitor
detect_mouseCall the pestcontrol utility; pestcontrol scans the serial ports and checks the PS/2 mouse port.
Device class: mouse
detect_pciThis script calls cprobe; cprobe scans the PCI bus and matches cards in the /etc/pcimap.inf file.
Device classes: video, scsi, ide, floppy, ipi, raid, storage, network, video3d, camera, audio, telephony, serial, parallel, winmodem, keyboard, point, mouse, input, firewire, accessbus, SSA, usb-stack, SMBus, irda, IRcon, RFcon, I2O, TVcon
detect_printerAsk the kernel what it has detected.
Device class: printer
detect_raidThis script translates the information from /etc/raidtab
Device class: raid
detect_usbAsk the kernel what devices are attached to the USB.
Device classes: audio, keyboard, mouse, joystick, printer, usbhub, usb
detect_xserverThis script detects the current version of the X Server to ensure that the config scripts are generated for the correct version.


This directory defines the order that the hardware will be detected. This is done by creating symlinks to the det_util directory in the form D##detutil; the ## is a number from 00 to 99, the symlinks are invoked in numerical order. update_det_order should be used to create and remove these links.
When installed, the detection package used update_det_order to create symlinks ... update_det_order detect_pci 10
update_det_order detect_usb 20
update_det_order detect_disks 30
update_det_order detect_mouse 41
update_det_order detect_kbd 42
update_det_order detect_monitor 60
update_det_order detect_printer 62
update_det_order detect_xserver 80
update_det_order detect_boot 85
update_det_order detect_floppy 90
update_det_order detect_raid 35


When the detection systems runs, it creates a new set of information called devices.new. The code copies devices.inf to devices.old then compares devices.new to devices.inf. Any differences between the two files are copied to the devices.inf file and the script for the corresponding device class is executed. For example, if the detection discovers that the user has changed their video card, the script conf_util/video will rebuild the X server configuration files to reflect the change of video card.

audioInstall driver in /etc/modules
bootRun fooze
cdromRun fooze, then restart autofs
defaultRun buildxconf
diskRun buildhdinf then fooze
keyboardRun buildxconf
monitorRun buildxconf
mouseCreate a symlink to /dev/mouse then run buildxconf
networkInstall driver in /etc/install and restart the interface
usb-stackInstall driver in /etc/modules
videoSpecial code to load the agpgart module if necessary and then run buildxconf
winmodemInstall driver in /etc/modules
zipRun fooze, then restart autofs


/sbin/detectThis is the script which controls the detection process
/etc/init.d/detectorThis script calls detect from the run-levels
This is run as /etc/rcS.d/S90detector.
/sbin/update_det_orderThis utility installs and removes symlinks from the det_order directory.
etcdevQuery or Get information from devices.inf style files
etcdevdiffCompare devices.inf and devices.new, copy changes and execute scripts from the conf_util directory.
etcdevovrApply the devices.ovr file to the devices.new file.
etcdevsetSet information in devices.inf style files
buildhdinfCreate the /etc/harddrive.inf file used by fooze to create the fstab and lilo.conf files.
ddetectiveDisk Detective; determine the contents of a partition.
foozeCreate the /etc/fstab and any necessary mount points as well as building/etc/lilo.conf, /etc/lilop.conf and running lilo.
buildxconfCreate the /etc/X11/XF86Config file to configure the X server.

Operational Overview

/etc/rcS.d/S90detectoris symlinked to /etc/init.d/detector
/etc/init.d/detectorexecutes /sbin/detect probe
/sbin/detectrun the detection system...
copy devices.inf to devices.old
remove /var/log/devices.log
remove devices.new
Execute the symlinks from det_order and pipe the output to devices.new
Use etcdevovr to apply the devices.ovr file to devices.new
Use etcdevdiff to compare and edit devices.inf with devices.new.For each devices class that has changed, run the corresponding conf_util script.
The detection will restart if any changes are detected. This may happen upto 3 times.


Robin Burgener, Corel Corporation, robinb@corel.com

See Also

pcimap.inf, etcdev, update_det_order


Component Details
Operational Overview
See Also

Reply to: