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
+3
View File
@@ -64,6 +64,9 @@ iso:
cp grubshit/caller katauos/katau/caller
cp grubshit/callee katauos/katau/callee
cp grubshit/callee2 katauos/katau/callee2
cp grubshit/zsh katauos/katau/zsh
sudo umount tmp/
grub-mkrescue -o boot.iso katauos/
+1 -1
View File
@@ -5,7 +5,7 @@
#include <stddef.h>
#define KHEAP_START 0xE0000000 // Start of kernel heap
#define KHEAP_INITIAL_SIZE 0x100000 // 1 MiB initial size
#define KHEAP_INITIAL_SIZE 0x400000 // 1 MiB initial size
#define KHEAP_END (KHEAP_START + KHEAP_INITIAL_SIZE)
#define KHEAP_PAGES (KHEAP_INITIAL_SIZE / PAGE_SIZE)
+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, ".");
+11 -2
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,6 +139,7 @@ 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");
+5
View File
@@ -526,6 +526,11 @@ void handle_syscall(TrapFrame *tf)
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);
break;