Skip to content
Open
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
372 changes: 257 additions & 115 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api/axfeat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ driver-ramdisk = ["axdriver/ramdisk"]
driver-sdmmc = ["axdriver/sdmmc"]
driver-ixgbe = ["axdriver/ixgbe"]
driver-fxmac = ["axdriver/fxmac"] # fxmac ethernet driver for PhytiumPi
driver-dwmac = ["axdriver/dwmac"] # dwmac ethernet driver for StarFive VisionFive 2
driver-bcm2835-sdhci = ["axdriver/bcm2835-sdhci"]

# Logging
Expand Down
22 changes: 13 additions & 9 deletions modules/axdriver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dyn = []
bus-mmio = []
bus-pci = ["dep:axdriver_pci", "dep:axhal", "dep:axconfig"]
block = ["axdriver_block"]
gpt = ["dep:gpt_disk_io"]
display = ["axdriver_display"]
input = ["axdriver_input"]
net = ["axdriver_net"]
Expand All @@ -33,9 +34,10 @@ virtio-net = ["net", "virtio", "axdriver_virtio/net"]
virtio-socket = ["vsock", "virtio", "axdriver_virtio/socket"]
bcm2835-sdhci = ["block", "axdriver_block/bcm2835-sdhci"]
ramdisk = ["block", "axdriver_block/ramdisk", "dep:axhal", "dep:axconfig"]
sdmmc = ["block", "axdriver_block/sdmmc", "dep:axhal", "dep:axconfig"]
sdmmc = ["block", "gpt", "axdriver_block/sdmmc", "dep:axhal", "dep:axconfig"]
ixgbe = ["net", "axdriver_net/ixgbe", "dep:axalloc", "dep:axhal", "dep:axdma"]
fxmac = ["net", "axdriver_net/fxmac", "dep:axalloc", "dep:axhal", "dep:axdma"]
dwmac = ["net", "axdriver_net/dwmac", "dep:axalloc", "dep:axhal", "dep:jh7110-vf2-13b-pac"]
# more devices example: e1000 = ["net", "axdriver_net/e1000"]

[dependencies]
Expand All @@ -44,16 +46,18 @@ axconfig = { workspace = true, optional = true }
axdma = { workspace = true, optional = true }
axhal = { workspace = true, optional = true }

axdriver_base = { version = "0.1", git = "https://github.com/arceos-org/axdriver_crates.git", tag = "dev-v01" }
axdriver_block = { version = "0.1", git = "https://github.com/arceos-org/axdriver_crates.git", tag = "dev-v01", optional = true }
axdriver_display = { version = "0.1", git = "https://github.com/arceos-org/axdriver_crates.git", tag = "dev-v01", optional = true }
axdriver_input = { version = "0.1", git = "https://github.com/arceos-org/axdriver_crates.git", tag = "dev-v01", optional = true }
axdriver_net = { version = "0.1", git = "https://github.com/arceos-org/axdriver_crates.git", tag = "dev-v01", optional = true }
axdriver_pci = { version = "0.1", git = "https://github.com/arceos-org/axdriver_crates.git", tag = "dev-v01", optional = true }
axdriver_vsock = { version = "0.1", git = "https://github.com/arceos-org/axdriver_crates.git", tag = "dev-v01", optional = true }
axdriver_virtio = { version = "0.1", git = "https://github.com/arceos-org/axdriver_crates.git", tag = "dev-v01", optional = true }
axdriver_base = { version = "0.1", git = "https://github.com/elliott10/axdriver_crates.git", branch = "tag-dev-v01" }
axdriver_block = { version = "0.1", git = "https://github.com/elliott10/axdriver_crates.git", branch = "tag-dev-v01", optional = true }
axdriver_display = { version = "0.1", git = "https://github.com/elliott10/axdriver_crates.git", branch = "tag-dev-v01", optional = true }
axdriver_input = { version = "0.1", git = "https://github.com/elliott10/axdriver_crates.git", branch = "tag-dev-v01", optional = true }
axdriver_net = { version = "0.1", git = "https://github.com/elliott10/axdriver_crates.git", branch = "tag-dev-v01", optional = true }
axdriver_pci = { version = "0.1", git = "https://github.com/elliott10/axdriver_crates.git", branch = "tag-dev-v01", optional = true }
axdriver_vsock = { version = "0.1", git = "https://github.com/elliott10/axdriver_crates.git", branch = "tag-dev-v01", optional = true }
axdriver_virtio = { version = "0.1", git = "https://github.com/elliott10/axdriver_crates.git", branch = "tag-dev-v01", optional = true }

gpt_disk_io = { version = "0.16.2", optional = true }
cfg-if = { workspace = true }
crate_interface = { workspace = true }
log = { workspace = true }
smallvec = { version = "1.15.1", features = ["const_generics", "union"] }
jh7110-vf2-13b-pac = { version = "0.2.0", optional = true }
2 changes: 1 addition & 1 deletion modules/axdriver/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const NET_DEV_FEATURES: &[&str] = &["fxmac", "ixgbe", "virtio-net"];
const NET_DEV_FEATURES: &[&str] = &["dwmac", "fxmac", "ixgbe", "virtio-net"];
const BLOCK_DEV_FEATURES: &[&str] = &["ramdisk", "bcm2835-sdhci", "sdmmc", "virtio-blk"];
const DISPLAY_DEV_FEATURES: &[&str] = &["virtio-gpu"];
const INPUT_DEV_FEATURES: &[&str] = &["virtio-input"];
Expand Down
24 changes: 24 additions & 0 deletions modules/axdriver/src/bus/mmio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,29 @@ impl AllDevices {
}
});
}

// Probe regular MMIO devices
#[cfg(feature = "dwmac")]
for reg in axconfig::devices::MMIO_RANGES {
if reg.0 != axconfig::devices::ETHERNET0_PADDR
&& reg.0 != axconfig::devices::ETHERNET1_PADDR
{
continue;
}
debug!("Probing MMIO device @ {:#x}", reg.0);

for_each_drivers!(type Driver, {
if let Some(dev) = Driver::probe_mmio(reg.0, reg.1) {
info!(
"registered a new {:?} device at [PA:{:#x}, PA:{:#x}): {:?}",
dev.device_type(),
reg.0, reg.0 + reg.1,
dev.device_name(),
);
self.add_device(dev);
continue; // skip to the next device
}
});
}
}
}
51 changes: 46 additions & 5 deletions modules/axdriver/src/drivers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,22 @@ cfg_if::cfg_if! {
cfg_if::cfg_if! {
if #[cfg(block_dev = "sdmmc")] {
use axhal::mem::phys_to_virt;
use axdriver_block::sdmmc::SdMmcDriver;
use super::gpt::GptPartitionDev;

pub struct SdMmcDriver;
register_block_driver!(SdMmcDriver, axdriver_block::sdmmc::SdMmcDriver);
pub struct SdMmcBlock;
register_block_driver!(SdMmcBlock, GptPartitionDev<SdMmcDriver>);

impl DriverProbe for SdMmcDriver {
impl DriverProbe for SdMmcBlock {
fn probe_global() -> Option<AxDeviceEnum> {
let root = axconfig::devices::ROOT_PARTITION_NAME.parse().unwrap();
info!("Probe SD MMC ROOT Part: {:?} @ {:#x}", root, axconfig::devices::SDMMC_PADDR);
let sdmmc = unsafe {
axdriver_block::sdmmc::SdMmcDriver::new(
SdMmcDriver::new(
phys_to_virt(axconfig::devices::SDMMC_PADDR.into()).into(),
)
};
Some(AxDeviceEnum::from_block(sdmmc))
GptPartitionDev::new(sdmmc, |part| part.name == root).ok().map(AxDeviceEnum::from_block)
}
}
}
Expand Down Expand Up @@ -208,3 +212,40 @@ cfg_if::cfg_if! {
}
}
}

cfg_if::cfg_if! {
if #[cfg(net_dev = "dwmac")] {
use crate::dwmac::DwmacHalImpl;
use core::ptr::NonNull;

pub struct DwmacDriver;
register_net_driver!(DwmacDriver, axdriver_net::dwmac::DwmacNic<DwmacHalImpl>);

impl DriverProbe for DwmacDriver {
#[cfg(bus = "mmio")]
fn probe_mmio(mmio_base: usize, mmio_size: usize) -> Option<AxDeviceEnum> {
// Try both GMAC0 and GMAC1 for tutorial
if mmio_base == axconfig::devices::ETHERNET1_PADDR {
let gmac_name = "GMAC1";
info!("DWMAC tutorial device found at {:#x} ({})", mmio_base, gmac_name);

let base_ptr = unsafe { core::ptr::NonNull::new_unchecked(axhal::mem::phys_to_virt(mmio_base.into()).as_mut_ptr()) };

// Initialize the DWMAC device (clock verification is now informational only)
match axdriver_net::dwmac::DwmacNic::<DwmacHalImpl>::init(base_ptr, mmio_size) {
Ok(device) => {
info!("✅ DWMAC tutorial device ({}) initialized successfully!", gmac_name);
Some(AxDeviceEnum::Net(device))
}
Err(e) => {
error!("❌ DWMAC tutorial device ({}) initialization failed: {}", gmac_name, e);
None
}
}
} else {
None
}
}
}
}
}
Loading