rcore-os / rCore-Tutorial-deploy

Tutorial Doc for rCore OS step by step (3rd edition)
https://rcore-os.github.io/rCore-Tutorial-deploy/
GNU General Public License v3.0
3 stars 1 forks source link

接口封装和代码整理 · GitBook #18

Open LyricZhao opened 4 years ago

LyricZhao commented 4 years ago

https://rcore-os.github.io/rCore-Tutorial-deploy/docs/lab-0/guide/part-9.html

KuangjuX commented 3 years ago

make run之后只输出了OpenSBI的信息,而没有输出控制台信息OK\n,我将可执行文件反汇编后如下:

target/riscv64imac-unknown-none-elf/debug/os:   file format elf64-littleriscv

Disassembly of section .text:

000000008020001c <_start>:
8020001c: 17 01 01 00   auipc   sp, 16
80200020: 13 01 81 06   addi    sp, sp, 104
80200024: 97 00 00 00   auipc   ra, 0
80200028: e7 80 00 03   jalr    48(ra)

000000008020002c <_ZN2os15console_putchar17heef8c19e73f7d5a4E>:
8020002c: 39 71         addi    sp, sp, -64
8020002e: aa 85         add a1, zero, a0
80200030: a3 0f a1 00   sb  a0, 31(sp)
80200034: 13 75 f5 0f   andi    a0, a0, 255
80200038: 2a f0         sd  a0, 32(sp)
8020003a: 01 46         mv  a2, zero
8020003c: 32 f4         sd  a2, 40(sp)
8020003e: 32 f8         sd  a2, 48(sp)
80200040: 85 46         addi    a3, zero, 1
80200042: 36 fc         sd  a3, 56(sp)
80200044: 2e e4         sd  a1, 8(sp)
80200046: b2 85         add a1, zero, a2
80200048: b6 88         add a7, zero, a3
8020004a: 73 00 00 00   ecall   
8020004e: 2a e8         sd  a0, 16(sp)
80200050: 21 61         addi    sp, sp, 64
80200052: 82 80         ret

0000000080200054 <rust_main>:
80200054: 41 11         addi    sp, sp, -16
80200056: 06 e4         sd  ra, 8(sp)
80200058: 13 05 f0 04   addi    a0, zero, 79
8020005c: 97 00 00 00   auipc   ra, 0
80200060: e7 80 00 fd   jalr    -48(ra)
80200064: 09 a0         j   2 <rust_main+0x12>
80200066: 13 05 b0 04   addi    a0, zero, 75
8020006a: 97 00 00 00   auipc   ra, 0
8020006e: e7 80 20 fc   jalr    -62(ra)
80200072: 09 a0         j   2 <rust_main+0x20>
80200074: 29 45         addi    a0, zero, 10
80200076: 97 00 00 00   auipc   ra, 0
8020007a: e7 80 60 fb   jalr    -74(ra)
8020007e: 09 a0         j   2 <rust_main+0x2c>
80200080: 09 a0         j   2 <rust_main+0x2e>
80200082: 01 a0         j   0 <rust_main+0x2e>

在这里你可以看到rust_main的信息,请问这是什么原因?

Observer-yl commented 3 years ago

请问出现这个错误是由什么原因导致

make run

Compiling os v0.1.0 (/home/liujiaxu/Desktop/learn/ch1/os) Finished dev [unoptimized + debuginfo] target(s) in 0.21s

OpenSBI v0.6


/ \ / __ _ _ __ (___ _) ' \ / \ '_ \ ___ \ _ < __ _) __/ ____) _) _ ____/ ./ _ _ _ _____/ __/___
_

Platform Name : QEMU Virt Machine Platform HART Features : RV64ACDFIMSU Platform Max HARTs : 8 Current Hart : 0 Firmware Base : 0x80000000 Firmware Size : 120 KB Runtime SBI Version : 0.2

MIDELEG : 0x0000000000000222 MEDELEG : 0x000000000000b109 PMP0 : 0x0000000080000000-0x000000008001ffff (A) PMP1 : 0x0000000000000000-0xffffffffffffffff (A,R,W,X) Hello rCore-Tutorial! panic: 'end of rust_main 结束' sbi_trap_error: hart0: page/access fault handler failed (error -2) sbi_trap_error: hart0: mcause=0x0000000000000007 mtval=0x0000000000100000 sbi_trap_error: hart0: mepc=0x0000000080004056 mstatus=0x8000000000007800 sbi_trap_error: hart0: ra=0x0000000080001df0 sp=0x000000008001daa8 sbi_trap_error: hart0: gp=0x0000000000000000 tp=0x000000008001de00 sbi_trap_error: hart0: s0=0x000000008001dab8 s1=0x000000008001de00 sbi_trap_error: hart0: a0=0x0000000000000000 a1=0x0000000080004042 sbi_trap_error: hart0: a2=0x0000000080004042 a3=0x0000000080004042 sbi_trap_error: hart0: a4=0x0000000000100000 a5=0x0000000000005555 sbi_trap_error: hart0: a6=0x0000000000004042 a7=0x000000008000c0d0 sbi_trap_error: hart0: s2=0x0000000000000000 s3=0x0000000000000000 sbi_trap_error: hart0: s4=0x000000008001dba0 s5=0x0000000080211e88 sbi_trap_error: hart0: s6=0x0000000080211e88 s7=0x0000000000000000 sbi_trap_error: hart0: s8=0x0000000000000000 s9=0x0000000000000000 sbi_trap_error: hart0: s10=0x0000000000000004 s11=0x0000000000000008 sbi_trap_error: hart0: t0=0x0000000000000000 t1=0x0000000000000000 sbi_trap_error: hart0: t2=0x0000000080211e88 t3=0x0000000000000000 sbi_trap_error: hart0: t4=0x0000000000000000 t5=0x0000000000000000 sbi_trap_error: hart0: t6=0x0000000000000000

stjimreal commented 3 years ago

@KuangjuX 在make run之后只输出了OpenSBI的信息,而没有输出控制台信息OK\n,我将可执行文件反汇编后如下:

target/riscv64imac-unknown-none-elf/debug/os: file format elf64-littleriscv

Disassembly of section .text:

000000008020001c <_start>:
8020001c: 17 01 01 00     auipc   sp, 16
80200020: 13 01 81 06     addi    sp, sp, 104
80200024: 97 00 00 00     auipc   ra, 0
80200028: e7 80 00 03     jalr    48(ra)

000000008020002c <_ZN2os15console_putchar17heef8c19e73f7d5a4E>:
8020002c: 39 71           addi    sp, sp, -64
8020002e: aa 85           add a1, zero, a0
80200030: a3 0f a1 00     sb  a0, 31(sp)
80200034: 13 75 f5 0f     andi    a0, a0, 255
80200038: 2a f0           sd  a0, 32(sp)
8020003a: 01 46           mv  a2, zero
8020003c: 32 f4           sd  a2, 40(sp)
8020003e: 32 f8           sd  a2, 48(sp)
80200040: 85 46           addi    a3, zero, 1
80200042: 36 fc           sd  a3, 56(sp)
80200044: 2e e4           sd  a1, 8(sp)
80200046: b2 85           add a1, zero, a2
80200048: b6 88           add a7, zero, a3
8020004a: 73 00 00 00     ecall   
8020004e: 2a e8           sd  a0, 16(sp)
80200050: 21 61           addi    sp, sp, 64
80200052: 82 80           ret

0000000080200054 <rust_main>:
80200054: 41 11           addi    sp, sp, -16
80200056: 06 e4           sd  ra, 8(sp)
80200058: 13 05 f0 04     addi    a0, zero, 79
8020005c: 97 00 00 00     auipc   ra, 0
80200060: e7 80 00 fd     jalr    -48(ra)
80200064: 09 a0           j   2 <rust_main+0x12>
80200066: 13 05 b0 04     addi    a0, zero, 75
8020006a: 97 00 00 00     auipc   ra, 0
8020006e: e7 80 20 fc     jalr    -62(ra)
80200072: 09 a0           j   2 <rust_main+0x20>
80200074: 29 45           addi    a0, zero, 10
80200076: 97 00 00 00     auipc   ra, 0
8020007a: e7 80 60 fb     jalr    -74(ra)
8020007e: 09 a0           j   2 <rust_main+0x2c>
80200080: 09 a0           j   2 <rust_main+0x2e>
80200082: 01 a0           j   0 <rust_main+0x2e>

在这里你可以看到rust_main的信息,请问这是什么原因?

QEMU 串口重定向的问题,综合网上的做法在 qemu-system-riscv64选项增加-kernel $(bin_file)即可。

Peng-Hu commented 3 years ago

@Observer-yl 请问出现这个错误是由什么原因导致

make run

Compiling os v0.1.0 (/home/liujiaxu/Desktop/learn/ch1/os) Finished dev [unoptimized + debuginfo] target(s) in 0.21s

OpenSBI v0.6


/ \ / __ _ _ __ (___ _) ' \ / \ '_ \ ___ \ _ < __ _) __/ ____) _) _ ____/ ./ _ _ _ _____/ __/___
_

Platform Name : QEMU Virt Machine Platform HART Features : RV64ACDFIMSU Platform Max HARTs : 8 Current Hart : 0 Firmware Base : 0x80000000 Firmware Size : 120 KB Runtime SBI Version : 0.2

MIDELEG : 0x0000000000000222 MEDELEG : 0x000000000000b109 PMP0 : 0x0000000080000000-0x000000008001ffff (A) PMP1 : 0x0000000000000000-0xffffffffffffffff (A,R,W,X) Hello rCore-Tutorial! panic: 'end of rust_main 结束' sbi_trap_error: hart0: page/access fault handler failed (error -2) sbi_trap_error: hart0: mcause=0x0000000000000007 mtval=0x0000000000100000 sbi_trap_error: hart0: mepc=0x0000000080004056 mstatus=0x8000000000007800 sbi_trap_error: hart0: ra=0x0000000080001df0 sp=0x000000008001daa8 sbi_trap_error: hart0: gp=0x0000000000000000 tp=0x000000008001de00 sbi_trap_error: hart0: s0=0x000000008001dab8 s1=0x000000008001de00 sbi_trap_error: hart0: a0=0x0000000000000000 a1=0x0000000080004042 sbi_trap_error: hart0: a2=0x0000000080004042 a3=0x0000000080004042 sbi_trap_error: hart0: a4=0x0000000000100000 a5=0x0000000000005555 sbi_trap_error: hart0: a6=0x0000000000004042 a7=0x000000008000c0d0 sbi_trap_error: hart0: s2=0x0000000000000000 s3=0x0000000000000000 sbi_trap_error: hart0: s4=0x000000008001dba0 s5=0x0000000080211e88 sbi_trap_error: hart0: s6=0x0000000080211e88 s7=0x0000000000000000 sbi_trap_error: hart0: s8=0x0000000000000000 s9=0x0000000000000000 sbi_trap_error: hart0: s10=0x0000000000000004 s11=0x0000000000000008 sbi_trap_error: hart0: t0=0x0000000000000000 t1=0x0000000000000000 sbi_trap_error: hart0: t2=0x0000000080211e88 t3=0x0000000000000000 sbi_trap_error: hart0: t4=0x0000000000000000 t5=0x0000000000000000 sbi_trap_error: hart0: t6=0x0000000000000000

@Observer-yl 请问出现这个错误是由什么原因导致

make run

Compiling os v0.1.0 (/home/liujiaxu/Desktop/learn/ch1/os) Finished dev [unoptimized + debuginfo] target(s) in 0.21s

OpenSBI v0.6


/ \ / __ _ _ __ (___ _) ' \ / \ '_ \ ___ \ _ < __ _) __/ ____) _) _ ____/ ./ _ _ _ _____/ __/___
_

Platform Name : QEMU Virt Machine Platform HART Features : RV64ACDFIMSU Platform Max HARTs : 8 Current Hart : 0 Firmware Base : 0x80000000 Firmware Size : 120 KB Runtime SBI Version : 0.2

MIDELEG : 0x0000000000000222 MEDELEG : 0x000000000000b109 PMP0 : 0x0000000080000000-0x000000008001ffff (A) PMP1 : 0x0000000000000000-0xffffffffffffffff (A,R,W,X) Hello rCore-Tutorial! panic: 'end of rust_main 结束' sbi_trap_error: hart0: page/access fault handler failed (error -2) sbi_trap_error: hart0: mcause=0x0000000000000007 mtval=0x0000000000100000 sbi_trap_error: hart0: mepc=0x0000000080004056 mstatus=0x8000000000007800 sbi_trap_error: hart0: ra=0x0000000080001df0 sp=0x000000008001daa8 sbi_trap_error: hart0: gp=0x0000000000000000 tp=0x000000008001de00 sbi_trap_error: hart0: s0=0x000000008001dab8 s1=0x000000008001de00 sbi_trap_error: hart0: a0=0x0000000000000000 a1=0x0000000080004042 sbi_trap_error: hart0: a2=0x0000000080004042 a3=0x0000000080004042 sbi_trap_error: hart0: a4=0x0000000000100000 a5=0x0000000000005555 sbi_trap_error: hart0: a6=0x0000000000004042 a7=0x000000008000c0d0 sbi_trap_error: hart0: s2=0x0000000000000000 s3=0x0000000000000000 sbi_trap_error: hart0: s4=0x000000008001dba0 s5=0x0000000080211e88 sbi_trap_error: hart0: s6=0x0000000080211e88 s7=0x0000000000000000 sbi_trap_error: hart0: s8=0x0000000000000000 s9=0x0000000000000000 sbi_trap_error: hart0: s10=0x0000000000000004 s11=0x0000000000000008 sbi_trap_error: hart0: t0=0x0000000000000000 t1=0x0000000000000000 sbi_trap_error: hart0: t2=0x0000000080211e88 t3=0x0000000000000000 sbi_trap_error: hart0: t4=0x0000000000000000 t5=0x0000000000000000 sbi_trap_error: hart0: t6=0x0000000000000000

我也遇到相同的问题,请问最后如何解决的?什么原因

hjs99 commented 3 years ago

error[E0765]: unterminated double quote string --> src/main.rs:21:29 | 21 | panic!("end of rustmain") | ____^ 22 | | } 23 | | | |_^

error: aborting due to previous error

For more information about this error, try rustc --explain E0765. error: could not compile os.

To learn more, run the command again with --verbose. make: *** [Makefile:14: kernel] Error 101

最后make的时候出现以下错误,请问是什么原因??

rare-oxygen commented 2 years ago

我沒有顯示QEMU VM是什麼鬼,我Terminal上是跟教程一样的,用的是MacBook M1

rare-oxygen commented 2 years ago

OpenSBI v0.9


/ \ / __ _ _ __ (___ _) ' \ / \ '_ \ ___ \ _ < __ _) __/ ____) _) _ ____/ ./ _ _ _ _____/ __/___
_

Platform Name : riscv-virtio,qemu Platform Features : timer,mfdeleg Platform HART Count : 1 Firmware Base : 0x80000000 Firmware Size : 100 KB Runtime SBI Version : 0.2

Domain0 Name : root Domain0 Boot HART : 0 Domain0 HARTs : 0* Domain0 Region00 : 0x0000000080000000-0x000000008001ffff () Domain0 Region01 : 0x0000000000000000-0xffffffffffffffff (R,W,X) Domain0 Next Address : 0x0000000000000000 Domain0 Next Arg1 : 0x0000000087000000 Domain0 Next Mode : S-mode Domain0 SysReset : yes

Boot HART ID : 0 Boot HART Domain : root Boot HART ISA : rv64imafdcsu Boot HART Features : scounteren,mcounteren,time Boot HART PMP Count : 16 Boot HART PMP Granularity : 4 Boot HART PMP Address Bits: 54 Boot HART MHPM Count : 0 Boot HART MHPM Count : 0 Boot HART MIDELEG : 0x0000000000000222 Boot HART MEDELEG : 0x000000000000b109