|
Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
|
#include "procc/process.h"#include "hal/cpu/paging.h"#include "init/init.h"#include "libk/executable/elf.h"#include "libk/math.h"#include "libk/serial.h"#include "memory/kalloc.h"#include "memory/memory_utils.h"#include "memory/phys_base_allocator.h"#include "memory/slab.h"#include "memory/vm_manager.h"#include "procc/scheduler.h"#include "procc/thread.h"#include "string.h"#include "sys/fd.h"#include "tty/tty.h"#include "type.h"#include "vfs/dentry.h"#include "vfs/enum.h"#include "vfs/vnode.h"#include <str.h>#include <sys/syscall.h>Go to the source code of this file.
Macros | |
| #define | AT_NULL 0 |
| #define | AT_IGNORE 1 |
| #define | AT_EXECFD 2 /* File descriptor from program */ |
| #define | AT_PHDR 3 /* Program Headers Address from main executable */ |
| #define | AT_PHENT 4 /* program heder entry size */ |
| #define | AT_PHNUM 5 /* Program Headers num*/ |
| #define | AT_PAGESZ 6 /* page size (4096) */ |
| #define | AT_BASE 7 /* Base address dari interpreter (ld.so) jika ada */ |
| #define | AT_FLAGS 8 /* Flags */ |
| #define | AT_ENTRY 9 /* Entry point dari executable utama */ |
| #define | AT_NOTELF 10 /* Program not ELF */ |
| #define | AT_UID 11 /* Real User ID */ |
| #define | AT_EUID 12 /* Effective User ID */ |
| #define | AT_GID 13 /* Real Group ID */ |
| #define | AT_EGID 14 /* Effective Group ID */ |
| #define | AT_PLATFORM 15 /* String CPU format (ex: "x86_64") */ |
| #define | AT_HWCAP 16 /* Bitmask CPU capability */ |
| #define | AT_CLKTCK 17 /* clock freq, for times() */ |
| #define | AT_SECURE |
| #define | AT_RANDOM 25 /* Pointer into 16 byte random for stack canary/ASLR */ |
| #define | AT_EXECFN 31 /* String path name executbale file */ |
| #define | AT_SYSINFO_EHDR 33 |
| #define | USER_STACK_PAGES 256 |
| #define | USER_STACK_SIZE (USER_STACK_PAGES * 4096) |
Functions | |
| __attribute__ ((unused)) | |
| INIT (Process) | |
| static uintptr_t | elf_prepare_stack (uintptr_t stack_top_kernel, uintptr_t stack_top_user, int argc, char *const *argv, char *const *envp, Elf64_Ehdr *ehdr, uintptr_t entry_addr, uintptr_t phdr_vaddr, uintptr_t interp_base_addr) |
| int | execve (const char *path, char *const *argv, char *const *envp) |
| pid_t | alloc_pid (void) |
| void | free_pid (pid_t pid) |
| process_t * | create_process (char *name, thread_t *main_thread) |
Variables | |
| static struct slab_cache * | process_cache = 0 |
| static uint8_t * | pid_bitmap = 0 |
| static dentry_ptr | process_dentry = 0 |
| static process_t * | _process_list = 0 |
| #define AT_BASE 7 /* Base address dari interpreter (ld.so) jika ada */ |
Definition at line 45 of file process.c.
Referenced by elf_prepare_stack().
| #define AT_EGID 14 /* Effective Group ID */ |
Definition at line 53 of file process.c.
Referenced by elf_prepare_stack().
| #define AT_ENTRY 9 /* Entry point dari executable utama */ |
Definition at line 47 of file process.c.
Referenced by elf_prepare_stack().
| #define AT_EUID 12 /* Effective User ID */ |
Definition at line 51 of file process.c.
Referenced by elf_prepare_stack().
| #define AT_GID 13 /* Real Group ID */ |
Definition at line 52 of file process.c.
Referenced by elf_prepare_stack().
| #define AT_HWCAP 16 /* Bitmask CPU capability */ |
Definition at line 57 of file process.c.
Referenced by elf_prepare_stack().
| #define AT_NULL 0 |
Definition at line 38 of file process.c.
Referenced by elf_prepare_stack().
Definition at line 44 of file process.c.
Referenced by elf_prepare_stack().
| #define AT_PHDR 3 /* Program Headers Address from main executable */ |
Definition at line 41 of file process.c.
Referenced by elf_prepare_stack().
| #define AT_PHENT 4 /* program heder entry size */ |
Definition at line 42 of file process.c.
Referenced by elf_prepare_stack().
| #define AT_PHNUM 5 /* Program Headers num*/ |
Definition at line 43 of file process.c.
Referenced by elf_prepare_stack().
| #define AT_PLATFORM 15 /* String CPU format (ex: "x86_64") */ |
Definition at line 62 of file process.c.
Referenced by elf_prepare_stack().
| #define AT_SECURE |
Definition at line 60 of file process.c.
Referenced by elf_prepare_stack().
| #define AT_UID 11 /* Real User ID */ |
Definition at line 50 of file process.c.
Referenced by elf_prepare_stack().
| #define USER_STACK_SIZE (USER_STACK_PAGES * 4096) |
| pid_t alloc_pid | ( | void | ) |
Definition at line 529 of file process.c.
References INVALID_PID, MAX_PID_ALLOWED, and pid_bitmap.
Referenced by create_process().
| process_t * create_process | ( | char * | name, |
| thread_t * | main_thread ) |
Definition at line 552 of file process.c.
References _process_list, alloc_fd(), alloc_fdtable(), alloc_pid(), CREATE_MISSING_ENTRY, process_head::first, get_tty_dentry(), h, itoa(), main_thread, name, name_len, process_node::next, NULL, process_node::prev, process_cache, process_dentry, resolve_dentry(), strlen(), strncpy(), tail, dentry::vnode, and vxSlabAlloc().
Referenced by execve().
|
static |
Definition at line 69 of file process.c.
References AT_BASE, AT_EGID, AT_ENTRY, AT_EUID, AT_GID, AT_HWCAP, AT_NULL, AT_PAGESZ, AT_PHDR, AT_PHENT, AT_PHNUM, AT_RANDOM, AT_SECURE, AT_UID, Elf64_Ehdr::e_phentsize, Elf64_Ehdr::e_phnum, entry_addr, kalloc(), kfree2(), len, memcopy(), serial2_printf(), and strlen().
Referenced by execve().
| int execve | ( | const char * | path, |
| char *const * | argv, | ||
| char *const * | envp ) |
Definition at line 173 of file process.c.
References ALIGN_UP, attach_to_scheduler(), base_addr, BLOCK_SIZE, kstring::c_str, create_process(), create_thread(), create_vmm_page(), dentry_put(), Elf64_Ehdr::e_entry, Elf64_Ehdr::e_ident, Elf64_Ehdr::e_phentsize, Elf64_Ehdr::e_phnum, Elf64_Ehdr::e_phoff, Elf64_Ehdr::e_type, Elf64_Ehdr::e_version, elf_count_load_size(), elf_dyn_map_all(), elf_get_phdr_dynamic(), elf_gnu_hash_parse(), elf_load(), elf_prepare_stack(), ELF_PTR, elf_relocate_dyn(), elf_section_map_all(), ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, entry_addr, ET_DYN, ET_EXEC, get_kernel_vmm_page(), get_root_dentry(), elf_section_map::gnuhash, heap_start, kalloc(), kfree2(), LOG2_ERROR, LOG2_INFO, LOG_ERROR, LOG_INFO, elf_load_mmap_table::mapped, memcopy(), min(), dentry::name, elf_dynamic_map::needed, NULL, ops, vnode::ops, Elf64_Phdr::p_memsz, Elf64_Phdr::p_offset, Elf64_Phdr::p_type, Elf64_Phdr::p_vaddr, page, paging_create_page_directory(), paging_get_highest_page_map(), paging_setup(), paging_unmap_page(), dentry::parent, path, phys_base_alloc(), print_dentry_tree(), PT_INTERP, PT_LOAD, resolve_dentry(), serial2_printf(), serial_printf(), serial_trace, size, vector_uint64_t::size, vnode::size, str(), str_release(), elf_dynamic_map::strtab, THREAD_USER, vnode::type, USER_STACK_PAGES, USER_STACK_SIZE, USER_STACK_VADDR, elf_load_mmap_table::vaddr, VFS_OK, vma_lookup_free_vaddr(), VMA_REGION_A, VMA_REGION_PROCESS, vma_register(), vma_unregister(), dentry::vnode, VNODE_TYPE_FILE, VNODE_TYPE_LNK, and vxMultipleMmap().
Referenced by __attribute__(), and execve().
| void free_pid | ( | pid_t | pid | ) |
Definition at line 546 of file process.c.
References pid, and pid_bitmap.
| INIT | ( | Process | ) |
Definition at line 30 of file process.c.
References kalloc(), MAX_PID_ALLOWED, memset(), pid_bitmap, process_cache, process_dentry, vxCreateSlabCache(), and vxnamei().
|
static |
Definition at line 28 of file process.c.
Referenced by create_process().
|
static |
Definition at line 25 of file process.c.
Referenced by alloc_pid(), free_pid(), and INIT().
|
static |
Definition at line 24 of file process.c.
Referenced by create_process(), and INIT().
|
static |
Definition at line 26 of file process.c.
Referenced by create_process(), and INIT().