mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-29 16:13:27 +00:00
Refactor drivers
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
d809eca81d
commit
edd808bd3d
@ -95,7 +95,7 @@ impl BlockDevice {
|
||||
.unwrap();
|
||||
|
||||
fn handle_block_device(_: &TrapFrame) {
|
||||
jinux_block::get_device(&(super::DEVICE_NAME.to_string()))
|
||||
jinux_block::get_device(super::DEVICE_NAME)
|
||||
.unwrap()
|
||||
.handle_irq();
|
||||
}
|
||||
|
@ -112,14 +112,14 @@ impl ConsoleDevice {
|
||||
callbacks: SpinLock::new(Vec::new()),
|
||||
};
|
||||
|
||||
let mut recv_lock = device.receive_queue.lock();
|
||||
recv_lock
|
||||
let mut receive_queue = device.receive_queue.lock();
|
||||
receive_queue
|
||||
.add(&[], &[device.buffer.lock().as_mut()])
|
||||
.unwrap();
|
||||
if recv_lock.should_notify() {
|
||||
recv_lock.notify();
|
||||
if receive_queue.should_notify() {
|
||||
receive_queue.notify();
|
||||
}
|
||||
drop(recv_lock);
|
||||
drop(receive_queue);
|
||||
device
|
||||
.transport
|
||||
.register_queue_callback(RECV0_QUEUE_INDEX, Box::new(handle_console_input), false)
|
||||
@ -137,9 +137,7 @@ impl ConsoleDevice {
|
||||
}
|
||||
|
||||
fn handle_console_input(_: &TrapFrame) {
|
||||
jinux_console::get_device(&DEVICE_NAME.to_string())
|
||||
.unwrap()
|
||||
.handle_irq();
|
||||
jinux_console::get_device(DEVICE_NAME).unwrap().handle_irq();
|
||||
}
|
||||
|
||||
fn config_space_change(_: &TrapFrame) {
|
||||
|
@ -111,7 +111,7 @@ impl InputDevice {
|
||||
|
||||
fn handle_input(_: &TrapFrame) {
|
||||
debug!("Handle Virtio input interrupt");
|
||||
let device = jinux_input::get_device(&(super::DEVICE_NAME.to_string())).unwrap();
|
||||
let device = jinux_input::get_device(super::DEVICE_NAME).unwrap();
|
||||
device.handle_irq().unwrap();
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ use alloc::{boxed::Box, string::ToString, sync::Arc, vec::Vec};
|
||||
use jinux_frame::{offset_of, sync::SpinLock, trap::TrapFrame};
|
||||
use jinux_network::{
|
||||
buffer::{RxBuffer, TxBuffer},
|
||||
EthernetAddr, NetDeviceIrqHandler, VirtioNetError,
|
||||
AnyNetworkDevice, EthernetAddr, NetDeviceIrqHandler, VirtioNetError,
|
||||
};
|
||||
use jinux_util::{field_ptr, slot_vec::SlotVec};
|
||||
use log::debug;
|
||||
@ -86,7 +86,7 @@ impl NetworkDevice {
|
||||
|
||||
/// Interrupt handler if network device receives some packet
|
||||
fn handle_network_event(_: &TrapFrame) {
|
||||
jinux_network::handle_recv_irq(&(super::DEVICE_NAME.to_string()));
|
||||
jinux_network::handle_recv_irq(super::DEVICE_NAME);
|
||||
}
|
||||
|
||||
device
|
||||
@ -169,7 +169,7 @@ fn queue_to_network_error(err: QueueError) -> VirtioNetError {
|
||||
}
|
||||
}
|
||||
|
||||
impl jinux_network::NetworkDevice for NetworkDevice {
|
||||
impl AnyNetworkDevice for NetworkDevice {
|
||||
fn mac_addr(&self) -> EthernetAddr {
|
||||
self.mac_addr
|
||||
}
|
||||
|
Reference in New Issue
Block a user