can run virtio gpu/block

This commit is contained in:
Yu Chen 2022-06-18 17:50:50 +08:00
parent efc35aee3b
commit e7e7d572ba
5 changed files with 17 additions and 4 deletions

Binary file not shown.

9
os/run.sh Executable file
View File

@ -0,0 +1,9 @@
qemu-system-riscv64 -M 128m -machine virt \
-bios ../bootloader/rustsbi-qemu.bin \
-device loader,file=target/riscv64gc-unknown-none-elf/release/os.bin,addr=0x80200000 \
-drive file=../user/target/riscv64gc-unknown-none-elf/release/fs.img,if=none,format=raw,id=x0 \
-device virtio-blk-device,drive=x0 \
-device virtio-gpu-device \
-device virtio-keyboard-device \
-device virtio-mouse-device \
-serial stdio

View File

@ -1,8 +1,8 @@
pub const CLOCK_FREQ: usize = 12500000;
pub const MMIO: &[(usize, usize)] = &[
(0x1000_0000, 0x1000), // VIRT_UART0 in virt machine
(0x1000_1000, 0x1000), // VIRT_VIRTIO in virt machine
(0x1000_0000, 0xa000), // VIRT_UART0 in virt machine
// (0x1000_1000, 0x9000), // VIRT_VIRTIO with GPU in virt machine
(0x0C00_0000, 0x40_0000), // VIRT_PLIC in virt machine
(0x0010_0000, 0x00_2000), // VIRT_TEST/RTC in virt machine
];

View File

@ -12,7 +12,7 @@ use lazy_static::*;
use virtio_drivers::{BlkResp, RespStatus, VirtIOBlk, VirtIOHeader};
#[allow(unused)]
const VIRTIO0: usize = 0x10001000;
const VIRTIO0: usize = 0x10008000;
pub struct VirtIOBlock {
virtio_blk: UPIntrFreeCell<VirtIOBlk<'static>>,

View File

@ -22,6 +22,7 @@ mod console;
mod config;
mod drivers;
mod fs;
mod gui;
mod lang_items;
mod mm;
mod sbi;
@ -30,7 +31,6 @@ mod syscall;
mod task;
mod timer;
mod trap;
mod gui;
core::arch::global_asm!(include_str!("entry.asm"));
@ -57,9 +57,13 @@ lazy_static! {
pub fn rust_main() -> ! {
clear_bss();
mm::init();
println!("KERN: init gpu");
GPU_DEVICE.clone();
println!("KERN: init keyboard");
KEYBOARD_DEVICE.clone();
println!("KERN: init mouse");
MOUSE_DEVICE.clone();
println!("KERN: init trap");
trap::init();
trap::enable_timer_interrupt();
timer::set_next_trigger();