From 3238e02772050ecabe9de36bdfaad77c6cddfb9e Mon Sep 17 00:00:00 2001 From: Godones <1925466036@qq.com> Date: Tue, 27 Aug 2024 20:21:49 +0800 Subject: [PATCH] enable SD card on vf2 --- Makefile | 7 +++++-- subsystems/devices/src/lib.rs | 3 ++- user/musl/ftest/src/main.rs | 17 ++++++++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index cf6c5565..10c061b6 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ QEMU := qemu-system-riscv64 comma:= , empty:= space:= $(empty) $(empty) - +SD ?= n ifeq ($(GUI),y) QEMU_ARGS += -device virtio-gpu-device \ @@ -44,7 +44,10 @@ endif ifeq ($(VF2),y) -FEATURES += vf2 ramdisk +FEATURES += vf2 +ifeq ($(SD),n) +FEATURES += ramdisk +endif else ifeq ($(UNMATCHED),y) FEATURES += hifive ramdisk else diff --git a/subsystems/devices/src/lib.rs b/subsystems/devices/src/lib.rs index dfbcedf5..fff4a967 100644 --- a/subsystems/devices/src/lib.rs +++ b/subsystems/devices/src/lib.rs @@ -213,7 +213,8 @@ fn init_block_device(blk: prob::DeviceInfo, mmio_transport: Option = env::args().collect(); + if args.len() < 2 { + println!("Usage: {} ", args[0]); + return; + } + let blk_size= args[1].parse::().unwrap(); + read_bash_test(blk_size); // in cache - read_bash_test(); + read_bash_test(blk_size); // read_once_test(); } -fn read_bash_test() { + +fn read_bash_test(blk_size:usize) { let mut file = File::open("/tests/bash2").unwrap(); let now = Instant::now(); - let mut buf = [0u8; 4096]; + let mut buf = vec![0u8; blk_size]; let mut bytes = 0; loop { let res = file.read(&mut buf).unwrap();