Kernel: you can now ask process if it is userspace process

This commit is contained in:
Bananymous 2023-07-23 18:52:55 +03:00
parent 9eb72f4392
commit 3784da0d18
2 changed files with 4 additions and 0 deletions

View File

@ -114,6 +114,7 @@ namespace Kernel
PageTable& page_table() { return m_page_table ? *m_page_table : PageTable::kernel(); } PageTable& page_table() { return m_page_table ? *m_page_table : PageTable::kernel(); }
bool is_userspace() const { return m_is_userspace; }
const userspace_info_t& userspace_info() const { return m_userspace_info; } const userspace_info_t& userspace_info() const { return m_userspace_info; }
private: private:
@ -157,6 +158,7 @@ namespace Kernel
vaddr_t m_signal_handlers[_SIGMAX + 1] { }; vaddr_t m_signal_handlers[_SIGMAX + 1] { };
bool m_is_userspace { false };
userspace_info_t m_userspace_info; userspace_info_t m_userspace_info;
ExitStatus m_exit_status; ExitStatus m_exit_status;

View File

@ -58,6 +58,7 @@ namespace Kernel
process->load_elf_to_memory(*elf); process->load_elf_to_memory(*elf);
process->m_is_userspace = true;
process->m_userspace_info.entry = elf->file_header_native().e_entry; process->m_userspace_info.entry = elf->file_header_native().e_entry;
// NOTE: we clear the elf since we don't need the memory anymore // NOTE: we clear the elf since we don't need the memory anymore
@ -305,6 +306,7 @@ namespace Kernel
forked->m_mapped_ranges = BAN::move(mapped_ranges); forked->m_mapped_ranges = BAN::move(mapped_ranges);
forked->m_fixed_width_allocators = BAN::move(fixed_width_allocators); forked->m_fixed_width_allocators = BAN::move(fixed_width_allocators);
forked->m_general_allocator = BAN::move(general_allocator); forked->m_general_allocator = BAN::move(general_allocator);
forked->m_is_userspace = m_is_userspace;
forked->m_userspace_info = m_userspace_info; forked->m_userspace_info = m_userspace_info;
memcpy(forked->m_signal_handlers, m_signal_handlers, sizeof(m_signal_handlers)); memcpy(forked->m_signal_handlers, m_signal_handlers, sizeof(m_signal_handlers));