Kernel: Move userspace entry functions to Process instead of Thread

This commit is contained in:
Bananymous
2023-05-31 19:25:53 +03:00
parent dcb23f686f
commit 5fb69300ca
4 changed files with 23 additions and 19 deletions

View File

@@ -25,6 +25,13 @@ namespace Kernel
public:
using entry_t = Thread::entry_t;
struct userspace_entry_t
{
uintptr_t entry { 0 };
int argc { 0 };
char** argv { 0 };
};
public:
static Process* create_kernel(entry_t, void*);
static BAN::ErrorOr<Process*> create_userspace(BAN::StringView);
@@ -71,6 +78,8 @@ namespace Kernel
PageTable& page_table() { return m_page_table ? *m_page_table : PageTable::kernel(); }
const userspace_entry_t& userspace_entry() const { return m_userspace_entry; }
private:
Process(pid_t);
static Process* create_process();
@@ -103,6 +112,8 @@ namespace Kernel
BAN::Vector<FixedWidthAllocator*> m_fixed_width_allocators;
GeneralAllocator* m_general_allocator;
userspace_entry_t m_userspace_entry;
PageTable* m_page_table { nullptr };
TTY* m_tty { nullptr };
};

View File

@@ -28,7 +28,7 @@ namespace Kernel
public:
static BAN::ErrorOr<Thread*> create_kernel(entry_t, void*, Process*);
static BAN::ErrorOr<Thread*> create_userspace(uintptr_t, Process*, int, char**);
static BAN::ErrorOr<Thread*> create_userspace(Process*);
~Thread();
BAN::ErrorOr<Thread*> clone(Process*, uintptr_t rsp, uintptr_t rip);
@@ -67,14 +67,6 @@ namespace Kernel
void validate_stack() const;
private:
struct userspace_entry_t
{
uintptr_t entry;
int argc { 0 };
char** argv { 0 };
};
private:
static constexpr size_t m_kernel_stack_size = PAGE_SIZE * 1;
static constexpr size_t m_userspace_stack_size = PAGE_SIZE * 2;
@@ -89,8 +81,6 @@ namespace Kernel
bool m_in_syscall { false };
bool m_is_userspace { false };
userspace_entry_t m_userspace_entry;
friend class Scheduler;
};