Closed tomoyuki-nakabayashi closed 5 years ago
** Arithmetic right shift on signed integer types, logical right shift on unsigned integer types.
なるほど。
よし、じゃあテスト実行する方法を考えるか!
$ 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でインストールしたの失敗だなぁ。
https://groups.google.com/a/groups.riscv.org/forum/#!topic/sw-dev/DjWSUuqiRXI
なるほど。Linuxツールチェインじゃだめなのか。作りなおすか。
start addressは、0x80000000になっているので、プログラムはここからスタートする必要がある。
ecall, csr, mret命令は実装しないとダメみたいだ。
ecallは、trap_vectorに飛べば良い。 その際に、mcauseを設定しておく。
8か9か11を設定すれば良いっぽいが?
8: User external interrupt 9: Supervisor external interrupt 11: Machine external interrupt
ということで、11にしておけばOK。
mretはepcのアドレスに飛べば良い。
最後に0x80001000への書き込みでエミュレータを止めて、gpの値が1になっていれば、テストがパスしている。
忘れていた。rv32ui-p-simpleが通るようになった。 先にelf loaderを作ってしまおう。
全部通るようになった。
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