Skip to content

Commit

Permalink
Migrate virtio-blk from semu
Browse files Browse the repository at this point in the history
This commit migrates @shengwen-tw's brilliant virtio implementation
from semu, with the following modification:

1. Rename virtio_blk_reg_read/write to virtio_blk_read/write
The original virtio_blk_read verified whether the virtio MMIO was
aligned to 4. Since rv32emu does not enforce alignment checks for UART
and PLIC devices or raise misalignment exceptions, this verification
has been omitted.

2. Implement MMIO_VIRTIOBLK

3. Implement vblk_new() and vblk_delete()
These functions align with the conventions used for UART and PLIC
devices.

4. Introduce new argument '-v' for virtio-blk disk image
  • Loading branch information
otteryc committed Jan 23, 2025
1 parent ee3bd57 commit b6bd4b2
Show file tree
Hide file tree
Showing 8 changed files with 597 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ $ make ENABLE_SYSTEM=1 system
Build using run using specified images:
```shell
$ make ENABLE_SYSTEM=1
$ build/rv32emu -k <kernel_img_path> -i <rootfs_img_path>
$ build/rv32emu -k <kernel_img_path> -i <rootfs_img_path> -v <virtio_img_path>
```

#### Build Linux image
Expand Down
6 changes: 6 additions & 0 deletions src/devices/minimal.dts
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,11 @@
no-loopback-test;
clock-frequency = <5000000>; /* the baudrate divisor is ignored */
};

blk0: virtio@4200000 {
compatible = "virtio,mmio";
reg = <0x4200000 0x200>;
interrupts = <3>;
};
};
};
Loading

0 comments on commit b6bd4b2

Please sign in to comment.