FreeBSD 4.11-RELEASE をインストールした日立 FLORA 270SX-14(PCNH8-ASE22H320)には AMD 社製のネットワークカードが内蔵されている。 
pciconf コマンドで見ても、ちゃんとネットワークデバイスとして認識されているのに、有効(利用可能)な状態にならないのだ。 
 
akebi# pciconf -vl 
<略> 
lnc0@pci0:11:0: class=0x020000 card=0x20001022 chip=0x20001022 rev=0x42 hdr=0x00 
    vendor   = 'Advanced Micro Devices (AMD)' 
    device   = 'Am79C970/1/2/3/5/6 PCnet LANCE PCI Ethernet Controller' 
    class    = network 
    subclass = ethernet 
<以下略> 
 
上記のように認識されているが、起動時には、 
 
pcn0: couldn't map ports/memory 
lnc0: <PCNet/PCI Ethernet adapter> at device 11.0 on pci0 
lnc0: pci_port_map_attach failed?! 
lnc0: driver is using old-style compatibility shims 
 
というエラーを出して有効にならない。 
当然のことながら、ifconfig などで見ても lnc0 などというデバイスは出てこないのだ。(実は、lnc0 という認識そのものが間違い。本当は pcn0 として認識されないといけない。(後述)) 
 
実はこれは FLORA の BIOS が「怠惰」なため。 
本来なら BIOS が PCI デバイスの I/O ポートやメモリを動作可能な値に設定してくれないといけない。しかし、「怠惰」な BIOS はそれをしないため、割込番号(IRQ)なども割り当てられず、つまりこの PCI デバイスは動作可能にならない。(これって、Windows での利用しか想定していない BIOS だからなのかな。む〜ん。) 
 
そこで、FreeBSD がそれらを強制的に有効化するカーネルオプションをつけてカーネルの再構築を行ってやる必要があるのだ。(つまり、Windows は常に強制的に有効にしてるってことかな?(余談)) 
 
カーネル再構築を行う。 
 
akebi# cd /sys/i386/conf 
akebi# ls -la 
total 130 
drwxr-xr-x   2 root  wheel     512 Apr 18 20:38 . 
drwxr-xr-x  13 root  wheel     512 Apr 16 18:02 .. 
-rw-r--r--   1 root  wheel    9175 Apr 20 21:51 AKEBI 
-rw-r--r--   1 root  wheel    9816 Jan 14 12:07 GENERIC 
-rw-r--r--   1 root  wheel  107550 Jan 20 03:24 LINT 
akebi# vi AKEBI 
<略> 
options         AHD_REG_PRETTY_PRINT    # Print register bitfields in debug 
                                        # output.  Adds ~215k to driver. 
# 2005/04/20 
options         PCI_ENABLE_IO_MODES ← 追加 
 
# To make an SMP kernel, the next two are needed 
#options        SMP                     # Symmetric MultiProcessor Kernel 
<略> 
 
コンフィグファイルの修正が終わったら、新カーネルの make を行う。 
 
akebi# config AKEBI 
Don't forget to do a ``make depend'' 
Kernel build directory is ../../compile/AKEBI 
akebi# cd ../../compile/AKEBI 
akebi# make depend 
rm -f .newdep 
make -V CFILES -V SYSTEM_CFILES -V GEN_CFILES | xargs  mkdep -a -f .newdep -O -pipe  -Wall -Wredundan 
t-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qu 
al  -fformat-extensions -ansi  -nostdinc -I- -I. -I../.. -I/usr/include -I../../contrib/dev/acpica -I
../../contrib/ipfilter  -D_KERNEL -include opt_global.h  -mpreferred-stack-boundary=2 
<略> 
===> pst 
===> twa 
===> vesa 
akebi# make 
cd ../../modules ; env MAKEOBJDIRPREFIX=/usr/src/sys/compile/AKEBI/modules COPTS="-include /usr/src/sys/compile/AKEBI/opt_global.h" M 
ACHINE=i386 make obj ;  env MAKEOBJDIRPREFIX=/usr/src/sys/compile/AKEBI/modules COPTS="-include /usr/src/sys/compile/AKEBI/opt_global 
.h" MACHINE=i386 make all 
===> accf_data 
===> accf_http 
===> agp 
===> aha 
<略> 
===> mly 
===> pst 
===> twa 
===> vesa 
akebi# make install 
chflags noschg /kernel 
mv /kernel /kernel.old 
install -m 555 -o root -g wheel -fschg  kernel /kernel 
<略> 
===> twa 
install -o root -g wheel -m 555   twa.ko /modules 
===> vesa 
install -o root -g wheel -m 555   vesa.ko /modules 
akebi# ls -la /kernel* 
-r-xr-xr-x  1 root  wheel  2788484 Apr 21 07:36 /kernel 
-r-xr-xr-x  1 root  wheel  4388756 Jan 22 02:21 /kernel.GENERIC 
-r-xr-xr-x  1 root  wheel  2788452 Apr 20 21:54 /kernel.old 
 
無事、新カーネルが出来上がったので PC の再起動を行う。 
 
これで、起動時に、 
 
pcn0: <AMD PCnet/PCI 10/100BaseTX> port 0x10c0-0x10df mem 0xfc008000-0xfc00801f irq 9 at device 11.0 on pci0 
pcn0: Ethernet address: 00:90:f5:XX:XX:XX 
miibus0: <MII bus> on pcn0 
 
と無事認識されているし、pciconf で見ても、 
 
pcn0@pci0:11:0: class=0x020000 card=0x20001022 chip=0x20001022 rev=0x42 hdr=0x00 
    vendor   = 'Advanced Micro Devices (AMD)' 
    device   = 'Am79C970/1/2/3/5/6 PCnet LANCE PCI Ethernet Controller' 
    class    = network 
    subclass = ethernet 
 
と、正しく pcn0 デバイスとして認識されている。(今までは lnc0 デバイスと誤認されていた) 
後は、ifconfig で IP アドレスを割り当ててやるだけである。 
good. 
 
 |   
 |