[使用 Qemu 加载内核镜像] · GitBook
https://rcore-os.github.io/rCore_tutorial_doc/chapter2/part5.html
对openSBI的输出给出一个简明的解释比较好一些。同时,建议给出openSBI加载os后的物理地址空间布局。
ecall还是要有简明的解释为好,包括基本的内嵌汇编的解释。
在下一节都讲了,不错!
从源码编译 Qemu 的过程中,可能会遇到以下错误:
glib-2.40 gthread-2.0 is required to compile QEMU
这时我们可以安装一些依赖库:
sudo apt-get install build-essential zlib1g-dev pkg-config libglib2.0-dev binutils-dev libboost-all-dev autoconf libtool libssl-dev libpixman-1-dev libpython-dev python-pip python-capstone virtualenv
一般可以解决问题。
rustup 2020-05-24 nightly 编译不了asm! 替换成llvm_asm!才能给过(包括修改feature)
@qwtsc rustup 2020-05-24 nightly 编译不了asm! 替换成llvm_asm!才能给过(包括修改feature)
同学可以把命令写的更详细一点吗, 我改成了这样也还是一样不行。
➜ os git:(ch2-pa5) ✗ rustc -v -V rustc 1.45.0-nightly (46e85b432 2020-05-24) binary: rustc commit-hash: 46e85b4328fe18492894093c1092dfe509df4370 commit-date: 2020-05-24 host: x86_64-apple-darwin release: 1.45.0-nightly LLVM version: 10.0
unsafe {
llvm_asm!("ecall"
: "={x10}" (ret)
: "{x10}" (arg0), "{x11}" (arg1), "{x12}" (arg2), "{x17}" (which)
: "memory"
: "volatile"
);
}
@gongbo2018
@qwtsc rustup 2020-05-24 nightly 编译不了asm! 替换成llvm_asm!才能给过(包括修改feature)
同学可以把命令写的更详细一点吗, 我改成了这样也还是一样不行。
➜ os git:(ch2-pa5) ✗ rustc -v -V rustc 1.45.0-nightly (46e85b432 2020-05-24) binary: rustc commit-hash: 46e85b4328fe18492894093c1092dfe509df4370 commit-date: 2020-05-24 host: x86_64-apple-darwin release: 1.45.0-nightly LLVM version: 10.0
unsafe { llvm_asm!("ecall" : "={x10}" (ret) : "{x10}" (arg0), "{x11}" (arg1), "{x12}" (arg2), "{x17}" (which) : "memory" : "volatile" ); }
你得把feature也给成llvm_asm 也就是#![feature(llvm_asm)],虽然我也不是很懂,但是这样编译器就过了。
@qwtsc 谢谢, 可以了。
我把答案总结再整理下,
- 把 main.rs 第4行的 #![feature(asm)] 改成 #![feature(llvm_asm)]
- 把main.rs 第27行的 asm!("ecall" 改成 llvm_asm!("ecall"
1.我没有用上述同学的llvm方法 2.error:Makefile:1: *** missing separator. Stop. 参考https://blog.csdn.net/limanjihe/article/details/52231243 有空的开头全改tab,好坑啊
使用示例仓库中 ch2-pa5 运行 make run,结尾是:
OpenSBI v0.4 (Jul 2 2019 11:53:53)
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|
Platform Name : QEMU Virt Machine
Platform HART Features : RV64ACDFIMSU
Platform Max HARTs : 8
Current Hart : 0
Firmware Base : 0x80000000
Firmware Size : 112 KB
Runtime SBI Version : 0.1
PMP0: 0x0000000080000000-0x000000008001ffff (A)
PMP1: 0x0000000000000000-0xffffffffffffffff (A,R,W,X)
之后就没有任何输出了。没有 OK 字符,但是编译通过了。
@PeterlitsZo 使用示例仓库中 ch2-pa5 运行
make run,结尾是:OpenSBI v0.4 (Jul 2 2019 11:53:53) ____ _____ ____ _____ / __ \ / ____| _ \_ _| | | | |_ __ ___ _ __ | (___ | |_) || | | | | | '_ \ / _ \ '_ \ \___ \| _ < | | | |__| | |_) | __/ | | |____) | |_) || |_ \____/| .__/ \___|_| |_|_____/|____/_____| | | |_| Platform Name : QEMU Virt Machine Platform HART Features : RV64ACDFIMSU Platform Max HARTs : 8 Current Hart : 0 Firmware Base : 0x80000000 Firmware Size : 112 KB Runtime SBI Version : 0.1 PMP0: 0x0000000080000000-0x000000008001ffff (A) PMP1: 0x0000000000000000-0xffffffffffffffff (A,R,W,X)之后就没有任何输出了。没有
OK字符,但是编译通过了。
1.请检查kernel.bin文件是否存在 2.请贴出main.rs 3.请检查Makefile run:部分是否有改动
@PeterlitsZo 使用示例仓库中 ch2-pa5 运行
make run,结尾是:OpenSBI v0.4 (Jul 2 2019 11:53:53) ____ _____ ____ _____ / __ \ / ____| _ \_ _| | | | |_ __ ___ _ __ | (___ | |_) || | | | | | '_ \ / _ \ '_ \ \___ \| _ < | | | |__| | |_) | __/ | | |____) | |_) || |_ \____/| .__/ \___|_| |_|_____/|____/_____| | | |_| Platform Name : QEMU Virt Machine Platform HART Features : RV64ACDFIMSU Platform Max HARTs : 8 Current Hart : 0 Firmware Base : 0x80000000 Firmware Size : 112 KB Runtime SBI Version : 0.1 PMP0: 0x0000000080000000-0x000000008001ffff (A) PMP1: 0x0000000000000000-0xffffffffffffffff (A,R,W,X)之后就没有任何输出了。没有
OK字符,但是编译通过了。1.请检查kernel.bin文件是否存在 2.请贴出main.rs 3.请检查Makefile run:部分是否有改动
- 文件存在
- 请点击链接进入相关版本查看。
- 没有进行改动。
值得一提的是,在下一章节处,即调用 OpenSBI 接口来进行输出是有结果的。
做lab的时候遇到asm!里面会有execpted
,的问题,nightly 1.79中已经无法使用llvm_asm!来解决了,如果用的旧代码的话把asm!里面的代码改成如上图中最新的就好了^_^