Skip to content

Starry-OS/fxmac_rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FXMAC ethernet driver

fxmac ethernet driver in Rust on PhytiumPi board.

Quick Start

For instance, fxmac_rs ethernet driver in Rust on ArceOS

fxmac_rs on arceos

  • Initialize ethernet driver
pub struct FXmacDriver;

#[crate_interface::impl_interface]
impl axdriver_net::fxmac::KernelFunc for FXmacDriver{
	/// 虚拟地址转换成物理地址
	fn virt_to_phys(addr: usize) -> usize {
	}

	/// 物理地址转换成虚拟地址
	fn phys_to_virt(addr: usize) -> usize {
	}

	/// 申请页对齐的DMA连续内存页
	/// 返回((cpu virtual address, dma physical address))
	fn dma_alloc_coherent(pages: usize) -> (usize, usize) {
	}

	/// 释放DMA内存页
	fn dma_free_coherent(vaddr: usize, pages: usize) {
	}

	/// 使能并注册网卡中断
	fn dma_request_irq(_irq: usize, _handler: fn()) {
		warn!("unimplemented dma_request_irq for fxmax");
	}
}

let hwaddr: [u8; 6] = [0x55, 0x44, 0x33, 0x22, 0x11, 0x00];
let fxmac_device: &'static mut FXmac = fxmac_rs::fxmac::xmac_init(&hwaddr);
  • Sending network packets
let mut tx_vec = Vec::new();
tx_vec.push(packet.to_vec());
FXmacLwipPortTx(fxmac_device, tx_vec);
  • Receiving network packets
let recv_packets = FXmacRecvHandler(fxmac_device);

Build

cargo build --target=aarch64-unknown-none-softfloat

Testing (建议)

由于该驱动强依赖硬件与 DMA,建议分层补充测试并按能力选择运行环境:

  • 单元测试/文档测试(主机可跑):cargo test --all-featurescargo test --doc
  • 功能测试(mock/模拟):对 BD ring、地址转换与错误分支做行为验证
  • 系统测试(真实板子):在 PhytiumPi 上验证链路协商、收发路径与中断处理

About ethernet

PHY: Motorcomm YT8521

yt8521

Reference

About

fxmac ethernet Rust driver on PhytiumPi board.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 100.0%