Use naked_asm instead in naked functions
This commit is contained in:
parent
7e620c574e
commit
4548d9540e
@ -9,7 +9,7 @@ use crate::{
|
|||||||
use alloc::{boxed::Box, vec::Vec};
|
use alloc::{boxed::Box, vec::Vec};
|
||||||
use az::WrappingCast;
|
use az::WrappingCast;
|
||||||
use cast::{u64, usize};
|
use cast::{u64, usize};
|
||||||
use core::{arch::asm, ffi::CStr, fmt::Write, ptr, slice};
|
use core::{arch::{asm, naked_asm}, ffi::CStr, fmt::Write, ptr, slice};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use pic8259::ChainedPics;
|
use pic8259::ChainedPics;
|
||||||
use saturating_cast::SaturatingCast;
|
use saturating_cast::SaturatingCast;
|
||||||
@ -282,7 +282,7 @@ static mut SYSCALL_REGS: SyscallRegs = SyscallRegs {
|
|||||||
#[naked]
|
#[naked]
|
||||||
extern "x86-interrupt" fn syscall_handler_header(stack_frame: InterruptStackFrame) {
|
extern "x86-interrupt" fn syscall_handler_header(stack_frame: InterruptStackFrame) {
|
||||||
unsafe {
|
unsafe {
|
||||||
asm!(
|
naked_asm!(
|
||||||
"mov [rip+SYSCALL_REGS], rax",
|
"mov [rip+SYSCALL_REGS], rax",
|
||||||
"mov [rip+SYSCALL_REGS+8], rbx",
|
"mov [rip+SYSCALL_REGS+8], rbx",
|
||||||
"mov [rip+SYSCALL_REGS+16], rcx",
|
"mov [rip+SYSCALL_REGS+16], rcx",
|
||||||
@ -300,7 +300,6 @@ extern "x86-interrupt" fn syscall_handler_header(stack_frame: InterruptStackFram
|
|||||||
"mov [rip+SYSCALL_REGS+112], r14",
|
"mov [rip+SYSCALL_REGS+112], r14",
|
||||||
"mov [rip+SYSCALL_REGS+120], r15",
|
"mov [rip+SYSCALL_REGS+120], r15",
|
||||||
"jmp syscall_handler",
|
"jmp syscall_handler",
|
||||||
options(noreturn)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ use alloc::{
|
|||||||
};
|
};
|
||||||
use core::{
|
use core::{
|
||||||
alloc::Layout,
|
alloc::Layout,
|
||||||
arch::asm,
|
arch::naked_asm,
|
||||||
ffi::CStr,
|
ffi::CStr,
|
||||||
ptr::{addr_of, addr_of_mut},
|
ptr::{addr_of, addr_of_mut},
|
||||||
sync::atomic::{AtomicBool, Ordering},
|
sync::atomic::{AtomicBool, Ordering},
|
||||||
@ -24,7 +24,7 @@ use cast::{u64, usize};
|
|||||||
#[naked]
|
#[naked]
|
||||||
extern "C" fn switch_to_asm(current_stack: *mut *mut usize, next_stack: *mut usize) {
|
extern "C" fn switch_to_asm(current_stack: *mut *mut usize, next_stack: *mut usize) {
|
||||||
unsafe {
|
unsafe {
|
||||||
asm!(
|
naked_asm!(
|
||||||
"push rbp",
|
"push rbp",
|
||||||
"push rbx",
|
"push rbx",
|
||||||
"push r12",
|
"push r12",
|
||||||
@ -40,7 +40,6 @@ extern "C" fn switch_to_asm(current_stack: *mut *mut usize, next_stack: *mut usi
|
|||||||
"pop rbx",
|
"pop rbx",
|
||||||
"pop rbp",
|
"pop rbp",
|
||||||
"ret",
|
"ret",
|
||||||
options(noreturn)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,7 +47,7 @@ extern "C" fn switch_to_asm(current_stack: *mut *mut usize, next_stack: *mut usi
|
|||||||
#[naked]
|
#[naked]
|
||||||
extern "C" fn switch_to_asm_exit(next_stack: *mut usize) {
|
extern "C" fn switch_to_asm_exit(next_stack: *mut usize) {
|
||||||
unsafe {
|
unsafe {
|
||||||
asm!(
|
naked_asm!(
|
||||||
"mov rsp, rdi",
|
"mov rsp, rdi",
|
||||||
"pop r15",
|
"pop r15",
|
||||||
"pop r14",
|
"pop r14",
|
||||||
@ -57,7 +56,6 @@ extern "C" fn switch_to_asm_exit(next_stack: *mut usize) {
|
|||||||
"pop rbx",
|
"pop rbx",
|
||||||
"pop rbp",
|
"pop rbp",
|
||||||
"ret",
|
"ret",
|
||||||
options(noreturn)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,7 +63,7 @@ extern "C" fn switch_to_asm_exit(next_stack: *mut usize) {
|
|||||||
#[naked]
|
#[naked]
|
||||||
extern "C" fn task_init() {
|
extern "C" fn task_init() {
|
||||||
unsafe {
|
unsafe {
|
||||||
asm!(
|
naked_asm!(
|
||||||
"pop rcx", // Get the user stack pointer
|
"pop rcx", // Get the user stack pointer
|
||||||
"pop rbx", // Get the entry point
|
"pop rbx", // Get the entry point
|
||||||
"push 43", // Push the stack segment selector - same as data
|
"push 43", // Push the stack segment selector - same as data
|
||||||
@ -77,7 +75,6 @@ extern "C" fn task_init() {
|
|||||||
"push 51", // Push the code selector
|
"push 51", // Push the code selector
|
||||||
"push rbx", // Push the entry point
|
"push rbx", // Push the entry point
|
||||||
"iretq", // Return from the fake interrupt and enter user mode
|
"iretq", // Return from the fake interrupt and enter user mode
|
||||||
options(noreturn)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user