mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 07:06:47 +00:00
* 测试RESET * 测试RESET * 基于轮询的实现 * 规范化部分unsafe的使用 * 完成中断处理函数,同时去除了不必要的内存拷贝行为,准备编写napi机制 * 实现现有协议栈下的部分napi机制;修复了内存泄漏的问题;添加了一部分代码注释 * 去除部分无用代码 * 去除一些无用代码 * 适配新的驱动模型 * 完成msi中断测试 * 去除一些无用代码 * 格式化代码 * 增加了一些注释,提高代码可读性 * 去除无关文件 * 优化了读取mac地址的方式,提高可读性
32 lines
800 B
Rust
32 lines
800 B
Rust
use alloc::string::String;
|
|
use smoltcp::{
|
|
iface,
|
|
wire::{self, EthernetAddress},
|
|
};
|
|
|
|
use crate::{libs::spinlock::SpinLock, syscall::SystemError};
|
|
|
|
use super::base::device::driver::Driver;
|
|
|
|
mod dma;
|
|
pub mod e1000e;
|
|
pub mod virtio_net;
|
|
|
|
pub trait NetDriver: Driver {
|
|
/// @brief 获取网卡的MAC地址
|
|
fn mac(&self) -> EthernetAddress;
|
|
|
|
fn name(&self) -> String;
|
|
|
|
/// @brief 获取网卡的id
|
|
fn nic_id(&self) -> usize;
|
|
|
|
fn poll(&self, sockets: &mut iface::SocketSet) -> Result<(), SystemError>;
|
|
|
|
fn update_ip_addrs(&self, ip_addrs: &[wire::IpCidr]) -> Result<(), SystemError>;
|
|
|
|
/// @brief 获取smoltcp的网卡接口类型
|
|
fn inner_iface(&self) -> &SpinLock<smoltcp::iface::Interface>;
|
|
// fn as_any_ref(&'static self) -> &'static dyn core::any::Any;
|
|
}
|