apio
5e564e9ae3
Since this is only used by user threads, UserVM is a convenient/related place to store the PageDirectory in a RAII manner.
37 lines
833 B
C++
37 lines
833 B
C++
#pragma once
|
|
|
|
#include "ELF.h"
|
|
#include "arch/CPU.h"
|
|
#include "arch/MMU.h"
|
|
#include "fs/VFS.h"
|
|
#include "memory/UserVM.h"
|
|
#include "thread/Thread.h"
|
|
#include <luna/LinkedList.h>
|
|
#include <luna/OwnedPtr.h>
|
|
#include <luna/Result.h>
|
|
#include <luna/Stack.h>
|
|
#include <luna/String.h>
|
|
#include <luna/Vector.h>
|
|
|
|
class Thread;
|
|
|
|
class ThreadImage
|
|
{
|
|
public:
|
|
static Result<OwnedPtr<ThreadImage>> try_load_from_elf(SharedPtr<VFS::Inode> inode);
|
|
|
|
static Result<OwnedPtr<ThreadImage>> clone_from_thread(Thread* parent);
|
|
|
|
Result<u64> push_mem_on_stack(const u8* mem, usize size);
|
|
Result<u64> push_string_vector_on_stack(const Vector<String>& vec);
|
|
|
|
void apply(Thread* thread);
|
|
|
|
private:
|
|
OwnedPtr<UserVM> m_vm_allocator;
|
|
Stack m_user_stack;
|
|
Stack m_kernel_stack;
|
|
ELFData m_loaded_image_data;
|
|
u64 m_sp;
|
|
};
|