Add back x86_32 support #5
|
@ -199,6 +199,33 @@ namespace Kernel
|
||||||
BAN::ErrorOr<void> validate_string_access(const char*);
|
BAN::ErrorOr<void> validate_string_access(const char*);
|
||||||
BAN::ErrorOr<void> validate_pointer_access(const void*, size_t);
|
BAN::ErrorOr<void> validate_pointer_access(const void*, size_t);
|
||||||
|
|
||||||
|
uint64_t signal_pending_mask() const
|
||||||
|
{
|
||||||
|
return ((uint64_t)m_signal_pending_mask[1].load() << 32) | m_signal_pending_mask[0].load();
|
||||||
|
}
|
||||||
|
|
||||||
|
void add_pending_signal(uint8_t signal)
|
||||||
|
{
|
||||||
|
ASSERT(signal >= _SIGMIN);
|
||||||
|
ASSERT(signal <= _SIGMAX);
|
||||||
|
ASSERT(signal < 64);
|
||||||
|
if (signal < 32)
|
||||||
|
m_signal_pending_mask[0] |= (uint32_t)1 << signal;
|
||||||
|
else
|
||||||
|
m_signal_pending_mask[1] |= (uint32_t)1 << (signal - 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
void remove_pending_signal(uint8_t signal)
|
||||||
|
{
|
||||||
|
ASSERT(signal >= _SIGMIN);
|
||||||
|
ASSERT(signal <= _SIGMAX);
|
||||||
|
ASSERT(signal < 64);
|
||||||
|
if (signal < 32)
|
||||||
|
m_signal_pending_mask[0] &= ~((uint32_t)1 << signal);
|
||||||
|
else
|
||||||
|
m_signal_pending_mask[1] &= ~((uint32_t)1 << (signal - 32));
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ExitStatus
|
struct ExitStatus
|
||||||
{
|
{
|
||||||
|
@ -226,7 +253,8 @@ namespace Kernel
|
||||||
BAN::Vector<Thread*> m_threads;
|
BAN::Vector<Thread*> m_threads;
|
||||||
|
|
||||||
BAN::Atomic<vaddr_t> m_signal_handlers[_SIGMAX + 1] { };
|
BAN::Atomic<vaddr_t> m_signal_handlers[_SIGMAX + 1] { };
|
||||||
BAN::Atomic<uint64_t> m_signal_pending_mask { 0 };
|
// This is 2 32 bit values to allow atomicity on 32 targets
|
||||||
|
BAN::Atomic<uint32_t> m_signal_pending_mask[2] { 0, 0 };
|
||||||
|
|
||||||
BAN::Vector<BAN::String> m_cmdline;
|
BAN::Vector<BAN::String> m_cmdline;
|
||||||
BAN::Vector<BAN::String> m_environ;
|
BAN::Vector<BAN::String> m_environ;
|
||||||
|
|
|
@ -79,6 +79,7 @@ namespace Kernel
|
||||||
static pid_t current_tid();
|
static pid_t current_tid();
|
||||||
|
|
||||||
Process& process();
|
Process& process();
|
||||||
|
const Process& process() const;
|
||||||
bool has_process() const { return m_process; }
|
bool has_process() const { return m_process; }
|
||||||
|
|
||||||
bool is_userspace() const { return m_is_userspace; }
|
bool is_userspace() const { return m_is_userspace; }
|
||||||
|
|
|
@ -1488,7 +1488,7 @@ namespace Kernel
|
||||||
|
|
||||||
if (pid == m_pid)
|
if (pid == m_pid)
|
||||||
{
|
{
|
||||||
m_signal_pending_mask |= 1 << signal;
|
add_pending_signal(signal);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1501,7 +1501,7 @@ namespace Kernel
|
||||||
found = true;
|
found = true;
|
||||||
if (signal)
|
if (signal)
|
||||||
{
|
{
|
||||||
process.m_signal_pending_mask |= 1 << signal;
|
process.add_pending_signal(signal);
|
||||||
// FIXME: This feels hacky
|
// FIXME: This feels hacky
|
||||||
Scheduler::get().unblock_thread(process.m_threads.front()->tid());
|
Scheduler::get().unblock_thread(process.m_threads.front()->tid());
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,12 @@ namespace Kernel
|
||||||
return *m_process;
|
return *m_process;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Process& Thread::process() const
|
||||||
|
{
|
||||||
|
ASSERT(m_process);
|
||||||
|
return *m_process;
|
||||||
|
}
|
||||||
|
|
||||||
Thread::~Thread()
|
Thread::~Thread()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -241,7 +247,7 @@ namespace Kernel
|
||||||
auto& interrupt_stack = *reinterpret_cast<InterruptStack*>(interrupt_stack_base() + interrupt_stack_size() - sizeof(InterruptStack));
|
auto& interrupt_stack = *reinterpret_cast<InterruptStack*>(interrupt_stack_base() + interrupt_stack_size() - sizeof(InterruptStack));
|
||||||
if (!GDT::is_user_segment(interrupt_stack.cs))
|
if (!GDT::is_user_segment(interrupt_stack.cs))
|
||||||
return false;
|
return false;
|
||||||
uint64_t full_pending_mask = m_signal_pending_mask | m_process->m_signal_pending_mask;
|
uint64_t full_pending_mask = m_signal_pending_mask | process().signal_pending_mask();;
|
||||||
return full_pending_mask & ~m_signal_block_mask;
|
return full_pending_mask & ~m_signal_block_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +271,7 @@ namespace Kernel
|
||||||
|
|
||||||
if (signal == 0)
|
if (signal == 0)
|
||||||
{
|
{
|
||||||
uint64_t full_pending_mask = m_signal_pending_mask | process().m_signal_pending_mask;
|
uint64_t full_pending_mask = m_signal_pending_mask | process().signal_pending_mask();
|
||||||
for (signal = _SIGMIN; signal <= _SIGMAX; signal++)
|
for (signal = _SIGMIN; signal <= _SIGMAX; signal++)
|
||||||
{
|
{
|
||||||
uint64_t mask = 1ull << signal;
|
uint64_t mask = 1ull << signal;
|
||||||
|
@ -283,7 +289,7 @@ namespace Kernel
|
||||||
vaddr_t signal_handler = process().m_signal_handlers[signal];
|
vaddr_t signal_handler = process().m_signal_handlers[signal];
|
||||||
|
|
||||||
m_signal_pending_mask &= ~(1ull << signal);
|
m_signal_pending_mask &= ~(1ull << signal);
|
||||||
process().m_signal_pending_mask &= ~(1ull << signal);
|
process().remove_pending_signal(signal);
|
||||||
|
|
||||||
if (signal_handler == (vaddr_t)SIG_IGN)
|
if (signal_handler == (vaddr_t)SIG_IGN)
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in New Issue