feat(userspace): userspace support

build: updated CMakeLists to build and copy to initramfs

wip(syscalls): initial syscalls

chore(ksh/kfetch): minor changes

chore(gitignore): added initramfs/*
This commit is contained in:
Karina
2026-01-29 21:25:45 +04:00
parent 3f3a026432
commit 55ea8fc533
23 changed files with 399 additions and 135 deletions
+7 -3
View File
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 0xKarinyash
#pragma once
#include <types.h>
#define CPU_FEAT_FPU (1ULL << 0)
@@ -24,7 +24,11 @@
#define CPU_FEAT_HYPERVISOR (1ULL << 30)
typedef struct {
i32 features;
u64 user_rsp;
u64 kernel_rsp;
u64 self;
u64 features;
char vendor[13];
u32 family;
u32 model;
@@ -32,5 +36,5 @@ typedef struct {
extern cpu_info g_cpu;
void cpuinfo_init();
void cpuinfo_init(u64 kernel_stack_top);
bool cpu_has(u64 feature);
+20
View File
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 0xKarinyash
#pragma once
#define MSR_EFER 0xC0000080
#define MSR_STAR 0xC0000081
#define MSR_LSTAR 0xC0000082
#define MSR_FMASK 0xC0000084
#define MSR_KERNEL_GS_BASE 0xC0000102
#define EFER_SCE 0x01 // System Call Enable
typedef enum {
SYS_EXIT,
SYS_EXEC,
SYS_WRITE,
} syscalls;
void syscall_init();
+9
View File
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 0xKarinyash
#pragma once
#include <types.h>
bool exec_init(const char* path);
void init_task_entry();
+6
View File
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 0xKarinyash
#pragma once
void jump_to_userspace(void* entry, void* user_stack_top);
+1 -9
View File
@@ -26,16 +26,8 @@ typedef struct {
const unsigned char* base;
} SG_Font;
typedef struct {
SG_Context *ctx;
SG_Point pos;
const char *title;
} SG_Window;
void sg_init(SG_Context *ctx);
u32 sg_get_pixel(SG_Context *ctx, SG_Point *p);
void sg_put_img(SG_Context *ctx, SG_Point *p, SG_Image *img);
void sg_draw_rect(SG_Context *ctx, SG_Point *p, u32 w, u32 h, u32 color);
void sg_draw_char_bitmap(SG_Context *ctx, SG_Point *p, char c, u32 color, SG_Font *font);
SG_Window* create_window(const char *title, SG_Point* size, SG_Point* position);
void composer_task();
void sg_draw_char_bitmap(SG_Context *ctx, SG_Point *p, char c, u32 color, SG_Font *font);