From e1242a867f90213d66a7d4ee5e57eedad3fe32ba Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 23 Jan 2020 09:20:17 +0100 Subject: [PATCH] Move global_asm inline in threads module --- src/multitasking/context_switch.s | 13 ------------- src/threads.rs | 22 +++++++++++++++++++--- 2 files changed, 19 insertions(+), 16 deletions(-) delete mode 100644 src/multitasking/context_switch.s diff --git a/src/multitasking/context_switch.s b/src/multitasking/context_switch.s deleted file mode 100644 index a4740a9a..00000000 --- a/src/multitasking/context_switch.s +++ /dev/null @@ -1,13 +0,0 @@ -.intel_syntax noprefix - -asm_context_switch: - pushfq - - mov rax, rsp - mov rsp, rdi - - mov rdi, rax - call add_paused_thread - - popfq - ret diff --git a/src/threads.rs b/src/threads.rs index 97b17bbb..924a6530 100644 --- a/src/threads.rs +++ b/src/threads.rs @@ -2,19 +2,35 @@ use alloc::collections::VecDeque; use x86_64::structures::paging::{FrameAllocator, Mapper, Size4KiB}; use x86_64::VirtAddr; -global_asm!(include_str!("multitasking/context_switch.s")); - pub unsafe fn context_switch(stack_pointer: VirtAddr) { asm!( "call asm_context_switch" : : "{rdi}"(stack_pointer.as_u64()) : "rax", "rbx", "rcx", "rdx", "rsi", "rdi", "rpb", "r8", "r9", "r10", - "r11", "r12", "r13", "r14", "r15", "rflags", "memory" + "r11", "r12", "r13", "r14", "r15", "rflags", "memory" : "intel", "volatile" ); } +global_asm!( + " + .intel_syntax noprefix + + asm_context_switch: + pushfq + + mov rax, rsp + mov rsp, rdi + + mov rdi, rax + call add_paused_thread + + popfq + ret +" +); + pub fn scheduler() { let next = PAUSED_THREADS.try_lock().and_then(|mut paused_threads| { paused_threads