From d36454b3244a37d861a895b9fe01d9ec05cadec7 Mon Sep 17 00:00:00 2001 From: Pawel Wieczorkiewicz Date: Sun, 27 Aug 2023 17:09:04 +0200 Subject: [PATCH] arch,entry: cleanup: rearrange code Signed-off-by: Pawel Wieczorkiewicz --- arch/x86/entry.S | 70 ++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/arch/x86/entry.S b/arch/x86/entry.S index 62661c5e..16abb335 100644 --- a/arch/x86/entry.S +++ b/arch/x86/entry.S @@ -92,6 +92,21 @@ ENTRY(asm_interrupt_handler_\sym) END_FUNC(asm_interrupt_handler_\sym) .endm +ENTRY(handle_exception) + cld + SAVE_ALL_REGS + + mov %_ASM_SP, %_ASM_DI + call do_exception + + RESTORE_ALL_REGS + + add $8, %_ASM_SP + + enter_to_usermode + IRET +END_FUNC(handle_exception) + exception_handler DE X86_EX_DE 0 exception_handler DB X86_EX_DB 0 exception_handler NMI X86_EX_NMI 0 @@ -115,21 +130,6 @@ exception_handler XM X86_EX_XM 0 exception_handler VE X86_EX_VE 0 exception_handler SE X86_EX_SE 1 -ENTRY(handle_exception) - cld - SAVE_ALL_REGS - - mov %_ASM_SP, %_ASM_DI - call do_exception - - RESTORE_ALL_REGS - - add $8, %_ASM_SP - - enter_to_usermode - IRET -END_FUNC(handle_exception) - interrupt_handler timer timer_interrupt_handler interrupt_handler uart uart_interrupt_handler interrupt_handler keyboard keyboard_interrupt_handler @@ -137,6 +137,26 @@ interrupt_handler keyboard keyboard_interrupt_handler interrupt_handler acpi acpi_interrupt_handler #endif +ENTRY(syscall_exit) + POPF + + /* Save exit code to return value register (AX) */ + mov %_ASM_SI, cpu_regs_ax(%_ASM_SP) + RESTORE_ALL_REGS + + ret +END_FUNC(syscall_exit) + +ENTRY(terminate_user_task) + SWITCH_STACK + POPF + + movl $-EFAULT, cpu_regs_ax(%_ASM_SP) + RESTORE_ALL_REGS + + ret +END_FUNC(terminate_user_task) + ENTRY(enter_usermode) /* FIXME: Add 32-bit support */ @@ -164,26 +184,6 @@ ENTRY(enter_usermode) IRET END_FUNC(enter_usermode) -ENTRY(syscall_exit) - POPF - - /* Save exit code to return value register (AX) */ - mov %_ASM_SI, cpu_regs_ax(%_ASM_SP) - RESTORE_ALL_REGS - - ret -END_FUNC(syscall_exit) - -ENTRY(terminate_user_task) - SWITCH_STACK - POPF - - movl $-EFAULT, cpu_regs_ax(%_ASM_SP) - RESTORE_ALL_REGS - - ret -END_FUNC(terminate_user_task) - .align PAGE_SIZE ENTRY(syscall_handler_entry) SAVE_CALLEE_SAVED_REGS