more fixes

This commit is contained in:
2026-10-05 23:55:10 +02:00
committed by Marvin Friedrich
parent 8f0c73f4dc
commit 4dd59ef79a
32 changed files with 403 additions and 59 deletions
+12
View File
@@ -0,0 +1,12 @@
#include <zinnia/panic.h>
#include <zinnia/syscall.h>
struct syscall_ret sys_exit(int err) {
struct syscall_ret ret = {};
ret.errno = ENOSYS;
panic("sys::exit() not implemented!\n");
return ret;
}
+2
View File
@@ -1,5 +1,7 @@
kernel_sources += files(
'archctl.c',
'dispatch.c',
'exit.c',
'syslog.c',
'uname.c',
)
+62
View File
@@ -0,0 +1,62 @@
#include <zinnia/alloc.h>
#include <zinnia/panic.h>
#include <zinnia/print.h>
#include <zinnia/syscall.h>
#include <zinnia/usercopy.h>
#include <stdint.h>
enum syslog_kind : uintptr_t {
SYSLOG_EMERG = 0,
SYSLOG_ALERT = 1,
SYSLOG_CRIT = 2,
SYSLOG_ERR = 3,
SYSLOG_WARNING = 4,
SYSLOG_NOTICE = 5,
SYSLOG_INFO = 6,
SYSLOG_DEBUG = 7,
};
struct syscall_ret sys_syslog(enum syslog_kind kind, __user char* message, size_t len) {
struct syscall_ret ret = {};
const size_t buf_len = MIN(len + 1, 0x1000);
char* buf = mem_alloc(buf_len, ALLOC_NOZERO);
usercopy_read(buf, message, buf_len - 1);
buf[buf_len] = 0;
const char* log_level;
switch (kind) {
case SYSLOG_EMERG:
log_level = "emerg";
break;
case SYSLOG_ALERT:
log_level = "alert";
break;
case SYSLOG_CRIT:
log_level = "crit";
break;
case SYSLOG_ERR:
log_level = "err";
break;
case SYSLOG_WARNING:
log_level = "warning";
break;
case SYSLOG_NOTICE:
log_level = "notice";
break;
case SYSLOG_INFO:
log_level = "info";
break;
case SYSLOG_DEBUG:
log_level = "debug";
break;
default:
log_level = "invalid";
}
log("syslog(%s): %s\n", log_level, buf);
mem_free(buf);
return ret;
}