FreeBSD-current/mipsが動いた

初めてマトモに起動してるところをみた。
以下、作業記録:

cvsupでcurrentをダウンロードしてくる。
supfileはこんな感じ:

*default host=cvsup.jp.FreeBSD.org
*default base=/home/syuu/FreeBSD
*default prefix=/home/syuu/FreeBSD/cvsroot
*default release=cvs tag=.
*default delete use-rel-suffix
*default compress
src-all

次が重要。
patchを当てなければならない。まだcurrentには全部のコードがマージされてないっぽいのだ。

cd /home/syuu/FreeBSD/cvsroot/src
fetch http://people.freebsd.org/~imp/MipsSvn.diff
patch -p0 < MipsSvn.diff

ビルドしてみる。今回はgxemulでmaltaをエミュレートしてみることにした。

export MAKEOBJDIRPREFIX=~/FreeBSD/cvsroot/src/obj
sudo make WITHOUT_CDDL=1 TARGET_ARCH=mips buildworld
sudo make WITHOUT_CDDL=1 TARGET_ARCH=mips KERNCONF=MALTA buildkernel

ディスクイメージを作成。

dd if=/dev/zero of=freebsd-mips.img count=1024 bs=1m
sudo mdconfig -a -t vnode -f ./freebsd-mips.img
sudo disklabel -w /dev/md0
sudo disklabel -e /dev/md0

aのunusedを4.2BSDに変更して保存。

sudo newfs /dev/md0a
sudo mount /dev/md0a /mnt/

ディスクイメージにユーザランドを書き込み。

sudo make WITHOUT_CDDL=1 TARGET_ARCH=mips DESTDIR=/mnt/ installworld
sudo umount /mnt

エミュレータを実行。

sudo gxemul -emalta -d freebsd-mips.img /usr/obj/mips/usr/home/asada/FreeBSD/cvsroot/src/sys/MALTA/kernel

何故かカーネルが/usr/obj/mipsにインストールされてしまった。どうして?

ともあれ、何とか起動してくる。

GXemul 0.4.6.5    Copyright (C) 2003-2008  Anders Gavare
Read the source code and/or documentation for other Copyright messages.

Simple setup...
    net:
        simulated network: 10.0.0.0/8 (max outgoing: TCP=100, UDP=100)
        simulated gateway+nameserver: 10.0.0.254 (60:50:40:30:20:10)
        simulated nameserver uses real nameserver 10.65.0.2
        domain: s.axe-inc.co.jp
    machine:
        memory: 128 MB
        cpu0: 5Kc (I+D = 32+32 KB)
        machine: MALTA (evbmips, little endian) (33.00 MHz)
        bootstring: kernel
        diskimage: freebsd-mips.img
            IDE DISK id 0, read/write, 1024 MB (2097152 sectors)
        loading /usr/obj/mips/usr/home/asada/FreeBSD/cvsroot/src/sys/MALTA/kernel
        cpu0: starting at 0xffffffff8012d930 (gp=0xffffffff803c0840)
-------------------------------------------------------------------------------

entry: platform_start()
cmd line: kernel
envp:
        baseboardserial = 0000000000
        bootprot = tftp
        bootserport = tty0
        bootserver = 10.0.0.254
        ethaddr = 10.20.30.00.00.10
        gateway = 10.0.0.254
        ipaddr = 10.0.0.1
        memsize = 0x08000000
        modetty0 = 38400,n,8,1,none
        modetty1 = 38400,n,8,1,none
        prompt = YAMON
        yamonrev = 02.06
        subnetmask = 255.0.0.0
        khz = 33000
memsize = 08000000
  picache_stride    = 4096
  picache_loopcount = 8
  pdcache_stride    = 4096
  pdcache_loopcount = 8
Physical memory chunk(s):
0x3ccaf0 - 0x7ffffff, 130233616 bytes (31795 pages)
Va=0xc0000000 Ve=ffffc000
init kernel_segmap va >> = 768 nkpt:120
avail_start:0x458af0 avail_end:0x8000000
KDB: debugger backends: ddb
KDB: current backend: ddb
hz=100 cyl_per_hz:33000 cyl_per_usec:33 freq:33000000 cyl_per_hz:330000 cyl_per_sec:33000000
Copyright (c) 1992-2008 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 8.0-CURRENT #0: Sun Dec  7 13:44:55 JST 2008
    root@dorry.s.axe-inc.co.jp:/usr/obj/mips/usr/home/asada/FreeBSD/cvsroot/src/sys/MALTA
real memory  = 0 (0K bytes)
Physical memory chunk(s):
0x00459000 - 0x07d64fff, 126926848 bytes (30988 pages)
avail memory = 126119936 (120MB)
mem: <memory>
nfslock: pseudo-device
null: <null device, zero device>
nexus0: <MIPS32 root nexus>
clock0: <Generic MIPS32 ticker> on nexus0
nexus_alloc_resource: entry (0xc0c3d600, 0xc0c3d500, 1, 0x803dd830, 0x5, 0x5, 1, 2)
nexus_alloc_resource: requested rid is 0
Establish HARD IRQ 5: filt 0x8034b204 handler 0 arg 0
clock0: [FILTER]
gt0: <GT64120 chip> on nexus0
pcib0: <GT64120 PCI bridge> on gt0
[ 8259: TODO: Level triggered (MCA bus) ]
[ 8259: WARNING: Bit 2 set ]
[ 8259: TODO: Level triggered (MCA bus) ]
[ 8259: WARNING: Bit 2 set ]
nexus_alloc_resource: entry (0xc0c3d600, 0xc0c3d400, 1, 0x803dd7a8, 0, 0, 1, 6)
nexus_alloc_resource: requested rid is -2145342356
Establish HARD IRQ 0: filt 0x803570a4 handler 0 arg 0xc0c0f200
pcib0: [FILTER]
pci0: <PCI bus> on pcib0
pci0: domain=0, physical bus=0
found-> vendor=0x11ab, dev=0x4620, revid=0x02
        domain=0, bus=0, slot=0, func=0
        class=06-00-00, hdrtype=0x00, mfdev=0
        cmdreg=0x0003, statreg=0x0000, cachelnsz=0 (dwords)
        lattimer=0x00 (0 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
found-> vendor=0x8086, dev=0x7110, revid=0x01
        domain=0, bus=0, slot=9, func=0
        class=06-01-00, hdrtype=0x00, mfdev=1
        cmdreg=0x0003, statreg=0x0000, cachelnsz=0 (dwords)
        lattimer=0x40 (1920 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
found-> vendor=0x8086, dev=0x7111, revid=0x01
        domain=0, bus=0, slot=9, func=1
        class=01-01-80, hdrtype=0x00, mfdev=0
        cmdreg=0x0003, statreg=0x0000, cachelnsz=0 (dwords)
        lattimer=0x00 (0 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
uart0: <8250 or 16450 or compatible> on obio0
uart0: [FILTER]
uart0: fast interrupt
uart0: console (115200,n,8,1)
pci0: <bridge, PCI-ISA> at device 9.0 (no driver attached)
atapci0: <Intel PIIX4 UDMA33 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376 at device 9.1 on pci0
atapci0: Lazy allocation of 0x4 bytes rid 0x20 type 4 at 0
ata0: <ATA channel 0> on atapci0
ata0: WARNING - DMA initialization failed, disabling DMA
atapci0: Reserved 0x8 bytes for rid 0x10 type 4 at 0x1f0
atapci0: Reserved 0x1 bytes for rid 0x14 type 4 at 0x3f6
ata0: reset tp1 mask=03 ostat0=51 ostat1=01
ata0: stat0=0x51 err=0x01 lsb=0x00 msb=0x00
ata0: stat1=0x01 err=0x01 lsb=0x00 msb=0x00
ata0: reset tp2 stat0=51 stat1=01 devices=0x1
ata0: FAILURE - create sg_tag
ata0: WARNING - DMA allocation failed, disabling DMA
ata0: [MPSAFE]
ata0: [ITHREAD]
ata1: <ATA channel 1> on atapci0
ata1: WARNING - DMA initialization failed, disabling DMA
atapci0: Reserved 0x8 bytes for rid 0x18 type 4 at 0x170
atapci0: Reserved 0x1 bytes for rid 0x1c type 4 at 0x376
ata1: reset tp1 mask=03 ostat0=00 ostat1=00
ata1: stat0=0x00 err=0x00 lsb=0x00 msb=0x00
ata1: stat1=0x00 err=0x00 lsb=0x00 msb=0x00
ata1: reset tp2 stat0=00 stat1=00 devices=0x0
ata1: FAILURE - create sg_tag
ata1: WARNING - DMA allocation failed, disabling DMA
ata1: [MPSAFE]
ata1: [ITHREAD]
Device configuration finished.
Timecounter "MIPS32" frequency 33000000 Hz quality 800
Timecounters tick every 10.000 msec
ata0: identify ch->devices=00000001
ata0-master: pio=PIO4 wdma=UNSUPPORTED udma=UNSUPPORTED cable=40 wire
ad0: setting PIO4 on PIIX4 chip
ad0: 1028MB <freebsd mips.img 1.0> at ata0-master PIO4
ad0: 2105344 sectors [2088C/16H/63S] 1 sectors/interrupt 1 depth queue
ata1: identify ch->devices=00000000
GEOM: new disk ad0
Trying to mount root from ufs:ad0s1a

Manual root filesystem specification:
  <fstype>:<device>  Mount <device> using filesystem <fstype>
                       eg. ufs:/dev/da0a
  ?                  List valid disk boot devices
  <empty line>       Abort manual input

mountroot>

ここで、ufs:/dev/ad0aと打つとユーザランドが起動しはじめる。

mountroot> ufs:/dev/ad0a
Trying to mount root from ufs:/dev/ad0a
warning: no time-of-day clock registered, system time will not be set accurately
start_init: trying /sbin/init
Dec  7 07:09:10 init: login_getclass: unknown class 'daemon'
/etc/rc: Can't open /etc/rc: No such file or directory
Enter full pathname of shell or RETURN for /bin/sh:
#

なんか放置してるとこんなメッセージでましたけど:

t_delta 15.b5c77e39d636d8c0 too short
t_delta 16.1afb4cbe04278520 too long
t_delta 16.32ca762853617d40 too long

なんだこれ。
でもなんか動いてる。