SoraOS/kernel.c
2025-11-18 22:58:28 +00:00

43 lines
1.1 KiB
C

// File: kernel.c
// SoraOS Kernel - Main entry point
// Simple helper to write a character at a specific position
static inline void write_char(int row, int col, char c, unsigned char color) {
volatile unsigned short *vga = (volatile unsigned short *)0xB8000;
int pos = (row * 80) + col;
vga[pos] = (color << 8) | c;
}
// Simple helper to write a string
static void write_string(int row, int col, const char *str, unsigned char color) {
int i = 0;
while (str[i] != '\0') {
write_char(row, col + i, str[i], color);
i++;
}
}
// Clear the entire screen
static void clear_screen(void) {
volatile unsigned short *vga = (volatile unsigned short *)0xB8000;
int i;
for (i = 0; i < 80 * 25; i++) {
vga[i] = (0x00 << 8) | ' ';
}
}
void kmain(void) {
// Clear screen
clear_screen();
// Write messages
write_string(10, 30, "SORA OS KERNEL", 0x0A); // Green
write_string(12, 25, "64-bit kernel running!", 0x0F); // White
write_string(14, 28, "System Initialized", 0x0E); // Yellow
// Infinite loop
while (1) {
__asm__ volatile ("hlt");
}
}