2023-03-16 21:44:58 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "arch/CPU.h"
|
|
|
|
#include "arch/MMU.h"
|
2023-07-30 16:25:44 +00:00
|
|
|
#include "binfmt/BinaryFormat.h"
|
2023-03-16 21:44:58 +00:00
|
|
|
#include "fs/VFS.h"
|
2023-07-09 18:38:04 +00:00
|
|
|
#include "memory/AddressSpace.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>
|
2023-04-07 12:37:06 +00:00
|
|
|
#include <luna/String.h>
|
2023-04-07 12:36:24 +00:00
|
|
|
#include <luna/Vector.h>
|
2023-03-16 21:44:58 +00:00
|
|
|
|
|
|
|
class Thread;
|
|
|
|
|
|
|
|
class ThreadImage
|
|
|
|
{
|
|
|
|
public:
|
2023-07-30 16:25:44 +00:00
|
|
|
static Result<OwnedPtr<ThreadImage>> try_load_from_binary(SharedPtr<BinaryFormatLoader> inode);
|
2023-03-16 21:44:58 +00:00
|
|
|
|
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-04-07 12:36:24 +00:00
|
|
|
Result<u64> push_string_vector_on_stack(const Vector<String>& vec);
|
2023-03-18 21:25:19 +00:00
|
|
|
|
2023-03-16 21:44:58 +00:00
|
|
|
void apply(Thread* thread);
|
|
|
|
|
|
|
|
private:
|
2023-07-09 18:38:04 +00:00
|
|
|
OwnedPtr<AddressSpace> m_address_space;
|
2023-03-16 21:44:58 +00:00
|
|
|
Stack m_user_stack;
|
|
|
|
Stack m_kernel_stack;
|
2023-07-30 16:25:44 +00:00
|
|
|
u64 m_program_entry;
|
2023-03-18 21:25:19 +00:00
|
|
|
u64 m_sp;
|
2023-03-16 21:44:58 +00:00
|
|
|
};
|