# only_my_kernel **Repository Path**: YanDevelop/only_my_kernel ## Basic Information - **Project Name**: only_my_kernel - **Description**: Yet It Just Is My Kernel。 Rust语言实现的基于RISC-V架构的具有内存管理,进程管理,虚拟内存,小型文件系统,Shell的实时操作系统内核 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-01-16 - **Last Updated**: 2024-06-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # build guide(构建指导) ## bare metal build ```bash cargo build --target riscv64gc-unknown-none-elf [--release] ``` ## test on qemu ```bash qemu-system-riscv64 -machine virt -bios none -nographic -smp 1 -kernel ./target/riscv64gc-unknown-none-elf//rust_bare_metal ``` ## debug by gdb for linux, you should install risc-v toolchains first. for example, on ArchLinux: > paru -S riscv64-elf-gdb riscv64-< vendor>-elf-gdb may also work, but I don't try on it. ```shell cd $project_dir riscv64-elf-gdb target/riscv64gc-unknown-none-elf/debug/rust_bare_metal -q -x gdbinit ``` you can also use rust-gdb. for more information about rust-gdb, this command may be helpful. ```shell rustup component add llvm-tools-preview ``` ## disassemble before using rust-objcopy CLI, make sure you have installed rust-binutils(more details to see rCore Tutorial) you can also use other risc-v dissemble tools to dump elf,but it may not work better than rust-objdump. ```shell rust-objdump -C -d -g target/riscv64gc-unknown-none-elf/debug/rust_bare_metal ``` ## about rustc(关于rust语言编译器) Sometimes, we need to look at the asm compiled by rustc,and the whole project is too big to dump elf.The below two commands may be helpful. ```rust #![no_std] #![no_main] use core::arch::global_asm; use core::panic::PanicInfo; global_asm!( ".global _entry", ".section .text.entry", "_entry:", "j kernel_start" ); #[panic_handler] fn handler<'a, 'b>(info: &'a PanicInfo<'b>) -> !{ todo!() } #[no_mangle] fn kernel_start() { todo!() } ``` ```shell rustc main.rs --target riscv64gc-unknown-none-elf -Clink-arg=-T../linker/kernel.ld ``` ```shell rust-objdump -d main ``` # 致谢 感谢操作系统课程老师对我的支持和培养