mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:57:44 +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:
parent
e4267020c4
commit
e49d6cc7e9
2 changed files with 82 additions and 82 deletions
|
@ -62,67 +62,67 @@ asm(
|
||||||
" add $0x4, %esp\n"
|
" add $0x4, %esp\n"
|
||||||
" iret\n");
|
" iret\n");
|
||||||
|
|
||||||
#define EH_ENTRY(ec) \
|
#define EH_ENTRY(ec, title) \
|
||||||
extern "C" void exception_##ec##_handler(RegisterDump); \
|
extern "C" void title##_asm_entry(); \
|
||||||
extern "C" void exception_##ec##_entry(); \
|
extern "C" void title##_handler(RegisterDump); \
|
||||||
asm( \
|
asm( \
|
||||||
".globl exception_" #ec "_entry\n" \
|
".globl " #title "_asm_entry\n" \
|
||||||
"exception_" #ec "_entry: \n" \
|
"" #title "_asm_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" \
|
||||||
" cld\n" \
|
" cld\n" \
|
||||||
" call exception_" #ec "_handler\n" \
|
" call " #title "_handler\n" \
|
||||||
" popw %gs\n" \
|
" popw %gs\n" \
|
||||||
" popw %gs\n" \
|
" popw %gs\n" \
|
||||||
" popw %fs\n" \
|
" popw %fs\n" \
|
||||||
" popw %es\n" \
|
" popw %es\n" \
|
||||||
" popw %ds\n" \
|
" popw %ds\n" \
|
||||||
" popa\n" \
|
" popa\n" \
|
||||||
" add $0x4, %esp\n" \
|
" add $0x4, %esp\n" \
|
||||||
" iret\n");
|
" iret\n");
|
||||||
|
|
||||||
#define EH_ENTRY_NO_CODE(ec) \
|
#define EH_ENTRY_NO_CODE(ec, title) \
|
||||||
extern "C" void exception_##ec##_handler(RegisterDump); \
|
extern "C" void title##_handler(RegisterDump); \
|
||||||
extern "C" void exception_##ec##_entry(); \
|
extern "C" void title##_asm_entry(); \
|
||||||
asm( \
|
asm( \
|
||||||
".globl exception_" #ec "_entry\n" \
|
".globl " #title "_asm_entry\n" \
|
||||||
"exception_" #ec "_entry: \n" \
|
"" #title "_asm_entry: \n" \
|
||||||
" pushl $0x0\n" \
|
" pushl $0x0\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" \
|
||||||
" cld\n" \
|
" cld\n" \
|
||||||
" call exception_" #ec "_handler\n" \
|
" call " #title "_handler\n" \
|
||||||
" popw %gs\n" \
|
" popw %gs\n" \
|
||||||
" popw %gs\n" \
|
" popw %gs\n" \
|
||||||
" popw %fs\n" \
|
" popw %fs\n" \
|
||||||
" popw %es\n" \
|
" popw %es\n" \
|
||||||
" popw %ds\n" \
|
" popw %ds\n" \
|
||||||
" popa\n" \
|
" popa\n" \
|
||||||
" add $0x4, %esp\n" \
|
" add $0x4, %esp\n" \
|
||||||
" iret\n");
|
" iret\n");
|
||||||
|
|
||||||
static void dump(const RegisterDump& regs)
|
static void dump(const RegisterDump& regs)
|
||||||
|
@ -184,27 +184,27 @@ void handle_crash(RegisterDump& regs, const char* description, int signal)
|
||||||
current->process().crash(signal, regs.eip);
|
current->process().crash(signal, regs.eip);
|
||||||
}
|
}
|
||||||
|
|
||||||
EH_ENTRY_NO_CODE(6);
|
EH_ENTRY_NO_CODE(6, illegal_instruction);
|
||||||
void exception_6_handler(RegisterDump regs)
|
void illegal_instruction_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, divide_error);
|
||||||
void exception_0_handler(RegisterDump regs)
|
void divide_error_handler(RegisterDump regs)
|
||||||
{
|
{
|
||||||
handle_crash(regs, "Division by zero", SIGFPE);
|
handle_crash(regs, "Divide error", SIGFPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
EH_ENTRY(13);
|
EH_ENTRY(13, general_protection_fault);
|
||||||
void exception_13_handler(RegisterDump regs)
|
void general_protection_fault_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, fpu_exception);
|
||||||
void exception_7_handler(RegisterDump regs)
|
void fpu_exception_handler(RegisterDump regs)
|
||||||
{
|
{
|
||||||
(void)regs;
|
(void)regs;
|
||||||
|
|
||||||
|
@ -235,8 +235,8 @@ void exception_7_handler(RegisterDump regs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 14: Page Fault
|
// 14: Page Fault
|
||||||
EH_ENTRY(14);
|
EH_ENTRY(14, page_fault);
|
||||||
void exception_14_handler(RegisterDump regs)
|
void page_fault_handler(RegisterDump regs)
|
||||||
{
|
{
|
||||||
ASSERT(current);
|
ASSERT(current);
|
||||||
|
|
||||||
|
@ -457,21 +457,21 @@ void idt_init()
|
||||||
for (u8 i = 0xff; i > 0x10; --i)
|
for (u8 i = 0xff; i > 0x10; --i)
|
||||||
register_interrupt_handler(i, unimp_trap);
|
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(0x01, _exception1);
|
||||||
register_interrupt_handler(0x02, _exception2);
|
register_interrupt_handler(0x02, _exception2);
|
||||||
register_interrupt_handler(0x03, _exception3);
|
register_interrupt_handler(0x03, _exception3);
|
||||||
register_interrupt_handler(0x04, _exception4);
|
register_interrupt_handler(0x04, _exception4);
|
||||||
register_interrupt_handler(0x05, _exception5);
|
register_interrupt_handler(0x05, _exception5);
|
||||||
register_interrupt_handler(0x06, exception_6_entry);
|
register_interrupt_handler(0x06, illegal_instruction_asm_entry);
|
||||||
register_interrupt_handler(0x07, exception_7_entry);
|
register_interrupt_handler(0x07, fpu_exception_asm_entry);
|
||||||
register_interrupt_handler(0x08, _exception8);
|
register_interrupt_handler(0x08, _exception8);
|
||||||
register_interrupt_handler(0x09, _exception9);
|
register_interrupt_handler(0x09, _exception9);
|
||||||
register_interrupt_handler(0x0a, _exception10);
|
register_interrupt_handler(0x0a, _exception10);
|
||||||
register_interrupt_handler(0x0b, _exception11);
|
register_interrupt_handler(0x0b, _exception11);
|
||||||
register_interrupt_handler(0x0c, _exception12);
|
register_interrupt_handler(0x0c, _exception12);
|
||||||
register_interrupt_handler(0x0d, exception_13_entry);
|
register_interrupt_handler(0x0d, general_protection_fault_asm_entry);
|
||||||
register_interrupt_handler(0x0e, exception_14_entry);
|
register_interrupt_handler(0x0e, page_fault_asm_entry);
|
||||||
register_interrupt_handler(0x0f, _exception15);
|
register_interrupt_handler(0x0f, _exception15);
|
||||||
register_interrupt_handler(0x10, _exception16);
|
register_interrupt_handler(0x10, _exception16);
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
#include <Kernel/Syscall.h>
|
#include <Kernel/Syscall.h>
|
||||||
#include <Kernel/VM/MemoryManager.h>
|
#include <Kernel/VM/MemoryManager.h>
|
||||||
|
|
||||||
extern "C" void syscall_trap_entry(RegisterDump);
|
extern "C" void syscall_handler(RegisterDump);
|
||||||
extern "C" void syscall_trap_handler();
|
extern "C" void syscall_asm_entry();
|
||||||
|
|
||||||
asm(
|
asm(
|
||||||
".globl syscall_trap_handler \n"
|
".globl syscall_asm_entry\n"
|
||||||
"syscall_trap_handler:\n"
|
"syscall_asm_entry:\n"
|
||||||
" pushl $0x0\n"
|
" pushl $0x0\n"
|
||||||
" pusha\n"
|
" pusha\n"
|
||||||
" pushw %ds\n"
|
" pushw %ds\n"
|
||||||
|
@ -26,7 +26,7 @@ asm(
|
||||||
" popw %fs\n"
|
" popw %fs\n"
|
||||||
" popw %gs\n"
|
" popw %gs\n"
|
||||||
" cld\n"
|
" cld\n"
|
||||||
" call syscall_trap_entry\n"
|
" call syscall_handler\n"
|
||||||
" popw %gs\n"
|
" popw %gs\n"
|
||||||
" popw %gs\n"
|
" popw %gs\n"
|
||||||
" popw %fs\n"
|
" popw %fs\n"
|
||||||
|
@ -42,7 +42,7 @@ static int handle(RegisterDump&, u32 function, u32 arg1, u32 arg2, u32 arg3);
|
||||||
|
|
||||||
void initialize()
|
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");
|
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();
|
auto& process = current->process();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue