feat: centralize OS version info in kernel syscall

This commit is contained in:
boreddevnl 2026-03-17 16:06:00 +01:00
parent 0491c4ad0f
commit 7b7f134e27
7 changed files with 127 additions and 12 deletions

33
src/core/version.c Normal file
View file

@ -0,0 +1,33 @@
// Copyright (c) 2023-2026 Chris (boreddevnl)
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
// This header needs to maintain in any file it is present in, as per the GPL license terms.
#include "syscall.h"
#include <stddef.h>
extern void mem_memcpy(void *dest, const void *src, size_t len);
void get_os_info(os_info_t *info) {
if (!info) return;
char *p = (char *)info;
for (size_t i = 0; i < sizeof(os_info_t); i++) p[i] = 0;
const char *os_name = "BoredOS";
const char *os_version = "1.72";
const char *os_codename = "Retrowave";
const char *kernel_name = "Boredkernel";
const char *kernel_version = "3.1.2";
const char *build_date = __DATE__;
const char *build_time = __TIME__;
const char *build_arch = "x86_64";
int j;
j = 0; while (os_name[j] && j < 63) { info->os_name[j] = os_name[j]; j++; } info->os_name[j] = '\0';
j = 0; while (os_version[j] && j < 63) { info->os_version[j] = os_version[j]; j++; } info->os_version[j] = '\0';
j = 0; while (os_codename[j] && j < 63) { info->os_codename[j] = os_codename[j]; j++; } info->os_codename[j] = '\0';
j = 0; while (kernel_name[j] && j < 63) { info->kernel_name[j] = kernel_name[j]; j++; } info->kernel_name[j] = '\0';
j = 0; while (kernel_version[j] && j < 63) { info->kernel_version[j] = kernel_version[j]; j++; } info->kernel_version[j] = '\0';
j = 0; while (build_date[j] && j < 63) { info->build_date[j] = build_date[j]; j++; } info->build_date[j] = '\0';
j = 0; while (build_time[j] && j < 63) { info->build_time[j] = build_time[j]; j++; } info->build_time[j] = '\0';
j = 0; while (build_arch[j] && j < 63) { info->build_arch[j] = build_arch[j]; j++; } info->build_arch[j] = '\0';
}

View file

@ -1258,6 +1258,12 @@ static uint64_t syscall_handler_inner(registers_t *regs) {
return 0; return 0;
} }
return -1; return -1;
} else if (cmd == 49) { // SYSTEM_CMD_GET_OS_INFO
os_info_t *info = (os_info_t *)arg2;
if (!info) return -1;
extern void get_os_info(os_info_t *info);
get_os_info(info);
return 0;
} }
return -1; return -1;
} }

View file

@ -10,6 +10,17 @@
typedef struct Window Window; typedef struct Window Window;
typedef struct registers_t registers_t; typedef struct registers_t registers_t;
typedef struct {
char os_name[64];
char os_version[64];
char os_codename[64];
char kernel_name[64];
char kernel_version[64];
char build_date[64];
char build_time[64];
char build_arch[64];
} os_info_t;
// MSRs used for syscalls in x86_64 // MSRs used for syscalls in x86_64
#define MSR_EFER 0xC0000080 #define MSR_EFER 0xC0000080
#define MSR_STAR 0xC0000081 #define MSR_STAR 0xC0000081
@ -46,6 +57,7 @@ typedef struct registers_t registers_t;
#define SYSTEM_CMD_GET_CPU_MODEL 45 #define SYSTEM_CMD_GET_CPU_MODEL 45
#define SYSTEM_CMD_SLEEP 46 #define SYSTEM_CMD_SLEEP 46
#define SYSTEM_CMD_SET_RESOLUTION 47 #define SYSTEM_CMD_SET_RESOLUTION 47
#define SYSTEM_CMD_GET_OS_INFO 49
void syscall_init(void); void syscall_init(void);
uint64_t syscall_handler_c(registers_t *regs); uint64_t syscall_handler_c(registers_t *regs);

View file

@ -237,13 +237,29 @@ int main(int argc, char **argv) {
if (config.separator[0]) { if (config.separator[0]) {
strcpy(info_lines[info_line_count++], config.separator); strcpy(info_lines[info_line_count++], config.separator);
} }
os_info_t os_info;
sys_get_os_info(&os_info);
if (config.os_label[0]) { if (config.os_label[0]) {
strcpy(info_lines[info_line_count], config.os_label); strcpy(info_lines[info_line_count], config.os_label);
strcat(info_lines[info_line_count++], ": BoredOS V1.72 'Retrowave'"); strcat(info_lines[info_line_count], ": ");
strcat(info_lines[info_line_count], os_info.os_name);
strcat(info_lines[info_line_count], " V");
strcat(info_lines[info_line_count], os_info.os_version);
strcat(info_lines[info_line_count], " '");
strcat(info_lines[info_line_count], os_info.os_codename);
strcat(info_lines[info_line_count], "'");
info_line_count++;
} }
if (config.kernel_label[0]) { if (config.kernel_label[0]) {
strcpy(info_lines[info_line_count], config.kernel_label); strcpy(info_lines[info_line_count], config.kernel_label);
strcat(info_lines[info_line_count++], ": Boredkernel V3.1.2 x86_64"); strcat(info_lines[info_line_count], ": ");
strcat(info_lines[info_line_count], os_info.kernel_name);
strcat(info_lines[info_line_count], " V");
strcat(info_lines[info_line_count], os_info.kernel_version);
strcat(info_lines[info_line_count], " ");
strcat(info_lines[info_line_count], os_info.build_arch);
info_line_count++;
} }
if (config.uptime_label[0]) { if (config.uptime_label[0]) {
uint64_t ticks = sys_system(16, 0, 0, 0, 0); uint64_t ticks = sys_system(16, 0, 0, 0, 0);

View file

@ -84,10 +84,9 @@ static void draw_ascii_logo(ui_window_t win, int x, int y) {
} }
static void about_paint(ui_window_t win) { static void about_paint(ui_window_t win) {
int w = 340; int w = 380;
int h = 240; int h = 260;
// Clear background to prevent alpha-blended text from accumulating on repaints
ui_draw_rect(win, 0, 0, w, h, 0xFF1E1E1E); ui_draw_rect(win, 0, 0, w, h, 0xFF1E1E1E);
int offset_x = 15; int offset_x = 15;
@ -96,19 +95,51 @@ static void about_paint(ui_window_t win) {
draw_ascii_logo(win, 14, offset_y); draw_ascii_logo(win, 14, offset_y);
int fh = ui_get_font_height(); int fh = ui_get_font_height();
ui_draw_string(win, offset_x, offset_y + 105, "BoredOS 'Retrowave'", 0xFFFFFFFF); os_info_t os_info;
ui_draw_string(win, offset_x, offset_y + 105 + fh, "BoredOS Version 1.72", 0xFFFFFFFF); sys_get_os_info(&os_info);
ui_draw_string(win, offset_x, offset_y + 105 + fh*2, "Kernel Version 3.1.2", 0xFFFFFFFF);
char os_name_str[128];
os_name_str[0] = 0;
strcat(os_name_str, os_info.os_name);
strcat(os_name_str, " '");
strcat(os_name_str, os_info.os_codename);
strcat(os_name_str, "'");
char os_version_str[128];
os_version_str[0] = 0;
strcat(os_version_str, os_info.os_name);
strcat(os_version_str, " Version ");
strcat(os_version_str, os_info.os_version);
char kernel_version_str[128];
kernel_version_str[0] = 0;
strcat(kernel_version_str, os_info.kernel_name);
strcat(kernel_version_str, " Version ");
strcat(kernel_version_str, os_info.kernel_version);
strcat(kernel_version_str, " ");
strcat(kernel_version_str, os_info.build_arch);
char build_date_str[128];
build_date_str[0] = 0;
strcat(build_date_str, "Build Date: ");
strcat(build_date_str, os_info.build_date);
strcat(build_date_str, " ");
strcat(build_date_str, os_info.build_time);
ui_draw_string(win, offset_x, offset_y + 105, os_name_str, 0xFFFFFFFF);
ui_draw_string(win, offset_x, offset_y + 105 + fh, os_version_str, 0xFFFFFFFF);
ui_draw_string(win, offset_x, offset_y + 105 + fh*2, kernel_version_str, 0xFFFFFFFF);
ui_draw_string(win, offset_x, offset_y + 105 + fh*3, build_date_str, 0xFFFFFFFF);
// Copyright // Copyright
ui_draw_string(win, offset_x, offset_y + 105 + fh*3, "(C) 2026 boreddevnl.", 0xFFFFFFFF); ui_draw_string(win, offset_x, offset_y + 105 + fh*4, "(C) 2026 boreddevnl.", 0xFFFFFFFF);
ui_draw_string(win, offset_x, offset_y + 105 + fh*4, "All rights reserved.", 0xFFFFFFFF); ui_draw_string(win, offset_x, offset_y + 105 + fh*5, "All rights reserved.", 0xFFFFFFFF);
ui_mark_dirty(win, 0, 0, w, h); ui_mark_dirty(win, 0, 0, w, h);
} }
int main(void) { int main(void) {
ui_window_t win_about = ui_window_create("About BoredOS", 250, 180, 340, 240); ui_window_t win_about = ui_window_create("About BoredOS", 250, 180, 380, 260);
about_paint(win_about); about_paint(win_about);
@ -121,7 +152,6 @@ int main(void) {
sys_exit(0); sys_exit(0);
} }
} else { } else {
// Avoid high CPU usage
sleep(10); sleep(10);
} }
} }

View file

@ -251,3 +251,7 @@ void sys_yield(void) {
syscall1(SYS_SYSTEM, SYSTEM_CMD_YIELD); syscall1(SYS_SYSTEM, SYSTEM_CMD_YIELD);
} }
int sys_get_os_info(os_info_t *info) {
return (int)syscall5(SYS_SYSTEM, SYSTEM_CMD_GET_OS_INFO, (uint64_t)info, 0, 0, 0);
}

View file

@ -75,6 +75,7 @@
#define SYSTEM_CMD_SET_RAW_MODE 41 #define SYSTEM_CMD_SET_RAW_MODE 41
#define SYSTEM_CMD_TCP_RECV_NB 42 #define SYSTEM_CMD_TCP_RECV_NB 42
#define SYSTEM_CMD_YIELD 43 #define SYSTEM_CMD_YIELD 43
#define SYSTEM_CMD_GET_OS_INFO 49
// Internal assembly entry into Ring 0 // Internal assembly entry into Ring 0
extern uint64_t syscall0(uint64_t sys_num); extern uint64_t syscall0(uint64_t sys_num);
@ -91,6 +92,19 @@ void *sys_sbrk(int incr);
void sys_kill(int pid); void sys_kill(int pid);
int sys_system(int cmd, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4); int sys_system(int cmd, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4);
typedef struct {
char os_name[64];
char os_version[64];
char os_codename[64];
char kernel_name[64];
char kernel_version[64];
char build_date[64];
char build_time[64];
char build_arch[64];
} os_info_t;
int sys_get_os_info(os_info_t *info);
// FS API // FS API
int sys_open(const char *path, const char *mode); int sys_open(const char *path, const char *mode);
int sys_read(int fd, void *buf, uint32_t len); int sys_read(int fd, void *buf, uint32_t len);