Feat: Kernel has now a functions for better screen printing
This commit is contained in:
@@ -1,42 +1,53 @@
|
||||
// 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;
|
||||
}
|
||||
// INFO:
|
||||
// 0xA0000 for EGA/VGA graphics modes (64 KB)
|
||||
// 0xB0000 for monochrome text mode (32 KB)
|
||||
// 0xB8000 for color text mode and CGA-compatible graphics modes (32 KB)
|
||||
|
||||
// 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++;
|
||||
}
|
||||
}
|
||||
#include "colors.h"
|
||||
|
||||
// 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) | ' ';
|
||||
}
|
||||
|
||||
/*
|
||||
static void __put_char(char c, unsigned char color) {
|
||||
volatile unsigned short *vga = (volatile unsigned short *)0xB8000;
|
||||
|
||||
static int line = 0;
|
||||
static int column = 2;
|
||||
|
||||
if (line >= 16) {
|
||||
column += 3;
|
||||
line = 0;
|
||||
}
|
||||
|
||||
line++;
|
||||
|
||||
vga[line * 80 + 0 + column] = (0x2F << 8) | line; // White color
|
||||
vga[line * 80 + 1 + column] = (color << 8) | c; // White color
|
||||
}
|
||||
*/
|
||||
|
||||
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");
|
||||
}
|
||||
__clear_screen();
|
||||
|
||||
_VGA Char;
|
||||
Char.codepoint = 'T';
|
||||
Char.color = (WHITE << 4) | BLACK;
|
||||
|
||||
_VGA_screen_space Space;
|
||||
Space.column = 2;
|
||||
Space.line = 7;
|
||||
|
||||
__put_char_VGA_POS(Char, Space, 1);
|
||||
|
||||
Space.line = 4;
|
||||
Space.column = 3;
|
||||
|
||||
__put_char_VGA_POS(Char, Space, 0);
|
||||
|
||||
// Infinite loop
|
||||
while (1) {
|
||||
__asm__ volatile("hlt");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user