mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 12:35:13 +00:00
Thread.cpp: add method get_RegisterDump_from_stack().
This refactors some the RegisterDump code from dispatch_signal into a stand-alone function, allowing for better reuse.
This commit is contained in:
parent
a6e9119537
commit
44f22c99ef
2 changed files with 11 additions and 4 deletions
|
@ -417,10 +417,7 @@ ShouldUnblockThread Thread::dispatch_signal(u8 signal)
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessPagingScope paging_scope(m_process);
|
ProcessPagingScope paging_scope(m_process);
|
||||||
// The userspace registers should be stored at the top of the stack
|
auto& regs = get_RegisterDump_from_stack();
|
||||||
// We have to subtract 2 because the processor decrements the kernel
|
|
||||||
// stack before pushing the args.
|
|
||||||
auto& regs = *(RegisterDump*)(kernel_stack_top() - sizeof(RegisterDump) - 2);
|
|
||||||
|
|
||||||
u32 old_signal_mask = m_signal_mask;
|
u32 old_signal_mask = m_signal_mask;
|
||||||
u32 new_signal_mask = action.mask;
|
u32 new_signal_mask = action.mask;
|
||||||
|
@ -509,6 +506,14 @@ void Thread::push_value_on_stack(u32 value)
|
||||||
*stack_ptr = value;
|
*stack_ptr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RegisterDump& Thread::get_RegisterDump_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) - 2);
|
||||||
|
}
|
||||||
|
|
||||||
void Thread::make_userspace_stack_for_main_thread(Vector<String> arguments, Vector<String> environment)
|
void Thread::make_userspace_stack_for_main_thread(Vector<String> arguments, Vector<String> environment)
|
||||||
{
|
{
|
||||||
auto* region = m_process.allocate_region(VirtualAddress(), default_userspace_stack_size, "Stack (Main thread)", PROT_READ | PROT_WRITE, false);
|
auto* region = m_process.allocate_region(VirtualAddress(), default_userspace_stack_size, "Stack (Main thread)", PROT_READ | PROT_WRITE, false);
|
||||||
|
|
|
@ -210,6 +210,8 @@ 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_RegisterDump_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; }
|
||||||
const TSS32& tss() const { return m_tss; }
|
const TSS32& tss() const { return m_tss; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue