Fix #[allow(dead_code)] in virtio

This commit is contained in:
Ruihan Li 2025-01-24 17:38:05 +08:00 committed by Tate, Hongliang Tian
parent b415538097
commit 1c4e88e648
9 changed files with 9 additions and 24 deletions

View File

@ -63,6 +63,7 @@ impl ConfigManager<VirtioConsoleConfig> {
/// If `VIRTIO_CONSOLE_F_EMERG_WRITE` is supported then the driver can /// If `VIRTIO_CONSOLE_F_EMERG_WRITE` is supported then the driver can
/// use emergency write to output a single character without initializing /// use emergency write to output a single character without initializing
/// virtio queues, or even acknowledging the feature. /// virtio queues, or even acknowledging the feature.
#[expect(dead_code)]
pub(super) fn emerg_write(&self, value: u32) { pub(super) fn emerg_write(&self, value: u32) {
if self.is_modern() { if self.is_modern() {
self.write_once(offset_of!(VirtioConsoleConfig, emerg_wr), value) self.write_once(offset_of!(VirtioConsoleConfig, emerg_wr), value)

View File

@ -84,6 +84,7 @@ impl VirtioInputConfig {
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone, Pod)] #[derive(Debug, Copy, Clone, Pod)]
#[expect(dead_code)]
struct AbsInfo { struct AbsInfo {
min: u32, min: u32,
max: u32, max: u32,
@ -94,6 +95,7 @@ struct AbsInfo {
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone, Pod)] #[derive(Debug, Copy, Clone, Pod)]
#[expect(dead_code)]
struct DevIds { struct DevIds {
bustype: u16, bustype: u16,
vendor: u16, vendor: u16,

View File

@ -10,7 +10,6 @@ use ostd::{
use spin::Once; use spin::Once;
const RX_BUFFER_LEN: usize = 4096; const RX_BUFFER_LEN: usize = 4096;
const TX_BUFFER_LEN: usize = 4096;
pub static RX_BUFFER_POOL: Once<Arc<DmaPool>> = Once::new(); pub static RX_BUFFER_POOL: Once<Arc<DmaPool>> = Once::new();
pub static TX_BUFFER_POOL: Once<SpinLock<LinkedList<DmaStream>, LocalIrqDisabled>> = Once::new(); pub static TX_BUFFER_POOL: Once<SpinLock<LinkedList<DmaStream>, LocalIrqDisabled>> = Once::new();

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
use alloc::{boxed::Box, string::ToString, sync::Arc, vec, vec::Vec}; use alloc::{boxed::Box, string::ToString, sync::Arc, vec};
use core::{fmt::Debug, hint::spin_loop, mem::size_of}; use core::{fmt::Debug, hint::spin_loop, mem::size_of};
use aster_network::{RxBuffer, TxBuffer}; use aster_network::{RxBuffer, TxBuffer};
@ -13,7 +13,6 @@ use super::{
connect::{ConnectionInfo, VsockEvent}, connect::{ConnectionInfo, VsockEvent},
error::SocketError, error::SocketError,
header::{VirtioVsockHdr, VirtioVsockOp, VIRTIO_VSOCK_HDR_LEN}, header::{VirtioVsockHdr, VirtioVsockOp, VIRTIO_VSOCK_HDR_LEN},
VsockDeviceIrqHandler,
}; };
use crate::{ use crate::{
device::{ device::{
@ -44,7 +43,6 @@ pub struct SocketDevice {
rx_buffers: SlotVec<RxBuffer>, rx_buffers: SlotVec<RxBuffer>,
transport: Box<dyn VirtioTransport>, transport: Box<dyn VirtioTransport>,
callbacks: Vec<Box<dyn VsockDeviceIrqHandler>>,
} }
impl SocketDevice { impl SocketDevice {
@ -90,7 +88,6 @@ impl SocketDevice {
event_queue, event_queue,
rx_buffers, rx_buffers,
transport, transport,
callbacks: Vec::new(),
}; };
// Interrupt handler if vsock device config space changes // Interrupt handler if vsock device config space changes

View File

@ -3,7 +3,6 @@
//! The virtio of Asterinas. //! The virtio of Asterinas.
#![no_std] #![no_std]
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![allow(dead_code)]
#![feature(trait_alias)] #![feature(trait_alias)]
#![feature(fn_traits)] #![feature(fn_traits)]
#![feature(linked_list_cursors)] #![feature(linked_list_cursors)]

View File

@ -21,10 +21,6 @@ pub struct VirtioMmioDriver {
} }
impl VirtioMmioDriver { impl VirtioMmioDriver {
pub fn num_devices(&self) -> usize {
self.devices.lock().len()
}
pub fn pop_device_transport(&self) -> Option<VirtioMmioTransport> { pub fn pop_device_transport(&self) -> Option<VirtioMmioTransport> {
self.devices.lock().pop() self.devices.lock().pop()
} }

View File

@ -2,9 +2,10 @@
use alloc::sync::Arc; use alloc::sync::Arc;
use log::warn;
use ostd::bus::pci::{ use ostd::bus::pci::{
capability::vendor::CapabilityVndrData, capability::vendor::CapabilityVndrData,
cfg_space::{Bar, IoBar, MemoryBar}, cfg_space::{Bar, MemoryBar},
common_device::BarManager, common_device::BarManager,
}; };
@ -26,7 +27,6 @@ pub struct VirtioPciCapabilityData {
length: u32, length: u32,
option: Option<u32>, option: Option<u32>,
memory_bar: Option<Arc<MemoryBar>>, memory_bar: Option<Arc<MemoryBar>>,
io_bar: Option<Arc<IoBar>>,
} }
impl VirtioPciCapabilityData { impl VirtioPciCapabilityData {
@ -34,10 +34,6 @@ impl VirtioPciCapabilityData {
&self.memory_bar &self.memory_bar
} }
pub fn io_bar(&self) -> &Option<Arc<IoBar>> {
&self.io_bar
}
pub fn offset(&self) -> u32 { pub fn offset(&self) -> u32 {
self.offset self.offset
} }
@ -74,15 +70,14 @@ impl VirtioPciCapabilityData {
None None
}; };
let mut io_bar = None;
let mut memory_bar = None; let mut memory_bar = None;
if let Some(bar) = bar_manager.bar(bar) { if let Some(bar) = bar_manager.bar(bar) {
match bar { match bar {
Bar::Memory(memory) => { Bar::Memory(memory) => {
memory_bar = Some(memory); memory_bar = Some(memory);
} }
Bar::Io(io) => { Bar::Io(_) => {
io_bar = Some(io); warn!("`Bar::Io` is not supported")
} }
} }
}; };
@ -92,7 +87,6 @@ impl VirtioPciCapabilityData {
length, length,
option, option,
memory_bar, memory_bar,
io_bar,
} }
} }
} }

View File

@ -25,10 +25,6 @@ pub struct VirtioPciDriver {
} }
impl VirtioPciDriver { impl VirtioPciDriver {
pub fn num_devices(&self) -> usize {
self.devices.lock().len()
}
pub fn pop_device_transport(&self) -> Option<Box<dyn VirtioTransport>> { pub fn pop_device_transport(&self) -> Option<Box<dyn VirtioTransport>> {
self.devices.lock().pop() self.devices.lock().pop()
} }

View File

@ -53,6 +53,7 @@ const QUEUE_SIZE_OFFSET: usize = 0x0c;
const QUEUE_SELECT_OFFSET: usize = 0x0e; const QUEUE_SELECT_OFFSET: usize = 0x0e;
const QUEUE_NOTIFY_OFFSET: usize = 0x10; const QUEUE_NOTIFY_OFFSET: usize = 0x10;
const DEVICE_STATUS_OFFSET: usize = 0x12; const DEVICE_STATUS_OFFSET: usize = 0x12;
#[expect(dead_code)]
const ISR_STATUS_OFFSET: usize = 0x13; const ISR_STATUS_OFFSET: usize = 0x13;
// If MSI-X is enabled for the device, there are two additional fields. // If MSI-X is enabled for the device, there are two additional fields.
const CONFIG_MSIX_VECTOR_OFFSET: usize = 0x14; const CONFIG_MSIX_VECTOR_OFFSET: usize = 0x14;