1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 09:47:35 +00:00

Kernel: Don't build with -mregparm=3

It was really confusing to have different calling conventions in kernel
and userspace. Also this has prevented us from linking with libgcc.
This commit is contained in:
Andreas Kling 2019-11-06 13:03:45 +01:00
parent 01b21e5e05
commit 1c6f8d3cbd
6 changed files with 54 additions and 52 deletions

View file

@ -54,8 +54,9 @@ start:
call init call init
mov $exit_message, %eax pushl $exit_message
call kprintf call kprintf
add $4, %esp
cli cli

View file

@ -1,7 +1,7 @@
#include "APIC.h"
#include "Assertions.h" #include "Assertions.h"
#include "IRQHandler.h" #include "IRQHandler.h"
#include "PIC.h" #include "PIC.h"
#include "APIC.h"
#include "Process.h" #include "Process.h"
#include "Scheduler.h" #include "Scheduler.h"
#include <AK/Types.h> #include <AK/Types.h>
@ -82,8 +82,9 @@ asm(
" popw %es\n" \ " popw %es\n" \
" popw %fs\n" \ " popw %fs\n" \
" popw %gs\n" \ " popw %gs\n" \
" mov %esp, %eax\n" \ " pushl %esp\n" \
" call exception_" #ec "_handler\n" \ " call exception_" #ec "_handler\n" \
" add $4, %esp\n" \
" popw %gs\n" \ " popw %gs\n" \
" popw %gs\n" \ " popw %gs\n" \
" popw %fs\n" \ " popw %fs\n" \
@ -114,8 +115,9 @@ asm(
" popw %es\n" \ " popw %es\n" \
" popw %fs\n" \ " popw %fs\n" \
" popw %gs\n" \ " popw %gs\n" \
" mov %esp, %eax\n" \ " pushl %esp\n" \
" call exception_" #ec "_handler\n" \ " call exception_" #ec "_handler\n" \
" add $4, %esp\n" \
" popw %gs\n" \ " popw %gs\n" \
" popw %gs\n" \ " popw %gs\n" \
" popw %fs\n" \ " popw %fs\n" \
@ -265,7 +267,7 @@ void exception_14_handler(RegisterDump& regs)
auto response = MM.handle_page_fault(PageFault(regs.exception_code, VirtualAddress(fault_address))); auto response = MM.handle_page_fault(PageFault(regs.exception_code, VirtualAddress(fault_address)));
if (response == PageFaultResponse::ShouldCrash) { if (response == PageFaultResponse::ShouldCrash) {
if(current->has_signal_handler(SIGSEGV)){ if (current->has_signal_handler(SIGSEGV)) {
current->send_urgent_signal_to_self(SIGSEGV); current->send_urgent_signal_to_self(SIGSEGV);
return; return;
} }

View file

@ -251,16 +251,15 @@ inline u32 read_fs_u32(u32 offset)
u32 val; u32 val;
asm volatile( asm volatile(
"movl %%fs:%a[off], %k[val]" "movl %%fs:%a[off], %k[val]"
: [val] "=r" (val) : [ val ] "=r"(val)
: [off] "ir" (offset)); : [ off ] "ir"(offset));
return val; return val;
} }
inline void write_fs_u32(u32 offset, u32 val) inline void write_fs_u32(u32 offset, u32 val)
{ {
asm volatile( asm volatile(
"movl %k[val], %%fs:%a[off]" "movl %k[val], %%fs:%a[off]" ::[off] "ir"(offset), [ val ] "ir"(val)
:: [off] "ir" (offset), [val] "ir" (val)
: "memory"); : "memory");
} }
@ -383,7 +382,6 @@ struct [[gnu::packed]] RegisterDump
u16 ss_if_crossRing; u16 ss_if_crossRing;
}; };
struct [[gnu::aligned(16)]] FPUState struct [[gnu::aligned(16)]] FPUState
{ {
u8 buffer[512]; u8 buffer[512];
@ -459,8 +457,8 @@ public:
MSR(const MSR&) = delete; MSR(const MSR&) = delete;
MSR& operator=(const MSR&) = delete; MSR& operator=(const MSR&) = delete;
MSR(uint32_t msr): MSR(uint32_t msr)
m_msr(msr) : m_msr(msr)
{ {
} }
@ -473,7 +471,6 @@ public:
void set(u32 low, u32 high) void set(u32 low, u32 high)
{ {
asm volatile("wrmsr" asm volatile("wrmsr" ::"a"(low), "d"(high), "c"(m_msr));
:: "a"(low), "d"(high), "c"(m_msr));
} }
}; };

View file

@ -27,8 +27,9 @@ asm(
" popw %es\n" " popw %es\n"
" popw %fs\n" " popw %fs\n"
" popw %gs\n" " popw %gs\n"
" mov %esp, %eax\n" " pushl %esp\n"
" call timer_interrupt_handler\n" " call timer_interrupt_handler\n"
" add $4, %esp\n"
" popw %gs\n" " popw %gs\n"
" popw %gs\n" " popw %gs\n"
" popw %fs\n" " popw %fs\n"

View file

@ -107,7 +107,7 @@ CXX_OBJS = $(KERNEL_OBJS) $(VFS_OBJS) $(AK_OBJS)
OBJS = $(CXX_OBJS) Arch/i386/Boot/boot.ao OBJS = $(CXX_OBJS) Arch/i386/Boot/boot.ao
KERNEL = kernel KERNEL = kernel
CXXFLAGS += -ffreestanding -mregparm=3 -mno-80387 -mno-mmx -mno-sse -mno-sse2 CXXFLAGS += -ffreestanding -mno-80387 -mno-mmx -mno-sse -mno-sse2
CXXFLAGS += -nostdlib -nostdinc -nostdinc++ CXXFLAGS += -nostdlib -nostdinc -nostdinc++
CXXFLAGS += -I../Toolchain/Local/i686-pc-serenity/include/c++/8.3.0/ CXXFLAGS += -I../Toolchain/Local/i686-pc-serenity/include/c++/8.3.0/
CXXFLAGS += -I../Toolchain/Local/i686-pc-serenity/include/c++/8.3.0/i686-pc-serenity/ CXXFLAGS += -I../Toolchain/Local/i686-pc-serenity/include/c++/8.3.0/i686-pc-serenity/

View file

@ -28,8 +28,9 @@ asm(
" popw %es\n" " popw %es\n"
" popw %fs\n" " popw %fs\n"
" popw %gs\n" " popw %gs\n"
" mov %esp, %eax\n" " pushl %esp\n"
" call syscall_trap_entry\n" " call syscall_trap_entry\n"
" add $4, %esp\n"
" popw %gs\n" " popw %gs\n"
" popw %gs\n" " popw %gs\n"
" popw %fs\n" " popw %fs\n"