fix(baremetal): 512GB identity paging, early GOP splash, dual-output console & COM1/RTC timeout guards
- arch/x86_64/boot.s: Map 8GB..512GB using 1GB huge pages in PDPT; set Multiboot2 FB tag to required native 32bpp - drivers/serial.c: Add scratch register hardware probe & 50k timeout guard to prevent infinite polling hang on modern AMD chipsets - drivers/rtc.c: Add timeout guard to CMOS status register polling - drivers/vga.c: Bypass legacy 0x3D4/0x3D5 CRT ports in GOP mode; mirror all characters to active hardware framebuffer - drivers/vbe.c: Implement vbe_early_boot_splash, direct front-buffer console rendering & dynamic backbuffer allocation - kernel/kmain.c: Initialize GOP linear framebuffer at Step 0 for instant physical screen illumination; use pause+counter in render loop - scripts/build_iso.sh: Support universal GOP/VBE/VGA multi-resolution auto-detect for both bare metal and VirtualBox
This commit is contained in:
1 parent
6165197d0a
commit
da3f0788d0
11 files changed
+274
-57
No files matched your search
@@ -100,6 +100,11 @@ static const uint8_t s_font8x16[95][16] = {
|
||||
{0x00,0x76,0xDC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} /* '~' */
|
||||
};
|
||||
|
||||
const uint8_t* font_get_glyph(char c) {
|
||||
if (c < 32 || c > 126) c = '?';
|
||||
return s_font8x16[(uint8_t)c - 32];
|
||||
}
|
||||
|
||||
void font_draw_char(uint32_t x, uint32_t y, char c, uint32_t color) {
|
||||
if (c < 32 || c > 126) c = '?';
|
||||
const uint8_t* glyph = s_font8x16[(uint8_t)c - 32];
|
||||
|
||||
+3
-2
@@ -20,8 +20,9 @@ void rtc_init(void) {
|
||||
rtc_time_t rtc_get_time(void) {
|
||||
rtc_time_t t;
|
||||
|
||||
/* Wait if RTC update in progress */
|
||||
while (cmos_read(0x0A) & 0x80) {}
|
||||
/* Wait if RTC update in progress (guarded by safety timeout) */
|
||||
uint32_t timeout = 50000;
|
||||
while ((cmos_read(0x0A) & 0x80) && --timeout > 0) {}
|
||||
|
||||
t.second = cmos_read(0x00);
|
||||
t.minute = cmos_read(0x02);
|
||||
|
||||
+23
-3
@@ -1,7 +1,22 @@
|
||||
#include <airlys/serial.h>
|
||||
#include <airlys/io.h>
|
||||
|
||||
static bool s_com1_present = false;
|
||||
|
||||
void serial_init(void) {
|
||||
/* Test if COM1 actually exists using UART scratch register (offset +7) */
|
||||
outb(COM1_PORT + 7, 0x55);
|
||||
if (inb(COM1_PORT + 7) != 0x55) {
|
||||
s_com1_present = false;
|
||||
return;
|
||||
}
|
||||
outb(COM1_PORT + 7, 0xAA);
|
||||
if (inb(COM1_PORT + 7) != 0xAA) {
|
||||
s_com1_present = false;
|
||||
return;
|
||||
}
|
||||
|
||||
s_com1_present = true;
|
||||
outb(COM1_PORT + 1, 0x00); /* Disable all interrupts */
|
||||
outb(COM1_PORT + 3, 0x80); /* Enable DLAB (set baud rate divisor) */
|
||||
outb(COM1_PORT + 0, 0x01); /* Set divisor to 1 (115200 baud) */
|
||||
@@ -16,12 +31,17 @@ static inline bool is_transmit_empty(void) {
|
||||
}
|
||||
|
||||
void serial_putchar(char c) {
|
||||
while (!is_transmit_empty()) {}
|
||||
outb(COM1_PORT, c);
|
||||
if (!s_com1_present) return;
|
||||
|
||||
uint32_t timeout = 50000;
|
||||
while (!is_transmit_empty() && --timeout > 0) {}
|
||||
if (timeout > 0) {
|
||||
outb(COM1_PORT, c);
|
||||
}
|
||||
}
|
||||
|
||||
void serial_puts(const char* str) {
|
||||
if (!str) return;
|
||||
if (!s_com1_present || !str) return;
|
||||
while (*str) {
|
||||
if (*str == '\n') {
|
||||
serial_putchar('\r');
|
||||
|
||||
+133
-8
@@ -1,10 +1,13 @@
|
||||
#include <airlys/vbe.h>
|
||||
#include <airlys/font.h>
|
||||
#include <airlys/heap.h>
|
||||
#include <airlys/string.h>
|
||||
#include <airlys/printk.h>
|
||||
|
||||
static vbe_screen_t s_screen;
|
||||
static bool s_is_hardware = false;
|
||||
static uint32_t s_console_x = 24;
|
||||
static uint32_t s_console_y = 60;
|
||||
|
||||
/* Static fallback buffer (1024 x 768 @ 32bpp) */
|
||||
#define VBE_MAX_PIXELS (1024 * 768)
|
||||
@@ -15,8 +18,8 @@ bool vbe_is_hardware_framebuffer(void) {
|
||||
}
|
||||
|
||||
void vbe_set_physical_framebuffer(uint64_t addr, uint32_t width, uint32_t height, uint32_t pitch, uint32_t bpp) {
|
||||
if (width > 1920) width = 1920;
|
||||
if (height > 1080) height = 1080;
|
||||
if (width > 2560) width = 2560;
|
||||
if (height > 1440) height = 1440;
|
||||
if (width == 0) width = 1024;
|
||||
if (height == 0) height = 768;
|
||||
|
||||
@@ -27,16 +30,138 @@ void vbe_set_physical_framebuffer(uint64_t addr, uint32_t width, uint32_t height
|
||||
|
||||
/* Point front_buffer directly to physical GPU MMIO memory */
|
||||
s_screen.front_buffer = (uint32_t*)addr;
|
||||
s_screen.back_buffer = (uint32_t*)kmalloc(width * height * sizeof(uint32_t));
|
||||
if (!s_screen.back_buffer) {
|
||||
s_screen.back_buffer = s_pixel_buffer;
|
||||
}
|
||||
s_screen.back_buffer = s_pixel_buffer;
|
||||
|
||||
s_screen.initialized = true;
|
||||
s_is_hardware = true;
|
||||
}
|
||||
|
||||
printk(KERN_INFO "vbe: Physical UEFI GOP Framebuffer mapped at 0x%lx (%ux%u, pitch: %u)\n",
|
||||
addr, width, height, s_screen.pitch);
|
||||
void vbe_allocate_backbuffer(void) {
|
||||
if (!s_screen.initialized) return;
|
||||
uint32_t total_pixels = s_screen.width * s_screen.height;
|
||||
uint32_t* new_buf = (uint32_t*)kmalloc(total_pixels * sizeof(uint32_t));
|
||||
if (new_buf) {
|
||||
s_screen.back_buffer = new_buf;
|
||||
}
|
||||
}
|
||||
|
||||
void vbe_early_boot_splash(void) {
|
||||
if (!s_screen.initialized || !s_screen.front_buffer) return;
|
||||
|
||||
/* Fill screen with deep obsidian */
|
||||
for (uint32_t y = 0; y < s_screen.height; y++) {
|
||||
uint8_t* row = ((uint8_t*)s_screen.front_buffer) + (y * s_screen.pitch);
|
||||
uint32_t* pixels = (uint32_t*)row;
|
||||
for (uint32_t x = 0; x < s_screen.width; x++) {
|
||||
pixels[x] = COLOR_OBSIDIAN;
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw top status banner */
|
||||
const char* banner = " [ AIRLYS SOVEREIGN OS 64-BIT ] - UEFI GOP Linear Framebuffer Active ";
|
||||
const char* sub = " Founder & CEO: Er. Adam Eehan | Co-Pilot: Sovereign AI Aira 3 Ultra (Engine v3.6) ";
|
||||
|
||||
uint32_t x0 = 24;
|
||||
for (uint32_t i = 0; banner[i] != '\0'; i++) {
|
||||
const uint8_t* glyph = font_get_glyph(banner[i]);
|
||||
for (uint32_t row = 0; row < 16; row++) {
|
||||
uint8_t line = glyph[row];
|
||||
uint8_t* dst_row = ((uint8_t*)s_screen.front_buffer) + ((16 + row) * s_screen.pitch);
|
||||
uint32_t* p = (uint32_t*)dst_row;
|
||||
for (uint32_t col = 0; col < 8; col++) {
|
||||
if ((line >> (7 - col)) & 1) {
|
||||
p[x0 + col] = COLOR_CYAN_GLOW;
|
||||
}
|
||||
}
|
||||
}
|
||||
x0 += 8;
|
||||
}
|
||||
|
||||
x0 = 24;
|
||||
for (uint32_t i = 0; sub[i] != '\0'; i++) {
|
||||
const uint8_t* glyph = font_get_glyph(sub[i]);
|
||||
for (uint32_t row = 0; row < 16; row++) {
|
||||
uint8_t line = glyph[row];
|
||||
uint8_t* dst_row = ((uint8_t*)s_screen.front_buffer) + ((34 + row) * s_screen.pitch);
|
||||
uint32_t* p = (uint32_t*)dst_row;
|
||||
for (uint32_t col = 0; col < 8; col++) {
|
||||
if ((line >> (7 - col)) & 1) {
|
||||
p[x0 + col] = COLOR_GREEN_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
x0 += 8;
|
||||
}
|
||||
}
|
||||
|
||||
void vbe_console_clear(void) {
|
||||
if (!s_screen.initialized || !s_screen.front_buffer) return;
|
||||
for (uint32_t y = 56; y < s_screen.height; y++) {
|
||||
uint8_t* row = ((uint8_t*)s_screen.front_buffer) + (y * s_screen.pitch);
|
||||
uint32_t* pixels = (uint32_t*)row;
|
||||
for (uint32_t x = 0; x < s_screen.width; x++) {
|
||||
pixels[x] = COLOR_OBSIDIAN;
|
||||
}
|
||||
}
|
||||
s_console_x = 24;
|
||||
s_console_y = 60;
|
||||
}
|
||||
|
||||
void vbe_console_putchar(char c, uint32_t color) {
|
||||
if (!s_screen.initialized || !s_screen.front_buffer) return;
|
||||
|
||||
if (c == '\r') {
|
||||
s_console_x = 24;
|
||||
return;
|
||||
}
|
||||
|
||||
if (c == '\n') {
|
||||
s_console_x = 24;
|
||||
s_console_y += 18;
|
||||
if (s_console_y + 18 >= s_screen.height) {
|
||||
vbe_console_clear();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (c == '\t') {
|
||||
s_console_x = (s_console_x + 32) & ~31;
|
||||
if (s_console_x + 8 >= s_screen.width - 24) {
|
||||
s_console_x = 24;
|
||||
s_console_y += 18;
|
||||
if (s_console_y + 18 >= s_screen.height) {
|
||||
vbe_console_clear();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (c < 32 || c > 126) return;
|
||||
|
||||
const uint8_t* glyph = font_get_glyph(c);
|
||||
for (uint32_t row = 0; row < 16; row++) {
|
||||
uint8_t line = glyph[row];
|
||||
uint32_t py = s_console_y + row;
|
||||
if (py >= s_screen.height) break;
|
||||
uint8_t* dst_row = ((uint8_t*)s_screen.front_buffer) + (py * s_screen.pitch);
|
||||
uint32_t* pixels = (uint32_t*)dst_row;
|
||||
for (uint32_t col = 0; col < 8; col++) {
|
||||
uint32_t px = s_console_x + col;
|
||||
if (px >= s_screen.width) break;
|
||||
if ((line >> (7 - col)) & 1) {
|
||||
pixels[px] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s_console_x += 8;
|
||||
if (s_console_x + 8 >= s_screen.width - 24) {
|
||||
s_console_x = 24;
|
||||
s_console_y += 18;
|
||||
if (s_console_y + 18 >= s_screen.height) {
|
||||
vbe_console_clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void vbe_init(uint32_t width, uint32_t height) {
|
||||
|
||||
@@ -1,16 +1,41 @@
|
||||
#include <airlys/vga.h>
|
||||
#include <airlys/vbe.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;
|
||||
|
||||
static uint32_t vga_to_rgb(uint8_t vga_color) {
|
||||
uint8_t fg = vga_color & 0x0F;
|
||||
switch (fg) {
|
||||
case VGA_COLOR_BLACK: return 0xFF000000;
|
||||
case VGA_COLOR_BLUE: return 0xFF0055AA;
|
||||
case VGA_COLOR_GREEN: return 0xFF00AA00;
|
||||
case VGA_COLOR_CYAN: return 0xFF00AAAA;
|
||||
case VGA_COLOR_RED: return 0xFFAA0000;
|
||||
case VGA_COLOR_MAGENTA: return 0xFFAA00AA;
|
||||
case VGA_COLOR_BROWN: return 0xFFAA5500;
|
||||
case VGA_COLOR_LIGHT_GREY: return 0xFFAAAAAA;
|
||||
case VGA_COLOR_DARK_GREY: return 0xFF555555;
|
||||
case VGA_COLOR_LIGHT_BLUE: return 0xFF5555FF;
|
||||
case VGA_COLOR_LIGHT_GREEN: return 0xFF55FF55;
|
||||
case VGA_COLOR_LIGHT_CYAN: return 0xFF00E5FF;
|
||||
case VGA_COLOR_LIGHT_RED: return 0xFFFF5555;
|
||||
case VGA_COLOR_LIGHT_MAGENTA:return 0xFFFF55FF;
|
||||
case VGA_COLOR_LIGHT_BROWN: return 0xFFFFFF55;
|
||||
case VGA_COLOR_WHITE: return 0xFFFFFFFF;
|
||||
default: return 0xFFFFFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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) {
|
||||
if (vbe_is_hardware_framebuffer()) return;
|
||||
uint16_t pos = (uint16_t)(vga_row * VGA_WIDTH + vga_column);
|
||||
outb(0x3D4, 0x0F);
|
||||
outb(0x3D5, (uint8_t)(pos & 0xFF));
|
||||
@@ -53,6 +78,10 @@ void vga_clear(void) {
|
||||
}
|
||||
|
||||
void vga_putchar(char c) {
|
||||
if (vbe_is_hardware_framebuffer()) {
|
||||
vbe_console_putchar(c, vga_to_rgb(vga_current_color));
|
||||
}
|
||||
|
||||
if (c == '\b') {
|
||||
if (vga_column > 12) {
|
||||
vga_column--;
|
||||
|
||||
Reference in new issue
Block a user