From 179601da4006fe1403a754395cc0fa2b999743e1 Mon Sep 17 00:00:00 2001 From: Ivan Gualandri Date: Thu, 24 Oct 2024 00:23:41 +0100 Subject: [PATCH] create_task_from_elf cont. --- src/kernel/loaders/elf.c | 8 ++++++++ src/kernel/scheduling/task.c | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/kernel/loaders/elf.c b/src/kernel/loaders/elf.c index ea7e623..bf6be89 100644 --- a/src/kernel/loaders/elf.c +++ b/src/kernel/loaders/elf.c @@ -107,7 +107,15 @@ bool parse_section_header(Elf64_Ehdr *elf_start, uint64_t size, executable_loade return false; } +/** + * This function given an elf p_hdr flag returns the architecture dependent vmm flags + * + * + * @param flags elf flags + * @return architecture dependant flags + */ uint64_t elf_flags_to_memory_flags(Elf64_Word flags) { + // This function will be movede into the arch dependant code // Elf flags: // 1 = Read // 2 = Write diff --git a/src/kernel/scheduling/task.c b/src/kernel/scheduling/task.c index 18ac749..ede3c31 100644 --- a/src/kernel/scheduling/task.c +++ b/src/kernel/scheduling/task.c @@ -51,10 +51,12 @@ task_t *create_task_from_elf(char *name, void *args, Elf64_Ehdr *elf_header){ // clear all the memory not used // compute the entries for each page and insert them into the page tables. Elf64_Phdr phdr = phdr_list[i]; + size_t vmm_hdr_flags = elf_flags_to_memory_flags(phdr.p_type); pretty_logf(Verbose, "\t[%d]: Type: 0x%x, Flags: 0x%x - Vaddr: 0x%x - aligned: 0x%x ", i, phdr.p_type, phdr.p_flags, phdr.p_vaddr, align_value_to_page(phdr.p_vaddr)); - pretty_logf(Verbose, "\t\t - FileSz: 0x%x, Memsz: 0x%x ", phdr.p_filesz, phdr.p_memsz); + pretty_logf(Verbose, "\t\t - FileSz: 0x%x, Memsz: 0x%x, vmm flags: 0x%x", phdr.p_filesz, phdr.p_memsz, vmm_hdr_flags); Elf64_Half mem_pages = (Elf64_Half) get_number_of_pages_from_size(phdr.p_memsz); Elf64_Half filesz_pages = (Elf64_Half) get_number_of_pages_from_size(phdr.p_filesz); + } } // Create a new thread