Explorar o código

change(arch): move {Task, Trap}Context to HAL crate

greatbridf hai 8 meses
pai
achega
fb605cede1

+ 2 - 0
Cargo.lock

@@ -78,6 +78,7 @@ name = "eonix_hal"
 version = "0.1.0"
 dependencies = [
  "arch",
+ "cfg-if",
  "eonix_hal_macros",
  "eonix_hal_traits",
  "eonix_percpu",
@@ -153,6 +154,7 @@ version = "0.1.0"
 dependencies = [
  "arch",
  "atomic_unique_refcell",
+ "eonix_hal",
  "eonix_log",
  "eonix_percpu",
  "eonix_preempt",

+ 0 - 1
arch/src/lib.rs

@@ -1,5 +1,4 @@
 #![no_std]
-#![feature(naked_functions)]
 
 cfg_if::cfg_if! {
     if #[cfg(target_arch = "x86_64")] {

+ 1 - 1
arch/src/x86_64/bootstrap.rs

@@ -342,7 +342,7 @@ global_asm!(
     options(att_syntax),
 );
 
-#[naked]
+#[unsafe(naked)]
 pub unsafe extern "C" fn start_64bit() {
     naked_asm!(
         "mov $0x10, %ax",

+ 0 - 4
arch/src/x86_64/interrupt.rs

@@ -217,10 +217,6 @@ pub fn disable_irqs_save() -> IrqState {
     IrqState(state)
 }
 
-extern "C" {
-    pub fn _arch_fork_return();
-}
-
 fn lidt(base: usize, limit: u16) {
     let mut idt_descriptor = [0u16; 5];
 

+ 0 - 4
arch/src/x86_64/mod.rs

@@ -1,5 +1,4 @@
 mod bootstrap;
-mod context;
 mod fence;
 mod fpu;
 mod gdt;
@@ -8,14 +7,12 @@ mod interrupt;
 mod io;
 mod mm;
 mod percpu;
-mod trap;
 mod user;
 
 use core::arch::asm;
 use eonix_mm::address::{Addr as _, PAddr, VAddr};
 use eonix_mm::paging::PFN;
 
-pub use self::context::*;
 pub use self::gdt::*;
 pub use self::init::*;
 pub use self::interrupt::*;
@@ -26,7 +23,6 @@ pub use fence::*;
 pub use fpu::*;
 pub use mm::*;
 pub use percpu::*;
-pub use trap::*;
 
 #[inline(always)]
 pub fn flush_tlb(vaddr: usize) {

+ 2 - 0
crates/eonix_hal/Cargo.toml

@@ -10,3 +10,5 @@ eonix_hal_macros = { path = "./eonix_hal_macros" }
 arch = { path = "../../arch" }
 eonix_percpu = { path = "../eonix_percpu" }
 eonix_preempt = { path = "../eonix_preempt" }
+
+cfg-if = "1.0"

+ 41 - 0
crates/eonix_hal/eonix_hal_traits/src/context.rs

@@ -0,0 +1,41 @@
+#[doc(notable_trait)]
+pub trait RawTaskContext: Sized {
+    /// Creates a new instance of the task context with interrupt enabled and the program
+    /// counter and stack pointer set to zero (a.k.a. some invalid state).
+    ///
+    /// Using the created context without setting the program counter and stack pointer
+    /// will result in undefined behavior.
+    fn new() -> Self;
+
+    fn set_program_counter(&mut self, pc: usize);
+    fn set_stack_pointer(&mut self, sp: usize);
+
+    fn is_interrupt_enabled(&self) -> bool;
+    fn set_interrupt_enabled(&mut self, is_enabled: bool);
+
+    /// Sets the instruction pointer to the given function and prepares the context
+    /// to call it with the given argument.
+    fn call(&mut self, func: unsafe extern "C" fn(usize) -> !, arg: usize);
+
+    /// Switch the execution context from `from` to `to`.
+    ///
+    /// # Safety
+    /// This function is unsafe because it performs a context switch, which can lead to
+    /// undefined behavior if the contexts are not properly set up.
+    unsafe extern "C" fn switch(from: &mut Self, to: &mut Self);
+
+    /// Switches the execution context to `to` where we will not return.
+    ///
+    /// # Safety
+    /// This function is unsafe because it performs a context switch that does not return.
+    /// The caller must ensure that the `to` context is properly set up and that it will not
+    /// return to the caller.
+    unsafe extern "C" fn switch_to_noreturn(to: &mut Self) -> ! {
+        let mut from_ctx = Self::new();
+        unsafe {
+            Self::switch(&mut from_ctx, to);
+        }
+
+        unreachable!("We should never return from `switch_to_noreturn()`");
+    }
+}

+ 1 - 0
crates/eonix_hal/eonix_hal_traits/src/lib.rs

@@ -1,6 +1,7 @@
 #![no_std]
 #![feature(doc_notable_trait)]
 
+pub mod context;
 pub mod fault;
 pub mod fpu;
 pub mod trap;

+ 24 - 15
crates/eonix_hal/eonix_hal_traits/src/trap.rs

@@ -26,6 +26,18 @@ pub trait RawTrapContext: Copy {
     fn set_user_return_value(&mut self, retval: usize);
 }
 
+#[doc(notable_trait)]
+pub trait TrapReturn {
+    /// Return to the context before the trap occurred.
+    ///
+    /// # Safety
+    /// This function is unsafe because the caller MUST ensure that the
+    /// context before the trap is valid, that is, that the stack pointer
+    /// points to a valid stack frame and the program counter points to some
+    /// valid instruction.
+    unsafe fn trap_return(&mut self);
+}
+
 /// The reason that caused the trap.
 pub enum TrapType {
     Syscall { no: usize, args: [usize; 6] },
@@ -52,26 +64,23 @@ pub enum TrapType {
 ///
 /// While the following code should compile:
 ///
-/// ```
+/// ```no_run
 /// # use eonix_hal_traits::trap::IsRawTrapContext;
 /// struct RawTrapContextType;
 ///
 /// impl RawTrapContext for RawTrapContextType {
 ///     // ...
-/// #   fn trap_no(&self) -> usize {
-/// #       0
-/// #   }
-/// #   fn get_program_counter(&self) -> usize {
-/// #       0
-/// #   }
-/// #   fn get_stack_pointer(&self) -> usize {
-/// #       0
-/// #   }
-/// #   fn set_program_counter(&mut self, pc: usize) {}
-/// #   fn set_stack_pointer(&mut self, sp: usize) {}
-/// #   fn is_user_mode(&self) -> bool {
-/// #       false
-/// #   }
+/// #   fn new() -> Self { todo!() }
+/// #   fn trap_type() -> TrapType { todo!() }
+/// #   fn get_program_counter(&self) -> usize { todo!() }
+/// #   fn get_stack_pointer(&self) -> usize { todo!() }
+/// #   fn set_program_counter(&mut self, _: usize) { todo!() }
+/// #   fn set_stack_pointer(&mut self, _: usize) { todo!() }
+/// #   fn is_interrupt_enabled(&self) -> bool { todo!() }
+/// #   fn set_interrupt_enabled(&mut self, _: bool) { todo!() }
+/// #   fn is_user_mode(&self) -> bool { todo!() }
+/// #   fn set_user_mode(&mut self, _: bool) { todo!() }
+/// #   fn set_user_return_value(&mut self, _: usize) { todo!() }
 /// }
 ///
 /// struct UserStruct(RawTrapContextType, IsRawTrapContext<RawTrapContextType>);

+ 14 - 0
crates/eonix_hal/src/arch/mod.rs

@@ -0,0 +1,14 @@
+cfg_if::cfg_if! {
+    if #[cfg(target_arch = "x86_64")] {
+        mod x86_64;
+        pub use x86_64::*;
+    } else if #[cfg(target_arch = "aarch64")] {
+        pub mod aarch64;
+        pub use aarch64::*;
+    } else if #[cfg(target_arch = "riscv64")] {
+        pub mod riscv64;
+        pub use riscv64::*;
+    } else {
+        compile_error!("Unsupported architecture");
+    }
+}

+ 46 - 78
arch/src/x86_64/context.rs → crates/eonix_hal/src/arch/x86_64/context.rs

@@ -1,6 +1,7 @@
 use core::arch::naked_asm;
+use eonix_hal_traits::context::RawTaskContext;
 
-/// Necessary hardware states of task for context switch
+/// Necessary hardware states of task for doing context switches.
 #[repr(C)]
 #[derive(Debug, Default)]
 pub struct TaskContext {
@@ -34,73 +35,8 @@ impl TaskContext {
         }
     }
 
-    pub fn ip(&mut self, ip: usize) {
-        self.rip = ip as u64;
-    }
-
-    pub fn sp(&mut self, sp: usize) {
-        self.rsp = sp as u64;
-    }
-
-    pub fn call1(&mut self, func: unsafe extern "C" fn(usize) -> !, arg: [usize; 1]) {
-        self.ip(Self::do_call as _);
-        self.rbp = func as _;
-        self.r12 = arg[0] as _;
-    }
-
-    pub fn call2(&mut self, func: unsafe extern "C" fn(usize, usize) -> !, arg: [usize; 2]) {
-        self.ip(Self::do_call as _);
-        self.rbp = func as _;
-
-        (self.r12, self.r13) = (arg[0] as _, arg[1] as _);
-    }
-
-    pub fn call3(&mut self, func: unsafe extern "C" fn(usize, usize, usize) -> !, arg: [usize; 3]) {
-        self.ip(Self::do_call as _);
-        self.rbp = func as _;
-
-        (self.r12, self.r13, self.r14) = (arg[0] as _, arg[1] as _, arg[2] as _);
-    }
-
-    pub fn call4(
-        &mut self,
-        func: unsafe extern "C" fn(usize, usize, usize, usize) -> !,
-        arg: [usize; 4],
-    ) {
-        self.ip(Self::do_call as _);
-        self.rbp = func as _;
-
-        (self.r12, self.r13, self.r14, self.r15) =
-            (arg[0] as _, arg[1] as _, arg[2] as _, arg[3] as _);
-    }
-
-    pub fn call5(
-        &mut self,
-        func: unsafe extern "C" fn(usize, usize, usize, usize, usize) -> !,
-        arg: [usize; 5],
-    ) {
-        self.ip(Self::do_call as _);
-        self.rbp = func as _;
-
-        (self.r12, self.r13, self.r14, self.r15, self.rbx) = (
-            arg[0] as _,
-            arg[1] as _,
-            arg[2] as _,
-            arg[3] as _,
-            arg[4] as _,
-        );
-    }
-
-    pub fn interrupt(&mut self, is_enabled: bool) {
-        if is_enabled {
-            self.rflags |= 0x200; // IF = 1
-        } else {
-            self.rflags &= !0x200; // IF = 0
-        }
-    }
-
-    #[naked]
-    pub unsafe extern "C" fn switch(from: &mut Self, to: &mut Self) {
+    #[unsafe(naked)]
+    unsafe extern "C" fn _switch(from: &mut Self, to: &mut Self) {
         naked_asm!(
             "pop %rax",
             "pushf",
@@ -132,20 +68,52 @@ impl TaskContext {
         );
     }
 
-    #[naked]
-    /// Maximum of 5 arguments supported.
+    #[unsafe(naked)]
     unsafe extern "C" fn do_call() -> ! {
         naked_asm!(
             "mov %r12, %rdi",
-            "mov %r13, %rsi",
-            "mov %r14, %rdx",
-            "mov %r15, %rcx",
-            "mov %rbx, %r8",
-            "mov %rbp, %rax",
-            "xor %rbp, %rbp", // NULL previous stack frame
-            "push %rbp",      // NULL return address.
-            "jmp *%rax",
+            "push %rbp", // NULL return address.
+            "jmp *%rbx",
             options(att_syntax),
         );
     }
 }
+
+impl RawTaskContext for TaskContext {
+    fn new() -> Self {
+        Self::new()
+    }
+
+    fn set_program_counter(&mut self, pc: usize) {
+        self.rip = pc as u64;
+    }
+
+    fn set_stack_pointer(&mut self, sp: usize) {
+        self.rsp = sp as u64;
+    }
+
+    fn is_interrupt_enabled(&self) -> bool {
+        (self.rflags & 0x200) != 0 // IF = 1
+    }
+
+    fn set_interrupt_enabled(&mut self, is_enabled: bool) {
+        if is_enabled {
+            self.rflags |= 0x200; // IF = 1
+        } else {
+            self.rflags &= !0x200; // IF = 0
+        }
+    }
+
+    fn call(&mut self, func: unsafe extern "C" fn(usize) -> !, arg: usize) {
+        self.set_program_counter(Self::do_call as _);
+        self.rbx = func as _;
+        self.r12 = arg as _;
+        self.rbp = 0; // NULL previous stack frame
+    }
+
+    unsafe extern "C" fn switch(from: &mut Self, to: &mut Self) {
+        unsafe {
+            Self::_switch(from, to);
+        }
+    }
+}

+ 5 - 0
crates/eonix_hal/src/arch/x86_64/mod.rs

@@ -0,0 +1,5 @@
+mod context;
+mod trap;
+
+pub use context::TaskContext;
+pub use trap::{TrapContext, TRAP_STUBS_START};

+ 53 - 77
crates/eonix_hal/src/trap/trap_context.rs → crates/eonix_hal/src/arch/x86_64/trap.rs

@@ -1,23 +1,10 @@
-use arch::{TaskContext, TrapContext};
-use core::{
-    arch::{global_asm, naked_asm},
-    mem::transmute,
-};
-use eonix_hal_traits::trap::IsRawTrapContext;
+mod trap_context;
 
-#[doc(notable_trait)]
-pub trait TrapContextExt {
-    /// Return to the context before the trap occurred.
-    ///
-    /// # Safety
-    /// This function is unsafe because the caller MUST ensure that the
-    /// context before the trap is valid, that is, that the stack pointer
-    /// points to a valid stack frame and the program counter points to some
-    /// valid instruction.
-    unsafe fn trap_return(&mut self);
-}
+use super::TaskContext;
+use core::arch::{global_asm, naked_asm};
+use eonix_hal_traits::{context::RawTaskContext, trap::TrapReturn};
 
-struct _CheckTrapContext(IsRawTrapContext<TrapContext>);
+pub use trap_context::TrapContext;
 
 unsafe extern "C" {
     fn _default_trap_handler(trap_context: &mut TrapContext);
@@ -26,7 +13,7 @@ unsafe extern "C" {
 }
 
 #[eonix_percpu::define_percpu]
-static TRAP_HANDLER: usize = 0;
+static TRAP_HANDLER: unsafe extern "C" fn() = default_trap_handler;
 
 #[eonix_percpu::define_percpu]
 static CAPTURER_CONTEXT: TaskContext = TaskContext::new();
@@ -288,81 +275,70 @@ global_asm!(
 
 /// Default handler handles the trap on the current stack and returns
 /// to the context before interrut.
-#[naked]
+#[unsafe(naked)]
 unsafe extern "C" fn default_trap_handler() {
-    unsafe {
-        naked_asm!(
-            ".cfi_startproc",
-            "mov %rsp, %rbx",
-            ".cfi_def_cfa_register %rbx",
-            "",
-            "and $~0xf, %rsp",
-            "",
-            "mov %rbx, %rdi",
-            "call {handle_trap}",
-            "",
-            "mov %rbx, %rsp",
-            ".cfi_def_cfa_register %rsp",
-            "",
-            "jmp {trap_return}",
-            ".cfi_endproc",
-            handle_trap = sym _default_trap_handler,
-            trap_return = sym _raw_trap_return,
-            options(att_syntax),
-        );
-    }
+    naked_asm!(
+        ".cfi_startproc",
+        "mov %rsp, %rbx",
+        ".cfi_def_cfa_register %rbx",
+        "",
+        "and $~0xf, %rsp",
+        "",
+        "mov %rbx, %rdi",
+        "call {handle_trap}",
+        "",
+        "mov %rbx, %rsp",
+        ".cfi_def_cfa_register %rsp",
+        "",
+        "jmp {trap_return}",
+        ".cfi_endproc",
+        handle_trap = sym _default_trap_handler,
+        trap_return = sym _raw_trap_return,
+        options(att_syntax),
+    );
 }
 
-#[naked]
+#[unsafe(naked)]
 unsafe extern "C" fn captured_trap_handler() {
-    unsafe {
-        naked_asm!(
-            "mov ${from_context}, %rdi",
-            "mov %gs:0, %rsi",
-            "add ${to_context}, %rsi",
-            "",
-            "mov %rdi, %rsp", // We need a temporary stack to use `switch()`.
-            "",
-            "jmp {switch}",
-            from_context = sym DIRTY_TRAP_CONTEXT,
-            to_context = sym _percpu_inner_CAPTURER_CONTEXT,
-            switch = sym arch::TaskContext::switch,
-            options(att_syntax),
-        );
-    }
+    naked_asm!(
+        "mov ${from_context}, %rdi",
+        "mov %gs:0, %rsi",
+        "add ${to_context}, %rsi",
+        "",
+        "mov %rdi, %rsp", // We need a temporary stack to use `switch()`.
+        "",
+        "jmp {switch}",
+        from_context = sym DIRTY_TRAP_CONTEXT,
+        to_context = sym _percpu_inner_CAPTURER_CONTEXT,
+        switch = sym TaskContext::switch,
+        options(att_syntax),
+    );
 }
 
-#[naked]
+#[unsafe(naked)]
 unsafe extern "C" fn captured_trap_return(trap_context: usize) -> ! {
-    unsafe {
-        naked_asm!(
-            "jmp {trap_return}",
-            trap_return = sym _raw_trap_return,
-            options(att_syntax),
-        );
-    }
+    naked_asm!(
+        "jmp {trap_return}",
+        trap_return = sym _raw_trap_return,
+        options(att_syntax),
+    );
 }
 
-impl TrapContextExt for TrapContext {
+impl TrapReturn for TrapContext {
     unsafe fn trap_return(&mut self) {
         let irq_states = arch::disable_irqs_save();
-        let old_handler = TRAP_HANDLER.swap(captured_trap_handler as *const () as usize);
+        let old_handler = TRAP_HANDLER.swap(captured_trap_handler);
 
-        let mut to_ctx = arch::TaskContext::new();
-        to_ctx.ip(captured_trap_return as _);
-        to_ctx.sp(&raw mut *self as usize);
-        to_ctx.interrupt(false);
+        let mut to_ctx = TaskContext::new();
+        to_ctx.set_program_counter(captured_trap_return as _);
+        to_ctx.set_stack_pointer(&raw mut *self as usize);
+        to_ctx.set_interrupt_enabled(false);
 
         unsafe {
-            arch::TaskContext::switch(CAPTURER_CONTEXT.as_mut(), &mut to_ctx);
+            TaskContext::switch(CAPTURER_CONTEXT.as_mut(), &mut to_ctx);
         }
 
         TRAP_HANDLER.set(old_handler);
         irq_states.restore();
     }
 }
-
-pub fn init() {
-    let addr = unsafe { transmute::<_, usize>(default_trap_handler as *const ()) };
-    TRAP_HANDLER.set(addr as usize);
-}

+ 0 - 0
arch/src/x86_64/trap.rs → crates/eonix_hal/src/arch/x86_64/trap/trap_context.rs


+ 1 - 0
crates/eonix_hal/src/context.rs

@@ -0,0 +1 @@
+pub use crate::arch::TaskContext;

+ 3 - 1
crates/eonix_hal/src/lib.rs

@@ -1,7 +1,9 @@
 #![no_std]
 #![feature(doc_notable_trait)]
-#![feature(naked_functions)]
 
+pub(crate) mod arch;
+
+pub mod context;
 pub mod processor;
 pub mod trap;
 

+ 7 - 2
crates/eonix_hal/src/trap.rs

@@ -1,3 +1,8 @@
-mod trap_context;
+use eonix_hal_traits::trap::IsRawTrapContext;
 
-pub use trap_context::{init, TrapContextExt, TRAP_STUBS_START};
+pub use crate::arch::TrapContext;
+
+// TODO: Remove this once the arch module is fully implemented.
+pub use crate::arch::TRAP_STUBS_START;
+
+struct _CheckTrapContext(IsRawTrapContext<TrapContext>);

+ 1 - 0
crates/eonix_runtime/Cargo.toml

@@ -6,6 +6,7 @@ edition = "2024"
 [dependencies]
 arch = { path = "../../arch" }
 atomic_unique_refcell = { path = "../atomic_unique_refcell" }
+eonix_hal = { path = "../eonix_hal" }
 eonix_log = { path = "../eonix_log" }
 eonix_percpu = { path = "../eonix_percpu" }
 eonix_preempt = { path = "../eonix_preempt" }

+ 10 - 10
crates/eonix_runtime/src/context.rs

@@ -1,51 +1,51 @@
 use core::{cell::UnsafeCell, mem::transmute};
+use eonix_hal::context::TaskContext;
+use eonix_hal::traits::context::RawTaskContext;
 
 #[derive(Debug)]
-pub struct ExecutionContext(UnsafeCell<arch::TaskContext>);
+pub struct ExecutionContext(UnsafeCell<TaskContext>);
 
 unsafe impl Sync for ExecutionContext {}
 
 impl ExecutionContext {
     pub const fn new() -> Self {
-        Self(UnsafeCell::new(arch::TaskContext::new()))
+        Self(UnsafeCell::new(TaskContext::new()))
     }
 
     pub fn set_ip(&mut self, ip: usize) {
         let Self(context) = self;
-        context.get_mut().ip(ip);
+        context.get_mut().set_program_counter(ip);
     }
 
     pub fn set_sp(&mut self, sp: usize) {
         let Self(context) = self;
-        context.get_mut().sp(sp);
+        context.get_mut().set_stack_pointer(sp);
     }
 
     pub fn set_interrupt(&mut self, is_enabled: bool) {
         let Self(context) = self;
-        context.get_mut().interrupt(is_enabled);
+        context.get_mut().set_interrupt_enabled(is_enabled);
     }
 
     pub fn call1<T>(&mut self, func: unsafe extern "C" fn(T) -> !, arg: usize) {
         let Self(context) = self;
         context
             .get_mut()
-            .call1(unsafe { transmute(func as *mut ()) }, [arg]);
+            .call(unsafe { transmute(func as *mut ()) }, arg);
     }
 
     pub fn switch_to(&self, to: &Self) {
         let Self(from_ctx) = self;
         let Self(to_ctx) = to;
         unsafe {
-            arch::TaskContext::switch(&mut *from_ctx.get(), &mut *to_ctx.get());
+            TaskContext::switch(&mut *from_ctx.get(), &mut *to_ctx.get());
         }
     }
 
     pub fn switch_noreturn(&self) -> ! {
-        let mut from_ctx = arch::TaskContext::new();
         let Self(to_ctx) = self;
         unsafe {
-            arch::TaskContext::switch(&mut from_ctx, &mut *to_ctx.get());
+            TaskContext::switch_to_noreturn(&mut *to_ctx.get());
         }
-        unreachable!("We should never return from switch_to_noreturn");
     }
 }

+ 1 - 1
rust-toolchain

@@ -1 +1 @@
-nightly-2025-03-22
+nightly-2025-05-16

+ 1 - 1
src/kernel/interrupt.rs

@@ -4,9 +4,9 @@ use super::timer::timer_interrupt;
 use crate::kernel::constants::EINVAL;
 use crate::{driver::Port8, prelude::*};
 use alloc::sync::Arc;
-use arch::TrapContext;
 use eonix_hal::traits::fault::Fault;
 use eonix_hal::traits::trap::{RawTrapContext, TrapType};
+use eonix_hal::trap::TrapContext;
 use eonix_mm::address::{Addr as _, VAddr};
 use eonix_runtime::scheduler::Scheduler;
 use eonix_sync::SpinIrq as _;

+ 0 - 1
src/kernel/smp.rs

@@ -18,7 +18,6 @@ define_smp_bootstrap!(4, ap_entry, {
 
 unsafe extern "C" fn ap_entry() -> ! {
     init_localcpu();
-    eonix_hal::trap::init();
 
     Scheduler::init_local_scheduler::<KernelStack>();
     println_debug!("AP{} started", local_cpu().cpuid());

+ 2 - 1
src/kernel/task/signal.rs

@@ -6,9 +6,10 @@ use super::{ProcessList, Thread, WaitObject, WaitType};
 use crate::kernel::constants::{EFAULT, EINVAL};
 use crate::{kernel::user::UserPointer, prelude::*};
 use alloc::collections::binary_heap::BinaryHeap;
-use arch::{FpuState, TrapContext};
+use arch::FpuState;
 use core::{cmp::Reverse, task::Waker};
 use eonix_hal::traits::trap::RawTrapContext;
+use eonix_hal::trap::TrapContext;
 use eonix_runtime::task::Task;
 use eonix_sync::AsProof as _;
 use intrusive_collections::UnsafeRef;

+ 2 - 2
src/kernel/task/signal/signal_action.rs

@@ -8,9 +8,9 @@ use crate::{
     SIGNAL_NOW,
 };
 use alloc::collections::btree_map::BTreeMap;
-use arch::{FpuState, TrapContext};
+use arch::FpuState;
 use core::num::NonZero;
-use eonix_hal::traits::trap::RawTrapContext;
+use eonix_hal::{traits::trap::RawTrapContext, trap::TrapContext};
 use eonix_mm::address::{Addr as _, AddrOps as _, VAddr};
 use posix_types::signal::{SigAction, TryFromSigAction};
 

+ 3 - 3
src/kernel/task/thread.rs

@@ -14,7 +14,7 @@ use crate::{
     prelude::*,
 };
 use alloc::sync::Arc;
-use arch::{FpuState, TrapContext, UserTLS};
+use arch::{FpuState, UserTLS};
 use atomic_unique_refcell::AtomicUniqueRefCell;
 use core::{
     future::Future,
@@ -27,9 +27,9 @@ use eonix_hal::{
     traits::{
         fault::Fault,
         fpu::RawFpuState as _,
-        trap::{RawTrapContext, TrapType},
+        trap::{RawTrapContext, TrapReturn, TrapType},
     },
-    trap::TrapContextExt,
+    trap::TrapContext,
 };
 use eonix_mm::address::{Addr as _, VAddr};
 use eonix_runtime::run::{Contexted, Run, RunState};

+ 0 - 2
src/kernel_init.rs

@@ -214,8 +214,6 @@ extern "C" fn _init_on_new_stack(early_kernel_stack_pfn: PFN) -> ! {
 
     init_localcpu();
 
-    eonix_hal::trap::init();
-
     kernel::interrupt::init().unwrap();
 
     kernel_init(early_kernel_stack_pfn)

+ 0 - 1
src/lib.rs

@@ -5,7 +5,6 @@
 #![feature(arbitrary_self_types)]
 #![feature(get_mut_unchecked)]
 #![feature(macro_metavar_expr)]
-#![feature(naked_functions)]
 
 extern crate alloc;