Skip to content

Commit

Permalink
enable SD card on vf2
Browse files Browse the repository at this point in the history
  • Loading branch information
Godones committed Aug 30, 2024
1 parent 61510e2 commit 3238e02
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ QEMU := qemu-system-riscv64
comma:= ,
empty:=
space:= $(empty) $(empty)

SD ?= n

ifeq ($(GUI),y)
QEMU_ARGS += -device virtio-gpu-device \
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion subsystems/devices/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ fn init_block_device(blk: prob::DeviceInfo, mmio_transport: Option<MmioTransport
#[cfg(not(feature = "ramdisk"))]
{
use drivers::block_device::VF2SDDriver;
let block_device = VF2SDDriver::new();
let mut block_device = VF2SDDriver::new();
block_device.init();
let size = block_device.capacity();
println!("Block device size is {}MB", size * 512 / 1024 / 1024);
let block_device = Arc::new(GenericBlockDevice::new(Box::new(block_device)));
Expand Down
17 changes: 12 additions & 5 deletions user/musl/ftest/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
use std::{fs::File, io::Read, time::Instant};
use std::{env, fs::File, io::Read, time::Instant};

fn main() {
read_bash_test();
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
println!("Usage: {} <block size>", args[0]);
return;
}
let blk_size= args[1].parse::<usize>().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();
Expand Down

0 comments on commit 3238e02

Please sign in to comment.