2023-03-16 21:44:58 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ELF.h"
|
|
|
|
#include "arch/CPU.h"
|
|
|
|
#include "arch/MMU.h"
|
|
|
|
#include "fs/VFS.h"
|
|
|
|
#include "memory/UserVM.h"
|
2023-03-18 22:45:48 +00:00
|
|
|
#include "thread/Thread.h"
|
2023-03-16 21:44:58 +00:00
|
|
|
#include <luna/LinkedList.h>
|
|
|
|
#include <luna/OwnedPtr.h>
|
|
|
|
#include <luna/Result.h>
|
|
|
|
#include <luna/Stack.h>
|
|
|
|
|
|
|
|
class Thread;
|
|
|
|
|
|
|
|
class ThreadImage
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static Result<OwnedPtr<ThreadImage>> try_load_from_elf(SharedPtr<VFS::Inode> inode);
|
|
|
|
|
2023-03-18 22:45:48 +00:00
|
|
|
static Result<OwnedPtr<ThreadImage>> clone_from_thread(Thread* parent);
|
|
|
|
|
2023-03-18 21:25:19 +00:00
|
|
|
Result<u64> push_mem_on_stack(const u8* mem, usize size);
|
|
|
|
|
2023-03-16 21:44:58 +00:00
|
|
|
void apply(Thread* thread);
|
|
|
|
|
|
|
|
private:
|
|
|
|
OwnedPtr<UserVM> m_vm_allocator;
|
|
|
|
PageDirectory* m_directory { nullptr };
|
|
|
|
Stack m_user_stack;
|
|
|
|
Stack m_kernel_stack;
|
|
|
|
ELFData m_loaded_image_data;
|
2023-03-18 21:25:19 +00:00
|
|
|
u64 m_sp;
|
2023-03-16 21:44:58 +00:00
|
|
|
};
|