mirror of
https://github.com/JannisHeydemann/BoredOS.git
synced 2026-05-30 10:26:59 +00:00
feat: centralize OS version info in kernel syscall
This commit is contained in:
@@ -237,13 +237,29 @@ int main(int argc, char **argv) {
|
||||
if (config.separator[0]) {
|
||||
strcpy(info_lines[info_line_count++], config.separator);
|
||||
}
|
||||
os_info_t os_info;
|
||||
sys_get_os_info(&os_info);
|
||||
|
||||
if (config.os_label[0]) {
|
||||
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]) {
|
||||
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]) {
|
||||
uint64_t ticks = sys_system(16, 0, 0, 0, 0);
|
||||
|
||||
@@ -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) {
|
||||
int w = 340;
|
||||
int h = 240;
|
||||
int w = 380;
|
||||
int h = 260;
|
||||
|
||||
// Clear background to prevent alpha-blended text from accumulating on repaints
|
||||
ui_draw_rect(win, 0, 0, w, h, 0xFF1E1E1E);
|
||||
|
||||
int offset_x = 15;
|
||||
@@ -96,19 +95,51 @@ static void about_paint(ui_window_t win) {
|
||||
draw_ascii_logo(win, 14, offset_y);
|
||||
|
||||
int fh = ui_get_font_height();
|
||||
ui_draw_string(win, offset_x, offset_y + 105, "BoredOS 'Retrowave'", 0xFFFFFFFF);
|
||||
ui_draw_string(win, offset_x, offset_y + 105 + fh, "BoredOS Version 1.72", 0xFFFFFFFF);
|
||||
ui_draw_string(win, offset_x, offset_y + 105 + fh*2, "Kernel Version 3.1.2", 0xFFFFFFFF);
|
||||
os_info_t os_info;
|
||||
sys_get_os_info(&os_info);
|
||||
|
||||
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
|
||||
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, "All rights reserved.", 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*5, "All rights reserved.", 0xFFFFFFFF);
|
||||
|
||||
ui_mark_dirty(win, 0, 0, w, h);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -121,7 +152,6 @@ int main(void) {
|
||||
sys_exit(0);
|
||||
}
|
||||
} else {
|
||||
// Avoid high CPU usage
|
||||
sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,3 +251,7 @@ void sys_yield(void) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
#define SYSTEM_CMD_SET_RAW_MODE 41
|
||||
#define SYSTEM_CMD_TCP_RECV_NB 42
|
||||
#define SYSTEM_CMD_YIELD 43
|
||||
#define SYSTEM_CMD_GET_OS_INFO 49
|
||||
|
||||
// Internal assembly entry into Ring 0
|
||||
extern uint64_t syscall0(uint64_t sys_num);
|
||||
@@ -91,6 +92,19 @@ void *sys_sbrk(int incr);
|
||||
void sys_kill(int pid);
|
||||
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
|
||||
int sys_open(const char *path, const char *mode);
|
||||
int sys_read(int fd, void *buf, uint32_t len);
|
||||
|
||||
Reference in New Issue
Block a user