syscalls: start adding exit syscall, not done yet

This commit is contained in:
2025-06-21 18:54:52 +03:00
parent bb096f826a
commit 70d6aacb91
6 changed files with 102 additions and 3 deletions
+15 -1
View File
@@ -46,6 +46,14 @@ const char* flags_to_mode_str(int flags) {
return mode;
}
int sys_exit(TrapFrame *tf)
{
int error_code = tf->ebx;
task_kill(current);
return error_code;
}
int sys_read(TrapFrame *tf)
{
if(tf->ebx < 3)
@@ -72,7 +80,7 @@ int sys_write(TrapFrame *tf)
debug_log("\n=================SYS_WRITE output to stdout=====================\n");
print((char*)tf->ecx, tf->edx);
debug_log("\n=================END OF THAT SHIT=====================\n");
tf->ecx++;
return tf->edx;
}
}
else
@@ -140,6 +148,12 @@ void handle_syscall(TrapFrame *tf)
debug_log("EBX: %X ", tf->ebx);
debug_log("ECX: %s ", tf->ecx);
debug_log("EDX: %X\n", tf->edx);
if(tf->eax == 1)//exit
{
int r = sys_exit(tf);
tf->eax = r;
}
if(tf->eax == 3)//read
{