summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-11-06 13:15:55 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-06 13:15:55 +0100
commit9a4b117f48afde89b7f464badc224178289d7242 (patch)
tree1555df4cd7b3ba2c58dce3b5e72f54a8d916c368 /Kernel
parent349d2ec1c2605a5cc0e792b073d6bf9f13ebbfe8 (diff)
downloadserenity-9a4b117f48afde89b7f464badc224178289d7242.zip
Kernel: Simplify kernel entry points slightly
It was silly to push the address of the stack pointer when we can also just change the callee argument to be a value type.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Arch/i386/CPU.cpp72
-rw-r--r--Kernel/Arch/i386/PIT.cpp6
-rw-r--r--Kernel/Syscall.cpp6
3 files changed, 38 insertions, 46 deletions
diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp
index ab98e63454..738dcf35b3 100644
--- a/Kernel/Arch/i386/CPU.cpp
+++ b/Kernel/Arch/i386/CPU.cpp
@@ -62,40 +62,38 @@ asm(
" add $0x4, %esp\n"
" iret\n");
-#define EH_ENTRY(ec) \
- extern "C" void exception_##ec##_handler(RegisterDump&); \
- extern "C" void exception_##ec##_entry(); \
- asm( \
- ".globl exception_" #ec "_entry\n" \
- "exception_" #ec "_entry: \n" \
- " pusha\n" \
- " pushw %ds\n" \
- " pushw %es\n" \
- " pushw %fs\n" \
- " pushw %gs\n" \
- " pushw %ss\n" \
- " pushw %ss\n" \
- " pushw %ss\n" \
- " pushw %ss\n" \
- " pushw %ss\n" \
- " popw %ds\n" \
- " popw %es\n" \
- " popw %fs\n" \
- " popw %gs\n" \
- " pushl %esp\n" \
- " call exception_" #ec "_handler\n" \
- " add $4, %esp\n" \
- " popw %gs\n" \
- " popw %gs\n" \
- " popw %fs\n" \
- " popw %es\n" \
- " popw %ds\n" \
- " popa\n" \
- " add $0x4, %esp\n" \
+#define EH_ENTRY(ec) \
+ extern "C" void exception_##ec##_handler(RegisterDump); \
+ extern "C" void exception_##ec##_entry(); \
+ asm( \
+ ".globl exception_" #ec "_entry\n" \
+ "exception_" #ec "_entry: \n" \
+ " pusha\n" \
+ " pushw %ds\n" \
+ " pushw %es\n" \
+ " pushw %fs\n" \
+ " pushw %gs\n" \
+ " pushw %ss\n" \
+ " pushw %ss\n" \
+ " pushw %ss\n" \
+ " pushw %ss\n" \
+ " pushw %ss\n" \
+ " popw %ds\n" \
+ " popw %es\n" \
+ " popw %fs\n" \
+ " popw %gs\n" \
+ " call exception_" #ec "_handler\n" \
+ " popw %gs\n" \
+ " popw %gs\n" \
+ " popw %fs\n" \
+ " popw %es\n" \
+ " popw %ds\n" \
+ " popa\n" \
+ " add $0x4, %esp\n" \
" iret\n");
#define EH_ENTRY_NO_CODE(ec) \
- extern "C" void exception_##ec##_handler(RegisterDump&); \
+ extern "C" void exception_##ec##_handler(RegisterDump); \
extern "C" void exception_##ec##_entry(); \
asm( \
".globl exception_" #ec "_entry\n" \
@@ -115,9 +113,7 @@ asm(
" popw %es\n" \
" popw %fs\n" \
" popw %gs\n" \
- " pushl %esp\n" \
" call exception_" #ec "_handler\n" \
- " add $4, %esp\n" \
" popw %gs\n" \
" popw %gs\n" \
" popw %fs\n" \
@@ -186,26 +182,26 @@ static void handle_crash(RegisterDump& regs, const char* description, int signal
}
EH_ENTRY_NO_CODE(6);
-void exception_6_handler(RegisterDump& regs)
+void exception_6_handler(RegisterDump regs)
{
handle_crash(regs, "Illegal instruction", SIGILL);
}
EH_ENTRY_NO_CODE(0);
-void exception_0_handler(RegisterDump& regs)
+void exception_0_handler(RegisterDump regs)
{
handle_crash(regs, "Division by zero", SIGFPE);
}
EH_ENTRY(13);
-void exception_13_handler(RegisterDump& regs)
+void exception_13_handler(RegisterDump regs)
{
handle_crash(regs, "General protection fault", SIGSEGV);
}
// 7: FPU not available exception
EH_ENTRY_NO_CODE(7);
-void exception_7_handler(RegisterDump& regs)
+void exception_7_handler(RegisterDump regs)
{
(void)regs;
@@ -237,7 +233,7 @@ void exception_7_handler(RegisterDump& regs)
// 14: Page Fault
EH_ENTRY(14);
-void exception_14_handler(RegisterDump& regs)
+void exception_14_handler(RegisterDump regs)
{
ASSERT(current);
diff --git a/Kernel/Arch/i386/PIT.cpp b/Kernel/Arch/i386/PIT.cpp
index 1890dac617..b4861c3066 100644
--- a/Kernel/Arch/i386/PIT.cpp
+++ b/Kernel/Arch/i386/PIT.cpp
@@ -7,7 +7,7 @@
#define IRQ_TIMER 0
extern "C" void timer_interrupt_entry();
-extern "C" void timer_interrupt_handler(RegisterDump&);
+extern "C" void timer_interrupt_handler(RegisterDump);
asm(
".globl timer_interrupt_entry \n"
@@ -27,9 +27,7 @@ asm(
" popw %es\n"
" popw %fs\n"
" popw %gs\n"
- " pushl %esp\n"
" call timer_interrupt_handler\n"
- " add $4, %esp\n"
" popw %gs\n"
" popw %gs\n"
" popw %fs\n"
@@ -42,7 +40,7 @@ asm(
static u32 s_ticks_this_second;
static u32 s_seconds_since_boot;
-void timer_interrupt_handler(RegisterDump& regs)
+void timer_interrupt_handler(RegisterDump regs)
{
IRQHandlerScope scope(IRQ_TIMER);
if (++s_ticks_this_second >= TICKS_PER_SECOND) {
diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp
index aa581dc9fc..a055e79510 100644
--- a/Kernel/Syscall.cpp
+++ b/Kernel/Syscall.cpp
@@ -6,7 +6,7 @@
#include <Kernel/Scheduler.h>
#include <Kernel/Syscall.h>
-extern "C" void syscall_trap_entry(RegisterDump&);
+extern "C" void syscall_trap_entry(RegisterDump);
extern "C" void syscall_trap_handler();
extern volatile RegisterDump* syscallRegDump;
@@ -28,9 +28,7 @@ asm(
" popw %es\n"
" popw %fs\n"
" popw %gs\n"
- " pushl %esp\n"
" call syscall_trap_entry\n"
- " add $4, %esp\n"
" popw %gs\n"
" popw %gs\n"
" popw %fs\n"
@@ -329,7 +327,7 @@ static u32 handle(RegisterDump& regs, u32 function, u32 arg1, u32 arg2, u32 arg3
}
-void syscall_trap_entry(RegisterDump& regs)
+void syscall_trap_entry(RegisterDump regs)
{
current->process().big_lock().lock();
u32 function = regs.eax;