1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-12 02:30:30 +09:00

Kernel: Rename RegisterDump => RegisterState

This commit is contained in:
Andreas Kling 2020-02-16 00:15:37 +01:00
parent 5507945306
commit 0341ddc5eb
Notes: sideshowbarker 2024-07-19 09:17:41 +09:00
10 changed files with 79 additions and 79 deletions

View file

@ -66,7 +66,7 @@ void gdt_free_entry(u16 entry)
s_gdt_freelist->append(entry); s_gdt_freelist->append(entry);
} }
extern "C" void handle_irq(RegisterDump); extern "C" void handle_irq(RegisterState);
extern "C" void irq_common_asm_entry(); extern "C" void irq_common_asm_entry();
#define GENERATE_IRQ_ASM_ENTRY(irq, isr_number) \ #define GENERATE_IRQ_ASM_ENTRY(irq, isr_number) \
@ -100,60 +100,60 @@ asm(
" add $0x4, %esp\n" " add $0x4, %esp\n"
" iret\n"); " iret\n");
#define EH_ENTRY(ec, title) \ #define EH_ENTRY(ec, title) \
extern "C" void title##_asm_entry(); \ extern "C" void title##_asm_entry(); \
extern "C" void title##_handler(RegisterDump); \ extern "C" void title##_handler(RegisterState); \
asm( \ asm( \
".globl " #title "_asm_entry\n" \ ".globl " #title "_asm_entry\n" \
"" #title "_asm_entry: \n" \ "" #title "_asm_entry: \n" \
" pusha\n" \ " pusha\n" \
" pushl %ds\n" \ " pushl %ds\n" \
" pushl %es\n" \ " pushl %es\n" \
" pushl %fs\n" \ " pushl %fs\n" \
" pushl %gs\n" \ " pushl %gs\n" \
" pushl %ss\n" \ " pushl %ss\n" \
" mov $0x10, %ax\n" \ " mov $0x10, %ax\n" \
" mov %ax, %ds\n" \ " mov %ax, %ds\n" \
" mov %ax, %es\n" \ " mov %ax, %es\n" \
" cld\n" \ " cld\n" \
" call " #title "_handler\n" \ " call " #title "_handler\n" \
" add $0x4, %esp \n" \ " add $0x4, %esp \n" \
" popl %gs\n" \ " popl %gs\n" \
" popl %fs\n" \ " popl %fs\n" \
" popl %es\n" \ " popl %es\n" \
" popl %ds\n" \ " popl %ds\n" \
" popa\n" \ " popa\n" \
" add $0x4, %esp\n" \ " add $0x4, %esp\n" \
" iret\n"); " iret\n");
#define EH_ENTRY_NO_CODE(ec, title) \ #define EH_ENTRY_NO_CODE(ec, title) \
extern "C" void title##_handler(RegisterDump); \ extern "C" void title##_handler(RegisterState); \
extern "C" void title##_asm_entry(); \ extern "C" void title##_asm_entry(); \
asm( \ asm( \
".globl " #title "_asm_entry\n" \ ".globl " #title "_asm_entry\n" \
"" #title "_asm_entry: \n" \ "" #title "_asm_entry: \n" \
" pushl $0x0\n" \ " pushl $0x0\n" \
" pusha\n" \ " pusha\n" \
" pushl %ds\n" \ " pushl %ds\n" \
" pushl %es\n" \ " pushl %es\n" \
" pushl %fs\n" \ " pushl %fs\n" \
" pushl %gs\n" \ " pushl %gs\n" \
" pushl %ss\n" \ " pushl %ss\n" \
" mov $0x10, %ax\n" \ " mov $0x10, %ax\n" \
" mov %ax, %ds\n" \ " mov %ax, %ds\n" \
" mov %ax, %es\n" \ " mov %ax, %es\n" \
" cld\n" \ " cld\n" \
" call " #title "_handler\n" \ " call " #title "_handler\n" \
" add $0x4, %esp\n" \ " add $0x4, %esp\n" \
" popl %gs\n" \ " popl %gs\n" \
" popl %fs\n" \ " popl %fs\n" \
" popl %es\n" \ " popl %es\n" \
" popl %ds\n" \ " popl %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 RegisterState& regs)
{ {
u16 ss; u16 ss;
u32 esp; u32 esp;
@ -199,7 +199,7 @@ static void dump(const RegisterDump& regs)
} }
} }
void handle_crash(RegisterDump& regs, const char* description, int signal) void handle_crash(RegisterState& regs, const char* description, int signal)
{ {
if (!current) { if (!current) {
kprintf("%s with !current\n", description); kprintf("%s with !current\n", description);
@ -229,21 +229,21 @@ void handle_crash(RegisterDump& regs, const char* description, int signal)
} }
EH_ENTRY_NO_CODE(6, illegal_instruction); EH_ENTRY_NO_CODE(6, illegal_instruction);
void illegal_instruction_handler(RegisterDump regs) void illegal_instruction_handler(RegisterState regs)
{ {
clac(); clac();
handle_crash(regs, "Illegal instruction", SIGILL); handle_crash(regs, "Illegal instruction", SIGILL);
} }
EH_ENTRY_NO_CODE(0, divide_error); EH_ENTRY_NO_CODE(0, divide_error);
void divide_error_handler(RegisterDump regs) void divide_error_handler(RegisterState regs)
{ {
clac(); clac();
handle_crash(regs, "Divide error", SIGFPE); handle_crash(regs, "Divide error", SIGFPE);
} }
EH_ENTRY(13, general_protection_fault); EH_ENTRY(13, general_protection_fault);
void general_protection_fault_handler(RegisterDump regs) void general_protection_fault_handler(RegisterState regs)
{ {
clac(); clac();
handle_crash(regs, "General protection fault", SIGSEGV); handle_crash(regs, "General protection fault", SIGSEGV);
@ -251,7 +251,7 @@ void general_protection_fault_handler(RegisterDump regs)
// 7: FPU not available exception // 7: FPU not available exception
EH_ENTRY_NO_CODE(7, fpu_exception); EH_ENTRY_NO_CODE(7, fpu_exception);
void fpu_exception_handler(RegisterDump) void fpu_exception_handler(RegisterState)
{ {
// Just clear the TS flag. We've already restored the FPU state eagerly. // Just clear the TS flag. We've already restored the FPU state eagerly.
// FIXME: It would be nice if we didn't have to do this at all. // FIXME: It would be nice if we didn't have to do this at all.
@ -260,7 +260,7 @@ void fpu_exception_handler(RegisterDump)
// 14: Page Fault // 14: Page Fault
EH_ENTRY(14, page_fault); EH_ENTRY(14, page_fault);
void page_fault_handler(RegisterDump regs) void page_fault_handler(RegisterState regs)
{ {
clac(); clac();
//ASSERT(current); //ASSERT(current);
@ -543,7 +543,7 @@ void load_task_register(u16 selector)
asm("ltr %0" ::"r"(selector)); asm("ltr %0" ::"r"(selector));
} }
void handle_irq(RegisterDump regs) void handle_irq(RegisterState regs)
{ {
clac(); clac();
ASSERT(regs.isr_number >= 0x50 && regs.isr_number <= 0x5f); ASSERT(regs.isr_number >= 0x50 && regs.isr_number <= 0x5f);

View file

@ -242,7 +242,7 @@ public:
}; };
class IRQHandler; class IRQHandler;
struct RegisterDump; struct RegisterState;
void gdt_init(); void gdt_init();
void idt_init(); void idt_init();
@ -258,7 +258,7 @@ u16 gdt_alloc_entry();
void gdt_free_entry(u16); void gdt_free_entry(u16);
Descriptor& get_gdt_entry(u16 selector); Descriptor& get_gdt_entry(u16 selector);
void write_gdt_entry(u16 selector, Descriptor&); void write_gdt_entry(u16 selector, Descriptor&);
void handle_crash(RegisterDump&, const char* description, int signal); void handle_crash(RegisterState&, const char* description, int signal);
[[noreturn]] static inline void hang() [[noreturn]] static inline void hang()
{ {
@ -415,7 +415,7 @@ private:
VirtualAddress m_vaddr; VirtualAddress m_vaddr;
}; };
struct [[gnu::packed]] RegisterDump struct [[gnu::packed]] RegisterState
{ {
u32 ss; u32 ss;
u32 gs; u32 gs;

View file

@ -33,7 +33,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(RegisterState);
asm( asm(
".globl timer_interrupt_entry \n" ".globl timer_interrupt_entry \n"
@ -62,7 +62,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(RegisterState regs)
{ {
clac(); clac();
IRQHandlerScope scope(IRQ_TIMER); IRQHandlerScope scope(IRQ_TIMER);

View file

@ -664,7 +664,7 @@ int Process::sys$gethostname(char* buffer, ssize_t size)
return 0; return 0;
} }
pid_t Process::sys$fork(RegisterDump& regs) pid_t Process::sys$fork(RegisterState& regs)
{ {
REQUIRE_PROMISE(proc); REQUIRE_PROMISE(proc);
Thread* child_first_thread = nullptr; Thread* child_first_thread = nullptr;
@ -1412,7 +1412,7 @@ void create_kernel_info_page()
memset(s_info_page_address_for_kernel.as_ptr(), 0, PAGE_SIZE); memset(s_info_page_address_for_kernel.as_ptr(), 0, PAGE_SIZE);
} }
int Process::sys$sigreturn(RegisterDump& registers) int Process::sys$sigreturn(RegisterState& registers)
{ {
REQUIRE_PROMISE(stdio); REQUIRE_PROMISE(stdio);
SmapDisabler disabler; SmapDisabler disabler;

View file

@ -199,7 +199,7 @@ public:
int sys$lseek(int fd, off_t, int whence); int sys$lseek(int fd, off_t, int whence);
int sys$kill(pid_t pid, int sig); int sys$kill(pid_t pid, int sig);
[[noreturn]] void sys$exit(int status); [[noreturn]] void sys$exit(int status);
int sys$sigreturn(RegisterDump& registers); int sys$sigreturn(RegisterState& registers);
pid_t sys$waitid(const Syscall::SC_waitid_params*); pid_t sys$waitid(const Syscall::SC_waitid_params*);
void* sys$mmap(const Syscall::SC_mmap_params*); void* sys$mmap(const Syscall::SC_mmap_params*);
int sys$munmap(void*, size_t size); int sys$munmap(void*, size_t size);
@ -223,7 +223,7 @@ public:
int sys$readlink(const Syscall::SC_readlink_params*); int sys$readlink(const Syscall::SC_readlink_params*);
int sys$ttyname_r(int fd, char*, ssize_t); int sys$ttyname_r(int fd, char*, ssize_t);
int sys$ptsname_r(int fd, char*, ssize_t); int sys$ptsname_r(int fd, char*, ssize_t);
pid_t sys$fork(RegisterDump&); pid_t sys$fork(RegisterState&);
int sys$execve(const Syscall::SC_execve_params*); int sys$execve(const Syscall::SC_execve_params*);
int sys$getdtablesize(); int sys$getdtablesize();
int sys$dup(int oldfd); int sys$dup(int oldfd);

View file

@ -582,7 +582,7 @@ void Scheduler::initialize()
load_task_register(s_redirection.selector); load_task_register(s_redirection.selector);
} }
void Scheduler::timer_tick(RegisterDump& regs) void Scheduler::timer_tick(RegisterState& regs)
{ {
if (!current) if (!current)
return; return;

View file

@ -34,7 +34,7 @@
class Process; class Process;
class Thread; class Thread;
class WaitQueue; class WaitQueue;
struct RegisterDump; struct RegisterState;
struct SchedulerData; struct SchedulerData;
extern Thread* current; extern Thread* current;
@ -48,7 +48,7 @@ extern SchedulerData* g_scheduler_data;
class Scheduler { class Scheduler {
public: public:
static void initialize(); static void initialize();
static void timer_tick(RegisterDump&); static void timer_tick(RegisterState&);
static bool pick_next(); static bool pick_next();
static void pick_next_and_switch_now(); static void pick_next_and_switch_now();
static void switch_now(); static void switch_now();

View file

@ -31,7 +31,7 @@
#include <Kernel/Syscall.h> #include <Kernel/Syscall.h>
#include <Kernel/VM/MemoryManager.h> #include <Kernel/VM/MemoryManager.h>
extern "C" void syscall_handler(RegisterDump); extern "C" void syscall_handler(RegisterState);
extern "C" void syscall_asm_entry(); extern "C" void syscall_asm_entry();
asm( asm(
@ -62,7 +62,7 @@ asm(
namespace Syscall { namespace Syscall {
static int handle(RegisterDump&, u32 function, u32 arg1, u32 arg2, u32 arg3); static int handle(RegisterState&, u32 function, u32 arg1, u32 arg2, u32 arg3);
void initialize() void initialize()
{ {
@ -80,7 +80,7 @@ static Handler s_syscall_table[] = {
#undef __ENUMERATE_SYSCALL #undef __ENUMERATE_SYSCALL
#undef __ENUMERATE_REMOVED_SYSCALL #undef __ENUMERATE_REMOVED_SYSCALL
int handle(RegisterDump& regs, u32 function, u32 arg1, u32 arg2, u32 arg3) int handle(RegisterState& regs, u32 function, u32 arg1, u32 arg2, u32 arg3)
{ {
ASSERT_INTERRUPTS_ENABLED(); ASSERT_INTERRUPTS_ENABLED();
auto& process = current->process(); auto& process = current->process();
@ -119,7 +119,7 @@ int handle(RegisterDump& regs, u32 function, u32 arg1, u32 arg2, u32 arg3)
} }
void syscall_handler(RegisterDump regs) void syscall_handler(RegisterState regs)
{ {
// Special handling of the "gettid" syscall since it's extremely hot. // Special handling of the "gettid" syscall since it's extremely hot.
// FIXME: Remove this hack once userspace locks stop calling it so damn much. // FIXME: Remove this hack once userspace locks stop calling it so damn much.

View file

@ -568,8 +568,8 @@ ShouldUnblockThread Thread::dispatch_signal(u8 signal)
// We now place the thread state on the userspace stack. // We now place the thread state on the userspace stack.
// Note that when we are in the kernel (ie. blocking) we cannot use the // Note that when we are in the kernel (ie. blocking) we cannot use the
// tss, as that will contain kernel state; instead, we use a RegisterDump. // tss, as that will contain kernel state; instead, we use a RegisterState.
// Conversely, when the thread isn't blocking the RegisterDump may not be // Conversely, when the thread isn't blocking the RegisterState may not be
// valid (fork, exec etc) but the tss will, so we use that instead. // valid (fork, exec etc) but the tss will, so we use that instead.
if (!in_kernel()) { if (!in_kernel()) {
u32* stack = &m_tss.esp; u32* stack = &m_tss.esp;
@ -612,12 +612,12 @@ void Thread::push_value_on_stack(uintptr_t value)
copy_to_user(stack_ptr, &value); copy_to_user(stack_ptr, &value);
} }
RegisterDump& Thread::get_register_dump_from_stack() RegisterState& Thread::get_register_dump_from_stack()
{ {
// The userspace registers should be stored at the top of the stack // The userspace registers should be stored at the top of the stack
// We have to subtract 2 because the processor decrements the kernel // We have to subtract 2 because the processor decrements the kernel
// stack before pushing the args. // stack before pushing the args.
return *(RegisterDump*)(kernel_stack_top() - sizeof(RegisterDump)); return *(RegisterState*)(kernel_stack_top() - sizeof(RegisterState));
} }
u32 Thread::make_userspace_stack_for_main_thread(Vector<String> arguments, Vector<String> environment) u32 Thread::make_userspace_stack_for_main_thread(Vector<String> arguments, Vector<String> environment)

View file

@ -270,7 +270,7 @@ public:
u32 frame_ptr() const { return m_tss.ebp; } u32 frame_ptr() const { return m_tss.ebp; }
u32 stack_ptr() const { return m_tss.esp; } u32 stack_ptr() const { return m_tss.esp; }
RegisterDump& get_register_dump_from_stack(); RegisterState& get_register_dump_from_stack();
u16 selector() const { return m_far_ptr.selector; } u16 selector() const { return m_far_ptr.selector; }
TSS32& tss() { return m_tss; } TSS32& tss() { return m_tss; }