FPGA開発日記

カテゴリ別記事インデックス https://msyksphinz.github.io/github_pages , English Version https://fpgadevdiary.hatenadiary.com/

テキストを読んで、xv6のブートプロセスを理解する(1)

xv6のブートプロセスが難しくて詰まっている。いろいろググっていると、何だ。xv6のテキストにちゃんと書いてあるじゃないか。

という訳で、翻訳ついでに、翻訳中である(笑)。

http://pdos.csail.mit.edu/6.828/2014/xv6/book-rev8.pdf

github.com

1. 最初はセグメンテーションもページングも効いておらず、単純に読まれたコードを実行していくだけ ブートローダはbootasm.Sだが、そこではまだページングも何も効いていない。ここで、16ビットモード-->32ビットモードと進化していく。 2. キーボードの設定は何だろうと思ったら、メモリアドレスの21ビット目を有効にするためのハッキングだった...

仮想のsegment:offsetのアドレスでは、21ビットの物理アドレスを取り扱うことができるが、Intel 8088では、20ビットのメモリしか扱うことができない。 そのため、先頭の0xffff0+0xffff=0x10ffefは破棄される。 初期のソフトウェアでは、ハードウェアが21番目のビットを虫することに依存しており、 従って、Intelが20ビット以上の物理アドレスを導入したとき、IDBMはPCの互換性のあるハードウェアとしての動作を維持するために、 互換性のハッキングを提供していた。 もしキーボードコノローラの出力ポートの2番目のビットが0であるならば、21番目の物理アドレスビットは常に0となる; もし1であれば、21番目のビットは通常通り処理される。 ブートローダは21番目のアドレスビットを、キーボードコントローラの0x64および0x60ポートを制御することによって 有効化しなければならなかった。
A virtual segment:offset can yield a 21-bit physical address, but the Intel 8088
could only address 20 bits of memory, so it discarded the top bit: 0xffff0+0xffff =
0x10ffef, but virtual address 0xffff:0xffff on the 8088 referred to physical address
0x0ffef. Some early software relied on the hardware ignoring the 21st address bit, so
when Intel introduced processors with more than 20 bits of physical address, IBM provided
a compatibility hack that is a requirement for PC-compatible hardware. If the
second bit of the keyboard controller’s output port is low, the 21st physical address bit
is always cleared; if high, the 21st bit acts normally. The boot loader must enable the
21st address bit using I/O to the keyboard controller on ports 0x64 and 0x60 (8920-
8936).

3. xv6はセグメンテーションは利用しない。最低限の設定のみ行って、ページングに制御を委ねる テキストと、データのパーミッションの設定くらいしかしない。

4. 最後に、カーネルをロードするためにbootmain.c内のbootmainに飛ぶ。 bootmain内で動作に失敗すると、戻ってきて、ひたすらspinする。シミュレータ中では、0x8a00にアクセスすると、シミュレータに権限が戻るらしい。