Skip to content

Commit

Permalink
Merge pull request #1269 from hermit-os/rename-virtio
Browse files Browse the repository at this point in the history
refactor: rename `virtio-spec` dependency to `virtio`
  • Loading branch information
mkroening authored Jun 10, 2024
2 parents b71107d + 0fb3491 commit 57f7cd4
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 127 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ idle-poll = []

[dependencies]
hermit-macro = { path = "hermit-macro" }
virtio-spec = { path = "virtio-spec", features = ["zerocopy"] }
virtio = { package = "virtio-spec", path = "virtio-spec", features = ["zerocopy"] }
ahash = { version = "0.8", default-features = false }
align-address = "0.3"
anstyle = { version = "1", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions src/arch/riscv64/kernel/devicetree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::ptr::NonNull;

use fdt::Fdt;
#[cfg(all(feature = "tcp", not(feature = "pci")))]
use virtio_spec::mmio::{DeviceRegisterVolatileFieldAccess, DeviceRegisters};
use virtio::mmio::{DeviceRegisterVolatileFieldAccess, DeviceRegisters};
#[cfg(all(feature = "tcp", not(feature = "pci")))]
use volatile::VolatileRef;

Expand Down Expand Up @@ -209,7 +209,7 @@ pub fn init_drivers() {
// Verify the device-ID to find the network card
let id = mmio.as_ptr().device_id().read();

if id != virtio_spec::Id::Net {
if id != virtio::Id::Net {
debug!("It's not a network card at {mmio:p}");
} else {
info!("Found network card at {mmio:p}");
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86_64/kernel/mmio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::{ptr, str};

use align_address::Align;
use hermit_sync::{without_interrupts, InterruptTicketMutex};
use virtio_spec::mmio::{DeviceRegisterVolatileFieldAccess, DeviceRegisters};
use virtio::mmio::{DeviceRegisterVolatileFieldAccess, DeviceRegisters};
use volatile::VolatileRef;

use crate::arch::x86_64::mm::paging::{
Expand Down Expand Up @@ -62,7 +62,7 @@ unsafe fn check_ptr(ptr: *mut u8) -> Option<VolatileRef<'static, DeviceRegisters
// Verify the device-ID to find the network card
let id = mmio.as_ptr().device_id().read();

if id != virtio_spec::Id::Net {
if id != virtio::Id::Net {
trace!("It's not a network card at {mmio:p}");
return None;
}
Expand Down
17 changes: 7 additions & 10 deletions src/drivers/fs/virtio_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloc::string::{String, ToString};
use alloc::vec::Vec;

use pci_types::InterruptLine;
use virtio_spec::FeatureBits;
use virtio::FeatureBits;

use crate::config::VIRTIO_MAX_QUEUE_SIZE;
#[cfg(feature = "pci")]
Expand All @@ -25,7 +25,7 @@ use crate::fs::fuse::{self, FuseInterface};
pub(crate) struct FsDevCfg {
pub raw: &'static FsDevCfgRaw,
pub dev_id: u16,
pub features: virtio_spec::fs::F,
pub features: virtio::fs::F,
}

/// Virtio file system driver struct.
Expand Down Expand Up @@ -56,11 +56,8 @@ impl VirtioFsDriver {

/// Negotiates a subset of features, understood and wanted by both the OS
/// and the device.
fn negotiate_features(
&mut self,
driver_features: virtio_spec::fs::F,
) -> Result<(), VirtioFsError> {
let device_features = virtio_spec::fs::F::from(self.com_cfg.dev_features());
fn negotiate_features(&mut self, driver_features: virtio::fs::F) -> Result<(), VirtioFsError> {
let device_features = virtio::fs::F::from(self.com_cfg.dev_features());

if device_features.requirements_satisfied() {
debug!("Feature set wanted by filesystem driver are in conformance with specification.")
Expand Down Expand Up @@ -95,7 +92,7 @@ impl VirtioFsDriver {
// Indicate device, that driver is able to handle it
self.com_cfg.set_drv();

let features = virtio_spec::fs::F::VERSION_1;
let features = virtio::fs::F::VERSION_1;
self.negotiate_features(features)?;

// Indicates the device, that the current feature set is final for the driver
Expand Down Expand Up @@ -183,10 +180,10 @@ pub mod error {
FailFeatureNeg(u16),
/// The first field contains the feature bits wanted by the driver.
/// but which are incompatible with the device feature set, second field.
IncompatibleFeatureSets(virtio_spec::fs::F, virtio_spec::fs::F),
IncompatibleFeatureSets(virtio::fs::F, virtio::fs::F),
/// Set of features does not adhere to the requirements of features
/// indicated by the specification
FeatureRequirementsNotMet(virtio_spec::fs::F),
FeatureRequirementsNotMet(virtio::fs::F),
Unknown,
}
}
2 changes: 1 addition & 1 deletion src/drivers/fs/virtio_pci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl VirtioFsDriver {
Some(FsDevCfg {
raw: dev_cfg,
dev_id: cap.dev_id(),
features: virtio_spec::fs::F::empty(),
features: virtio::fs::F::empty(),
})
}

Expand Down
10 changes: 5 additions & 5 deletions src/drivers/net/virtio/mmio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use alloc::vec::Vec;
use core::str::FromStr;

use smoltcp::phy::ChecksumCapabilities;
use virtio_spec::mmio::{DeviceRegisterVolatileFieldAccess, DeviceRegisters};
use virtio::mmio::{DeviceRegisterVolatileFieldAccess, DeviceRegisters};
use volatile::VolatileRef;

use crate::drivers::net::virtio::{CtrlQueue, NetDevCfg, RxQueues, TxQueues, VirtioNetDriver};
Expand All @@ -22,20 +22,20 @@ impl VirtioNetDriver {
mut registers: VolatileRef<'static, DeviceRegisters>,
irq: u8,
) -> Result<Self, VirtioNetError> {
let dev_cfg_raw: &'static virtio_spec::net::Config = unsafe {
let dev_cfg_raw: &'static virtio::net::Config = unsafe {
&*registers
.borrow_mut()
.as_mut_ptr()
.config()
.as_raw_ptr()
.cast::<virtio_spec::net::Config>()
.cast::<virtio::net::Config>()
.as_ptr()
};
let dev_cfg_raw = VolatileRef::from_ref(dev_cfg_raw);
let dev_cfg = NetDevCfg {
raw: dev_cfg_raw,
dev_id,
features: virtio_spec::net::F::empty(),
features: virtio::net::F::empty(),
};
let isr_stat = IsrStatus::new(registers.borrow_mut());
let notif_cfg = NotifCfg::new(registers.borrow_mut());
Expand Down Expand Up @@ -64,7 +64,7 @@ impl VirtioNetDriver {

pub fn print_information(&mut self) {
self.com_cfg.print_information();
if self.dev_status() == virtio_spec::net::S::LINK_UP {
if self.dev_status() == virtio::net::S::LINK_UP {
info!("The link of the network device is up!");
}
}
Expand Down
Loading

0 comments on commit 57f7cd4

Please sign in to comment.