Skip to content

Commit

Permalink
create_task_from_elf cont.
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamos82 committed Oct 23, 2024
1 parent 449bdfb commit 179601d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/kernel/loaders/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/kernel/scheduling/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 179601d

Please sign in to comment.