SlideShare a Scribd company logo
あるブートローダの話
Kernel/VM/探検隊@北陸 part 4
えとみ なるあき@nullnilaki
自己紹介
• 名前:えとみ なるあき
• twitter:nullnilaki
• 職業:物流センターの現場職員
• 名古屋在住
• 経済学部卒業でコンピューターのこと良くわかっていません…
プログラマーでもない… (´;ω;`)
+
20DC96の
コンテナを見
ました!
日本国外では早くから広範囲に普及していたが、
日本国内では道路交通法による高さ制限等の問題
で普及していなかった。
また、日本国内に流通している各種の
ハイ・キューブ・コンテナは流通コストの関係で、
20ft型はまれである。
トラ柄が96の証
コンテナは種類に
よって外観に
違いがある
大きな違いが
あります
コンテナと違って
外観に違いはない?
基板
R4000(64bit!)
マルチ
チップ
カッコ
いい!
大きい
CPU
カッコ
いい!
R3000(32bit)
どっちが
R3000?
R3000 R4000
パラレル
ポートの色
が違う(白)
パラレル
ポートの色
が違う(黒)
あるブートローダの話
ファームウェア
の画面
R3000(のっぺりな画面) R4000(立体的な画面)
NetBSDで
Indigo R3000
を動かす
>> bootp()kernel
Obtaining kernel from server xserve
3245520+0+98272 entry: 0x80002000
[ 1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
[ 1.0000000] 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
[ 1.0000000] 2018 The NetBSD Foundation, Inc. All rights reserved.
[ 1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
[ 1.0000000] The Regents of the University of California. All rights reserved.
[ 1.0000000] NetBSD 8.99.25 (GENERIC32_IP12) #0: Sun Oct 7 00:47:57 UTC 2018
[ 1.0000000] naruaki@:/usr/obj.sgimips/sys/arch/sgimips/compile/GENERIC32_IP12
[ 1.0000000] total memory = 32768 KB
[ 1.0000000] (0 reserved for ARCS)
[ 1.0000000] avail memory = 28744 KB
[ 1.0000000] WARNING: module error: sequencer: can't find builtin dependency `midi'
[ 1.0000000] mainbus0 (root): SGI-IP12 [SGI, IP12], 1 processor
[ 1.0000000] cpu0 at mainbus0: MIPS R3000A CPU (0x230) Rev. 3.0 with MIPS R3010 FPC Rev. 4.0
[ 1.0000000] cpu0: 32KB/4B direct-mapped Instruction cache, 64 TLB entries
[ 1.0000000] cpu0: 32KB/4B direct-mapped write-through Data cache
[ 1.0000000] int0 at mainbus0 addr 0x1fb801c0
[ 1.0000050] pic0 at mainbus0 addr 0x1fa00000
[ 1.0000050] pic0: Revision B: dblk (0x2), iblk (0x8)
[ 1.0000050] pic0: Indigo R3000, board revision 1
[ 1.0000050] pic0: cache disabled, store partial, bus drive
[ 1.0000050] gio0 at pic0
[ 1.0000050] light0 at gio0: SGI LG2 (board revision 2)
[ 1.0000050] wsdisplay0 at light0 kbdmux 1
[ 1.0000050] hpc0 at gio0: SGI HPC1.5 (onboard)
[ 1.0000050] zsc0 at hpc0 offset 0xd10
[ 1.0000050] zstty0 at zsc0 channel 1 (console i/o)
[ 1.0000050] zstty1 at zsc0 channel 0
[ 1.0000050] zsc1 at hpc0 offset 0xd00
[ 1.0000050] zsms0 at zsc1 channel 1: baud rate 4800
[ 1.0000050] wsmouse0 at zsms0 mux 0
[ 1.0000050] zskbd0 at zsc1 channel 0: baud rate 600
[ 1.0000050] wskbd0 at zskbd0 mux 1
[ 1.0000050] sq0 at hpc0 offset 0x100: SGI Seeq 8003
[ 1.0000050] sq0: Ethernet address 08:00:69:06:59:03
[ 1.0000050] wdsc0 at hpc0 offset 0x11f: WD33C93B (20.0 MHz clock, BURST DMA, SCSI ID 0)
[ 1.0000050] wdsc0: microcode revision 0x0c, Fast SCSI
[ 1.0000050] scsibus0 at wdsc0: 8 targets, 8 luns per target
[ 1.0000050] dpclock0 at mainbus0 addr 0x1fb80e00
[ 1.7853010] scsibus0: waiting 2 seconds for devices to settle...
2004年にサポートされてから
ほとんどだれも動かしてない?
とりあえず動くところまで修正してPR
NetBSD Problem Report #53654
Revive IP12(Indigo R3000) kernel on NetBSD/sgimips
HDDから起動
できない?
BOOT(8) NetBSD/sgimips System Manager's Manual BOOT(8)
NAME
boot -- sgimips system bootstrapping procedures
DESCRIPTION
Silicon Graphics MIPS-based computers all feature essentially similar
firmware systems. However, as of the Indigo R4x00 series (IP20), quasi-
ARCS (Advanced RISC Computing Specification) compatible features are
also
present. All known PROM implementations support loading executables
from
disk devices, as well as from the network via BOOTP and TFTP.
BUGS
NetBSD does not support booting from disk on systems lacking an
ARCS-compatible firmware (presently supported systems include
Personal Iris and Indigo R3000).
It is possible to work around this by creating a sufficiently large volume
header and placing the kernel in it, or by network booting.
ARC
Advanced
RISC
Computing
Advanced RISC Computing (ARC) は、コンピュータメーカーによる
今はなきコンソーシアム(Advanced Computing Environment (ACE) プロジェクト)
によって公開された標準的なMIPS RISCベースのハードウェアと
ファームウェア環境についての仕様である。
ACEはすでに存在していないし、ARC仕様に完全に従ったコンピュータは
製造されていないが、ARCシステムは全てのMicrosoft Windows NTベースの
オペレーティングシステムに幅広くレガシーとして影響を及ぼしている。
さらに、SGIは、ARCSと呼ばれる、手直ししたARCファームウェアを
SGI製のシステムで使っている。IRIX 6.1以降が動く全ての
SGIのコンピュータ(IndyやOctaneなど)では、まずはARCSコンソールが起動する。
加えて、ほとんどのWindow NTが動くRISCベースのコンピュータは
Window NTをブートさせるためにARCブートコンソールを使っている。
このようなコンピュータは以下のようである。
MIPS R4000ベースのシステム(MIPS Magnumワークステーションなど)
1999年9月にWindows NT Alphaのサポートが終了する前までに設計された
PCIバスを持った全てのAlphaベースのマシン(
AlphaのARCファームウェアはAlphaBIOSとも呼ばれた)
ほとんどのWindows NTに対応したPowerPCコンピュータ(IBM RS/6000 40Pなど)
ARCと
それ以前
R3000 R4000
>> printenv
netaddr=192.168.1.33
dbaud=9600
rbaud=1200
bootfile=dksc(0,4,8)sash
bootmode=c
console=d
diskless=0
keybd=d
volume=128
path=dksc(0,4,8)
cpufreq=33
>> printenv
SystemPartition=scsi(0)disk(1)rdisk(0)partition(8)
OSLoadPartition=scsi(0)disk(1)rdisk(0)partition(0)
OSLoader=aoutboot
OSLoadFilename=netbsd
OSLoadOptions=auto
TimeZone=PST8PDT
diskless=0
dbaud=9600
rbaud=1200
volume=128
sgilogo=y
AutoLoad=No
console=d
ConsoleOut=serial(0)
ConsoleIn=serial(0)
設定できる
環境変数が
違う
NetBSD/sgimips
のブートローダ
>> printenv
SystemPartition=scsi(0)disk(1)rdisk(0)partition(8)
OSLoadPartition=scsi(0)disk(1)rdisk(0)partition(0)
OSLoader=boot
OSLoadFilename=netbsd
>> boot -f scsi(0)disk(1)rdisk(0)partition(8)/boot
NetBSD/sgimips 6.1.5 Bootstrap, Revision 1.5
devopen: scsi(0)disk(1)rdisk(0)partition(0) type scsi file netbsd
4930576+131392 [270208+262451]=0x55644c
[ 1.0000000] phys segment: 0xd000 @ 0x8002000
[ 1.0000000] adding 0xd000 @ 0x8002000 to freelist 0
…
ファームウェアで指定した
HDDとカーネルを
ブートローダーは読み込む
ARCで文字を
出したりカー
ネルを読み込
む方法
N Offset Name
00 0x00 Load
01 0x04 Invoke
02 0x08 Execute
03 0x0c Halt
04 0x10 PowerDown
05 0x14 Restart
06 0x18 Reboot
23 0x5c Open
24 0x60 Close
25 0x64 Read
26 0x68 GetReadStatus
27 0x6c Write
28 0x70 Seek
29 0x74 Mount
30 0x78 GetEnvironmentVariable
Firmware call vector
Firmware functions are called indirectly through call vector
table. Arguments to functions are placed in registers a0 to
a3. Return values are placed in register v0.
ARCでないマ
シンで文字を
出したりカー
ネルを読み込
む方法
>> boot -f dksc(0,2,8)sashIP12
166848+82032+319248 entry: 0x80700c90
Standalone Shell SGI Version 5.3 IP12 Nov 3, 1994 (BE)
sash: boot -f dksc(0,1,1)unix.IP12
1346176+195088+193472 entry: 0x800026f0
IRIX Release 5.3 IP12 Version 11091810 System V
Copyright 1987-1994 Silicon Graphics, Inc.
All Rights Reserved.
オリジナルのsgi製
ブートローダを逆アセンブル
してファームウェアのサブ
ルーチンの使い方を調べる?
あるブートローダの話
設計と実装
⚫ カーネルをHDDから読むためにSCSIドライバを組み込む
→Western Digital WD33c93を積んでいるので、対応するwdscドライバ
からDMAとか同期転送を削除して、必要なところだけを抽出
⚫ 文字を出力するためにコンソールドライバを組み込む
→Zilog 8530を積んでいるので、対応するzscドライバから必要な
ところだけを抽出
⚫ SCSIコマンドはTEST UNIT READY、READ CAPACITY、READのみ使用
⚫ 割り込みが面倒なので文字の入力は未実装
⚫ open()やstrategy()などのDISK I/O API、 printf()といった文字列出力関数、
ファイルシステムの解釈はNetBSDのlibsa(standalone実行用サポートラ
イブラリ)におまかせ
⚫ 大抵のブートローダはファームウェアに実装されているサブルーチン
を呼んで文字を出力したり、カーネルを読んでいる
→ブートローダにSCSIドライバが組み込まれている実装は少ない
→NetBSD/hp300のブートローダを参考に実装
irisboot
NetBSD Problem Report #53539
irisboot (I named) Yet another sgimips
bootloader
http://gnats.netbsd.org/53539
>> boot -f dksc(0,4,8)irisboot dksc(0,4,0)/netbsd
55696+0+1832 entry: 0x80368000
NetBSD/sgimips 8.99.24 Yet another Bootstrap, Revision 1.0 (Sun Aug 19 09:19:08 UTC
2018)
3001008+88272 [188544+180745]=0x34cbd0
[ 1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
[ 1.0000000] 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
[ 1.0000000] 2018 The NetBSD Foundation, Inc. All rights reserved.
[ 1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
[ 1.0000000] The Regents of the University of California. All rights reserved.
[ 1.0000000] NetBSD 8.99.21 (GENERIC32_IP12) #1: Sun Aug 12 14:48:19 UTC 2018
[ 1.0000000]
naruaki@xserve:/usr/obj.sgimips/sys/arch/sgimips/compile/GENERIC32_IP12
[ 1.0000000] total memory = 32768 KB
[ 1.0000000] (0 reserved for ARCS)
[ 1.0000000] avail memory = 28988 KB
[ 1.0000000] WARNING: module error: sequencer: can't find builtin dependency `midi'
[ 1.0000000] mainbus0 (root): SGI-IP12 [SGI, IP12], 1 processor
[ 1.0000000] cpu0 at mainbus0: MIPS R3000A CPU (0x230) Rev. 3.0 with MIPS R3010 FPC
Rev. 4.0
[ 1.0000000] cpu0: 32KB/4B direct-mapped Instruction cache, 64 TLB entries
[ 1.0000000] cpu0: 32KB/4B direct-mapped write-through Data cache
ARCなマシン
でも
ARCなIndigo R4000やINDYでも動くようにちょっと改造
(Indigo R3000と同じシリアル、SCSIコントローラーを使っているので)
#ifdef INDIGO_R3K_MODE
#define ZS_ADDR 0x1fb80d10
#define SCSIA_ADDR 0x1FB80122
#define SCSID_ADDR 0x1FB80126
#ifdef INDIGO_R4K_MODE
#define ZS_ADDR 0x1fb80d10
#define SCSIA_ADDR 0x1FB80122
#define SCSID_ADDR 0x1FB80126
#ifdef INDY_MODE
#define ZS_ADDR 0x1fbd9830
#define SCSIA_ADDR 0x1FBC0003
#define SCSID_ADDR 0x1FBC0007
問題点
• カーネルとブートローダ用の領域が少ない
→ 0x80002000 - 0x8037fffcの3.49MB
→圧縮カーネルを使う
ブートローダと一緒にロードされた「圧縮されたカーネル」が
ブートローダのdataセグメントにあって、それを
「カーネルがロードされるべきアドレス」にgunzip展開しつつコピー
→sysinst(installkernel)が同じく容量の問題で動かない
NetBSD/Sun2でsysinstを使わないインストールスクリプトがあるらしい…
• Irisbootという名前なので入手困難だけれどPersonal IRISをサポートしたい
→お金の力で解決
• 仕事が忙しくてコードレビューしていただいたのに返信できていない…
良かったこと
• カーネルを書く人は結構いるが、ブートローダーを書く人はあまりいな
いので良い経験になった
• SCSIドライバがどのようにファイルを読んでいるのか勉強になった
• ブートローダはある意味簡易カーネルとも言えるので、
カーネルのデバッグにブートローダの知識が役立った
• NetBSD/sgimipsのTODOリストから課題を一個消せた
(sekiya)
* grtwo needs cursor and hardware color fill support
* ip12 needs ROM-based bootloader
* hpc devices need real probe routines
* port newport driver to x.org
• NetBSD以外のOSSなOSではIndigo R3000をサポートしていないので、
カーネルの修正を含め、動くようになってめっちゃ感謝された
スペシャル
サンクス
Frankさん
Dear Naruaki,
On 08/25/2018 01:41 PM, Frank Scheiner wrote:
> I'll try to do more testing as soon as I find out how to use the
> non-original disk.
Ok, in the end I used another narrow SCSI disk (a ST39216N, the original
disk is a ST1280N) that just worked.
As I don't have my Indys at hand currently, I followed "Installing
without sysinst" ([1]) and installed NetBSD (NetBSD-daily/HEAD
/201808230630Z) on disk from my working diskless NetBSD installation -
actually two times, as I didn't anticipate that one needs to reserve some
space at the beginning of the disk for the SGI volume header as
mentioned on [2]. :-D
The result is working:
```
>> boot -f dksc(0,1,8)irisboot dksc(0,1,0)/netbsd
56784+0+1832 entry: 0x80368000
NetBSD/sgimips 8.99.24 Yet another Bootstrap, Revision 1.0 (Sun Aug 19
08:53:34 UTC 2018)
2829712+82768 [185024+176400]=0x31fa74
[ 1.0000000] arcemu: unknown console "", using serial
[ 1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002,
2003, 2004, 2005,
[ 1.0000000] 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014,
Again much thanks for making NetBSD on Indigo R3K
possible again! If you need me to test future revisions,
just let me know. Cheers, Frank
スペシャル
サンクス
つついさん
参考文献など
• SCSI-2詳細解説
最新SCSI規格とコマンドリファレンス
• MIPS RISCアーキテクチャ
-R2000/R3000-
• 起動プログラム ブート・ローダ入門
クロックの初期化や外部メモリの設定からOSの起動まで

More Related Content

PDF
あるキャッシュメモリの話
nullnilaki
 
PDF
オープンソース開発と、 あるフレームバッファコンソールの話 ~名古屋応用編~
nullnilaki
 
PDF
あるmmapの話
nullnilaki
 
PPTX
RHEL on Azure、初めの一歩
Ryo Fujita
 
PDF
C/C++プログラマのための開発ツール
MITSUNARI Shigeo
 
PPTX
Verilator勉強会 2021/05/29
ryuz88
 
PDF
Linux KVM環境におけるGPGPU活用最新動向
Taira Hajime
 
PPTX
Yet another Intel Chipset Internal SMBus device’s driver: ismt(4) (and spdmem...
Masanobu Saitoh
 
あるキャッシュメモリの話
nullnilaki
 
オープンソース開発と、 あるフレームバッファコンソールの話 ~名古屋応用編~
nullnilaki
 
あるmmapの話
nullnilaki
 
RHEL on Azure、初めの一歩
Ryo Fujita
 
C/C++プログラマのための開発ツール
MITSUNARI Shigeo
 
Verilator勉強会 2021/05/29
ryuz88
 
Linux KVM環境におけるGPGPU活用最新動向
Taira Hajime
 
Yet another Intel Chipset Internal SMBus device’s driver: ismt(4) (and spdmem...
Masanobu Saitoh
 

What's hot (20)

ODP
「前回の COMSTAR ネタに刺激されてしまったので、オレも COMSTAR を使ってみた。」(仮)
Kazuyuki Sato
 
PDF
Interrupt Affinityについて
Takuya ASADA
 
PDF
Trema day 1
ykuga
 
PDF
golang binary hacks
yaegashi
 
PDF
Spectre/Meltdownとその派生
MITSUNARI Shigeo
 
PPT
Open VZ
Kazuaki Fujikura
 
PDF
FreeBSD jail+vnetと戯れた話
Masaru Oki
 
PDF
Rust で RTOS を考える
ryuz88
 
PDF
Ultra96ボードでYOLOを高速化
Hiroyuki Okuhata
 
PDF
Good Arm FPGA Board Ultra96 and Google AI YOLO
If_CQ
 
PDF
Introduction of OpenBSD/luna88k at OSC 2014 Nagoya
Kenji Aoyama
 
PDF
BHyVeでOSvを起動したい
〜BIOSがなくてもこの先生きのこるには〜
Takuya ASADA
 
PDF
GR-CITRUS搭載のRubyファームウェアの説明
三七男 山本
 
PDF
UEFI時代のブートローダ
Takuya ASADA
 
PDF
Google 20130218
Takefumi MIYOSHI
 
PDF
NetBSD, On the ROAD 2016
Jun Ebihara
 
PDF
2章 Linuxカーネル - メモリ管理1
mao999
 
PDF
0章 Linuxカーネルを読む前に最低限知っておくべきこと
mao999
 
PDF
最近遊んだLinuxボードたち
t n
 
PDF
仮想記憶入門 BSD-4.3を例題に
magoroku Yamamoto
 
「前回の COMSTAR ネタに刺激されてしまったので、オレも COMSTAR を使ってみた。」(仮)
Kazuyuki Sato
 
Interrupt Affinityについて
Takuya ASADA
 
Trema day 1
ykuga
 
golang binary hacks
yaegashi
 
Spectre/Meltdownとその派生
MITSUNARI Shigeo
 
FreeBSD jail+vnetと戯れた話
Masaru Oki
 
Rust で RTOS を考える
ryuz88
 
Ultra96ボードでYOLOを高速化
Hiroyuki Okuhata
 
Good Arm FPGA Board Ultra96 and Google AI YOLO
If_CQ
 
Introduction of OpenBSD/luna88k at OSC 2014 Nagoya
Kenji Aoyama
 
BHyVeでOSvを起動したい
〜BIOSがなくてもこの先生きのこるには〜
Takuya ASADA
 
GR-CITRUS搭載のRubyファームウェアの説明
三七男 山本
 
UEFI時代のブートローダ
Takuya ASADA
 
Google 20130218
Takefumi MIYOSHI
 
NetBSD, On the ROAD 2016
Jun Ebihara
 
2章 Linuxカーネル - メモリ管理1
mao999
 
0章 Linuxカーネルを読む前に最低限知っておくべきこと
mao999
 
最近遊んだLinuxボードたち
t n
 
仮想記憶入門 BSD-4.3を例題に
magoroku Yamamoto
 
Ad

Similar to あるブートローダの話 (20)

ODP
カーネルをmakeしよう! - 第4回つくらぐ勉強会
University of Tsukuba Linux User Group
 
PPT
Bsd suki
yamori813
 
PDF
NetBSD/evbarm (APC9750) への道
tokudahiroshi
 
PDF
Debianを用いたCortex-M3マイコン開発事例のご紹介
Kiwamu Okabe
 
PDF
NetBSD/evbarm on Raspberry Pi
tokudahiroshi
 
PDF
JTF2020 クロスコンパイルだけが能ではない組み込みLinuxシステムのCI/CDインフラ構築
yaegashi
 
PDF
retrobsd-2012-JUL-07 at JNUG BSD BoF
たけおか しょうぞう
 
PDF
PF部第19回資料 poor man's JTAG
daye001
 
PPTX
Functions
do_aki
 
PDF
Oracle solaris 10 u9 iSCSI Boot
Kazuyuki Sato
 
PPTX
2021 10-12.linx device-tree
Shin-ya Koga
 
PDF
[Basic 7] OS の基本 / 割り込み / システム コール / メモリ管理
Yuto Takei
 
PDF
ちょっと古いマシンにLinuxを
Kenichiro MATOHARA
 
PDF
Kernel bootstrap
Kai Sasaki
 
PDF
デバドラを書いてみよう!
Masami Ichikawa
 
PPTX
ロボットシステム学2015年第5回
Ryuichi Ueda
 
ODP
Bhyve Internals
Takuya ASADA
 
PDF
Running lagopus on Xeon D
Masaru Oki
 
PDF
Infinite Debian - Platform for mass-producing system every second
Taisuke Yamada
 
PDF
NetBSD on Google Compute Engine
Ryo ONODERA
 
カーネルをmakeしよう! - 第4回つくらぐ勉強会
University of Tsukuba Linux User Group
 
Bsd suki
yamori813
 
NetBSD/evbarm (APC9750) への道
tokudahiroshi
 
Debianを用いたCortex-M3マイコン開発事例のご紹介
Kiwamu Okabe
 
NetBSD/evbarm on Raspberry Pi
tokudahiroshi
 
JTF2020 クロスコンパイルだけが能ではない組み込みLinuxシステムのCI/CDインフラ構築
yaegashi
 
retrobsd-2012-JUL-07 at JNUG BSD BoF
たけおか しょうぞう
 
PF部第19回資料 poor man's JTAG
daye001
 
Functions
do_aki
 
Oracle solaris 10 u9 iSCSI Boot
Kazuyuki Sato
 
2021 10-12.linx device-tree
Shin-ya Koga
 
[Basic 7] OS の基本 / 割り込み / システム コール / メモリ管理
Yuto Takei
 
ちょっと古いマシンにLinuxを
Kenichiro MATOHARA
 
Kernel bootstrap
Kai Sasaki
 
デバドラを書いてみよう!
Masami Ichikawa
 
ロボットシステム学2015年第5回
Ryuichi Ueda
 
Bhyve Internals
Takuya ASADA
 
Running lagopus on Xeon D
Masaru Oki
 
Infinite Debian - Platform for mass-producing system every second
Taisuke Yamada
 
NetBSD on Google Compute Engine
Ryo ONODERA
 
Ad

あるブートローダの話

  • 2. 自己紹介 • 名前:えとみ なるあき • twitter:nullnilaki • 職業:物流センターの現場職員 • 名古屋在住 • 経済学部卒業でコンピューターのこと良くわかっていません… プログラマーでもない… (´;ω;`) +
  • 9. NetBSDで Indigo R3000 を動かす >> bootp()kernel Obtaining kernel from server xserve 3245520+0+98272 entry: 0x80002000 [ 1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, [ 1.0000000] 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, [ 1.0000000] 2018 The NetBSD Foundation, Inc. All rights reserved. [ 1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993 [ 1.0000000] The Regents of the University of California. All rights reserved. [ 1.0000000] NetBSD 8.99.25 (GENERIC32_IP12) #0: Sun Oct 7 00:47:57 UTC 2018 [ 1.0000000] naruaki@:/usr/obj.sgimips/sys/arch/sgimips/compile/GENERIC32_IP12 [ 1.0000000] total memory = 32768 KB [ 1.0000000] (0 reserved for ARCS) [ 1.0000000] avail memory = 28744 KB [ 1.0000000] WARNING: module error: sequencer: can't find builtin dependency `midi' [ 1.0000000] mainbus0 (root): SGI-IP12 [SGI, IP12], 1 processor [ 1.0000000] cpu0 at mainbus0: MIPS R3000A CPU (0x230) Rev. 3.0 with MIPS R3010 FPC Rev. 4.0 [ 1.0000000] cpu0: 32KB/4B direct-mapped Instruction cache, 64 TLB entries [ 1.0000000] cpu0: 32KB/4B direct-mapped write-through Data cache [ 1.0000000] int0 at mainbus0 addr 0x1fb801c0 [ 1.0000050] pic0 at mainbus0 addr 0x1fa00000 [ 1.0000050] pic0: Revision B: dblk (0x2), iblk (0x8) [ 1.0000050] pic0: Indigo R3000, board revision 1 [ 1.0000050] pic0: cache disabled, store partial, bus drive [ 1.0000050] gio0 at pic0 [ 1.0000050] light0 at gio0: SGI LG2 (board revision 2) [ 1.0000050] wsdisplay0 at light0 kbdmux 1 [ 1.0000050] hpc0 at gio0: SGI HPC1.5 (onboard) [ 1.0000050] zsc0 at hpc0 offset 0xd10 [ 1.0000050] zstty0 at zsc0 channel 1 (console i/o) [ 1.0000050] zstty1 at zsc0 channel 0 [ 1.0000050] zsc1 at hpc0 offset 0xd00 [ 1.0000050] zsms0 at zsc1 channel 1: baud rate 4800 [ 1.0000050] wsmouse0 at zsms0 mux 0 [ 1.0000050] zskbd0 at zsc1 channel 0: baud rate 600 [ 1.0000050] wskbd0 at zskbd0 mux 1 [ 1.0000050] sq0 at hpc0 offset 0x100: SGI Seeq 8003 [ 1.0000050] sq0: Ethernet address 08:00:69:06:59:03 [ 1.0000050] wdsc0 at hpc0 offset 0x11f: WD33C93B (20.0 MHz clock, BURST DMA, SCSI ID 0) [ 1.0000050] wdsc0: microcode revision 0x0c, Fast SCSI [ 1.0000050] scsibus0 at wdsc0: 8 targets, 8 luns per target [ 1.0000050] dpclock0 at mainbus0 addr 0x1fb80e00 [ 1.7853010] scsibus0: waiting 2 seconds for devices to settle... 2004年にサポートされてから ほとんどだれも動かしてない? とりあえず動くところまで修正してPR NetBSD Problem Report #53654 Revive IP12(Indigo R3000) kernel on NetBSD/sgimips
  • 10. HDDから起動 できない? BOOT(8) NetBSD/sgimips System Manager's Manual BOOT(8) NAME boot -- sgimips system bootstrapping procedures DESCRIPTION Silicon Graphics MIPS-based computers all feature essentially similar firmware systems. However, as of the Indigo R4x00 series (IP20), quasi- ARCS (Advanced RISC Computing Specification) compatible features are also present. All known PROM implementations support loading executables from disk devices, as well as from the network via BOOTP and TFTP. BUGS NetBSD does not support booting from disk on systems lacking an ARCS-compatible firmware (presently supported systems include Personal Iris and Indigo R3000). It is possible to work around this by creating a sufficiently large volume header and placing the kernel in it, or by network booting.
  • 11. ARC Advanced RISC Computing Advanced RISC Computing (ARC) は、コンピュータメーカーによる 今はなきコンソーシアム(Advanced Computing Environment (ACE) プロジェクト) によって公開された標準的なMIPS RISCベースのハードウェアと ファームウェア環境についての仕様である。 ACEはすでに存在していないし、ARC仕様に完全に従ったコンピュータは 製造されていないが、ARCシステムは全てのMicrosoft Windows NTベースの オペレーティングシステムに幅広くレガシーとして影響を及ぼしている。 さらに、SGIは、ARCSと呼ばれる、手直ししたARCファームウェアを SGI製のシステムで使っている。IRIX 6.1以降が動く全ての SGIのコンピュータ(IndyやOctaneなど)では、まずはARCSコンソールが起動する。 加えて、ほとんどのWindow NTが動くRISCベースのコンピュータは Window NTをブートさせるためにARCブートコンソールを使っている。 このようなコンピュータは以下のようである。 MIPS R4000ベースのシステム(MIPS Magnumワークステーションなど) 1999年9月にWindows NT Alphaのサポートが終了する前までに設計された PCIバスを持った全てのAlphaベースのマシン( AlphaのARCファームウェアはAlphaBIOSとも呼ばれた) ほとんどのWindows NTに対応したPowerPCコンピュータ(IBM RS/6000 40Pなど)
  • 12. ARCと それ以前 R3000 R4000 >> printenv netaddr=192.168.1.33 dbaud=9600 rbaud=1200 bootfile=dksc(0,4,8)sash bootmode=c console=d diskless=0 keybd=d volume=128 path=dksc(0,4,8) cpufreq=33 >> printenv SystemPartition=scsi(0)disk(1)rdisk(0)partition(8) OSLoadPartition=scsi(0)disk(1)rdisk(0)partition(0) OSLoader=aoutboot OSLoadFilename=netbsd OSLoadOptions=auto TimeZone=PST8PDT diskless=0 dbaud=9600 rbaud=1200 volume=128 sgilogo=y AutoLoad=No console=d ConsoleOut=serial(0) ConsoleIn=serial(0) 設定できる 環境変数が 違う
  • 13. NetBSD/sgimips のブートローダ >> printenv SystemPartition=scsi(0)disk(1)rdisk(0)partition(8) OSLoadPartition=scsi(0)disk(1)rdisk(0)partition(0) OSLoader=boot OSLoadFilename=netbsd >> boot -f scsi(0)disk(1)rdisk(0)partition(8)/boot NetBSD/sgimips 6.1.5 Bootstrap, Revision 1.5 devopen: scsi(0)disk(1)rdisk(0)partition(0) type scsi file netbsd 4930576+131392 [270208+262451]=0x55644c [ 1.0000000] phys segment: 0xd000 @ 0x8002000 [ 1.0000000] adding 0xd000 @ 0x8002000 to freelist 0 … ファームウェアで指定した HDDとカーネルを ブートローダーは読み込む
  • 14. ARCで文字を 出したりカー ネルを読み込 む方法 N Offset Name 00 0x00 Load 01 0x04 Invoke 02 0x08 Execute 03 0x0c Halt 04 0x10 PowerDown 05 0x14 Restart 06 0x18 Reboot 23 0x5c Open 24 0x60 Close 25 0x64 Read 26 0x68 GetReadStatus 27 0x6c Write 28 0x70 Seek 29 0x74 Mount 30 0x78 GetEnvironmentVariable Firmware call vector Firmware functions are called indirectly through call vector table. Arguments to functions are placed in registers a0 to a3. Return values are placed in register v0.
  • 15. ARCでないマ シンで文字を 出したりカー ネルを読み込 む方法 >> boot -f dksc(0,2,8)sashIP12 166848+82032+319248 entry: 0x80700c90 Standalone Shell SGI Version 5.3 IP12 Nov 3, 1994 (BE) sash: boot -f dksc(0,1,1)unix.IP12 1346176+195088+193472 entry: 0x800026f0 IRIX Release 5.3 IP12 Version 11091810 System V Copyright 1987-1994 Silicon Graphics, Inc. All Rights Reserved. オリジナルのsgi製 ブートローダを逆アセンブル してファームウェアのサブ ルーチンの使い方を調べる?
  • 17. 設計と実装 ⚫ カーネルをHDDから読むためにSCSIドライバを組み込む →Western Digital WD33c93を積んでいるので、対応するwdscドライバ からDMAとか同期転送を削除して、必要なところだけを抽出 ⚫ 文字を出力するためにコンソールドライバを組み込む →Zilog 8530を積んでいるので、対応するzscドライバから必要な ところだけを抽出 ⚫ SCSIコマンドはTEST UNIT READY、READ CAPACITY、READのみ使用 ⚫ 割り込みが面倒なので文字の入力は未実装 ⚫ open()やstrategy()などのDISK I/O API、 printf()といった文字列出力関数、 ファイルシステムの解釈はNetBSDのlibsa(standalone実行用サポートラ イブラリ)におまかせ ⚫ 大抵のブートローダはファームウェアに実装されているサブルーチン を呼んで文字を出力したり、カーネルを読んでいる →ブートローダにSCSIドライバが組み込まれている実装は少ない →NetBSD/hp300のブートローダを参考に実装
  • 18. irisboot NetBSD Problem Report #53539 irisboot (I named) Yet another sgimips bootloader http://gnats.netbsd.org/53539 >> boot -f dksc(0,4,8)irisboot dksc(0,4,0)/netbsd 55696+0+1832 entry: 0x80368000 NetBSD/sgimips 8.99.24 Yet another Bootstrap, Revision 1.0 (Sun Aug 19 09:19:08 UTC 2018) 3001008+88272 [188544+180745]=0x34cbd0 [ 1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, [ 1.0000000] 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, [ 1.0000000] 2018 The NetBSD Foundation, Inc. All rights reserved. [ 1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993 [ 1.0000000] The Regents of the University of California. All rights reserved. [ 1.0000000] NetBSD 8.99.21 (GENERIC32_IP12) #1: Sun Aug 12 14:48:19 UTC 2018 [ 1.0000000] naruaki@xserve:/usr/obj.sgimips/sys/arch/sgimips/compile/GENERIC32_IP12 [ 1.0000000] total memory = 32768 KB [ 1.0000000] (0 reserved for ARCS) [ 1.0000000] avail memory = 28988 KB [ 1.0000000] WARNING: module error: sequencer: can't find builtin dependency `midi' [ 1.0000000] mainbus0 (root): SGI-IP12 [SGI, IP12], 1 processor [ 1.0000000] cpu0 at mainbus0: MIPS R3000A CPU (0x230) Rev. 3.0 with MIPS R3010 FPC Rev. 4.0 [ 1.0000000] cpu0: 32KB/4B direct-mapped Instruction cache, 64 TLB entries [ 1.0000000] cpu0: 32KB/4B direct-mapped write-through Data cache
  • 19. ARCなマシン でも ARCなIndigo R4000やINDYでも動くようにちょっと改造 (Indigo R3000と同じシリアル、SCSIコントローラーを使っているので) #ifdef INDIGO_R3K_MODE #define ZS_ADDR 0x1fb80d10 #define SCSIA_ADDR 0x1FB80122 #define SCSID_ADDR 0x1FB80126 #ifdef INDIGO_R4K_MODE #define ZS_ADDR 0x1fb80d10 #define SCSIA_ADDR 0x1FB80122 #define SCSID_ADDR 0x1FB80126 #ifdef INDY_MODE #define ZS_ADDR 0x1fbd9830 #define SCSIA_ADDR 0x1FBC0003 #define SCSID_ADDR 0x1FBC0007
  • 20. 問題点 • カーネルとブートローダ用の領域が少ない → 0x80002000 - 0x8037fffcの3.49MB →圧縮カーネルを使う ブートローダと一緒にロードされた「圧縮されたカーネル」が ブートローダのdataセグメントにあって、それを 「カーネルがロードされるべきアドレス」にgunzip展開しつつコピー →sysinst(installkernel)が同じく容量の問題で動かない NetBSD/Sun2でsysinstを使わないインストールスクリプトがあるらしい… • Irisbootという名前なので入手困難だけれどPersonal IRISをサポートしたい →お金の力で解決 • 仕事が忙しくてコードレビューしていただいたのに返信できていない…
  • 21. 良かったこと • カーネルを書く人は結構いるが、ブートローダーを書く人はあまりいな いので良い経験になった • SCSIドライバがどのようにファイルを読んでいるのか勉強になった • ブートローダはある意味簡易カーネルとも言えるので、 カーネルのデバッグにブートローダの知識が役立った • NetBSD/sgimipsのTODOリストから課題を一個消せた (sekiya) * grtwo needs cursor and hardware color fill support * ip12 needs ROM-based bootloader * hpc devices need real probe routines * port newport driver to x.org • NetBSD以外のOSSなOSではIndigo R3000をサポートしていないので、 カーネルの修正を含め、動くようになってめっちゃ感謝された
  • 22. スペシャル サンクス Frankさん Dear Naruaki, On 08/25/2018 01:41 PM, Frank Scheiner wrote: > I'll try to do more testing as soon as I find out how to use the > non-original disk. Ok, in the end I used another narrow SCSI disk (a ST39216N, the original disk is a ST1280N) that just worked. As I don't have my Indys at hand currently, I followed "Installing without sysinst" ([1]) and installed NetBSD (NetBSD-daily/HEAD /201808230630Z) on disk from my working diskless NetBSD installation - actually two times, as I didn't anticipate that one needs to reserve some space at the beginning of the disk for the SGI volume header as mentioned on [2]. :-D The result is working: ``` >> boot -f dksc(0,1,8)irisboot dksc(0,1,0)/netbsd 56784+0+1832 entry: 0x80368000 NetBSD/sgimips 8.99.24 Yet another Bootstrap, Revision 1.0 (Sun Aug 19 08:53:34 UTC 2018) 2829712+82768 [185024+176400]=0x31fa74 [ 1.0000000] arcemu: unknown console "", using serial [ 1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, [ 1.0000000] 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, Again much thanks for making NetBSD on Indigo R3K possible again! If you need me to test future revisions, just let me know. Cheers, Frank
  • 24. 参考文献など • SCSI-2詳細解説 最新SCSI規格とコマンドリファレンス • MIPS RISCアーキテクチャ -R2000/R3000- • 起動プログラム ブート・ローダ入門 クロックの初期化や外部メモリの設定からOSの起動まで