feat(kernel): implement SMP multi-core affinity, ACPI subsystem, hardware RNG (RDRAND), and Ring 3 signal fault isolation

This commit is contained in:
RarDog
2026-09-02 21:23:49 +03:00
parent 99a3730c0d
commit f751c20439
13 changed files with 697 additions and 46 deletions
+54
View File
@@ -399,6 +399,60 @@ static void execute_console_command(const char *raw_cmd) {
} else {
lv_textarea_add_text(g_txt_term_output, "[dmesg] No new kernel log messages.\n");
}
} else if (strcmp(raw_cmd, "random") == 0 || strcmp(raw_cmd, "rng") == 0) {
uint8_t rand_bytes[16];
register uint64_t rax __asm__("rax") = SYS_GETRANDOM;
register uint64_t rdi __asm__("rdi") = (uint64_t)rand_bytes;
register uint64_t rsi __asm__("rsi") = sizeof(rand_bytes);
__asm__ volatile("syscall" : "+r"(rax) : "r"(rdi), "r"(rsi) : "rcx", "r11", "memory");
if ((int64_t)rax > 0) {
snprintf(buf, sizeof(buf), "Hardware RNG (16 bytes): %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
rand_bytes[0], rand_bytes[1], rand_bytes[2], rand_bytes[3],
rand_bytes[4], rand_bytes[5], rand_bytes[6], rand_bytes[7],
rand_bytes[8], rand_bytes[9], rand_bytes[10], rand_bytes[11],
rand_bytes[12], rand_bytes[13], rand_bytes[14], rand_bytes[15]);
lv_textarea_add_text(g_txt_term_output, buf);
} else {
lv_textarea_add_text(g_txt_term_output, "random: RNG syscall failed\n");
}
} else if (strcmp(raw_cmd, "acpi") == 0) {
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");
if (acpi.found) {
snprintf(buf, sizeof(buf),
"ACPI Subsystem:\n"
" RSDP: Revision %u\n"
" MADT: %u CPU Cores enabled\n"
" FADT: PM1a=0x%04x, PM1b=0x%04x\n"
" Power: Hardware S5 Shutdown & Reset Active\n",
acpi.revision, acpi.lapic_count, acpi.pm1a_cnt, acpi.pm1b_cnt);
lv_textarea_add_text(g_txt_term_output, buf);
} else {
lv_textarea_add_text(g_txt_term_output, "ACPI: RSDP table not found.\n");
}
} else if (strcmp(raw_cmd, "smp") == 0 || strcmp(raw_cmd, "cpu") == 0) {
cpu_info_data_t cpu = {0, 0, {0, 0, 0, 0}};
register uint64_t rax __asm__("rax") = SYS_CPU_INFO;
register uint64_t rdi __asm__("rdi") = (uint64_t)&cpu;
__asm__ volatile("syscall" : "+r"(rax) : "r"(rdi) : "rcx", "r11", "memory");
snprintf(buf, sizeof(buf),
"SMP Multi-Core Topology:\n"
" Cores Online: %u physical cores\n"
" Current CPU: CPU %u (Executing GUI)\n"
" Core 0 Ticks: %lu (Kernel & Interrupts)\n"
" Core 1 Ticks: %lu (Dedicated GUI Compositor)\n"
" Core 2 Ticks: %lu (Dedicated Interactive Shell)\n"
" Core 3 Ticks: %lu (Dedicated Background Services)\n",
cpu.cores_online, cpu.current_cpu_id,
(unsigned long)cpu.core_ticks[0], (unsigned long)cpu.core_ticks[1],
(unsigned long)cpu.core_ticks[2], (unsigned long)cpu.core_ticks[3]);
lv_textarea_add_text(g_txt_term_output, buf);
} else if (strcmp(raw_cmd, "crash_test") == 0) {
lv_textarea_add_text(g_txt_term_output, "[CRASH-TEST] Triggering Ring 3 null-pointer fault (*(int*)0 = 42)...\n");
volatile int *p = (volatile int *)0;
*p = 42;
} else if (strcmp(raw_cmd, "reboot") == 0) {
lv_textarea_add_text(g_txt_term_output, "Rebooting system...\n");
register uint64_t rax __asm__("rax") = SYS_REBOOT;