feat(kernel): genesis of Airlys 64-bit sovereign OS kernel (Phase 1)
This commit is contained in:
commit
7210b60fc7
15 files changed
+746
No files matched your search
@@ -0,0 +1,46 @@
|
||||
#include <airlys/kernel.h>
|
||||
#include <airlys/vga.h>
|
||||
|
||||
void kernel_main(uint64_t magic, uint64_t addr) {
|
||||
/* Initialize hardware VGA terminal console */
|
||||
vga_init();
|
||||
|
||||
/* Banner & Sovereign Branding */
|
||||
vga_set_color(VGA_COLOR_LIGHT_CYAN, VGA_COLOR_BLACK);
|
||||
vga_puts("================================================================================\n");
|
||||
vga_puts(" _ ___ ____ _ __ ______ \n");
|
||||
vga_puts(" / \\ |_ _| _ \\| | \\ \\ / / ___| \n");
|
||||
vga_puts(" / _ \\ | || |_) | | \\ V /\\___ \\ \n");
|
||||
vga_puts(" / ___ \\ | || _ <| |___| | ___) |\n");
|
||||
vga_puts(" /_/ \\_\\___|_| \\_\\_____|_| |____/ SOVEREIGN OS KERNEL v0.1.0\n");
|
||||
vga_puts("================================================================================\n");
|
||||
|
||||
vga_set_color(VGA_COLOR_WHITE, VGA_COLOR_BLACK);
|
||||
vga_puts(" [OK] Airlys Kernel Genesis initialized successfully!\n");
|
||||
vga_puts(" [OK] Architecture : x86_64 (64-Bit Long Mode)\n");
|
||||
vga_puts(" [OK] Creator : Er. Adam Eehan (Founder & CEO, Aira Group)\n");
|
||||
vga_puts(" [OK] Co-Pilot : Sovereign AI Aira 3 Ultra (Engine v3.6)\n");
|
||||
|
||||
vga_set_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK);
|
||||
vga_puts("--------------------------------------------------------------------------------\n");
|
||||
|
||||
vga_set_color(VGA_COLOR_LIGHT_GREEN, VGA_COLOR_BLACK);
|
||||
vga_puts(" [*] Bootloader Magic : ");
|
||||
vga_puthex(magic);
|
||||
vga_puts("\n");
|
||||
vga_puts(" [*] Multiboot Info : ");
|
||||
vga_puthex(addr);
|
||||
vga_puts("\n");
|
||||
|
||||
vga_set_color(VGA_COLOR_LIGHT_CYAN, VGA_COLOR_BLACK);
|
||||
vga_puts(" [*] Physical VGA Memory Map: 0x000B8000 (80x25 Text Mode)\n");
|
||||
vga_puts(" [*] Preemptive Subsystems: Ready for Stage 2 (GDT & IDT Interrupts)\n");
|
||||
|
||||
vga_set_color(VGA_COLOR_LIGHT_MAGENTA, VGA_COLOR_BLACK);
|
||||
vga_puts("\n >>> Airlys System Idle Loop Active. CPU Halted awaiting hardware ticks.\n");
|
||||
|
||||
/* Infinite safe idle loop */
|
||||
for (;;) {
|
||||
__asm__ volatile ("hlt");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <airlys/kernel.h>
|
||||
#include <airlys/vga.h>
|
||||
|
||||
void kernel_panic(const char* message) {
|
||||
vga_set_color(VGA_COLOR_WHITE, VGA_COLOR_RED);
|
||||
vga_clear();
|
||||
vga_puts("\n\n");
|
||||
vga_puts(" ========================================================================\n");
|
||||
vga_puts(" [!] AIRLYS SOVEREIGN KERNEL PANIC\n");
|
||||
vga_puts(" ========================================================================\n\n");
|
||||
vga_puts(" An unrecoverable system state occurred.\n\n");
|
||||
vga_puts(" Reason: ");
|
||||
vga_puts(message ? message : "Unknown error");
|
||||
vga_puts("\n\n");
|
||||
vga_puts(" System Halted. Please reboot the host machine.\n");
|
||||
vga_puts(" Architecture: x86_64 Long Mode | Aira Group of Technology\n");
|
||||
vga_puts(" ========================================================================\n");
|
||||
|
||||
/* Halt the CPU */
|
||||
for (;;) {
|
||||
__asm__ volatile ("cli; hlt");
|
||||
}
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
#include <airlys/vga.h>
|
||||
|
||||
static size_t vga_row;
|
||||
static size_t vga_column;
|
||||
static uint8_t vga_current_color;
|
||||
static volatile uint16_t* const vga_buffer = (volatile uint16_t*)VGA_BUFFER_PHYSICAL;
|
||||
|
||||
/* Outport byte to I/O port (used for hardware cursor updates) */
|
||||
static inline void outb(uint16_t port, uint8_t val) {
|
||||
__asm__ volatile ("outb %0, %1" : : "a"(val), "Nd"(port));
|
||||
}
|
||||
|
||||
static void vga_update_cursor(void) {
|
||||
uint16_t pos = (uint16_t)(vga_row * VGA_WIDTH + vga_column);
|
||||
outb(0x3D4, 0x0F);
|
||||
outb(0x3D5, (uint8_t)(pos & 0xFF));
|
||||
outb(0x3D4, 0x0E);
|
||||
outb(0x3D5, (uint8_t)((pos >> 8) & 0xFF));
|
||||
}
|
||||
|
||||
static void vga_scroll(void) {
|
||||
for (size_t y = 0; y < VGA_HEIGHT - 1; y++) {
|
||||
for (size_t x = 0; x < VGA_WIDTH; x++) {
|
||||
vga_buffer[y * VGA_WIDTH + x] = vga_buffer[(y + 1) * VGA_WIDTH + x];
|
||||
}
|
||||
}
|
||||
for (size_t x = 0; x < VGA_WIDTH; x++) {
|
||||
vga_buffer[(VGA_HEIGHT - 1) * VGA_WIDTH + x] = vga_entry(' ', vga_current_color);
|
||||
}
|
||||
vga_row = VGA_HEIGHT - 1;
|
||||
}
|
||||
|
||||
void vga_init(void) {
|
||||
vga_row = 0;
|
||||
vga_column = 0;
|
||||
vga_current_color = vga_entry_color(VGA_COLOR_LIGHT_CYAN, VGA_COLOR_BLACK);
|
||||
vga_clear();
|
||||
}
|
||||
|
||||
void vga_set_color(vga_color_t fg, vga_color_t bg) {
|
||||
vga_current_color = vga_entry_color(fg, bg);
|
||||
}
|
||||
|
||||
void vga_clear(void) {
|
||||
for (size_t y = 0; y < VGA_HEIGHT; y++) {
|
||||
for (size_t x = 0; x < VGA_WIDTH; x++) {
|
||||
vga_buffer[y * VGA_WIDTH + x] = vga_entry(' ', vga_current_color);
|
||||
}
|
||||
}
|
||||
vga_row = 0;
|
||||
vga_column = 0;
|
||||
vga_update_cursor();
|
||||
}
|
||||
|
||||
void vga_putchar(char c) {
|
||||
if (c == '\n') {
|
||||
vga_column = 0;
|
||||
if (++vga_row == VGA_HEIGHT) {
|
||||
vga_scroll();
|
||||
}
|
||||
vga_update_cursor();
|
||||
return;
|
||||
}
|
||||
|
||||
if (c == '\r') {
|
||||
vga_column = 0;
|
||||
vga_update_cursor();
|
||||
return;
|
||||
}
|
||||
|
||||
if (c == '\t') {
|
||||
vga_column = (vga_column + 4) & ~3;
|
||||
if (vga_column >= VGA_WIDTH) {
|
||||
vga_column = 0;
|
||||
if (++vga_row == VGA_HEIGHT) {
|
||||
vga_scroll();
|
||||
}
|
||||
}
|
||||
vga_update_cursor();
|
||||
return;
|
||||
}
|
||||
|
||||
const size_t index = vga_row * VGA_WIDTH + vga_column;
|
||||
vga_buffer[index] = vga_entry((unsigned char)c, vga_current_color);
|
||||
|
||||
if (++vga_column == VGA_WIDTH) {
|
||||
vga_column = 0;
|
||||
if (++vga_row == VGA_HEIGHT) {
|
||||
vga_scroll();
|
||||
}
|
||||
}
|
||||
vga_update_cursor();
|
||||
}
|
||||
|
||||
void vga_write(const char* data, size_t size) {
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
vga_putchar(data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void vga_puts(const char* str) {
|
||||
if (!str) return;
|
||||
while (*str) {
|
||||
vga_putchar(*str++);
|
||||
}
|
||||
}
|
||||
|
||||
void vga_puthex(uint64_t val) {
|
||||
const char hex_chars[] = "0123456789ABCDEF";
|
||||
vga_puts("0x");
|
||||
for (int i = 60; i >= 0; i -= 4) {
|
||||
vga_putchar(hex_chars[(val >> i) & 0xF]);
|
||||
}
|
||||
}
|
||||
|
||||
void vga_putdec(uint64_t val) {
|
||||
if (val == 0) {
|
||||
vga_putchar('0');
|
||||
return;
|
||||
}
|
||||
char buf[24];
|
||||
int i = 0;
|
||||
while (val > 0) {
|
||||
buf[i++] = (char)('0' + (val % 10));
|
||||
val /= 10;
|
||||
}
|
||||
while (--i >= 0) {
|
||||
vga_putchar(buf[i]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user