feat(sh): add fastfetch with ASCII art logo and stylish Kali/Powerline terminal prompt

This commit is contained in:
RarDog
2026-09-02 21:28:51 +03:00
parent f751c20439
commit 053be85ff7
2 changed files with 76 additions and 9 deletions
+29
View File
@@ -294,6 +294,35 @@ static void execute_console_command(const char *raw_cmd) {
" clear - Clear terminal screen\n" " clear - Clear terminal screen\n"
" reboot - Reboot system\n" " reboot - Reboot system\n"
" poweroff - Power off system\n"); " poweroff - Power off system\n");
} else if (strcmp(raw_cmd, "fastfetch") == 0 || strcmp(raw_cmd, "neofetch") == 0 || strcmp(raw_cmd, "fetch") == 0) {
sysinfo_data_t info = {0, 0, 0, 0, 0};
register uint64_t rax __asm__("rax") = SYS_SYSINFO;
register uint64_t rdi __asm__("rdi") = (uint64_t)&info;
__asm__ volatile("syscall" : "+r"(rax) : "r"(rdi) : "rcx", "r11", "memory");
uint64_t total_mb = info.total_memory_bytes / (1024 * 1024);
uint64_t free_mb = info.free_memory_bytes / (1024 * 1024);
uint64_t used_mb = (total_mb >= free_mb) ? (total_mb - free_mb) : 0;
uint32_t uptime_sec = (uint32_t)(info.uptime_ticks / 100);
snprintf(buf, sizeof(buf),
" ___ root@opencoreC\n"
" / \\ -----------------\n"
" | (o) | ___ OS: opencoreC Microkernel x86_64\n"
" | | / \\ Kernel: v0.1.0-release (Rust #![no_std])\n"
" \\ ___ / | (o) | Uptime: %u mins, %u secs\n"
" \\___/ Shell: osh (opencore shell)\n"
" [=== opencoreC ===] Display: 1280x800 @ 60Hz 32bpp (Limine FB)\n"
" x86_64 SMP DE/WM: LVGL Desktop Compositor (Ring 3)\n"
" Ring 3 Userspace CPU: QEMU Virtual CPU (4 Cores SMP)\n"
" Fast-Path IPC Cap RAM: %u MiB / %u MiB (%u%%)\n"
" Network: RTL8139 Fast Ethernet (10.0.2.15)\n"
" ACPI: MADT 4 Cores, S5 Power, Hardware Reset\n"
" Security: Ring 3 Fault Isolation (SIGSEGV)\n"
" RNG: Hardware RDRAND / RDSEED Active\n",
uptime_sec / 60, uptime_sec % 60,
(unsigned int)used_mb, (unsigned int)total_mb,
total_mb > 0 ? (unsigned int)(used_mb * 100 / total_mb) : 0);
lv_textarea_add_text(g_txt_term_output, buf);
} else if (strcmp(raw_cmd, "clear") == 0) { } else if (strcmp(raw_cmd, "clear") == 0) {
lv_textarea_set_text(g_txt_term_output, "opencoreC Linux-compatible Terminal (osh)\nType 'help' for available commands.\n"); lv_textarea_set_text(g_txt_term_output, "opencoreC Linux-compatible Terminal (osh)\nType 'help' for available commands.\n");
} else if (strcmp(raw_cmd, "uname") == 0 || strcmp(raw_cmd, "uname -a") == 0) { } else if (strcmp(raw_cmd, "uname") == 0 || strcmp(raw_cmd, "uname -a") == 0) {
+47 -9
View File
@@ -48,8 +48,51 @@ static EnvVar g_env[16] = {
}; };
static size_t g_env_count = 5; static size_t g_env_count = 5;
static void print_fastfetch() {
sysinfo_data_t info = {0, 0, 0, 0, 0};
sys_sysinfo(&info);
uint64_t total_mb = info.total_memory_bytes / (1024 * 1024);
uint64_t free_mb = info.free_memory_bytes / (1024 * 1024);
uint64_t used_mb = (total_mb >= free_mb) ? (total_mb - free_mb) : 0;
uint32_t uptime_sec = (uint32_t)(info.uptime_ticks / 100);
acpi_info_data_t acpi = {0, 0, 0, 0, 0};
register uint64_t rax __asm__("rax") = SYS_ACPI_INFO;
register uint64_t rdi __asm__("rdi") = (uint64_t)&acpi;
__asm__ volatile("syscall" : "+r"(rax) : "r"(rdi) : "rcx", "r11", "memory");
fb_info_t fb = {0, 0, 0, 0, 0};
rax = SYS_FB_INFO;
rdi = (uint64_t)&fb;
__asm__ volatile("syscall" : "+r"(rax) : "r"(rdi) : "rcx", "r11", "memory");
printf("\n");
printf(" \033[1;36m ___ \033[1;32mroot\033[0m@\033[1;36mopencoreC\033[0m\n");
printf(" \033[1;36m / \\ \033[0;37m-----------------\033[0m\n");
printf(" \033[1;36m | (o) | ___ \033[1;34mOS:\033[0m opencoreC Microkernel x86_64\n");
printf(" \033[1;36m | | / \\ \033[1;34mKernel:\033[0m v0.1.0-release (Rust #![no_std])\n");
printf(" \033[1;36m \\ ___ / | (o) | \033[1;34mUptime:\033[0m %u mins, %u secs\n", uptime_sec / 60, uptime_sec % 60);
printf(" \033[1;36m \\___/ \033[1;34mShell:\033[0m osh (opencore shell 1.0)\n");
if (fb.width > 0 && fb.height > 0) {
printf(" \033[1;34m [=== opencoreC ===] \033[1;34mDisplay:\033[0m %ux%u @ 60Hz 32bpp (Linear FB)\n", (unsigned int)fb.width, (unsigned int)fb.height);
} else {
printf(" \033[1;34m [=== opencoreC ===] \033[1;34mDisplay:\033[0m 1280x800 @ 60Hz (Limine FB)\n");
}
printf(" \033[1;35m x86_64 SMP \033[1;34mDE / WM:\033[0m LVGL v8.3 Windows/KDE Compositor\n");
printf(" \033[1;35m Ring 3 Userspace \033[1;34mCPU:\033[0m QEMU Virtual CPU (4 Cores SMP)\n");
printf(" \033[1;35m Fast-Path IPC Cap \033[1;34mMemory:\033[0m %u MiB / %u MiB (%u%%)\n",
(unsigned int)used_mb, (unsigned int)total_mb,
total_mb > 0 ? (unsigned int)(used_mb * 100 / total_mb) : 0);
printf(" \033[1;34mNetwork:\033[0m Realtek RTL8139 (10.0.2.15)\n");
printf(" \033[1;34mACPI:\033[0m S5 Poweroff, Reset, MADT 4 Cores\n");
printf(" \033[1;34mSecurity:\033[0m Ring 3 Signal Fault Isolation (SIGSEGV)\n");
printf(" \033[1;34mEntropy:\033[0m Hardware RNG (RDRAND / TSC)\n\n");
printf(" \033[40m \033[41m \033[42m \033[43m \033[44m \033[45m \033[46m \033[47m \033[0m\n");
printf(" \033[100m \033[101m \033[102m \033[103m \033[104m \033[105m \033[106m \033[107m \033[0m\n\n");
}
static void print_prompt() { static void print_prompt() {
const char prompt[] = "root@opencoreC:~# "; const char prompt[] = "\033[1;34m┌──(\033[1;32mroot\033[1;37m@\033[1;36mopencoreC\033[1;34m)-[\033[1;33m~\033[1;34m]\n\033[1;34m└─\033[1;35m#\033[0m ";
sys_log_debug(prompt, sizeof(prompt) - 1); sys_log_debug(prompt, sizeof(prompt) - 1);
} }
@@ -544,6 +587,8 @@ static void handle_command(char *cmd) {
puts("[CRASH-TEST] Expected outcome: Kernel delivers SIGSEGV, terminates this thread, kernel stays alive!"); puts("[CRASH-TEST] Expected outcome: Kernel delivers SIGSEGV, terminates this thread, kernel stays alive!");
volatile int *bad_ptr = (volatile int *)0; volatile int *bad_ptr = (volatile int *)0;
*bad_ptr = 42; *bad_ptr = 42;
} else if (strcmp(cmd, "fastfetch") == 0 || strcmp(cmd, "neofetch") == 0 || strcmp(cmd, "fetch") == 0) {
print_fastfetch();
} else if (strcmp(cmd, "clear") == 0) { } else if (strcmp(cmd, "clear") == 0) {
sys_log_debug("\033[2J\033[H", 7); sys_log_debug("\033[2J\033[H", 7);
} else if (strcmp(cmd, "reboot") == 0) { } else if (strcmp(cmd, "reboot") == 0) {
@@ -563,14 +608,7 @@ extern "C" void _start() {
} }
sys_log_debug("\033[2J\033[H", 7); sys_log_debug("\033[2J\033[H", 7);
puts("==============================================================================="); print_fastfetch();
puts(" opencoreC High-Performance Microkernel Operating System (x86_64) ");
puts("===============================================================================");
puts(" Kernel: Rust #![no_std] (Higher-Half, Long Mode, SMP 4 Cores)");
puts(" Architecture: x86_64 System V AMD64 ABI (4-Level Paging, Fast-Path IPC)");
puts(" User Space: C++20 & Freestanding C11 (Isolated Ring 3 Tasks)");
puts(" Subsystems: PCI RTL8139 Net, Limine Framebuffer GUI, Process Manager");
puts(" Type 'help' to view available commands.\n");
char input_line[256]; char input_line[256];
size_t line_len = 0; size_t line_len = 0;