Skip to content

Commit

Permalink
Fix aarch64 thread stack initialization (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
PandaZ3D authored Jun 21, 2024
1 parent da72015 commit eceaf1e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/kernel/src/arch/aarch64/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use registers::interfaces::Writeable;
use twizzler_abi::upcall::{UpcallFrame, UpcallInfo, UpcallTarget};

use super::{exception::ExceptionContext, interrupt::DAIFMaskBits, syscall::Armv8SyscallContext};
use crate::{memory::VirtAddr, thread::Thread};
use crate::{memory::VirtAddr, processor::KERNEL_STACK_SIZE, thread::Thread};

#[derive(Copy, Clone)]
pub enum Registers {
Expand Down Expand Up @@ -190,9 +190,9 @@ impl Thread {
}

pub unsafe fn init(&mut self, entry: extern "C" fn()) {
let stack = self.kernel_stack.as_ptr() as *mut u64;
let stack = new_stack_top(self.kernel_stack.as_ptr() as usize, KERNEL_STACK_SIZE);
// set the stack pointer as the last thing context (x30 + 1)
self.arch.context.sp = stack as u64;
self.arch.context.sp = stack.into();
// set the link register as the second to last entry (x30)
self.arch.context.lr = entry as u64;
// by default interrupts are enabled (unmask the I bit)
Expand Down

0 comments on commit eceaf1e

Please sign in to comment.