mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
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.
This commit is contained in:
parent
349d2ec1c2
commit
9a4b117f48
Notes:
sideshowbarker
2024-07-19 11:21:19 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/9a4b117f48a
3 changed files with 38 additions and 46 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue