Skip to content
Draft
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
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ axdriver_net = { git = "https://github.com/arceos-org/axdriver_crates.git", tag
axdriver_pci = { git = "https://github.com/arceos-org/axdriver_crates.git", tag = "dev-v01" }
axdriver_virtio = { git = "https://github.com/arceos-org/axdriver_crates.git", tag = "dev-v01" }
axdriver_vsock = { git = "https://github.com/arceos-org/axdriver_crates.git", tag = "dev-v01" }
axerrno = "0.1"
axio = "0.1"
axerrno = "0.2"
axfs-ng-vfs = "0.1"
axio = { git = "https://github.com/arceos-org/axio.git", tag = "dev-v02" }
axklib = { git = "https://github.com/arceos-hypervisor/axklib.git" } # FIXME: pin to a specific commit or tag
axplat = { git = "https://github.com/arceos-org/axplat_crates.git", tag = "dev-v03" }
axplat-aarch64-bsta1000b = { git = "https://github.com/arceos-org/axplat_crates.git", tag = "dev-v03" }
Expand All @@ -91,11 +92,13 @@ axplat-loongarch64-qemu-virt = { git = "https://github.com/arceos-org/axplat_cra
axplat-riscv64-qemu-virt = { git = "https://github.com/arceos-org/axplat_crates.git", tag = "dev-v03" }
axplat-x86-pc = { git = "https://github.com/arceos-org/axplat_crates.git", tag = "dev-v03" }
axpoll = "0.1"
axwatchdog = { git = "https://github.com/kylin-x-kernel/axwatchdog.git", branch = "lzx/dev"}
bindgen = "0.72"
cfg-if = "1.0"
chrono = { version = "0.4", default-features = false }
crate_interface = "0.1.4"
ctor_bare = "0.2"
enum_dispatch = "0.3"
event-listener = { version = "5.4.0", default-features = false }
kernel_guard = "0.1"
kspin = "0.1"
Expand All @@ -104,7 +107,9 @@ lazy_static = { version = "1.5", features = ["spin_no_std"] }
lock_api = { version = "0.4", default-features = false }
log = "0.4"
memory_addr = "0.4"
page_table_multiarch = "0.5"
page_table_multiarch = { git = "https://github.com/arceos-org/page_table_multiarch.git", tag = "dev-v05", features = [
"axerrno",
] }
percpu = "0.2"
scope-local = "0.1"
spin = "0.10"
2 changes: 0 additions & 2 deletions api/arceos_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ fs = ["dep:axfs", "dep:axdriver", "axfeat/fs"]
net = ["dep:axnet", "dep:axdriver", "axfeat/net"]
display = ["dep:axdisplay", "dep:axdriver", "axfeat/display"]

myfs = ["axfeat/myfs"]

# Use dummy functions if the feature is not enabled
dummy-if-not-enabled = []

Expand Down
10 changes: 7 additions & 3 deletions api/axfeat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ fs = [
"dep:axfs",
"axruntime/fs",
] # TODO: try to remove "paging"
myfs = ["axfs?/myfs"]
ext4fs = ["axfs?/ext4fs"]
fatfs = ["axfs?/fatfs"]
fs-ext4 = ["fs", "axfs/ext4"]
fs-fat = ["fs", "axfs/fat"]
fs-times = ["fs", "axfs/times"]

# Networking
net = ["alloc", "paging", "axdriver/virtio-net", "dep:axnet", "axruntime/net"]
Expand Down Expand Up @@ -98,12 +98,16 @@ driver-sdmmc = ["axdriver?/sdmmc"]
driver-ixgbe = ["axdriver?/ixgbe"]
driver-fxmac = ["axdriver?/fxmac"] # fxmac ethernet driver for PhytiumPi
driver-bcm2835-sdhci = ["axdriver?/bcm2835-sdhci"]
driver-ahci = ["axdriver?/ahci"]

driver-dyn = ["paging", "axruntime/driver-dyn", "axdriver/dyn"]

# Backtrace
dwarf = ["alloc", "axbacktrace/dwarf"]

# Lockup detect
watchdog = ["axruntime/watchdog", "axtask/watchdog"]

[dependencies]
axalloc = { workspace = true, optional = true }
axbacktrace.workspace = true
Expand Down
9 changes: 0 additions & 9 deletions examples/shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,7 @@ authors = ["Yuekai Jia <equation618@gmail.com>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
use-ramfs = [
"axstd/myfs",
"dep:axfs_vfs",
"dep:axfs_ramfs",
"dep:crate_interface",
]
default = []

[dependencies]
axfs_vfs = { version = "0.1", optional = true }
axfs_ramfs = { version = "0.1", optional = true }
crate_interface = { workspace = true, optional = true }
axstd = { workspace = true, features = ["alloc", "fs"], optional = true }
3 changes: 0 additions & 3 deletions examples/shell/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ fn path_to_str(path: &str) -> &str {

mod cmd;

#[cfg(feature = "use-ramfs")]
mod ramfs;

use std::io::prelude::*;

const LF: u8 = b'\n';
Expand Down
15 changes: 0 additions & 15 deletions examples/shell/src/ramfs.rs

This file was deleted.

1 change: 1 addition & 0 deletions modules/axdriver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ virtio-socket = ["vsock", "virtio", "axdriver_virtio/socket"]
ramdisk = ["block", "axdriver_block/ramdisk"]
bcm2835-sdhci = ["block", "axdriver_block/bcm2835-sdhci"]
sdmmc = ["block", "axdriver_block/sdmmc", "dep:axhal", "dep:axconfig"]
ahci = ["block", "axdriver_block/ahci", "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"]
# more devices example: e1000 = ["net", "axdriver_net/e1000"]
Expand Down
2 changes: 1 addition & 1 deletion modules/axdriver/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const NET_DEV_FEATURES: &[&str] = &["fxmac", "ixgbe", "virtio-net"];
const BLOCK_DEV_FEATURES: &[&str] = &["ramdisk", "sdmmc", "bcm2835-sdhci", "virtio-blk"];
const BLOCK_DEV_FEATURES: &[&str] = &["ahci", "ramdisk", "sdmmc", "bcm2835-sdhci", "virtio-blk"];
const DISPLAY_DEV_FEATURES: &[&str] = &["virtio-gpu"];
const INPUT_DEV_FEATURES: &[&str] = &["virtio-input"];
const VSOCK_DEV_FEATURES: &[&str] = &["virtio-socket"];
Expand Down
37 changes: 37 additions & 0 deletions modules/axdriver/src/drivers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,43 @@ cfg_if::cfg_if! {
}
}

cfg_if::cfg_if! {
if #[cfg(block_dev = "ahci")] {
pub struct AhciHalImpl;
impl axdriver_block::ahci::AhciHal for AhciHalImpl {
fn virt_to_phys(va: usize) -> usize {
axhal::mem::virt_to_phys(va.into()).as_usize()
}

fn current_ms() -> u64 {
axhal::time::monotonic_time_nanos() / 1_000_000
}

fn flush_dcache() {
#[cfg(target_arch = "loongarch64")]
unsafe {
// LoongArch64: Ensure data cache operations are synchronized for AHCI DMA coherency.
core::arch::asm!("dbar 0");
}
}
}

pub struct AhciDriver;
register_block_driver!(AhciDriver, axdriver_block::ahci::AhciDriver<AhciHalImpl>);

impl DriverProbe for AhciDriver {
fn probe_global() -> Option<AxDeviceEnum> {
let ahci = unsafe {
axdriver_block::ahci::AhciDriver::<AhciHalImpl>::try_new(
axhal::mem::phys_to_virt(axconfig::devices::AHCI_PADDR.into()).into(),
)?
};
Some(AxDeviceEnum::from_block(ahci))
}
}
}
}

cfg_if::cfg_if! {
if #[cfg(block_dev = "bcm2835-sdhci")]{
pub struct BcmSdhciDriver;
Expand Down
5 changes: 5 additions & 0 deletions modules/axdriver/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ macro_rules! for_each_drivers {
type $drv_type = crate::drivers::SdMmcDriver;
$code
}
#[cfg(block_dev = "ahci")]
{
type $drv_type = crate::drivers::AhciDriver;
$code
}
#[cfg(block_dev = "bcm2835-sdhci")]
{
type $drv_type = crate::drivers::BcmSdhciDriver;
Expand Down
74 changes: 33 additions & 41 deletions modules/axfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,52 @@
name = "axfs"
version.workspace = true
edition.workspace = true
authors = ["Yuekai Jia <equation618@gmail.com>"]
authors = ["Mivik <mivikq@gmail.com>"]
description = "ArceOS filesystem module"
license.workspace = true
homepage.workspace = true
repository = "https://github.com/arceos-org/arceos/tree/main/modules/axfs"
documentation = "https://arceos-org.github.io/arceos/axfs/index.html"

[features]
devfs = ["dep:axfs_devfs"]
ramfs = ["dep:axfs_ramfs"]
procfs = ["dep:axfs_ramfs"]
sysfs = ["dep:axfs_ramfs"]
ext4fs = ["dep:lwext4_rust"]
fatfs = ["dep:fatfs"]
myfs = ["dep:crate_interface"]
use-ramdisk = []

default = ["devfs", "ramfs", "fatfs", "procfs", "sysfs"]
default = []
use-ramdisk = [] # TODO: init ramdisk
fat = ["dep:fatfs"]
ext4 = ["dep:lwext4_rust"]
times = []
std = ["lwext4_rust?/std"]

[dependencies]
axalloc = { workspace = true }
axdriver = { workspace = true, features = ["block"] }
axdriver_block.workspace = true
axerrno.workspace = true
axfs_devfs = { version = "0.1", optional = true }
axfs_ramfs = { version = "0.1", optional = true }
axfs_vfs = "0.1"
axerrno = { workspace = true }
axfs-ng-vfs = { workspace = true }
axhal = { workspace = true }
axio = { workspace = true, features = ["alloc"] }
axsync.workspace = true
cap_access = "0.1"
cfg-if.workspace = true
crate_interface = { workspace = true, optional = true }
lazyinit.workspace = true
log.workspace = true
scope-local.workspace = true
axpoll = { workspace = true }
axsync = { workspace = true }
bitflags = "2.10"
cfg-if = { workspace = true }
chrono = { workspace = true }
intrusive-collections = "0.9.7"
kspin = { workspace = true }
log = { workspace = true }
lru = "0.16.0"
scope-local = { workspace = true }
slab = { version = "0.4.9", default-features = false }
spin = { workspace = true }

[dependencies.fatfs]
git = "https://github.com/rafalh/rust-fatfs"
rev = "4eccb50"
optional = true
[dependencies.lwext4_rust]
git = "https://github.com/Starry-OS/lwext4_rust.git"
rev = "033fa2c"
default-features = false
features = [ # no std
"alloc",
"lfn",
"log_level_trace",
"unicode",
]
optional = true

[dependencies.lwext4_rust]
git = "https://github.com/Josen-B/lwext4_rust.git"
rev = "99b3e5c"
[dependencies.fatfs]
git = "https://github.com/Starry-OS/rust-fatfs.git"
rev = "2685439"
default-features = false
optional = true
features = ["alloc", "lfn", "log_level_trace", "unicode"]

[dev-dependencies]
axdriver = { workspace = true, features = ["block", "ramdisk"] }
axdriver_block = { workspace = true, features = ["ramdisk"] }
axsync = { workspace = true, features = ["multitask"] }
axtask = { workspace = true, features = ["test"] }
env_logger = "0.11.8"
30 changes: 0 additions & 30 deletions modules/axfs/resources/create_test_img.sh

This file was deleted.

Binary file removed modules/axfs/resources/fat16.img
Binary file not shown.
51 changes: 51 additions & 0 deletions modules/axfs/resources/make_fs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

CUR_DIR=$(dirname $0)

write_fs() {
for i in $(seq 1 1000); do
echo "Rust is cool!" >>long.txt
done
echo "Rust is cool!" >short.txt
mkdir -p a/long/path
echo "Rust is cool!" >a/long/path/test.txt
mkdir -p very-long-dir-name
echo "Rust is cool!" >>very-long-dir-name/very-long-file-name.txt
}
init_fs() {
local name=$1
local options=$2
mkdir -p mnt
sudo mount -o loop "$name" mnt -o "$options"

sudo chmod 777 mnt

cd mnt
write_fs
cd ..

sudo umount mnt
rm -r mnt
}
create_fat_img() {
local name=$1
local kb=$2
local fatSize=$3
dd if=/dev/zero of="$name" bs=1K count=$kb
mkfs.vfat -s 1 -F $fatSize "$name"

init_fs "$name" rw,uid=$USER,gid=$USER
}
create_ext4_img() {
local name=$1
local kb=$2
dd if=/dev/zero of="$name" bs=1K count=$kb
mkfs.ext4 -O ^metadata_csum "$name"

init_fs "$name" rw
}

create_fat_img "$CUR_DIR/fat16.img" 2500 16
create_fat_img "$CUR_DIR/fat32.img" 34000 32

create_ext4_img "$CUR_DIR/ext4.img" 30000
Loading