1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 01:48:13 +00:00

Kernel: Tidy up kernel entry points a little bit

Now that we can see the kernel entry points all the time in profiles,
let's tweak the names a little bit and switch to named exceptions.
This commit is contained in:
Andreas Kling 2019-12-14 16:09:07 +01:00
parent e4267020c4
commit e49d6cc7e9
2 changed files with 82 additions and 82 deletions

View file

@ -62,12 +62,12 @@ asm(
" add $0x4, %esp\n"
" iret\n");
#define EH_ENTRY(ec) \
extern "C" void exception_##ec##_handler(RegisterDump); \
extern "C" void exception_##ec##_entry(); \
#define EH_ENTRY(ec, title) \
extern "C" void title##_asm_entry(); \
extern "C" void title##_handler(RegisterDump); \
asm( \
".globl exception_" #ec "_entry\n" \
"exception_" #ec "_entry: \n" \
".globl " #title "_asm_entry\n" \
"" #title "_asm_entry: \n" \
" pusha\n" \
" pushw %ds\n" \
" pushw %es\n" \
@ -83,7 +83,7 @@ asm(
" popw %fs\n" \
" popw %gs\n" \
" cld\n" \
" call exception_" #ec "_handler\n" \
" call " #title "_handler\n" \
" popw %gs\n" \
" popw %gs\n" \
" popw %fs\n" \
@ -93,12 +93,12 @@ asm(
" add $0x4, %esp\n" \
" iret\n");
#define EH_ENTRY_NO_CODE(ec) \
extern "C" void exception_##ec##_handler(RegisterDump); \
extern "C" void exception_##ec##_entry(); \
#define EH_ENTRY_NO_CODE(ec, title) \
extern "C" void title##_handler(RegisterDump); \
extern "C" void title##_asm_entry(); \
asm( \
".globl exception_" #ec "_entry\n" \
"exception_" #ec "_entry: \n" \
".globl " #title "_asm_entry\n" \
"" #title "_asm_entry: \n" \
" pushl $0x0\n" \
" pusha\n" \
" pushw %ds\n" \
@ -115,7 +115,7 @@ asm(
" popw %fs\n" \
" popw %gs\n" \
" cld\n" \
" call exception_" #ec "_handler\n" \
" call " #title "_handler\n" \
" popw %gs\n" \
" popw %gs\n" \
" popw %fs\n" \
@ -184,27 +184,27 @@ void handle_crash(RegisterDump& regs, const char* description, int signal)
current->process().crash(signal, regs.eip);
}
EH_ENTRY_NO_CODE(6);
void exception_6_handler(RegisterDump regs)
EH_ENTRY_NO_CODE(6, illegal_instruction);
void illegal_instruction_handler(RegisterDump regs)
{
handle_crash(regs, "Illegal instruction", SIGILL);
}
EH_ENTRY_NO_CODE(0);
void exception_0_handler(RegisterDump regs)
EH_ENTRY_NO_CODE(0, divide_error);
void divide_error_handler(RegisterDump regs)
{
handle_crash(regs, "Division by zero", SIGFPE);
handle_crash(regs, "Divide error", SIGFPE);
}
EH_ENTRY(13);
void exception_13_handler(RegisterDump regs)
EH_ENTRY(13, general_protection_fault);
void general_protection_fault_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)
EH_ENTRY_NO_CODE(7, fpu_exception);
void fpu_exception_handler(RegisterDump regs)
{
(void)regs;
@ -235,8 +235,8 @@ void exception_7_handler(RegisterDump regs)
}
// 14: Page Fault
EH_ENTRY(14);
void exception_14_handler(RegisterDump regs)
EH_ENTRY(14, page_fault);
void page_fault_handler(RegisterDump regs)
{
ASSERT(current);
@ -457,21 +457,21 @@ void idt_init()
for (u8 i = 0xff; i > 0x10; --i)
register_interrupt_handler(i, unimp_trap);
register_interrupt_handler(0x00, exception_0_entry);
register_interrupt_handler(0x00, divide_error_asm_entry);
register_interrupt_handler(0x01, _exception1);
register_interrupt_handler(0x02, _exception2);
register_interrupt_handler(0x03, _exception3);
register_interrupt_handler(0x04, _exception4);
register_interrupt_handler(0x05, _exception5);
register_interrupt_handler(0x06, exception_6_entry);
register_interrupt_handler(0x07, exception_7_entry);
register_interrupt_handler(0x06, illegal_instruction_asm_entry);
register_interrupt_handler(0x07, fpu_exception_asm_entry);
register_interrupt_handler(0x08, _exception8);
register_interrupt_handler(0x09, _exception9);
register_interrupt_handler(0x0a, _exception10);
register_interrupt_handler(0x0b, _exception11);
register_interrupt_handler(0x0c, _exception12);
register_interrupt_handler(0x0d, exception_13_entry);
register_interrupt_handler(0x0e, exception_14_entry);
register_interrupt_handler(0x0d, general_protection_fault_asm_entry);
register_interrupt_handler(0x0e, page_fault_asm_entry);
register_interrupt_handler(0x0f, _exception15);
register_interrupt_handler(0x10, _exception16);

View file

@ -4,12 +4,12 @@
#include <Kernel/Syscall.h>
#include <Kernel/VM/MemoryManager.h>
extern "C" void syscall_trap_entry(RegisterDump);
extern "C" void syscall_trap_handler();
extern "C" void syscall_handler(RegisterDump);
extern "C" void syscall_asm_entry();
asm(
".globl syscall_trap_handler \n"
"syscall_trap_handler:\n"
".globl syscall_asm_entry\n"
"syscall_asm_entry:\n"
" pushl $0x0\n"
" pusha\n"
" pushw %ds\n"
@ -26,7 +26,7 @@ asm(
" popw %fs\n"
" popw %gs\n"
" cld\n"
" call syscall_trap_entry\n"
" call syscall_handler\n"
" popw %gs\n"
" popw %gs\n"
" popw %fs\n"
@ -42,7 +42,7 @@ static int handle(RegisterDump&, u32 function, u32 arg1, u32 arg2, u32 arg3);
void initialize()
{
register_user_callable_interrupt_handler(0x82, syscall_trap_handler);
register_user_callable_interrupt_handler(0x82, syscall_asm_entry);
kprintf("Syscall: int 0x82 handler installed\n");
}
@ -95,7 +95,7 @@ int handle(RegisterDump& regs, u32 function, u32 arg1, u32 arg2, u32 arg3)
}
void syscall_trap_entry(RegisterDump regs)
void syscall_handler(RegisterDump regs)
{
auto& process = current->process();