tomoyuki-nakabayashi / Rustemu86

Apache License 2.0
5 stars 0 forks source link

riscv-test rv32uiを通そう! #47

Closed tomoyuki-nakabayashi closed 5 years ago

tomoyuki-nakabayashi commented 5 years ago

https://content.riscv.org/wp-content/uploads/2017/05/riscv-privileged-v1.10.pdf https://content.riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf

https://github.com/riscv/riscv-tests/tree/master/isa/rv32ui

Integer Register-Immediate Instructions

Integer Register-Register Operations

Control Transfer Instructions

Load and Store Instructions

tomoyuki-nakabayashi commented 5 years ago

https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators

** Arithmetic right shift on signed integer types, logical right shift on unsigned integer types.

なるほど。

tomoyuki-nakabayashi commented 5 years ago

よし、じゃあテスト実行する方法を考えるか!

tomoyuki-nakabayashi commented 5 years ago
$ git clone https://github.com/riscv/riscv-tests
$ cd riscv-tests
$ git submodule update --init --recursive
$ autoconf
$ ./configure --prefix=/opt/riscv/bin
$ make
$ make install

toolchainがunknown-elfを対象としているのか。unknown-linux-gnuでインストールしたの失敗だなぁ。

tomoyuki-nakabayashi commented 5 years ago

https://groups.google.com/a/groups.riscv.org/forum/#!topic/sw-dev/DjWSUuqiRXI

なるほど。Linuxツールチェインじゃだめなのか。作りなおすか。

tomoyuki-nakabayashi commented 5 years ago

start addressは、0x80000000になっているので、プログラムはここからスタートする必要がある。

tomoyuki-nakabayashi commented 5 years ago

ecall, csr, mret命令は実装しないとダメみたいだ。

tomoyuki-nakabayashi commented 5 years ago

ecallは、trap_vectorに飛べば良い。 その際に、mcauseを設定しておく。

8か9か11を設定すれば良いっぽいが?

8: User external interrupt 9: Supervisor external interrupt 11: Machine external interrupt

ということで、11にしておけばOK。

tomoyuki-nakabayashi commented 5 years ago

mretはepcのアドレスに飛べば良い。

tomoyuki-nakabayashi commented 5 years ago

最後に0x80001000への書き込みでエミュレータを止めて、gpの値が1になっていれば、テストがパスしている。

tomoyuki-nakabayashi commented 5 years ago

忘れていた。rv32ui-p-simpleが通るようになった。 先にelf loaderを作ってしまおう。

tomoyuki-nakabayashi commented 5 years ago

全部通るようになった。