Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f6c26c9
perf: replace the annoyed ext4 crate with a new choice (called anothe…
SMS-Derfflinger Jul 23, 2025
f050373
feat(fs): impl write, create and mkdir for ext4 fs
SMS-Derfflinger Jul 25, 2025
d59a550
feat(fs): impl remove file and dir.
SMS-Derfflinger Jul 26, 2025
5c40166
fix(fs): fix some informations
SMS-Derfflinger Jul 26, 2025
1d1a025
feat(fs): impl rename
SMS-Derfflinger Jul 29, 2025
22458ed
fix(fs): fix rename's metadata
SMS-Derfflinger Jul 29, 2025
806c4fe
fix(fs): fix ext4's write offset update
SMS-Derfflinger Jul 31, 2025
082c5c5
Merge branch 'master' into ext4-replace
SMS-Derfflinger Aug 3, 2025
db1caeb
feat(fs): partial work for ext4's page cache
SMS-Derfflinger Aug 4, 2025
a2c50b9
feat(fs): temporary cache write back strategy for ext4
SMS-Derfflinger Aug 5, 2025
e89a286
runtime: rework the whole runtime arch. (partial)
greatbridf Aug 5, 2025
e23c9eb
runtime: new task sleep-wakeup method and some adaption
greatbridf Aug 7, 2025
fb9a175
runtime: add trace logs and fix few bugs
greatbridf Aug 7, 2025
3ab454f
riscv64, trap: remove load_interrupt_stack impl
greatbridf Aug 8, 2025
6b152c7
riscv64, trap: fix kernel space trap returns
greatbridf Aug 8, 2025
33ff315
task: brand new block_on and stackful wrapper
greatbridf Aug 8, 2025
5ada0d0
build, Makefile: remove --feature if none is present
greatbridf Aug 8, 2025
21dd5ea
rcu: provide call_rcu() to call rcu drop asynchronously
greatbridf Aug 8, 2025
874a4fa
task: migrate all Task::block_on calls to task::block_on
greatbridf Aug 8, 2025
661a159
riscv64, trap: rework to fix nested captured traps
greatbridf Aug 9, 2025
9c900be
task, thread: working version of threads
greatbridf Aug 9, 2025
30bfc5a
loongarch64, trap: rework to fix nested captured traps
greatbridf Aug 9, 2025
a622172
trap: introduce Breakpoint fault type
greatbridf Aug 9, 2025
21b7650
task: fix stackful waker implementation
greatbridf Aug 10, 2025
dee96a3
syscall: migrate all syscalls to async...
greatbridf Aug 10, 2025
973f6f2
partial work: vfs asynchronize
greatbridf Aug 11, 2025
db931a8
partial work: file array rework and asynchronize
greatbridf Aug 14, 2025
34a6252
feat: unwinding and printing stack backtrace
greatbridf Aug 16, 2025
3fb4966
task: fix infinite sleep in stackful tasks
greatbridf Aug 16, 2025
c57b71f
Merge remote-tracking branch 'SMS-Derfflinger/ext4-replace' into task…
greatbridf Aug 16, 2025
8c656b5
configure: check and use ARCH given in env
greatbridf Aug 25, 2025
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
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[build]
target = "riscv64gc-unknown-none-elf"
target-dir = 'build'
rustflags = ["-C", "force-unwind-tables"]

[unstable]
build-std-features = ['compiler-builtins-mem']
Expand Down
62 changes: 46 additions & 16 deletions Cargo.lock

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

20 changes: 14 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,39 @@ posix_types = { path = "./crates/posix_types" }
slab_allocator = { path = "./crates/slab_allocator" }

bitflags = "2.6.0"
intrusive-collections = "0.9.7"
intrusive-collections = { version = "0.9.8", git = "https://github.com/greatbridf/intrusive-rs" }
itertools = { version = "0.13.0", default-features = false }
acpi = "5.2.0"
align_ext = "0.1.0"
xmas-elf = "0.10.0"
ext4_rs = "1.3.2"
another_ext4 = { git = "https://github.com/SMS-Derfflinger/another_ext4", branch = "main" }
stalloc = { version = "0.6.1", default-features = false, features = [
"allocator-api",
] }

[target.'cfg(any(target_arch = "riscv64", target_arch = "loongarch64"))'.dependencies]
virtio-drivers = { version = "0.11.0" }

[target.'cfg(target_arch = "riscv64")'.dependencies]
unwinding = { version = "0.2.8", default-features = false, features = [
"unwinder",
"fde-static",
"personality",
"panic",
] }

[features]
default = []
trace_pci = []
trace_syscall = []
trace_scheduler = []
trace_scheduler = ["eonix_runtime/trace_scheduler"]
log_trace = ["trace_pci", "trace_syscall", "trace_scheduler"]
log_debug = []
smp = []

[profile.release]
debug = true

[profile.dev]
panic = "abort"

[profile.dev.package.eonix_preempt]
opt-level = "s"

Expand Down
10 changes: 9 additions & 1 deletion Makefile.src
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ KERNEL_CARGO_MANIFESTS += $(shell find src macros crates -name Cargo.toml -type
KERNEL_DEPS := $(KERNEL_SOURCES) $(KERNEL_CARGO_MANIFESTS)

QEMU_ARGS ?= -no-reboot
CARGO_FLAGS := --profile $(PROFILE) --features $(FEATURES)$(if $(SMP),$(COMMA)smp,)
CARGO_FLAGS := --profile $(PROFILE)

ifneq ($(SMP),)
CARGO_FLAGS += --features smp
endif

ifneq ($(FEATURES),)
CARGO_FLAGS += --features $(FEATURES)
endif

ifeq ($(HOST),darwin)
QEMU_ACCEL ?= -accel tcg
Expand Down
10 changes: 5 additions & 5 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ event() {
printf "$1... "
}

ARCH=${ARCH:-x86_64}
ARCH=${ARCH:-"$DEFAULT_ARCH"}

# Define toolchain and QEMU/GDB settings for per architecture
event "target architecture"
Expand Down Expand Up @@ -40,7 +40,7 @@ esac

if [ "$QEMU" = "" ]; then
event "checking default qemu"
QEMU="qemu-system-$DEFAULT_ARCH"
QEMU="qemu-system-$ARCH"
if $QEMU --version > /dev/null 2>&1; then
QEMU="qemu-system-\$(ARCH)"
break
Expand All @@ -65,7 +65,7 @@ check_gdb_arch() {
local item="$1"
if $item --init-eval-command 'set arch' \
--init-eval-command 'q' 2>&1 \
| grep "$DEFAULT_ARCH" >/dev/null 2>&1; then
| grep "$ARCH" >/dev/null 2>&1; then
return 0
else
return 1
Expand All @@ -74,7 +74,7 @@ check_gdb_arch() {

if [ "$GDB" = "" ]; then
event "checking default gdb"
if check_gdb_arch "$DEFAULT_ARCH-elf-gdb"; then
if check_gdb_arch "$ARCH-elf-gdb"; then
GDB="\$(ARCH)-elf-gdb"
break
fi
Expand Down Expand Up @@ -126,7 +126,7 @@ else
fi

cp Makefile.src "$OUT"
sed -i '' -e "s|##DEFAULT_ARCH##|$DEFAULT_ARCH|" "$OUT" > /dev/null 2>&1
sed -i '' -e "s|##DEFAULT_ARCH##|$ARCH|" "$OUT" > /dev/null 2>&1
sed -i '' -e "s|##GDB##|$GDB|" "$OUT" > /dev/null 2>&1
sed -i '' -e "s|##QEMU##|$QEMU|" "$OUT" > /dev/null 2>&1
sed -i '' -e "s|##FDISK##|$FDISK|" "$OUT" > /dev/null 2>&1
Expand Down
1 change: 1 addition & 0 deletions crates/eonix_hal/eonix_hal_traits/src/trap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ where
{
Syscall { no: usize, args: [usize; 6] },
Fault(Fault),
Breakpoint,
Irq { callback: FIrq },
Timer { callback: FTimer },
}
Expand Down
4 changes: 2 additions & 2 deletions crates/eonix_hal/src/arch/loongarch64/link.x
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ SECTIONS {
} > VDSO AT> RAM

VDSO_PADDR = LOADADDR(.vdso);
__kernel_end = ABSOLUTE(LOADADDR(.vdso) + SIZEOF(.vdso));
__kernel_end = __edata;
}
INSERT BEFORE .bss;
INSERT BEFORE .data.after;
2 changes: 0 additions & 2 deletions crates/eonix_hal/src/arch/loongarch64/memory.x
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ REGION_ALIAS("REGION_TEXT", KIMAGE);
REGION_ALIAS("REGION_RODATA", KIMAGE);
REGION_ALIAS("REGION_DATA", KIMAGE);
REGION_ALIAS("REGION_BSS", KBSS);
REGION_ALIAS("REGION_EHFRAME", KIMAGE);

REGION_ALIAS("LINK_REGION_TEXT", RAM);
REGION_ALIAS("LINK_REGION_RODATA", RAM);
REGION_ALIAS("LINK_REGION_DATA", RAM);
REGION_ALIAS("LINK_REGION_BSS", RAM);
REGION_ALIAS("LINK_REGION_EHFRAME", RAM);

_stext = ORIGIN(REGION_TEXT) + LOADADDR(.text) - ORIGIN(RAM);
2 changes: 2 additions & 0 deletions crates/eonix_hal/src/arch/loongarch64/mm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ impl PagingMode for PagingMode48 {

pub type ArchPagingMode = PagingMode48;

unsafe impl Send for RawPageTable48<'_> {}

impl<'a> RawPageTable<'a> for RawPageTable48<'a> {
type Entry = PTE64;

Expand Down
13 changes: 11 additions & 2 deletions crates/eonix_hal/src/arch/loongarch64/trap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,18 @@ impl TrapReturn for TrapContext {
to_ctx.set_interrupt_enabled(false);

unsafe {
let mut old_trap_ctx: usize;
let mut old_task_ctx: usize;

asm!(
"csrrd {old_trap_ctx}, {CSR_CAPTURED_TRAP_CONTEXT_ADDR}",
"csrrd {old_task_ctx}, {CSR_CAPTURER_TASK_CONTEXT_ADDR}",
"csrwr {captured_trap_context}, {CSR_CAPTURED_TRAP_CONTEXT_ADDR}",
"csrwr {capturer_task_context}, {CSR_CAPTURER_TASK_CONTEXT_ADDR}",
captured_trap_context = inout(reg) &raw mut *self => _,
capturer_task_context = inout(reg) &raw mut capturer_ctx => _,
old_trap_ctx = out(reg) old_trap_ctx,
old_task_ctx = out(reg) old_task_ctx,
CSR_CAPTURED_TRAP_CONTEXT_ADDR = const CSR_CAPTURED_TRAP_CONTEXT_ADDR,
CSR_CAPTURER_TASK_CONTEXT_ADDR = const CSR_CAPTURER_TASK_CONTEXT_ADDR,
options(nomem, nostack, preserves_flags),
Expand All @@ -291,8 +298,10 @@ impl TrapReturn for TrapContext {
TaskContext::switch(&mut capturer_ctx, &mut to_ctx);

asm!(
"csrwr $zero, {CSR_CAPTURED_TRAP_CONTEXT_ADDR}",
"csrwr $zero, {CSR_CAPTURER_TASK_CONTEXT_ADDR}",
"csrwr {old_trap_ctx}, {CSR_CAPTURED_TRAP_CONTEXT_ADDR}",
"csrwr {old_task_ctx}, {CSR_CAPTURER_TASK_CONTEXT_ADDR}",
old_trap_ctx = inout(reg) old_trap_ctx,
old_task_ctx = inout(reg) old_task_ctx,
CSR_CAPTURED_TRAP_CONTEXT_ADDR = const CSR_CAPTURED_TRAP_CONTEXT_ADDR,
CSR_CAPTURER_TASK_CONTEXT_ADDR = const CSR_CAPTURER_TASK_CONTEXT_ADDR,
options(nomem, nostack, preserves_flags),
Expand Down
15 changes: 13 additions & 2 deletions crates/eonix_hal/src/arch/loongarch64/trap/trap_context.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::processor::CPU;
use crate::{arch::trap::CSR_KERNEL_TP, processor::CPU};
use core::{arch::asm, mem::offset_of};
use eonix_hal_traits::{
fault::{Fault, PageFaultErrorCode},
Expand Down Expand Up @@ -173,6 +173,7 @@ impl RawTrapContext for TrapContext {
| Exception::MemoryAccessAddressError
| Exception::PagePrivilegeIllegal,
) => TrapType::Fault(Fault::BadAccess),
Trap::Exception(Exception::Breakpoint) => TrapType::Breakpoint,
Trap::Exception(Exception::InstructionNotExist) => TrapType::Fault(Fault::InvalidOp),
Trap::Exception(Exception::Syscall) => TrapType::Syscall {
no: self.syscall_no(),
Expand Down Expand Up @@ -226,7 +227,17 @@ impl RawTrapContext for TrapContext {
fn set_user_mode(&mut self, user: bool) {
match user {
true => self.prmd |= 0x3,
false => self.prmd &= !0x3,
false => {
unsafe {
asm!(
"csrrd {tp}, {CSR_KERNEL_TP}",
tp = out(reg) self.regs.tp,
CSR_KERNEL_TP = const CSR_KERNEL_TP,
options(nomem, nostack, preserves_flags),
)
}
self.prmd &= !0x3;
}
}
}

Expand Down
8 changes: 0 additions & 8 deletions crates/eonix_hal/src/arch/riscv64/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use super::{
console::write_str,
cpu::{CPUID, CPU_COUNT},
time::set_next_timer,
trap::TRAP_SCRATCH,
};
use crate::{
arch::{
Expand Down Expand Up @@ -234,13 +233,6 @@ fn setup_cpu(alloc: impl PageAlloc, hart_id: usize) {
}

percpu_area.register(cpu.cpuid());

unsafe {
// SAFETY: Interrupts are disabled.
TRAP_SCRATCH
.as_mut()
.set_kernel_tp(PercpuArea::get_for(cpu.cpuid()).unwrap().cast());
}
}

fn get_ap_start_addr() -> usize {
Expand Down
Loading
Loading