Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/arch/aarch64/kernel/mmio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ pub fn init_drivers() {
continue;
};

for i in compatible.all() {
if i == "virtio,mmio" {
for compatible in compatible.all() {
if compatible == "virtio,mmio" {
let virtio_region = node
.reg()
.expect("reg property for virtio mmio not found in FDT")
Expand Down
32 changes: 16 additions & 16 deletions src/drivers/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use volatile::access::ReadOnly;
use crate::config::VIRTIO_MAX_QUEUE_SIZE;
use crate::drivers::Driver;
use crate::drivers::virtio::ControlRegisters;
use crate::drivers::virtio::error::VirtioFsError;
use crate::drivers::virtio::error::VirtioFsInitError;
#[cfg(not(feature = "pci"))]
use crate::drivers::virtio::transport::mmio::{ComCfg, IsrStatus, NotifCfg};
#[cfg(feature = "pci")]
Expand All @@ -42,7 +42,7 @@ use crate::drivers::virtio::virtqueue::{
AvailBufferToken, BufferElem, BufferType, VirtQueue, Virtq,
};
use crate::errno::Errno;
use crate::fs::fuse::{self, FuseError, FuseInterface, Rsp, RspHeader};
use crate::fs::virtio_fs::{self, Rsp, RspHeader, VirtioFsError, VirtioFsInterface};
use crate::mm::device_alloc::DeviceAlloc;

/// A wrapper struct for the raw configuration structure.
Expand Down Expand Up @@ -85,7 +85,7 @@ impl VirtioFsDriver {
///
/// See Virtio specification v1.1. - 3.1.1.
/// and v1.1. - 5.11.5
pub(crate) fn init_dev(&mut self) -> Result<(), VirtioFsError> {
pub(crate) fn init_dev(&mut self) -> Result<(), VirtioFsInitError> {
// Reset
self.com_cfg.reset_dev();

Expand All @@ -103,7 +103,7 @@ impl VirtioFsDriver {

if !negotiated_features.contains(minimal_features) {
error!("Device features set, does not satisfy minimal features needed. Aborting!");
return Err(VirtioFsError::FailFeatureNeg(self.dev_cfg.dev_id));
return Err(VirtioFsInitError::FailFeatureNeg(self.dev_cfg.dev_id));
}

// Indicates the device, that the current feature set is final for the driver
Expand All @@ -120,7 +120,7 @@ impl VirtioFsDriver {
self.dev_cfg.features = negotiated_features;
} else {
error!("The device does not support our subset of features.");
return Err(VirtioFsError::FailFeatureNeg(self.dev_cfg.dev_id));
return Err(VirtioFsInitError::FailFeatureNeg(self.dev_cfg.dev_id));
}

// 1 highprio queue, and n normal request queues
Expand All @@ -133,7 +133,7 @@ impl VirtioFsDriver {
.to_ne() + 1;
if vqnum == 0 {
error!("0 request queues requested from device. Aborting!");
return Err(VirtioFsError::Unknown);
return Err(VirtioFsInitError::Unknown);
}

// create the queues and tell device about them
Expand Down Expand Up @@ -174,17 +174,17 @@ impl VirtioFsDriver {
}
}

impl FuseInterface for VirtioFsDriver {
fn send_command<O: fuse::ops::Op + 'static>(
impl VirtioFsInterface for VirtioFsDriver {
fn send_command<O: virtio_fs::ops::Op + 'static>(
&mut self,
cmd: fuse::Cmd<O>,
cmd: virtio_fs::Cmd<O>,
rsp_payload_len: u32,
) -> Result<fuse::Rsp<O>, FuseError>
) -> Result<virtio_fs::Rsp<O>, VirtioFsError>
where
<O as fuse::ops::Op>::InStruct: Send,
<O as fuse::ops::Op>::OutStruct: Send,
<O as virtio_fs::ops::Op>::InStruct: Send,
<O as virtio_fs::ops::Op>::OutStruct: Send,
{
let fuse::Cmd {
let virtio_fs::Cmd {
headers: cmd_headers,
payload: cmd_payload_opt,
} = cmd;
Expand Down Expand Up @@ -236,9 +236,9 @@ impl FuseInterface for VirtioFsDriver {
|| (written_header_len - size_of::<fuse_out_header>()) != size_of::<O::OutStruct>()
{
// "However, if the reply is an error reply (i.e., error is set), then no further payload data should be sent,
// independent of the request." (fuse man page)
// independent of the request." (FUSE man page)

return Err(FuseError::IOError(
return Err(VirtioFsError::IOError(
Errno::try_from_primitive(-headers.out_header.error).unwrap_or(Errno::Io),
));
}
Expand Down Expand Up @@ -277,7 +277,7 @@ pub mod error {

/// Network filesystem error enum.
#[derive(Error, Debug, Copy, Clone)]
pub enum VirtioFsError {
pub enum VirtioFsInitError {
#[cfg(feature = "pci")]
#[error(
"Virtio filesystem driver failed, for device {0:x}, due to a missing or malformed device config!"
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/fs/pci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl VirtioFsDriver {
pub fn new(
caps_coll: UniCapsColl,
device: &PciDevice<PciConfigRegion>,
) -> Result<Self, error::VirtioFsError> {
) -> Result<Self, error::VirtioFsInitError> {
let device_id = device.device_id();

let UniCapsColl {
Expand All @@ -40,7 +40,7 @@ impl VirtioFsDriver {

let Some(dev_cfg) = dev_cfg_list.iter().find_map(VirtioFsDriver::map_cfg) else {
error!("No dev config. Aborting!");
return Err(error::VirtioFsError::NoDevCfg(device_id));
return Err(error::VirtioFsInitError::NoDevCfg(device_id));
};

Ok(VirtioFsDriver {
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/virtio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub mod error {
#[cfg(feature = "virtio-console")]
pub use crate::drivers::console::error::VirtioConsoleError;
#[cfg(feature = "virtio-fs")]
pub use crate::drivers::fs::error::VirtioFsError;
pub use crate::drivers::fs::error::VirtioFsInitError;
#[cfg(all(
not(all(target_arch = "riscv64", feature = "gem-net", not(feature = "pci"))),
not(feature = "rtl8139"),
Expand Down Expand Up @@ -217,7 +217,7 @@ pub mod error {

#[cfg(feature = "virtio-fs")]
#[error(transparent)]
FsDriver(VirtioFsError),
FsDriver(VirtioFsInitError),

#[cfg(feature = "virtio-vsock")]
#[error(transparent)]
Expand Down
10 changes: 5 additions & 5 deletions src/fd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,19 +374,19 @@ async fn poll_fds(fds: &mut [PollFd]) -> io::Result<u64> {
future::poll_fn(|cx| {
let mut counter: u64 = 0;

for i in &mut *fds {
let fd = i.fd;
i.revents = PollEvent::empty();
for poll_fd in &mut *fds {
let fd = poll_fd.fd;
poll_fd.revents = PollEvent::empty();
let Ok(obj) = core_scheduler().get_object(fd) else {
continue;
};

let mut pinned = pin!(async { obj.read().await.poll(i.events).await });
let mut pinned = pin!(async { obj.read().await.poll(poll_fd.events).await });
if let Ready(Ok(e)) = pinned.as_mut().poll(cx)
&& !e.is_empty()
{
counter += 1;
i.revents = e;
poll_fd.revents = e;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/fd/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ impl ObjectInterface for Socket {
let mut guard = NIC.lock();
let nic = guard.as_nic_mut().unwrap();

for i in self.handle.iter() {
let socket = nic.get_mut_socket::<tcp::Socket<'_>>(*i);
for handle in self.handle.iter().copied() {
let socket = nic.get_mut_socket::<tcp::Socket<'_>>(handle);
socket.set_nagle_enabled(optval);
}

Expand Down
Loading
Loading