Feat: CPU Exceptions and load errors are now shown.

This commit is contained in:
AfonsoCMSousa
2025-11-18 22:58:28 +00:00
parent c1068d34e2
commit 9e4224793b
7 changed files with 692 additions and 238 deletions
+39 -12
View File
@@ -1,15 +1,42 @@
// file: kerlnel.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) {
// Kernel main function
// Set VGA memory address
volatile unsigned short *VGA_mem = (unsigned short *)0xB8000;
VGA_mem[0] = (0x07 << 8) | 'S';
VGA_mem[1] = (0x07 << 8) | 'O';
VGA_mem[2] = (0x07 << 8) | 'R';
VGA_mem[3] = (0x07 << 8) | 'A';
VGA_mem[4] = (0x07 << 8) | ' ';
VGA_mem[5] = (0x07 << 8) | 'O';
VGA_mem[6] = (0x07 << 8) | 'S';
// 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");
}
}