diff options
Diffstat (limited to 'kern/sched_asm.S')
| -rw-r--r-- | kern/sched_asm.S | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/kern/sched_asm.S b/kern/sched_asm.S new file mode 100644 index 0000000..747598e --- /dev/null +++ b/kern/sched_asm.S @@ -0,0 +1,67 @@ +/** @file sched_asm.S + * + * @brief scheduling functions. + * + * @author Hanjie Wu (hanjiew) + * @bug No functional bugs + */ + +#include <x86/seg.h> + +.text + +.global set_fs +.type set_fs, %function +set_fs: + push 0x4(%esp) + pop %fs + ret + +.macro PERCPU_GETSET name offset +.global get_\name +.type get_\name, %function +get_\name: + xor %eax, %eax + mov %fs:\offset(%eax), %eax + ret + +.global set_\name +.type set_\name, %function +set_\name: + xor %esi, %esi + mov 0x4(%esp), %eax + mov %eax, %fs:\offset(%esi) + ret +.endm + +PERCPU_GETSET current 0x0 +PERCPU_GETSET idle 0x4 +PERCPU_GETSET kthread 0x8 +PERCPU_GETSET mapped_phys_page 0xc +PERCPU_GETSET mapped_phys_page_pte 0x10 + +.global return_to_user +.type return_to_user, %function +return_to_user: + push %esp + call check_pending_exit + add $0x4, %esp + pop %gs /* restore from stack_frame_t structure */ + pop %fs + pop %es + pop %ds + popa + iret + +.global switch_stack_cleanup +.type switch_stack_cleanup, %function +switch_stack_cleanup: + mov 0x8(%esp), %eax + mov 0x4(%esp), %esp + push %eax + call cleanup_dead_thread + add $0x4, %esp + pop %ebp + pop %ebx + popf + ret |
