mirror of
https://github.com/RGBCube/serenity
synced 2025-07-22 22:07:34 +00:00
Kernel: Abstract Processor::assume_context flags using InterruptsState
The details of the specific interrupt bits that must be turned on are irrelevant to the sys$execve implementation. Abstract it away to the Processor implementations using the InterruptsState enum.
This commit is contained in:
parent
6ad8f4bb11
commit
a349570a04
5 changed files with 9 additions and 13 deletions
|
@ -255,10 +255,10 @@ void Processor::switch_context(Thread*& from_thread, Thread*& to_thread)
|
|||
dbgln_if(CONTEXT_SWITCH_DEBUG, "switch_context <-- from {} {} to {} {}", VirtualAddress(from_thread), *from_thread, VirtualAddress(to_thread), *to_thread);
|
||||
}
|
||||
|
||||
void Processor::assume_context(Thread& thread, FlatPtr flags)
|
||||
void Processor::assume_context(Thread& thread, InterruptsState new_interrupts_state)
|
||||
{
|
||||
(void)thread;
|
||||
(void)flags;
|
||||
(void)new_interrupts_state;
|
||||
TODO_AARCH64();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ class PageDirectory;
|
|||
class Thread;
|
||||
class Processor;
|
||||
struct TrapFrame;
|
||||
enum class InterruptsState;
|
||||
|
||||
// FIXME This needs to go behind some sort of platform abstraction
|
||||
// it is used between Thread and Processor.
|
||||
|
@ -270,7 +271,7 @@ public:
|
|||
|
||||
[[noreturn]] void initialize_context_switching(Thread& initial_thread);
|
||||
NEVER_INLINE void switch_context(Thread*& from_thread, Thread*& to_thread);
|
||||
[[noreturn]] static void assume_context(Thread& thread, FlatPtr flags);
|
||||
[[noreturn]] static void assume_context(Thread& thread, InterruptsState new_interrupts_state);
|
||||
FlatPtr init_context(Thread& thread, bool leave_crit);
|
||||
static ErrorOr<Vector<FlatPtr, 32>> capture_stack_trace(Thread& thread, size_t max_frames = 0);
|
||||
|
||||
|
|
|
@ -1569,7 +1569,7 @@ extern "C" FlatPtr do_init_context(Thread* thread, u32 flags)
|
|||
return Processor::current().init_context(*thread, true);
|
||||
}
|
||||
|
||||
void Processor::assume_context(Thread& thread, FlatPtr flags)
|
||||
void Processor::assume_context(Thread& thread, InterruptsState new_interrupts_state)
|
||||
{
|
||||
dbgln_if(CONTEXT_SWITCH_DEBUG, "Assume context for thread {} {}", VirtualAddress(&thread), thread);
|
||||
|
||||
|
@ -1579,6 +1579,7 @@ void Processor::assume_context(Thread& thread, FlatPtr flags)
|
|||
// and then the scheduler lock
|
||||
VERIFY(Processor::in_critical() == 2);
|
||||
|
||||
u32 flags = 2 | (new_interrupts_state == InterruptsState::Enabled ? 0x200 : 0);
|
||||
do_assume_context(&thread, flags);
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
|
|
|
@ -55,6 +55,7 @@ struct [[gnu::aligned(64), gnu::packed]] FPUState
|
|||
u8 ext_save_area[256];
|
||||
};
|
||||
|
||||
enum class InterruptsState;
|
||||
class Processor;
|
||||
// Note: We only support 64 processors at most at the moment,
|
||||
// so allocate 64 slots of inline capacity in the container.
|
||||
|
@ -414,7 +415,7 @@ public:
|
|||
|
||||
[[noreturn]] void initialize_context_switching(Thread& initial_thread);
|
||||
NEVER_INLINE void switch_context(Thread*& from_thread, Thread*& to_thread);
|
||||
[[noreturn]] static void assume_context(Thread& thread, FlatPtr flags);
|
||||
[[noreturn]] static void assume_context(Thread& thread, InterruptsState new_interrupts_state);
|
||||
FlatPtr init_context(Thread& thread, bool leave_crit);
|
||||
static ErrorOr<Vector<FlatPtr, 32>> capture_stack_trace(Thread& thread, size_t max_frames = 0);
|
||||
|
||||
|
|
|
@ -980,15 +980,8 @@ ErrorOr<FlatPtr> Process::sys$execve(Userspace<Syscall::SC_execve_params const*>
|
|||
VERIFY(Processor::in_critical() == 1);
|
||||
g_scheduler_lock.lock();
|
||||
current_thread->set_state(Thread::State::Running);
|
||||
#if ARCH(X86_64)
|
||||
FlatPtr prev_flags = previous_interrupts_state == InterruptsState::Enabled ? 0x200 : 0;
|
||||
Processor::assume_context(*current_thread, prev_flags);
|
||||
Processor::assume_context(*current_thread, previous_interrupts_state);
|
||||
VERIFY_NOT_REACHED();
|
||||
#elif ARCH(AARCH64)
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
# error Unknown architecture
|
||||
#endif
|
||||
}
|
||||
|
||||
// NOTE: This code path is taken in the non-syscall case, i.e when the kernel spawns
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue