refactor: extract shared hw-virtio crate, eliminate VirtIO protocol duplication
Two VirtIO block and two VirtIO GPU implementations (adapter + driver)
shared 90% of their protocol logic. Extracted the common code into
hw-virtio, parameterized by MmioAccess trait.
New crate: hw-virtio (no_std, zero deps)
- mmio.rs: MmioAccess trait, DirectMmio, init_legacy_device(), scan
- queue.rs: VirtioQueue with descriptor chain submit + poll
- block.rs: block read protocol (3-descriptor chain)
- gpu.rs: GPU commands (create_2d, attach_backing, set_scanout,
transfer_to_host, resource_flush)
Adapter thin wrappers (identity-mapped, statics for DMA):
- virtio_blk.rs: 220 → 53 lines
- virtio_gpu.rs: 165 → 37 lines
Driver thin wrappers (mapped VAs, phys-info for DMA):
- drivers/block/virtio: 139 → 70 lines
- drivers/framebuffer/virtio: 146 → 95 lines
Also deleted input-server/input_device.rs (1-line re-export,
superseded by port-input-device).
This commit is contained in:
7
Cargo.lock
generated
7
Cargo.lock
generated
@@ -12,6 +12,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"domain",
|
||||
"elf",
|
||||
"hw-virtio",
|
||||
"kernel",
|
||||
"platform",
|
||||
"types",
|
||||
@@ -81,6 +82,7 @@ dependencies = [
|
||||
name = "driver-block-virtio"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hw-virtio",
|
||||
"port-block-device",
|
||||
]
|
||||
|
||||
@@ -95,6 +97,7 @@ dependencies = [
|
||||
name = "driver-framebuffer-virtio"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hw-virtio",
|
||||
"port-framebuffer",
|
||||
]
|
||||
|
||||
@@ -125,6 +128,10 @@ dependencies = [
|
||||
"userspace-rt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hw-virtio"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "init"
|
||||
version = "0.1.0"
|
||||
|
||||
Reference in New Issue
Block a user