Rcore-Tutorial เวอร์ชัน 3.6 ดูเอกสารเป็นภาษาจีน
เอกสาร RCORE-TUTORIAL API ดูเอกสาร API ของสิบ OSE
หากคุณไม่รู้จักภาษาสนิมและพยายามเรียนรู้โปรดเยี่ยมชมแหล่งข้อมูลการเรียนรู้สนิม
หมายเลขกลุ่ม QQ อย่างเป็นทางการ: 735045051
โครงการนี้มีจุดมุ่งหมายเพื่อแสดงวิธีการเขียน ระบบปฏิบัติการที่เหมือน UNIX ที่ทำงานบนแพลตฟอร์ม RISC-V ตั้งแต่เริ่มต้น ใน Rust สำหรับ ผู้เริ่มต้น โดยไม่มีความรู้พื้นฐานเกี่ยวกับ สถาปัตยกรรมคอมพิวเตอร์ภาษาแอสเซมบลีหรือระบบปฏิบัติการ
qemu-system-riscv64 Simulator หรือ DEV Boards ตาม Kendryte K210 SOC เช่น MAIX Dockดูคู่มืออย่างเป็นทางการ
ติดตั้งเครื่องมือบางอย่าง:
$ rustup target add riscv64gc-unknown-none-elf
$ cargo install cargo-binutils --vers =0.3.3
$ rustup component add llvm-tools-preview
$ rustup component add rust-srcที่นี่เรารวบรวมและติดตั้ง QEMU 7.0.0 ด้วยตนเอง ตัวอย่างเช่นบน Ubuntu 18.04:
# install dependency packages
$ sudo apt install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev
gawk build-essential bison flex texinfo gperf libtool patchutils bc
zlib1g-dev libexpat-dev pkg-config libglib2.0-dev libpixman-1-dev git tmux python3 python3-pip
# download Qemu source code
$ wget https://download.qemu.org/qemu-7.0.0.tar.xz
# extract to qemu-7.0.0/
$ tar xvJf qemu-7.0.0.tar.xz
$ cd qemu-7.0.0
# build
$ ./configure --target-list=riscv64-softmmu,riscv64-linux-user
$ make -j $( nproc ) จากนั้นเพิ่มเนื้อหาต่อไปนี้เป็น ~/.bashrc (โปรดปรับเส้นทางเหล่านี้ตามสภาพแวดล้อมของคุณ):
export PATH=$PATH:/home/shinbokuow/Downloads/built/qemu-7.0.0
export PATH=$PATH:/home/shinbokuow/Downloads/built/qemu-7.0.0/riscv64-softmmu
export PATH=$PATH:/home/shinbokuow/Downloads/built/qemu-7.0.0/riscv64-linux-user
สุดท้ายอัปเดตเชลล์ปัจจุบัน:
$ source ~ /.bashrcตอนนี้เราสามารถตรวจสอบเวอร์ชันของ QEMU:
$ qemu-system-riscv64 --version
QEMU emulator version 7.0.0
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developersดาวน์โหลดไฟล์บีบอัดตามแพลตฟอร์มของคุณจากเว็บไซต์ sifive (Ctrl+f 'toolchain')
แยกมันออกและผนวกตำแหน่งของไดเรกทอรี 'bin' ภายใต้ไดเรกทอรีรูทไปยัง $PATH
ตัวอย่างเช่นเราสามารถตรวจสอบเวอร์ชันของ GDB:
$ riscv64-unknown-elf-gdb --version
GNU gdb (SiFive GDB-Metal 10.1.0-2020.12.7) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later < http://gnu.org/licenses/gpl.html >
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.$ pip3 install pyserial
$ sudo apt install python3-serial$ git clone https://github.com/rcore-os/rCore-Tutorial-v3.git
$ cd rCore-Tutorial-v3/os
$ make runหลังจากส่งข้อความถึงการดีบักเคอร์เนลจะแสดงแอปพลิเคชันทั้งหมดที่มีอยู่และป้อนเชลล์ผู้ใช้:
/**** APPS ****
mpsc_sem
usertests
pipetest
forktest2
cat
initproc
race_adder_loop
threads_arg
race_adder_mutex_spin
race_adder_mutex_blocking
forktree
user_shell
huge_write
race_adder
race_adder_atomic
threads
stack_overflow
filetest_simple
forktest_simple
cmdline_args
run_pipe_test
forktest
matrix
exit
fantastic_text
sleep_simple
yield
hello_world
pipe_large_test
sleep
phil_din_mutex
**************/
Rust user shell
>>
คุณสามารถเรียกใช้แอปพลิเคชันใด ๆ ยกเว้น initproc และ user_shell เอง ในการเรียกใช้แอปพลิเคชันเพียงแค่ป้อนชื่อไฟล์และกด Enter usertests สามารถเรียกใช้แอปพลิเคชันจำนวนมากดังนั้นจึงแนะนำ
พิมพ์ Ctrl+a จากนั้น x เพื่อออกจาก QEMU
ก่อนบทที่ 6 คุณไม่จำเป็นต้องใช้บัตร SD:
$ git clone https://github.com/rcore-os/rCore-Tutorial-v3.git
$ cd rCore-Tutorial-v3/os
$ make run BOARD=k210จากบทที่ 6 ก่อนที่จะเรียกใช้เคอร์เนลเราควรใส่การ์ด SD ลงในพีซีและเขียนภาพระบบไฟล์ด้วยตนเอง:
$ cd rCore-Tutorial-v3/os
$ make sdcard โดยค่าเริ่มต้นจะเขียนทับอุปกรณ์ /dev/sdb ซึ่งเป็นการ์ด SD แต่คุณสามารถระบุตำแหน่งอื่นได้ ตัวอย่างเช่น make sdcard SDCARD=/dev/sdc
หลังจากนั้นให้ถอดการ์ด SD ออกจากพีซีแล้วใส่ลงในสล็อตของ K210 เชื่อมต่อ K210 กับพีซีแล้ว:
$ git clone https://github.com/rcore-os/rCore-Tutorial-v3.git
$ cd rCore-Tutorial-v3/os
$ make run BOARD=k210 พิมพ์ Ctrl+] เพื่อตัดการเชื่อมต่อจาก K210
สาขาของ CH9-log มีข้อมูลการดีบักจำนวนมาก คุณสามารถลองใช้การสอน RCORE เพื่อทำความเข้าใจพฤติกรรมภายในของเคอร์เนล OS
$ git clone https://github.com/rcore-os/rCore-Tutorial-v3.git
$ cd rCore-Tutorial-v3/os
$ git checkout ch9-log
$ make run
......
[rustsbi] RustSBI version 0.2.0-alpha.10, adapting to RISC-V SBI v0.3
.______ __ __ _______.___________. _______..______ __
| _ | | | | / | | / || _ | |
| | _) | | | | | | (---- ` --- | | ---- ` | (---- ` | | _) || |
| / | | | | | | | _ < | |
| | - ---. | ` -- ' |.----) | | | .----) | | |_) || |
| _| `._____| ______/ |_______/ |__| |_______/ |______/ |__|
[rustsbi] Implementation: RustSBI-QEMU Version 0.0.2
[rustsbi-dtb] Hart count: cluster0 with 1 cores
[rustsbi] misa: RV64ACDFIMSU
[rustsbi] mideleg: ssoft, stimer, sext (0x222)
[rustsbi] medeleg: ima, ia, bkpt, la, sa, uecall, ipage, lpage, spage (0xb1ab)
[rustsbi] pmp0: 0x10000000 ..= 0x10001fff (rw-)
[rustsbi] pmp1: 0x2000000 ..= 0x200ffff (rw-)
[rustsbi] pmp2: 0xc000000 ..= 0xc3fffff (rw-)
[rustsbi] pmp3: 0x80000000 ..= 0x8fffffff (rwx)
[rustsbi] enter supervisor 0x80200000
[KERN] rust_main() begin
[KERN] clear_bss() begin
[KERN] clear_bss() end
[KERN] mm::init() begin
[KERN] mm::init_heap() begin
[KERN] mm::init_heap() end
[KERN] mm::init_frame_allocator() begin
[KERN] mm::frame_allocator::lazy_static!FRAME_ALLOCATOR begin
...... ขณะนี้สามารถช่วยคุณดูรหัสได้เนื่องจากมีการบันทึกไว้เพียงส่วนเล็ก ๆ ของรหัสเท่านั้น
คุณสามารถเปิด DOC HTML ของ os โดยใช้ cargo doc --no-deps --open ภายใต้ไดเรกทอรี os
เอกสาร API สำหรับ Ten OS
รุ่นแรกของเรา 3.6.0 (บทที่ 1-9) ได้รับการเผยแพร่และเรายังคงดำเนินการอยู่
นี่คือการอัปเดตตั้งแต่ 3.5.0:
power ในตอนแรกตอนนี้คุณสามารถค้นหาโมดูลัสในเอาต์พุต UPSafeCell แทน RefCell หรือ spin::Mutex เพื่อเข้าถึงโครงสร้างข้อมูลแบบคงที่และปรับ API เพื่อไม่ให้ยืมสองครั้งในแต่ละครั้ง (พูดถึง & .exclusive_access().task[0] ใน run_first_task ) TaskContext ไปยัง TaskControlBlock แทนที่จะกู้คืนไว้ในตำแหน่งเคอร์เนล (ตั้งแต่ CH3) กำจัด task_cx_ptr2 ที่น่ารำคาญ llvm_asm! กับ asm! rcore-fs-fuse เป็น 128MIB huge_write ซึ่งประเมินประสิทธิภาพ FS (QEMU ~ 500KIB/S K210 ~ 50KIB/S) spin::Mutex ด้วย UPSafeCell ก่อนบท SMP find_pte มากกว่า find_pte_create ใน PageTable::unmap find_pte แทนที่จะตรวจสอบนอกฟังก์ชั่นนี้" ไม่ควรเป็นข้อผิดพลาด cargo doc --no-deps --open เราจะเพิ่มพวกเขาในภายหลัง