fix(syscall/proc): i32 in sys_exit and sys_spawn

fix(userspace/string.h): gets_s now correctly work with \b

chore(kmain): now ring3 is default when pressing any key (instead of ksh)

feat(termosh): spawn in termosh
This commit is contained in:
Karina
2026-01-30 10:19:05 +04:00
parent c5741374cd
commit ae7e1a91d0
9 changed files with 48 additions and 23 deletions
+3 -3
View File
@@ -5,6 +5,6 @@
#include <types.h>
u64 sys_exit(i32 code);
u64 sys_spawn(const char* path);
u64 sys_wait(u64 pid);
i32 sys_exit(i32 code);
i32 sys_spawn(const char* path);
i32 sys_wait(u64 pid);
+6 -4
View File
@@ -96,10 +96,12 @@ void kmain(Bootinfo* info) {
staying_in_ksh = true;
}
kprintf("Press any key to stay in ^gksh^!. \nPress ^yenter^! to continue booting in ring 3\n");
char c = '\n';
c = console_getc();
if (c != '\n') staying_in_ksh = true;
if (!staying_in_ksh) {
kprintf("Press any key to continue booting. \nPress ^yq^! to stay in ^gksh^!\n");
char c = '\n';
c = console_getc();
if (c == 'q') staying_in_ksh = true;
}
if (staying_in_ksh) sched_spawn(ksh, nullptr, false, 0);
else sched_spawn(init_task_entry, nullptr, false, 0);
+4 -4
View File
@@ -8,18 +8,18 @@
extern task* curr_task;
u64 sys_exit(i32 code) {
kprintf("\n[Dewar] process %s exited with code %d", curr_task->proc->name, code);
i32 sys_exit(i32 code) {
kprintf("\n[Dewar] process %s exited with code %d\n", curr_task->proc->name, code);
sched_exit();
return code;
}
u64 sys_spawn(const char* path) {
i32 sys_spawn(const char* path) {
return process_spawn(path, path);
}
u64 sys_wait(u64 pid) {
i32 sys_wait(u64 pid) {
sched_block(pid);
return pid;
}
+2 -2
View File
@@ -4,5 +4,5 @@
#pragma once
#include <types.h>
u64 spawn(const char* path);
u64 wait(u64 pid);
i32 spawn(const char* path);
i32 wait(u64 pid);
+4 -4
View File
@@ -3,13 +3,13 @@
#include <process.h>
extern u64 sys_spawn(const char* path);
extern u64 sys_wait(u64 pid);
extern i32 sys_spawn(const char* path);
extern i32 sys_wait(u64 pid);
u64 spawn(const char* path) {
i32 spawn(const char* path) {
return sys_spawn(path);
}
u64 wait(u64 pid) {
i32 wait(u64 pid) {
return sys_wait(pid);
}
+10 -4
View File
@@ -117,16 +117,22 @@ char* gets_s(char* str, u64 size) {
while (i < size - 1) {
c = getchar();
if (c == EOF || c == '\n' || c == '\r') break;
if (c == '\b') {
if (i > 0) {
i--;
printf("\b \b");
}
continue;
}
str[i++] = (char)c;
char ch = (char)c;
sys_write(1, &ch, 1);
putchar(c);
}
str[i] = '\0';
char nl = '\n';
sys_write(1, &nl, 1);
putchar('\n');
return str;
}
+2 -1
View File
@@ -3,4 +3,5 @@
#pragma once
void not_implemented_yet();
void not_implemented_yet();
void cmd_spawn(const char* path);
+16
View File
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 0xKarinyash
#include <process.h>
#include <stdio.h>
void cmd_spawn(const char* path) {
i32 pid = spawn(path);
if (pid < 0) {
switch (pid) {
case -1: printf("\"%s\" not found.\n", path); break;
default: printf("failed to spawn (%d)\n", pid); break;
}
} else {
wait(pid);
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ int main() {
case TOKEN_QUIT: return 0;
case TOKEN_CLEAR: not_implemented_yet(); break;
case TOKEN_HELP: not_implemented_yet(); break;
case TOKEN_SPAWN: not_implemented_yet(); break;
case TOKEN_SPAWN: if (tokens_count >= 2) cmd_spawn(tokens[1]); break;
default: printf("Unknown command\n"); break;
}
}