diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-05-28 16:08:51 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-05-28 19:52:22 +0100 |
commit | 4fca9ee060fd761f006f751b3ab79875a4c526f0 (patch) | |
tree | 99727be49ec5718a93b667e778ae284fffa06111 | |
parent | b06d01f04057674d1ae05a1940b30affcb82e844 (diff) | |
download | serenity-4fca9ee060fd761f006f751b3ab79875a4c526f0.zip |
Kernel: Allow building the kernel with -O0
Unfortunately the kernel doesn't run with -O0 but at least it can be
successfully built with this change.
-rw-r--r-- | Kernel/Arch/x86/Interrupts.h | 18 | ||||
-rw-r--r-- | Kernel/Syscall.cpp | 70 |
2 files changed, 48 insertions, 40 deletions
diff --git a/Kernel/Arch/x86/Interrupts.h b/Kernel/Arch/x86/Interrupts.h index d9d9b8285b..63a666f33d 100644 --- a/Kernel/Arch/x86/Interrupts.h +++ b/Kernel/Arch/x86/Interrupts.h @@ -15,13 +15,17 @@ class GenericInterruptHandeler; extern "C" void interrupt_common_asm_entry(); -#define GENERATE_GENERIC_INTERRUPT_HANDLER_ASM_ENTRY(isr_number) \ - extern "C" void interrupt_##isr_number##_asm_entry(); \ - asm(".globl interrupt_" #isr_number "_asm_entry\n" \ - "interrupt_" #isr_number "_asm_entry:\n" \ - " pushw $" #isr_number "\n" \ - " pushw $0\n" \ - " jmp interrupt_common_asm_entry\n"); +#define GENERATE_GENERIC_INTERRUPT_HANDLER_ASM_ENTRY(isr_number) \ + extern "C" void interrupt_##isr_number##_asm_entry(); \ + static void interrupt_##isr_number##_asm_entry_dummy() __attribute__((used)); \ + NEVER_INLINE void interrupt_##isr_number##_asm_entry_dummy() \ + { \ + asm(".globl interrupt_" #isr_number "_asm_entry\n" \ + "interrupt_" #isr_number "_asm_entry:\n" \ + " pushw $" #isr_number "\n" \ + " pushw $0\n" \ + " jmp interrupt_common_asm_entry\n"); \ + } void register_interrupt_handler(u8 number, void (*handler)()); void register_user_callable_interrupt_handler(u8 number, void (*handler)()); diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index 77efffc0c7..49da400045 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -16,43 +16,47 @@ namespace Kernel { extern "C" void syscall_handler(TrapFrame*) __attribute__((used)); extern "C" void syscall_asm_entry(); -// clang-format off +static void syscall_asm_entry_dummy() __attribute__((used)); +NEVER_INLINE void syscall_asm_entry_dummy() +{ + // clang-format off #if ARCH(I386) -asm( - ".globl syscall_asm_entry\n" - "syscall_asm_entry:\n" - " pushl $0x0\n" - " pusha\n" - " pushl %ds\n" - " pushl %es\n" - " pushl %fs\n" - " pushl %gs\n" - " pushl %ss\n" - " mov $" __STRINGIFY(GDT_SELECTOR_DATA0) ", %ax\n" - " mov %ax, %ds\n" - " mov %ax, %es\n" - " mov $" __STRINGIFY(GDT_SELECTOR_PROC) ", %ax\n" - " mov %ax, %fs\n" - " cld\n" - " xor %esi, %esi\n" - " xor %edi, %edi\n" - " pushl %esp \n" // set TrapFrame::regs - " subl $" __STRINGIFY(TRAP_FRAME_SIZE - 4) ", %esp \n" - " movl %esp, %ebx \n" - " pushl %ebx \n" // push pointer to TrapFrame - " call enter_trap_no_irq \n" - " movl %ebx, 0(%esp) \n" // push pointer to TrapFrame - " call syscall_handler \n" - " movl %ebx, 0(%esp) \n" // push pointer to TrapFrame - " jmp common_trap_exit \n"); + asm( + ".globl syscall_asm_entry\n" + "syscall_asm_entry:\n" + " pushl $0x0\n" + " pusha\n" + " pushl %ds\n" + " pushl %es\n" + " pushl %fs\n" + " pushl %gs\n" + " pushl %ss\n" + " mov $" __STRINGIFY(GDT_SELECTOR_DATA0) ", %ax\n" + " mov %ax, %ds\n" + " mov %ax, %es\n" + " mov $" __STRINGIFY(GDT_SELECTOR_PROC) ", %ax\n" + " mov %ax, %fs\n" + " cld\n" + " xor %esi, %esi\n" + " xor %edi, %edi\n" + " pushl %esp \n" // set TrapFrame::regs + " subl $" __STRINGIFY(TRAP_FRAME_SIZE - 4) ", %esp \n" + " movl %esp, %ebx \n" + " pushl %ebx \n" // push pointer to TrapFrame + " call enter_trap_no_irq \n" + " movl %ebx, 0(%esp) \n" // push pointer to TrapFrame + " call syscall_handler \n" + " movl %ebx, 0(%esp) \n" // push pointer to TrapFrame + " jmp common_trap_exit \n"); #elif ARCH(X86_64) asm( - ".globl syscall_asm_entry\n" - "syscall_asm_entry:\n" - " cli\n" - " hlt\n"); + ".globl syscall_asm_entry\n" + "syscall_asm_entry:\n" + " cli\n" + " hlt\n"); #endif -// clang-format on + // clang-format on +} namespace Syscall { |