VIAのデュアルコア Nano X2 U4025搭載 ZBOX nano VD01 (5)
2012/01/21(土) 19:17 NetBSD はてブ情報 はてブに登録 はてブ数

さて、ZBOX nano VD01の起動しない問題、続々々々編です。

pci_modeを1にすることで無事に起動することが確認できたわけですが、修正自体はチェックロジックを潰すという非常に行儀の悪いものでした。

sys/arch/x86/pci/pci_machdep.cのpci_mode_detect関数をよく見ると、前半になにやらquirkという文字が。

どうやらここで特定のチップセットに対してpci_modeを設定しているようです。pci_conf_read関数を実行して得られたidとpcim1_quirk_tblテーブルに格納されたidを比較し、合致すれば後の処理を行わずにpci_modeを返しています。
518 pci_mode_detect(void)
中略
533 	pci_mode = 1; /* assume this for now */
534 	/*
535 	 * catch some known buggy implementations of mode 1
536 	 */
537 	for (i = 0; i < __arraycount(pcim1_quirk_tbl); i++) {
538 		pcitag_t t;
539 
540 		if (!pcim1_quirk_tbl[i].tag)
541 			break;
542 		t.mode1 = pcim1_quirk_tbl[i].tag;
543 		idreg = pci_conf_read(0, t, PCI_ID_REG); /* needs "pci_mode" */
544 		if (idreg == pcim1_quirk_tbl[i].id) {
545 #ifdef DEBUG
546 			printf("known mode 1 PCI chipset (%08x)\n",
547 			       idreg);
548 #endif
549 			return (pci_mode);
550 		}
551 	}
中略
593 }
つまり、pcim1_quirk_tblという配列にZBOX nano VD01向けの情報を入れれば良いはずです。

pcim1_quirk_tblは、sys/arch/x86/pci/pci_machdep.cで次のように定義されています。
179 #define _qe(bus, dev, fcn, vend, prod) \
180 	{_m1tag(bus, dev, fcn), PCI_ID_CODE(vend, prod)}
181 struct {
182 	uint32_t tag;
183 	pcireg_t id;
184 } pcim1_quirk_tbl[] = {
185 	_qe(0, 0, 0, PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_TRIFLEX1),
186 	/* XXX Triflex2 not tested */
187 	_qe(0, 0, 0, PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_TRIFLEX2),
188 	_qe(0, 0, 0, PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_TRIFLEX4),
189 	/* Triton needed for Connectix Virtual PC */
190 	_qe(0, 0, 0, PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82437FX),
191 	/* Connectix Virtual PC 5 has a 440BX */
192 	_qe(0, 0, 0, PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82443BX_NOAGP),
193 	/* Parallels Desktop for Mac */
194 	_qe(0, 2, 0, PCI_VENDOR_PARALLELS, PCI_PRODUCT_PARALLELS_VIDEO),
195 	_qe(0, 3, 0, PCI_VENDOR_PARALLELS, PCI_PRODUCT_PARALLELS_TOOLS),
196 	/* SIS 740 */
197 	_qe(0, 0, 0, PCI_VENDOR_SIS, PCI_PRODUCT_SIS_740),
198 	/* SIS 741 */
199 	_qe(0, 0, 0, PCI_VENDOR_SIS, PCI_PRODUCT_SIS_741),
200 	{0, 0xffffffff} /* patchable */
201 };
どうやら、PCIデバイスのベンダIDと製品IDが必要のようです。

ZBOX nano VD01はVIA製品ですからベンダID=0x1106まではすぐにわかるのですが、製品IDがわかりません。

とりあえず、このロジックの部分にidregを表示させるprintfを挿入して確認したところ製品IDは0x0410でした。

sys/dev/pci/pcidevsを見ても0x0410は存在しないため、新たに追加が必要だということになります。

追加は簡単なのですが、製品名として何を指定すればよいのでしょう。ZBOX nano VD01の使用を見るとチップセットがVX900Hだそうです。とはいえ、これで正しいのかよくわからないので、VIAのWebページからVX900 Series Programming Manualをダウンロードして確認してみたところ、P18にDevice IDの記載があります。ここに0410hと記載されているので、製品名としてはVX900でよさそうです。

ということで、sys/dev/pci/pcidevsの4591行目の後ろにVX900の記述を加えました。
4583 /* VIA Technologies products, from http://www.via.com.tw/ */
中略
4591 product VIATECH	VT8371_HB	0x0391	VT8371 (Apollo KX133) Host Bridge
     product VIATECH	VX900	0x0410	VX900
4592 product VIATECH VT8501_MVP4	0x0501	VT8501 (Apollo MVP4) Host Bridge
さらに、sys/arch/x86/pci/pci_machdep.cのpcim1_quirk_tblにVX900の定義を追加しました。
198 	/* SIS 741 */
199 	_qe(0, 0, 0, PCI_VENDOR_SIS, PCI_PRODUCT_SIS_741),
    	/* VIA technology VX900 */
    	_qe(0, 0, 0, PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900),
200 	{0, 0xffffffff} /* patchable */
201 };
これでうまく動いてくれているようで、ブート時に次のメッセージが表示されるようになりました。
known mode 1 PCI chipset (04101106)
これが正しい修正なのかはわかりませんが、だいぶマシになったかなと思います。

開始当初は、traceすらできない状況でしたが、まさに紆余曲折ありましたが、なんとか動かすことができてよかったです。

わかる人が見れば、最初のpci_make_tagのところで、pci_modeが1じゃないぞ、フツーpci_modeが1だからquirkつかって強制的にpci_modeを1にすれば動きそうだな。ぐらいの最短距離で動かせたかもしれませんね。

名前:  非公開コメント   

  • TB-URL  http://www.tokuda.net/diary/0766/tb/

VIAのデュアルコア Nano X2 U4025搭載 ZBOX nano VD01 (4)
2012/01/21(土) 16:59 NetBSD はてブ情報 はてブに登録 はてブ数

さて、ZBOX nano VD01の起動しない問題、続々々編です。

前回の時点で、panic処理に至るまでの挙動がぼんやりとつかめましたが、いかんせん先が見えない状況になってしまいました。

手がかりをつかむため、kernelのconfigにDEBUGを追加して様子を見ることにしました。今思うと、最初に追加すべきoptionsだったような。
options         DEBUG           # expensive debugging checks/support
すると、panicする前に次のようなメッセージが追加されました。
pci_mode_detect: mode 1 enable failed (0)
pci_mode_detectはsys/arch/x86/pci/pci_machdep.cにある関数で、pci_modeを判断する役割を担っているようです。

先のメッセージを出している部分は564行目です。pci_modeを判定するためにレジスタへの書き込みと読み込みを行い、読み込み結果が正しければpci_modeが1になり、そうでなければ567行目のgoto文のnot1というラベル名からもわかるとおりpci_modeは1じゃない処理に進みます。
518 pci_mode_detect(void)
519 {
中略
553 	/*
554 	 * Strong check for standard compliant mode 1:
555 	 * 1. bit 31 ("enable") can be set
556 	 * 2. byte/word access does not affect register
557 	 */
558 	outl(PCI_MODE1_ADDRESS_REG, PCI_MODE1_ENABLE);
559 	outb(PCI_MODE1_ADDRESS_REG + 3, 0);
560 	outw(PCI_MODE1_ADDRESS_REG + 2, 0);
561 	val = inl(PCI_MODE1_ADDRESS_REG);
562 	if ((val & 0x80fffffc) != PCI_MODE1_ENABLE) {
563 #ifdef DEBUG
564 		printf("pci_mode_detect: mode 1 enable failed (%x)\n",
565 		       val);
566 #endif
567 		goto not1;
568 	}
中略
593 }
そういえば、pci_make_tagでもswich文でpci_modeを判別していました。たしかにpci_modeが2で動作して(そしてpanicして)いるみたいですね。

pci_modeが1だろうと2だろうと、正しく動けばどっちでもいいなと思いながらも、なんとなく引っかかります。

また、mode 1とmode 2のコメントを見比べてみると、mode 1はがっちりチェック、mode 2はテキトーチェック、という風に読めます。
    553 	/*
    554 	 * Strong check for standard compliant mode 1:
    555 	 * 1. bit 31 ("enable") can be set
    556 	 * 2. byte/word access does not affect register
    557 	 */

    577 	/*
    578 	 * This mode 2 check is quite weak (and known to give false
    579 	 * positives on some Compaq machines).
    580 	 * However, this doesn't matter, because this is the
    581 	 * last test, and simply no PCI devices will be found if
    582 	 * this happens.
    583 	 */
コメントから読み取れるのチェックの力の入れっぷりと、最初にmode 1を試して、ダメならしぶしぶmode 2を試すというfallbackっぽいロジックになっていることから、pci_modeはフツーmode 1であるべきで、まれなケースでmode 2ということなんじゃないかと。

そもそも、2011年後半に発売されたマシンでmode 2っていうのがそもそもおかしくって、mode 1で動くべきなんじゃないのと。というより、ハードウェアとしてはmode 1で動いているつもりなんじゃないのかなと。

そう考えると、pci_make_tagでdeviceが16未満チェックに引っかかってpanicしているのも辻褄が合います。pci_make_tagのmode 1のチェックはdeviceに対して16未満チェックよりも広い32未満でチェックしています。

じゃぁ、強制的にmode 1で動作させてみたらどうだろう、ということで567行目のgoto not1;をコメントアウトしてみました。

どうやら、ビンゴのようです。一気にマルチユーザで起動しました。記念のdmesgを貼付けておきます。options DEBUGをつけているので冗長ですね。
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 5.99.59 (ZBOX) #14: Sat Jan 21 04:44:23 UTC 2012
	root@ideapad:/usr/home/tokuda/tmp/201112290510Z/source/usr/src/sys/arch/i386/compile/obj/ZBOX
total memory = 3327 MB
avail memory = 3259 MB
timecounter: Timecounters tick every 10.000 msec
timecounter: Timecounter "i8254" frequency 1193182 Hz quality 100
To Be Filled By O.E.M. To Be Filled By O.E.M. (To Be Filled By O.E.M.)
mainbus0 (root)
pci_mode_detect: mode 1 enable failed (0)
pci_mode_detect: mode1 force enable
Parsing all Control Methods:
Table [DSDT](id 0001) - 739 Objects with 71 Devices 179 Methods 48 Regions
Parsing all Control Methods:
Table [SSDT](id 0002) - 37 Objects with 0 Devices 23 Methods 0 Regions
 tbxface-0560 [02] TbLoadNamespace       : ACPI Tables successfully acquired
evxfevnt-0102 [02] Enable                : Transition to ACPI mode successful
cpu0 at mainbus0 apid 0: VIA Nano X2 U4025 @ 1.2 GHz, id 0x6fc
cpu1 at mainbus0 apid 2: VIA Nano X2 U4025 @ 1.2 GHz, id 0x6fc
ioapic0 at mainbus0 apid 3: pa 0xfec00000, version 3, 24 pins
ioapic1 at mainbus0 apid 4: pa 0xfecc0000, version 3, 24 pins
acpi0 at mainbus0: Intel ACPICA 20110623
acpi0: X/RSDT: OemId <083011,XSDT0920,20110830>, AslId <MSFT,00000097>
evxfevnt-0088 [02] Enable                : System is already in ACPI mode
evgpeblk-0449 [-2] EvCreateGpeBlock      : GPE 00 to 0F [_GPE] 2 regs on int 0x9
evgpeblk-0449 [-2] EvCreateGpeBlock      : GPE 10 to 1F [_GPE] 2 regs on int 0x9
  nseval-0454 [-3] NsExecModuleCode      : Executed module-level code at 0xce0225ec
Completing Region/Field/Buffer/Package initialization:..............................................................................................................................................
Initialized 38/48 Regions 44/44 Fields 32/32 Buffers 28/38 Packages (787 nodes)
Initializing Device/Processor/Thermal objects by executing _INI methods:.
Executed 1 _INI methods requiring 0 _STA executions (examined 77 objects)
acpi0: SCI interrupting at int 9
timecounter: Timecounter "ACPI-Fast" frequency 3579545 Hz quality 1000
hpet0 at acpi0: high precision event timer (mem 0xfed00000-0xfed00400)
timecounter: Timecounter "hpet0" frequency 14318180 Hz quality 2000
NBPE (PNP0C01) at acpi0 not configured
acpivga0 at acpi0 (VUMA): ACPI Display Adapter
acpiout0 at acpivga0 (CRT, 0x0100): ACPI Display Output Device
acpiout1 at acpivga0 (LCD, 0x0110): ACPI Display Output Device
acpiout1: brightness levels: 20 30 40 50 60 80 90 100
acpiout2 at acpivga0 (TV, 0x0200): ACPI Display Output Device
acpiout3 at acpivga0 (DVI, 0x0120): ACPI Display Output Device
acpivga0: connected output devices:
acpivga0:   0x0100 (acpiout0): Ext. Monitor, head 0, bios detect
acpivga0:   0x0110 (acpiout1): LCD Panel, head 0, bios detect
acpivga0:   0x0120 (acpiout3): Unknown Output Device, head 0, bios detect
acpivga0:   0x0200 (acpiout2): TV, head 0, bios detect
acpiacad0 at acpi0 (ACDP, ACPI0003): ACPI AC Adapter
attimer1 at acpi0 (TMR, PNP0100): io 0x40-0x43
pcppi1 at acpi0 (SPKR, PNP0800): io 0x61
midi0 at pcppi1: PC speaker
sysbeep0 at pcppi1
npx1 at acpi0 (COPR, PNP0C04): io 0xf0-0xff irq 13
npx1: reported by CPUID; using exception 16
CIR (ITE8704) at acpi0 not configured
SIOR (PNP0C02) at acpi0 not configured
RMSC (PNP0C02) at acpi0 not configured
OMSC (PNP0C02) at acpi0 not configured
PCIE (PNP0C02) at acpi0 not configured
acpibut0 at acpi0 (SLPB, PNP0C0E): ACPI Sleep Button
RMEM (PNP0C01) at acpi0 not configured
acpibut1 at acpi0 (PWRB, PNP0C0C-170): ACPI Power Button
apm0 at acpi0: Power Management spec V1.2
evgpeblk-0541 [-3] EvInitializeGpeBlock  : Enabled 3 GPEs in this block
attimer1: attached to pcppi1
pci0 at mainbus0 bus 0: configuration mode 1
pci0: i/o space, memory space enabled, rd/line, rd/mult, wr/inv ok
pchb0 at pci0 dev 0 function 0: vendor 0x1106 product 0x0410 (rev. 0x80)
pchb1 at pci0 dev 0 function 1: vendor 0x1106 product 0x1410 (rev. 0x00)
pchb2 at pci0 dev 0 function 2: vendor 0x1106 product 0x2410 (rev. 0x00)
pchb3 at pci0 dev 0 function 3: vendor 0x1106 product 0x3410 (rev. 0x00)
pchb4 at pci0 dev 0 function 4: vendor 0x1106 product 0x4410 (rev. 0x00)
pchb5 at pci0 dev 0 function 5: vendor 0x1106 product 0x5410 (rev. 0x00)
pchb6 at pci0 dev 0 function 6: vendor 0x1106 product 0x6410 (rev. 0x00)
pchb7 at pci0 dev 0 function 7: vendor 0x1106 product 0x7410 (rev. 0x00)
vga1 at pci0 dev 1 function 0: vendor 0x1106 product 0x7122 (rev. 0x00)
wsdisplay0 at vga1 kbdmux 1: console (80x25, vt100 emulation)
wsmux1: connecting to wsdisplay0
drm at vga1 not configured
hdaudio0 at pci0 dev 1 function 1: HD Audio Controller
hdaudio0: interrupting at ioapic1 pin 17
hdafg0 at hdaudio0: VIA product 9f80
hdafg0: HDMI00 2ch: Digital Out [Jack]
hdafg0: 2ch/0ch 32000Hz 44100Hz 48000Hz PCM16 PCM24 AC3
ppb0 at pci0 dev 3 function 0: vendor 0x1106 product 0xa410 (rev. 0x00)
ppb0: PCI Express 2.0 <Root Port of PCI-E Root Complex>
pci1 at ppb0 bus 1
pci1: i/o space, memory space enabled, rd/line, wr/inv ok
ppb1 at pci0 dev 3 function 1: vendor 0x1106 product 0xb410 (rev. 0x00)
ppb1: PCI Express 2.0 <Root Port of PCI-E Root Complex>
pci2 at ppb1 bus 2
pci2: i/o space, memory space enabled, rd/line, wr/inv ok
ath0 at pci2 dev 0 function 0: Atheros 9285
ath0: interrupting at ioapic1 pin 4
ath0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
ath0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
ath0: mac 192.2 phy 14.0 radio 12.0
ppb2 at pci0 dev 3 function 2: vendor 0x1106 product 0xc410 (rev. 0x00)
ppb2: PCI Express 2.0 <Root Port of PCI-E Root Complex>
pci3 at ppb2 bus 3
pci3: i/o space, memory space enabled, rd/line, wr/inv ok
vge0 at pci3 dev 0 function 0: VIA VT612X Gigabit Ethernet (rev. 0x82)
vge0: interrupting at ioapic1 pin 8
vge0: Ethernet address: ZZ:ZZ:ZZ:ZZ:ZZ:ZZ
ukphy0 at vge0 phy 22: OUI 0x0009c3, model 0x0019, rev. 0
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
ppb3 at pci0 dev 3 function 3: vendor 0x1106 product 0xd410 (rev. 0x00)
ppb3: PCI Express 2.0 <Root Port of PCI-E Root Complex>
pci4 at ppb3 bus 4
pci4: i/o space, memory space enabled, rd/line, wr/inv ok
vendor 0x1106 product 0x3432 (USB serial bus, interface 0x30, revision 0x02) at pci4 dev 0 function 0 not configured
pchb8 at pci0 dev 3 function 4: vendor 0x1106 product 0xe410 (rev. 0x00)
pciide0 at pci0 dev 15 function 0: vendor 0x1106 product 0x9001 (rev. 0x00)
pciide0: bus-master DMA support present, but unused (no driver support)
pciide0: primary channel configured to native-PCI mode
pciide0: using ioapic0 pin 21 for native-PCI interrupt
atabus0 at pciide0 channel 0
pciide0: secondary channel configured to native-PCI mode
atabus1 at pciide0 channel 1
uhci0 at pci0 dev 16 function 0: vendor 0x1106 product 0x3038 (rev. 0xa0)
uhci0: interrupting at ioapic0 pin 20
usb0 at uhci0: USB revision 1.0
uhci1 at pci0 dev 16 function 1: vendor 0x1106 product 0x3038 (rev. 0xa0)
uhci1: interrupting at ioapic0 pin 22
usb1 at uhci1: USB revision 1.0
uhci2 at pci0 dev 16 function 2: vendor 0x1106 product 0x3038 (rev. 0xa0)
uhci2: interrupting at ioapic0 pin 21
usb2 at uhci2: USB revision 1.0
uhci3 at pci0 dev 16 function 3: vendor 0x1106 product 0x3038 (rev. 0xa0)
uhci3: interrupting at ioapic0 pin 23
usb3 at uhci3: USB revision 1.0
ehci0 at pci0 dev 16 function 4: vendor 0x1106 product 0x3104 (rev. 0x90)
ehci0: interrupting at ioapic0 pin 23
ehci0: dropped intr workaround enabled
ehci0: EHCI version 1.0
ehci0: companion controllers, 2 ports each: uhci0 uhci1 uhci2 uhci3
usb4 at ehci0: USB revision 2.0
pcib0 at pci0 dev 17 function 0: vendor 0x1106 product 0x8410 (rev. 0x00)
pchb9 at pci0 dev 17 function 7: vendor 0x1106 product 0xa353 (rev. 0x00)
ppb4 at pci0 dev 19 function 0: vendor 0x1106 product 0xb353 (rev. 0x00)
pci5 at ppb4 bus 5
pci5: i/o space, memory space enabled
hdaudio1 at pci0 dev 20 function 0: HD Audio Controller
hdaudio1: interrupting at ioapic0 pin 17
hdafg1 at hdaudio1: VIA VT1708S
hdafg1: DAC00 2ch: Speaker [Jack], HP Out [Jack]
hdafg1: ADC01 2ch: Mic In [Jack]
hdafg1: 2ch/2ch 48000Hz PCM16*
audio0 at hdafg1: full duplex, playback, capture, independent
isa0 at pcib0
pckbc0 at isa0 port 0x60-0x64
acpicpu0 at cpu0: ACPI CPU
acpicpu0: C1: FFH, lat   1 us, pow  1000 mW
acpicpu0: P0: FFH, lat  20 us, pow     0 mW, 1200 MHz
acpicpu0: P1: FFH, lat  20 us, pow     0 mW, 1067 MHz
viac7temp0 at cpu0: VIA C7 temperature sensor
acpicpu1 at cpu1: ACPI CPU
viac7temp1 at cpu1: VIA C7 temperature sensor
timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
acpiacad0: AC adapter online.
wd0 at atabus0 drive 0
wd0: <WDC WD1600BEVT-24A23T0>
wd0: drive supports 16-sector PIO transfers, LBA48 addressing
wd0: 149 GB, 310101 cyl, 16 head, 63 sec, 512 bytes/sect x 312581808 sectors
uhub0 at usb0: vendor 0x1106 UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
uhub1 at usb1: vendor 0x1106 UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub1: 2 ports with 2 removable, self powered
uhub2 at usb2: vendor 0x1106 UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub2: 2 ports with 2 removable, self powered
uhub3 at usb3: vendor 0x1106 UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub3: 2 ports with 2 removable, self powered
uhub4 at usb4: vendor 0x1106 EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
uhub4: 8 ports with 8 removable, self powered
wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 6 (Ultra/133)
umass0 at uhub4 port 3 configuration 1 interface 0
umass0: Generic USB2.0-CRW, rev 2.00/38.82, addr 2
umass0: using SCSI over Bulk-Only
scsibus0 at umass0: 2 targets, 1 lun per target
sd0 at scsibus0 target 0 lun 0: <Generic-, Multi-Card, 1.00> disk removable
ehci0: handing over full speed device on port 4 to uhci1
sd0: fabricating a geometry
sd0: 15326 MB, 15326 cyl, 64 head, 32 sec, 512 bytes/sect x 31388672 sectors
sd0: fabricating a geometry
ehci0: handing over full speed device on port 7 to uhci3
Kernelized RAIDframe activated
boot device: sd0
root on sd0a dumps on sd0b
root file system type: ffs
warning: no /dev/console
uhub5 at uhub1 port 2: Chicony Generic USB Hub, class 9/0, rev 1.10/1.00, addr 2
uhub5: 3 ports with 2 removable, bus powered
aubtfwl0 at uhub3 port 1
aubtfwl0: ath3k-1.fw open fail 2
uhidev0 at uhub5 port 1 configuration 1 interface 0
uhidev0: Chicony PFU-65 USB Keyboard, rev 1.10/1.00, addr 3, iclass 3/1
ukbd0 at uhidev0: 8 modifier keys, 6 key codes
wskbd0 at ukbd0: console keyboard, using wsdisplay0
uname -aの結果もついでに。#14ってことで14回もkernelコンパイルしたんですね。
sdhc16g# uname -a
NetBSD sdhc16g 5.99.59 NetBSD 5.99.59 (ZBOX) #14: Sat Jan 21 04:44:23 UTC 2012  root@ideapad:/usr/home/tokuda/tmp/201112290510Z/source/usr/src/sys/arch/i386/compile/obj/ZBOX i386

名前:  非公開コメント   

  • TB-URL  http://www.tokuda.net/diary/0765/tb/

VIAのデュアルコア Nano X2 U4025搭載 ZBOX nano VD01 (3)
2012/01/21(土) 15:49 NetBSD はてブ情報 はてブに登録 はてブ数

ZBOX nano VD01の起動しない問題、続々編です。

さて、panicした部分はどこかを見てみると、pci_make_tag関数の413行目もしくは420行目ということになります。
398 pci_make_tag(pci_chipset_tag_t pc, int bus, int device, int function)
399 {
中略
410 	switch (pci_mode) {
411 	case 1:
412 		if (bus >= 256 || device >= 32 || function >= 8)
413 			panic("%s: bad request", __func__);
414 
415 		tag.mode1 = PCI_MODE1_ENABLE |
416 			    (bus << 16) | (device << 11) | (function << 8);
417 		return tag;
418 	case 2:
419 		if (bus >= 256 || device >= 16 || function >= 8)
420 			panic("%s: bad request", __func__);
421 
中略
429 }
どちらの文か区別できればよいので、何も考えずにpanicに与えるメッセージをかえてみたところ、420行目のpanicが呼ばれていることがわかりました。つまり419行目のチェックに引っかかっており、変数bus, device, functionのいずれかが異常な値だということになります。

じゃぁ、その異常値をよこしたのは誰だということになります。

前回のデバッガのtraceの結果から、このpci_make_tagを呼んでいるのはAcpiOsReadPciConfigurationですから、そちらを参照してみます。すると、pci_make_tagを呼ぶ前に210行目でpci_make_tagと同様のチェックをしていることがわかります。
202 AcpiOsReadPciConfiguration(ACPI_PCI_ID *PciId, UINT32 Register, UINT64 *Value,
203     UINT32 Width)
204 {
中略
210 	if (PciId->Bus >= 256 || PciId->Device >= 32 || PciId->Function >= 8)
211 		return AE_BAD_PARAMETER;
212 
213 	tag = pci_make_tag(acpi_softc->sc_pc, PciId->Bus, PciId->Device,
214 	    PciId->Function);
中略
235 }
このチェック内容を比較すると、bus, device, functionのうちdeviceだけがチェック項目に違いがあることがわかります。

親であるAcpiOsReadPciConfigurationでは32未満であることをチェックしていますが、pci_make_tagでは16未満であることをチェックしています。したがって、何らかの理由でdeviceが16から31の状態となり、AcpiOsReadPciConfigurationのチェックは通過するものの、pci_make_tagのチェックで引っかかり、panic処理へ進んでいると想定されます。

それでは、なぜdeviceがおかしな値になっているのか、という所を追求しなければなりません。

ということで、より上位の関数を追っかけてみたものの、私の実力では、その原因を見つけることはできませんでした。

名前:  非公開コメント   

  • TB-URL  http://www.tokuda.net/diary/0764/tb/