Hack 93 Display Hardware Information 
If you're new to FreeBSD, you
may be wondering where to find information about your
system's hardware and the resources it
uses.
You've
probably noticed that your FreeBSD
system didn't ship with a Microsoft-style Device
Manager. However, it does have plenty of useful utilities for
gathering hardware information.
9.6.1 Viewing Boot Messages
When you
boot your system, the kernel probes your
hardware devices and displays the results to your screen. You can
view these messages, even before you log in, by pressing the scroll
lock key and using your up arrow to scroll back through the message
buffer. When you're finished, press scroll lock
again to return to the login or command prompt.
You can type dmesg any time you need to read the
system message buffer. However, if it's been a while
since bootup, it's quite possible that system
messages have overwritten the boot messages. If so, look in the file
/var/run/dmesg.boot, which contains the messages
from the latest boot. This is an ASCII text file, so you can send it
to a pager such as more or
less.
You may find it more convenient to search for something particular.
For example, suppose you've added sound support to
your kernel by adding device pcm to your kernel
configuration file. This command will show if the PCM device was
successfully loaded by the new kernel:
% grep pcm /var/run/dmesg.boot
pcm0: <Creative CT5880-C> port 0xa800-0xa83f irq 10 at device 7.0 on pci0
pcm0: <SigmaTel STAC9708/11 AC97 Codec>
In this example, the kernel did indeed probe my Creative sound card
at bootup.
9.6.2 Viewing Resource Information
Sometimes
you just want to know which devices are
using which system resources. This
command will display the IRQs, DMAs, I/O
ports, and I/O memory addresses in use:
% devinfo -u
Interrupt request lines:
0 (root0)
1 (atkbd0)
2 (root0)
3 (sio1)
4 (sio0)
5 (rl0)
6 (fdc0)
7 (ppc0)
8 (root0)
9 (acpi0)
10 (pcm0)
11 (rl1)
12 (psm0)
13 (root0)
14 (ata0)
15 (ata1)
DMA request lines:
0-1 (root0)
2 (fdc0)
3 (ppc0)
4-7 (root0)
I/O ports:
0x0-0xf (root0)
0x10-0x1f (acpi_sysresource0)
0x20-0x21 (root0)
<snip>
I/O memory addresses:
0x0-0x9ffff (root0)
0xa0000-0xbffff (vga0)
0xc0000-0xcbfff (orm0)
0xcc000-0xfbffffff (root0)
0xfc000000-0xfdffffff (agp0)
0xfe000000-0xffffffff (root0)
Alternately, use devinfo -r if you prefer to see
your listing by device.
If you're unsure what a device is, use the
whatis command. For example, in my listing,
ppc0 uses IRQ 7 and DMA 3. To find out what
ppc0 is:
% whatis ppc
ppc(4) Parallel Port Chipset driver
Don't include the trailing number when using the
whatis command.
9.6.3 Gathering Interface Statistics
There are several ways to gather
network interface information. One of
the handiest is the -i switch to
netstat:
% netstat -i
Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll
rl0* 1500 <Link#1> 00:05:5d:d2:19:b7 0 0 0 0 0
rl1* 1500 <Link#2> 00:05:5d:d1:ff:9d 0 0 0 0 0
ed0 1500 <Link#3> 00:50:ba:de:36:33 15247 0 11301 0 78
ed0 1500 192.168.2 genisis. 15091 - 11222 - -
lp0* 1500 <Link#4> 0 0 0 0 0
lo0 16384 <Link#5> 179 0 179 0 0
lo0 16384 your-net localhost 179 - 179 - -
This
command
shows all interfaces, both physical and virtual. This particular
system has three network interface cards: rl0,
rl1, and ed0. The first two
interfaces are shut down, as indicated by the *
after the device name. These three are Ethernet cards, as indicated
by their MAC addresses. (This is also an excellent way to find all of
the MAC addresses on your system).
The ed0 interface and loopback interface
(lo0) have each been configured with a hostname
and an IP address, as indicated by the Network
column. If you're only interested in seeing
interfaces configured with an IPv4 address, add the
-f (family) switch:
% netstat -i -f inet
ed0 1500 192.168.2 genisis. 15091 - 11222 - -
lo0 16384 your-net localhost 179 - 179 - -
9.6.4 Viewing Kernel Environment
You
can
also find hardware information by using
kenv to view your kernel environment.
kenv will dump several screens worth of
information, so use grep when possible to zero in
on the information you want. For example, to view IRQ information:
% kenv | grep irq
hint.ata.0.irq="14"
hint.ata.1.irq="15"
hint.atkbd.0.irq="1"
hint.ed.0.irq="10"
hint.fdc.0.irq="6"
hint.ie.0.irq="10"
hint.le.0.irq="5"
hint.lnc.0.irq="10"
hint.pcic.1.irq="11"
hint.ppc.0.irq="7"
hint.psm.0.irq="12"
hint.sio.0.irq="4"
hint.sio.1.irq="3"
hint.sio.2.irq="5"
hint.sio.3.irq="9"
hint.sn.0.irq="10"
If you're unsure what is using a listed IRQ, use
whatis to look up the second word (the one after
hint). For example, this will show what is using
my IRQ 12:
% whatis psm
psm(4) - PS/2 mouse style pointing device driver
I actually prefer the output of kenv to that of
devinfo. Here, I'll search for
the I/O addresses used by my COM ports:
% kenv | grep port | grep sio
hint.sio.0.port="0x3F8"
hint.sio.1.port="0x2F8"
hint.sio.2.port="0x3E8"
hint.sio.3.port="0x2E8"
To see which devices are disabled:
% kenv | grep disabled
hint.sio.2.disabled="1"
hint.sio.3.disabled="1"
BSD gives the first com port the number zero, so it looks like I have
COM3 and COM4 disabled on this system.
9.6.5 See Also
man dmesg man devinfo man netstat
man kenv
|