Kernel: Rename RegisterDump => RegisterState
This commit is contained in:
parent
5507945306
commit
0341ddc5eb
Notes:
sideshowbarker
2024-07-19 09:17:41 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/0341ddc5ebc
10 changed files with 79 additions and 79 deletions
|
@ -66,7 +66,7 @@ void gdt_free_entry(u16 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();
|
||||
|
||||
#define GENERATE_IRQ_ASM_ENTRY(irq, isr_number) \
|
||||
|
@ -100,60 +100,60 @@ asm(
|
|||
" add $0x4, %esp\n"
|
||||
" iret\n");
|
||||
|
||||
#define EH_ENTRY(ec, title) \
|
||||
extern "C" void title##_asm_entry(); \
|
||||
extern "C" void title##_handler(RegisterDump); \
|
||||
asm( \
|
||||
".globl " #title "_asm_entry\n" \
|
||||
"" #title "_asm_entry: \n" \
|
||||
" pusha\n" \
|
||||
" pushl %ds\n" \
|
||||
" pushl %es\n" \
|
||||
" pushl %fs\n" \
|
||||
" pushl %gs\n" \
|
||||
" pushl %ss\n" \
|
||||
" mov $0x10, %ax\n" \
|
||||
" mov %ax, %ds\n" \
|
||||
" mov %ax, %es\n" \
|
||||
" cld\n" \
|
||||
" call " #title "_handler\n" \
|
||||
" add $0x4, %esp \n" \
|
||||
" popl %gs\n" \
|
||||
" popl %fs\n" \
|
||||
" popl %es\n" \
|
||||
" popl %ds\n" \
|
||||
" popa\n" \
|
||||
" add $0x4, %esp\n" \
|
||||
#define EH_ENTRY(ec, title) \
|
||||
extern "C" void title##_asm_entry(); \
|
||||
extern "C" void title##_handler(RegisterState); \
|
||||
asm( \
|
||||
".globl " #title "_asm_entry\n" \
|
||||
"" #title "_asm_entry: \n" \
|
||||
" pusha\n" \
|
||||
" pushl %ds\n" \
|
||||
" pushl %es\n" \
|
||||
" pushl %fs\n" \
|
||||
" pushl %gs\n" \
|
||||
" pushl %ss\n" \
|
||||
" mov $0x10, %ax\n" \
|
||||
" mov %ax, %ds\n" \
|
||||
" mov %ax, %es\n" \
|
||||
" cld\n" \
|
||||
" call " #title "_handler\n" \
|
||||
" add $0x4, %esp \n" \
|
||||
" popl %gs\n" \
|
||||
" popl %fs\n" \
|
||||
" popl %es\n" \
|
||||
" popl %ds\n" \
|
||||
" popa\n" \
|
||||
" add $0x4, %esp\n" \
|
||||
" iret\n");
|
||||
|
||||
#define EH_ENTRY_NO_CODE(ec, title) \
|
||||
extern "C" void title##_handler(RegisterDump); \
|
||||
extern "C" void title##_asm_entry(); \
|
||||
asm( \
|
||||
".globl " #title "_asm_entry\n" \
|
||||
"" #title "_asm_entry: \n" \
|
||||
" pushl $0x0\n" \
|
||||
" pusha\n" \
|
||||
" pushl %ds\n" \
|
||||
" pushl %es\n" \
|
||||
" pushl %fs\n" \
|
||||
" pushl %gs\n" \
|
||||
" pushl %ss\n" \
|
||||
" mov $0x10, %ax\n" \
|
||||
" mov %ax, %ds\n" \
|
||||
" mov %ax, %es\n" \
|
||||
" cld\n" \
|
||||
" call " #title "_handler\n" \
|
||||
" add $0x4, %esp\n" \
|
||||
" popl %gs\n" \
|
||||
" popl %fs\n" \
|
||||
" popl %es\n" \
|
||||
" popl %ds\n" \
|
||||
" popa\n" \
|
||||
" add $0x4, %esp\n" \
|
||||
#define EH_ENTRY_NO_CODE(ec, title) \
|
||||
extern "C" void title##_handler(RegisterState); \
|
||||
extern "C" void title##_asm_entry(); \
|
||||
asm( \
|
||||
".globl " #title "_asm_entry\n" \
|
||||
"" #title "_asm_entry: \n" \
|
||||
" pushl $0x0\n" \
|
||||
" pusha\n" \
|
||||
" pushl %ds\n" \
|
||||
" pushl %es\n" \
|
||||
" pushl %fs\n" \
|
||||
" pushl %gs\n" \
|
||||
" pushl %ss\n" \
|
||||
" mov $0x10, %ax\n" \
|
||||
" mov %ax, %ds\n" \
|
||||
" mov %ax, %es\n" \
|
||||
" cld\n" \
|
||||
" call " #title "_handler\n" \
|
||||
" add $0x4, %esp\n" \
|
||||
" popl %gs\n" \
|
||||
" popl %fs\n" \
|
||||
" popl %es\n" \
|
||||
" popl %ds\n" \
|
||||
" popa\n" \
|
||||
" add $0x4, %esp\n" \
|
||||
" iret\n");
|
||||
|
||||
static void dump(const RegisterDump& regs)
|
||||
static void dump(const RegisterState& regs)
|
||||
{
|
||||
u16 ss;
|
||||
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) {
|
||||
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);
|
||||
void illegal_instruction_handler(RegisterDump regs)
|
||||
void illegal_instruction_handler(RegisterState regs)
|
||||
{
|
||||
clac();
|
||||
handle_crash(regs, "Illegal instruction", SIGILL);
|
||||
}
|
||||
|
||||
EH_ENTRY_NO_CODE(0, divide_error);
|
||||
void divide_error_handler(RegisterDump regs)
|
||||
void divide_error_handler(RegisterState regs)
|
||||
{
|
||||
clac();
|
||||
handle_crash(regs, "Divide error", SIGFPE);
|
||||
}
|
||||
|
||||
EH_ENTRY(13, general_protection_fault);
|
||||
void general_protection_fault_handler(RegisterDump regs)
|
||||
void general_protection_fault_handler(RegisterState regs)
|
||||
{
|
||||
clac();
|
||||
handle_crash(regs, "General protection fault", SIGSEGV);
|
||||
|
@ -251,7 +251,7 @@ void general_protection_fault_handler(RegisterDump regs)
|
|||
|
||||
// 7: FPU not available 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.
|
||||
// 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
|
||||
EH_ENTRY(14, page_fault);
|
||||
void page_fault_handler(RegisterDump regs)
|
||||
void page_fault_handler(RegisterState regs)
|
||||
{
|
||||
clac();
|
||||
//ASSERT(current);
|
||||
|
@ -543,7 +543,7 @@ void load_task_register(u16 selector)
|
|||
asm("ltr %0" ::"r"(selector));
|
||||
}
|
||||
|
||||
void handle_irq(RegisterDump regs)
|
||||
void handle_irq(RegisterState regs)
|
||||
{
|
||||
clac();
|
||||
ASSERT(regs.isr_number >= 0x50 && regs.isr_number <= 0x5f);
|
||||
|
|
|
@ -242,7 +242,7 @@ public:
|
|||
};
|
||||
|
||||
class IRQHandler;
|
||||
struct RegisterDump;
|
||||
struct RegisterState;
|
||||
|
||||
void gdt_init();
|
||||
void idt_init();
|
||||
|
@ -258,7 +258,7 @@ u16 gdt_alloc_entry();
|
|||
void gdt_free_entry(u16);
|
||||
Descriptor& get_gdt_entry(u16 selector);
|
||||
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()
|
||||
{
|
||||
|
@ -415,7 +415,7 @@ private:
|
|||
VirtualAddress m_vaddr;
|
||||
};
|
||||
|
||||
struct [[gnu::packed]] RegisterDump
|
||||
struct [[gnu::packed]] RegisterState
|
||||
{
|
||||
u32 ss;
|
||||
u32 gs;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#define IRQ_TIMER 0
|
||||
|
||||
extern "C" void timer_interrupt_entry();
|
||||
extern "C" void timer_interrupt_handler(RegisterDump);
|
||||
extern "C" void timer_interrupt_handler(RegisterState);
|
||||
|
||||
asm(
|
||||
".globl timer_interrupt_entry \n"
|
||||
|
@ -62,7 +62,7 @@ asm(
|
|||
static u32 s_ticks_this_second;
|
||||
static u32 s_seconds_since_boot;
|
||||
|
||||
void timer_interrupt_handler(RegisterDump regs)
|
||||
void timer_interrupt_handler(RegisterState regs)
|
||||
{
|
||||
clac();
|
||||
IRQHandlerScope scope(IRQ_TIMER);
|
||||
|
|
|
@ -664,7 +664,7 @@ int Process::sys$gethostname(char* buffer, ssize_t size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
pid_t Process::sys$fork(RegisterDump& regs)
|
||||
pid_t Process::sys$fork(RegisterState& regs)
|
||||
{
|
||||
REQUIRE_PROMISE(proc);
|
||||
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);
|
||||
}
|
||||
|
||||
int Process::sys$sigreturn(RegisterDump& registers)
|
||||
int Process::sys$sigreturn(RegisterState& registers)
|
||||
{
|
||||
REQUIRE_PROMISE(stdio);
|
||||
SmapDisabler disabler;
|
||||
|
|
|
@ -199,7 +199,7 @@ public:
|
|||
int sys$lseek(int fd, off_t, int whence);
|
||||
int sys$kill(pid_t pid, int sig);
|
||||
[[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*);
|
||||
void* sys$mmap(const Syscall::SC_mmap_params*);
|
||||
int sys$munmap(void*, size_t size);
|
||||
|
@ -223,7 +223,7 @@ public:
|
|||
int sys$readlink(const Syscall::SC_readlink_params*);
|
||||
int sys$ttyname_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$getdtablesize();
|
||||
int sys$dup(int oldfd);
|
||||
|
|
|
@ -582,7 +582,7 @@ void Scheduler::initialize()
|
|||
load_task_register(s_redirection.selector);
|
||||
}
|
||||
|
||||
void Scheduler::timer_tick(RegisterDump& regs)
|
||||
void Scheduler::timer_tick(RegisterState& regs)
|
||||
{
|
||||
if (!current)
|
||||
return;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
class Process;
|
||||
class Thread;
|
||||
class WaitQueue;
|
||||
struct RegisterDump;
|
||||
struct RegisterState;
|
||||
struct SchedulerData;
|
||||
|
||||
extern Thread* current;
|
||||
|
@ -48,7 +48,7 @@ extern SchedulerData* g_scheduler_data;
|
|||
class Scheduler {
|
||||
public:
|
||||
static void initialize();
|
||||
static void timer_tick(RegisterDump&);
|
||||
static void timer_tick(RegisterState&);
|
||||
static bool pick_next();
|
||||
static void pick_next_and_switch_now();
|
||||
static void switch_now();
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <Kernel/Syscall.h>
|
||||
#include <Kernel/VM/MemoryManager.h>
|
||||
|
||||
extern "C" void syscall_handler(RegisterDump);
|
||||
extern "C" void syscall_handler(RegisterState);
|
||||
extern "C" void syscall_asm_entry();
|
||||
|
||||
asm(
|
||||
|
@ -62,7 +62,7 @@ asm(
|
|||
|
||||
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()
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ static Handler s_syscall_table[] = {
|
|||
#undef __ENUMERATE_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();
|
||||
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.
|
||||
// FIXME: Remove this hack once userspace locks stop calling it so damn much.
|
||||
|
|
|
@ -568,8 +568,8 @@ ShouldUnblockThread Thread::dispatch_signal(u8 signal)
|
|||
|
||||
// We now place the thread state on the userspace stack.
|
||||
// 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.
|
||||
// Conversely, when the thread isn't blocking the RegisterDump may not be
|
||||
// tss, as that will contain kernel state; instead, we use a RegisterState.
|
||||
// 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.
|
||||
if (!in_kernel()) {
|
||||
u32* stack = &m_tss.esp;
|
||||
|
@ -612,12 +612,12 @@ void Thread::push_value_on_stack(uintptr_t 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
|
||||
// We have to subtract 2 because the processor decrements the kernel
|
||||
// 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)
|
||||
|
|
|
@ -270,7 +270,7 @@ public:
|
|||
u32 frame_ptr() const { return m_tss.ebp; }
|
||||
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; }
|
||||
TSS32& tss() { return m_tss; }
|
||||
|
|
Loading…
Add table
Reference in a new issue