continue working on correct shell loading

This commit is contained in:
2025-10-01 21:15:26 +03:00
parent 2019f87b14
commit 05fa945421
5 changed files with 23 additions and 6 deletions
+1 -1
View File
@@ -134,7 +134,7 @@ void kmain(unsigned int magic, unsigned int info)
l9660_dir* dir = (l9660_dir*)malloc(sizeof(l9660_dir));
l9660_file* file = (l9660_file*)malloc(sizeof(l9660_file));
follow_path("/bin/bash.", file, dir);
follow_path("/katau/core.", file, dir);
exec_from_file(file, ".");
+12 -3
View File
@@ -68,12 +68,20 @@ void exec_from_file(l9660_file* fs_file, const char* dirname)
continue;
}
int pages_needed = DivRoundUp(elf_phdr->p_memsz, 0x1000);//(elf_phdr->p_memsz / 0x1000) + 1;
uint32_t start_addr = elf_phdr->p_vaddr;
uint32_t end_addr = start_addr + elf_phdr->p_memsz;
uint32_t start_page = start_addr & ~0xFFF;
uint32_t end_page = (end_addr - 1) & ~0xFFF;
int pages_needed = ((end_page - start_page) / 0x1000) + 1;
//int pages_needed = DivRoundUp(elf_phdr->p_memsz, 0x1000);//(elf_phdr->p_memsz / 0x1000) + 1;
//debug_log("pages needed: %X\n", pages_needed);
for(int j = 0; j < pages_needed; j++)
{
uint32_t vaddr = (elf_phdr->p_vaddr & ~0xFFF) + j * 0x1000;
uint32_t vaddr = start_page + j * 0x1000;
void* phys_addr = alloc_page();
debug_log("mapping 0x%X -> 0x%X\n", phys_addr, vaddr);
@@ -131,7 +139,8 @@ void exec_from_file(l9660_file* fs_file, const char* dirname)
*p_task1->cwd = dir;
uint32_t brk_address = DivRoundUp(bss_end+1, 0x1000)*0x1000;
debug_log("initial brk address: 0x%X\n", brk_address);
p_task1->brk = (void*)brk_address;
asm volatile("sti");
}
}
+6 -1
View File
@@ -525,6 +525,11 @@ void handle_syscall(TrapFrame *tf)
case 0x2d://brk
tf->eax = sys_brk(tf);
break;
case 0x36://ioctl
debug_log("IOCTL WAS CALLED, FUCKFUCK!!!!\n");
tf->eax = -38;//-ENOSYS
break;
case 0xa2://nanosleep
tf->eax = sys_nanosleep(tf);
@@ -535,4 +540,4 @@ void handle_syscall(TrapFrame *tf)
tf->eax = -1;
break;
}
}
}