This commit is contained in:
2026-09-25 15:39:16 +02:00
committed by Marvin Friedrich
parent b9ee87aed4
commit 6e92817f3f
35 changed files with 271 additions and 157 deletions
+4 -4
View File
@@ -1,8 +1,8 @@
#include <zinnia/compiler.h>
#include <zinnia/utils.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <zinnia/compiler.h>
#include <zinnia/utils.h>
[[__hot]]
size_t strlen(const char* str) {
@@ -25,8 +25,8 @@ size_t strnlen(const char* str, size_t len) {
[[__hot]]
int memcmp(const void* s1, const void* s2, size_t size) {
int diff = 0;
char* s1ptr = (char*)s1;
char* s2ptr = (char*)s2;
const uint8_t* s1ptr = s1;
const uint8_t* s2ptr = s2;
for (size_t i = 0; i < size; i++) {
if (s1ptr[i] != s2ptr[i])
-1
View File
@@ -13,4 +13,3 @@ kernel_sources += files(
subdir('lib')
subdir('mem')
subdir('sched')
subdir('syscalls')
+1 -1
View File
@@ -2,7 +2,7 @@
#include <zinnia/percpu.h>
#include <arch/percpu.h>
[[__percpu]]
[[__used, __section(".percpu.init")]]
struct percpu percpu_bsp = {
.self = &percpu_bsp,
.id = 0,
-6
View File
@@ -1,6 +0,0 @@
#include <zinnia/syscall.h>
#include <arch/archctl.h>
void sys_archctl(struct arch_context* ctx) {
ctx->ARCH_CTX_RET0 = arch_archctl(ctx->ARCH_CTX_A0, ctx->ARCH_CTX_A1);
}
-52
View File
@@ -1,52 +0,0 @@
#include <zinnia/compiler.h>
#include <zinnia/errno.h>
#include <zinnia/print.h>
#include <zinnia/sched.h>
#include <zinnia/syscall.h>
#include <zinnia/types.h>
#include <zinnia/utils.h>
#include <bits/sched.h>
// Declare all syscalls.
#include <zinnia/syscall_list.inc>
#undef SYSCALL_DECLARE
// Define them.
const struct syscall syscall_table[256] = {
#define SYSCALL_DECLARE(number, name, num_args) [number] = {sys_##name, num_args},
#include <zinnia/syscall_list.inc>
};
[[gnu::no_caller_saved_registers]]
struct syscall_ret syscall_dispatch_fast(
uintptr_t a0,
uintptr_t a1,
uintptr_t a2,
uintptr_t a3,
uintptr_t a4,
uintptr_t a5,
size_t num
) {
// No need to check the table size here. In order to get to this point,
// we already have to check if this is a fast syscall.
if (syscall_table[num].func == nullptr) {
return (struct syscall_ret){.errno = ENOSYS};
}
struct syscall_ret (*func)(uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t) =
syscall_table[num].func;
return func(a0, a1, a2, a3, a4, a5);
}
void syscall_dispatch(struct arch_context* ctx) {
const size_t num = ctx->ARCH_CTX_NUM;
if (num >= ARRAY_SIZE(syscall_table) || syscall_table[num].func == nullptr) {
ctx->ARCH_CTX_RET0 = ENOSYS;
return;
}
void (*func)(struct arch_context* ctx) = syscall_table[num].func;
func(ctx);
}
-33
View File
@@ -1,33 +0,0 @@
#include <zinnia/spin.h>
#include <zinnia/syscall.h>
#include <zinnia/usercopy.h>
#include <config.h>
#include <uapi/utsname.h>
static struct spinlock uname_lock = {};
static struct utsname uname_buf = {
.sysname = "Zinnia",
.release = ZINNIA_VERSION,
.version = CONFIG_KERNEL_FLAVOR,
.nodename = "localhost",
.machine = ZINNIA_ARCH,
};
struct syscall_ret sys_getuname(__user struct utsname* ptr) {
struct syscall_ret ret = {};
if (!ptr) {
ret.errno = EINVAL;
return ret;
}
spin_lock(&uname_lock);
if (!usercopy_write(ptr, &uname_buf, sizeof(uname_buf)))
ret.errno = EFAULT;
spin_unlock(&uname_lock);
return ret;
}
-5
View File
@@ -1,5 +0,0 @@
kernel_sources += files(
'archctl.c',
'dispatch.c',
'getuname.c',
)