[ TOP | Recently ]

2009-07-21 cpu_initclocks


mountrootまで動いたのはいいのだが、main() → configure2() → initclocks() → cpu_initclocks() でタイマが intr_establish された直後から割り込みがかかりっぱなしになる。
dispatcher で interrupt status をクリアしても消えませんよ? なんじゃらほい? と悩んでいた訳なのだが、単に制御レジスタの叩き方がまずいだけだった。
割り込みコントローラに Software Interrupt Register ってのがあるのだが、swi のことか? と思って何も考えず 1 を書いてしまっていたのである。
これは ARM の swi とは全然関係なくて(よく考えりゃあたりまえだ)、IRQをソフト的に発生させる、というレジスタで、そんなものとりあえず使わないので 0x00000000 書いて終了。

これで割り込みは問題なく動くようになった。

次、com_attach_subr() が固まる問題。

実は固まっているのではなく、ものすごく時間がかかっていただけで、偶然気付いたのだが数分放置していたら mountroot まで来ていた。
となると怪しい個所は何かの timeout 待ちか delay くらいしか思いつかず、すぐに判明。
タイマ関連の割り込み設定やレジスタ初期化は cpu_initclocks() で行うようにしているが、com_attach_subr() は cpu_initclocks() よりも先に呼ばれるためタイマが初期化できておらず、delay()が正常に動作していなかったのだった。
timer attach の中で初期化するようにして終わり。

というわけで、VM、割り込み、および timer と com の attach までクリア

Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009
    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.15 (STR81xx) #507: Tue Jul 21 01:35:53 JST 2009
        ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR81xx
total memory = 32768 KB
avail memory = 28576 KB
mainbus0 (root)
cpu0 at mainbus0: FA526 rev 1 (ARMv4 core)
cpu0: DC disabled IC enabled WB enabled LABT
cpu0: 8KB/16B 2-way Instruction cache
cpu0: 8KB/16B 2-way write-back-locking-B Data cache
star0 at mainbus0: Star STR8100 Equuleus Family SoC (0x8131eeee)
starclk0 at star0 addr 0x79000000-0x79000047: SoC Timer
com0 at star0 addr 0x78000000-0x7800001f irq 9: ns16550a, working fifo
com0: console
boot device: <unknown>
root device: ?
use one of: md0[a-h] ddb halt reboot
root device: ddb
Stopped in pid 0.1 (system) at  netbsd:cpu_Debugger+0x4:        mov     r15, r14

db> show event
evcnt type 1: cpu int 0 = 115
evcnt type 1: cpu int 1 = 75
evcnt type 1: cpu int 9 = 5
evcnt type 0: softint clk/0 = 5
evcnt type 0: callout late/0 = 3
evcnt type 0: crosscall unicast = 2
evcnt type 0: namecache under scan target = 1
db> c
use one of: md0[a-h] ddb halt reboot
root device: halt
syncing disks... done
unmounting file systems... done

The operating system has halted.
Please press any key to reboot.
rebooting...

USBはともかく、GPIOとかRTCとかWatchDogとか軽めのやつもいろいろ残ってるけど、次は当然Etherで。memory diskとかめんどくさいことせずに一気にnfsbootしちゃおう。


EOF