mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +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
3 changed files with 38 additions and 46 deletions
|
@ -62,40 +62,38 @@ asm(
|
||||||
" add $0x4, %esp\n"
|
" add $0x4, %esp\n"
|
||||||
" iret\n");
|
" iret\n");
|
||||||
|
|
||||||
#define EH_ENTRY(ec) \
|
#define EH_ENTRY(ec) \
|
||||||
extern "C" void exception_##ec##_handler(RegisterDump&); \
|
extern "C" void exception_##ec##_handler(RegisterDump); \
|
||||||
extern "C" void exception_##ec##_entry(); \
|
extern "C" void exception_##ec##_entry(); \
|
||||||
asm( \
|
asm( \
|
||||||
".globl exception_" #ec "_entry\n" \
|
".globl exception_" #ec "_entry\n" \
|
||||||
"exception_" #ec "_entry: \n" \
|
"exception_" #ec "_entry: \n" \
|
||||||
" pusha\n" \
|
" pusha\n" \
|
||||||
" pushw %ds\n" \
|
" pushw %ds\n" \
|
||||||
" pushw %es\n" \
|
" pushw %es\n" \
|
||||||
" pushw %fs\n" \
|
" pushw %fs\n" \
|
||||||
" pushw %gs\n" \
|
" pushw %gs\n" \
|
||||||
" pushw %ss\n" \
|
" pushw %ss\n" \
|
||||||
" pushw %ss\n" \
|
" pushw %ss\n" \
|
||||||
" pushw %ss\n" \
|
" pushw %ss\n" \
|
||||||
" pushw %ss\n" \
|
" pushw %ss\n" \
|
||||||
" pushw %ss\n" \
|
" pushw %ss\n" \
|
||||||
" popw %ds\n" \
|
" popw %ds\n" \
|
||||||
" popw %es\n" \
|
" popw %es\n" \
|
||||||
" popw %fs\n" \
|
" popw %fs\n" \
|
||||||
" popw %gs\n" \
|
" popw %gs\n" \
|
||||||
" pushl %esp\n" \
|
" call exception_" #ec "_handler\n" \
|
||||||
" call exception_" #ec "_handler\n" \
|
" popw %gs\n" \
|
||||||
" add $4, %esp\n" \
|
" popw %gs\n" \
|
||||||
" popw %gs\n" \
|
" popw %fs\n" \
|
||||||
" popw %gs\n" \
|
" popw %es\n" \
|
||||||
" popw %fs\n" \
|
" popw %ds\n" \
|
||||||
" popw %es\n" \
|
" popa\n" \
|
||||||
" popw %ds\n" \
|
" add $0x4, %esp\n" \
|
||||||
" popa\n" \
|
|
||||||
" add $0x4, %esp\n" \
|
|
||||||
" iret\n");
|
" iret\n");
|
||||||
|
|
||||||
#define EH_ENTRY_NO_CODE(ec) \
|
#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(); \
|
extern "C" void exception_##ec##_entry(); \
|
||||||
asm( \
|
asm( \
|
||||||
".globl exception_" #ec "_entry\n" \
|
".globl exception_" #ec "_entry\n" \
|
||||||
|
@ -115,9 +113,7 @@ asm(
|
||||||
" popw %es\n" \
|
" popw %es\n" \
|
||||||
" popw %fs\n" \
|
" popw %fs\n" \
|
||||||
" popw %gs\n" \
|
" popw %gs\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" \
|
||||||
|
@ -186,26 +182,26 @@ static void handle_crash(RegisterDump& regs, const char* description, int signal
|
||||||
}
|
}
|
||||||
|
|
||||||
EH_ENTRY_NO_CODE(6);
|
EH_ENTRY_NO_CODE(6);
|
||||||
void exception_6_handler(RegisterDump& regs)
|
void exception_6_handler(RegisterDump regs)
|
||||||
{
|
{
|
||||||
handle_crash(regs, "Illegal instruction", SIGILL);
|
handle_crash(regs, "Illegal instruction", SIGILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
EH_ENTRY_NO_CODE(0);
|
EH_ENTRY_NO_CODE(0);
|
||||||
void exception_0_handler(RegisterDump& regs)
|
void exception_0_handler(RegisterDump regs)
|
||||||
{
|
{
|
||||||
handle_crash(regs, "Division by zero", SIGFPE);
|
handle_crash(regs, "Division by zero", SIGFPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
EH_ENTRY(13);
|
EH_ENTRY(13);
|
||||||
void exception_13_handler(RegisterDump& regs)
|
void exception_13_handler(RegisterDump regs)
|
||||||
{
|
{
|
||||||
handle_crash(regs, "General protection fault", SIGSEGV);
|
handle_crash(regs, "General protection fault", SIGSEGV);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7: FPU not available exception
|
// 7: FPU not available exception
|
||||||
EH_ENTRY_NO_CODE(7);
|
EH_ENTRY_NO_CODE(7);
|
||||||
void exception_7_handler(RegisterDump& regs)
|
void exception_7_handler(RegisterDump regs)
|
||||||
{
|
{
|
||||||
(void)regs;
|
(void)regs;
|
||||||
|
|
||||||
|
@ -237,7 +233,7 @@ void exception_7_handler(RegisterDump& regs)
|
||||||
|
|
||||||
// 14: Page Fault
|
// 14: Page Fault
|
||||||
EH_ENTRY(14);
|
EH_ENTRY(14);
|
||||||
void exception_14_handler(RegisterDump& regs)
|
void exception_14_handler(RegisterDump regs)
|
||||||
{
|
{
|
||||||
ASSERT(current);
|
ASSERT(current);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#define IRQ_TIMER 0
|
#define IRQ_TIMER 0
|
||||||
|
|
||||||
extern "C" void timer_interrupt_entry();
|
extern "C" void timer_interrupt_entry();
|
||||||
extern "C" void timer_interrupt_handler(RegisterDump&);
|
extern "C" void timer_interrupt_handler(RegisterDump);
|
||||||
|
|
||||||
asm(
|
asm(
|
||||||
".globl timer_interrupt_entry \n"
|
".globl timer_interrupt_entry \n"
|
||||||
|
@ -27,9 +27,7 @@ asm(
|
||||||
" popw %es\n"
|
" popw %es\n"
|
||||||
" popw %fs\n"
|
" popw %fs\n"
|
||||||
" popw %gs\n"
|
" popw %gs\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"
|
||||||
|
@ -42,7 +40,7 @@ asm(
|
||||||
static u32 s_ticks_this_second;
|
static u32 s_ticks_this_second;
|
||||||
static u32 s_seconds_since_boot;
|
static u32 s_seconds_since_boot;
|
||||||
|
|
||||||
void timer_interrupt_handler(RegisterDump& regs)
|
void timer_interrupt_handler(RegisterDump regs)
|
||||||
{
|
{
|
||||||
IRQHandlerScope scope(IRQ_TIMER);
|
IRQHandlerScope scope(IRQ_TIMER);
|
||||||
if (++s_ticks_this_second >= TICKS_PER_SECOND) {
|
if (++s_ticks_this_second >= TICKS_PER_SECOND) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <Kernel/Scheduler.h>
|
#include <Kernel/Scheduler.h>
|
||||||
#include <Kernel/Syscall.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 "C" void syscall_trap_handler();
|
||||||
extern volatile RegisterDump* syscallRegDump;
|
extern volatile RegisterDump* syscallRegDump;
|
||||||
|
|
||||||
|
@ -28,9 +28,7 @@ asm(
|
||||||
" popw %es\n"
|
" popw %es\n"
|
||||||
" popw %fs\n"
|
" popw %fs\n"
|
||||||
" popw %gs\n"
|
" popw %gs\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"
|
||||||
|
@ -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();
|
current->process().big_lock().lock();
|
||||||
u32 function = regs.eax;
|
u32 function = regs.eax;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue